Skip to content
Snippets Groups Projects
Commit b340a421 authored by Chris Davidson's avatar Chris Davidson
Browse files

Fix store restocks only happening if you had already opened the shop at some...

Fix store restocks only happening if you had already opened the shop at some point.  All restocks and their associated levels are now stored and applied at Store:loadup.

Add support for player_material_level and restock_by_level
parent 13c91cf4
Branches ItemsAndShops
No related tags found
No related merge requests found
Pipeline #
......@@ -68,37 +68,46 @@ function _M:loadup(level, zone)
local old_minml = zone.min_material_level
local old_maxml = zone.max_material_level
if zone.store_levels_by_restock then
zone.base_level = zone.store_levels_by_restock[game.state.stores_restock] or zone.base_level
end
self.last_filled = self.last_filled or 0
if self.store.ignore_material_levels then
zone.min_material_level = 1
zone.max_material_level = 5
end
while self.last_filled < game.state.stores_restock do
local lev = (game.state.stores_restock_levels and game.state.stores_restock_levels[self.last_filled]) or 8
if zone.store_levels_by_restock then
zone.base_level = zone.store_levels_by_restock[self.last_filled] or zone.base_level
end
-- Increment material level every 10 levels
if self.store.player_material_level then
zone.min_material_level = 1
if game.player.level == 5 then
zone.max_material_level = 2
else
zone.max_material_level = math.floor(game.player.level / 10)
-- Increment material level every 10 levels with a special case at level 5
if self.store.player_material_level then
if lev == 5 then
zone.min_material_level = 1
zone.max_material_level = 2
else
zone.max_material_level = math.min(5, math.floor(lev / 10) + 1)
zone.min_material_level = math.max(1, zone.max_material_level - 1)
end
end
end
if Store.loadup(self, level, zone, self.store.nb_fill) then
self.last_filled = game.state.stores_restock
end
-- ignore_material_levels gets priority over other systems
if self.store.ignore_material_levels then
zone.min_material_level = 1
zone.max_material_level = 5
end
zone.min_material_level = old_minml
zone.max_material_level = old_maxml
zone.base_level = oldlev
-- Engine.store.loadup sets last_filled to something silly so we have to save it
local old_last_filled = self.last_filled
if Store.loadup(self, level, zone, self.store.nb_fill) then
self.last_filled = old_last_filled + 1
end
-- clear chrono worlds and their various effects
if game._chronoworlds then
game.log("#CRIMSON#Your timetravel has no effect on pre-determined outcomes such as this.")
game._chronoworlds = nil
zone.min_material_level = old_minml
zone.max_material_level = old_maxml
zone.base_level = oldlev
-- clear chrono worlds and their various effects
if game._chronoworlds then
game.log("#CRIMSON#Your timetravel has no effect on pre-determined outcomes such as this.")
game._chronoworlds = nil
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment