From 2a240d6f57e1599353e0fd0e5cbb563582d860ec Mon Sep 17 00:00:00 2001 From: a327ex Date: Tue, 25 May 2021 20:41:51 -0300 Subject: [PATCH] Save mid-run --- arena.lua | 5 +++++ buy_screen.lua | 1 + engine/datastructures/table.lua | 2 ++ engine/system.lua | 14 ++++++++++++++ main.lua | 13 ++++++++----- todo | 26 +++++++++++--------------- 6 files changed, 41 insertions(+), 20 deletions(-) diff --git a/arena.lua b/arena.lua index 18beaa5..154cf71 100644 --- a/arena.lua +++ b/arena.lua @@ -333,6 +333,7 @@ function Arena:update(dt) } max_units = 7 + new_game_plus main:add(BuyScreen'buy_screen') + system.save_run(0, gold, {}, passives, run_passive_pool_by_tiers) main:go_to('buy_screen', 0, {}, passives) end, text = Text({{text = '[wavy, bg]restarting...', font = pixul_font, alignment = 'center'}}, global_text_tags)} end} @@ -430,6 +431,7 @@ function Arena:update(dt) } max_units = 7 + new_game_plus main:add(BuyScreen'buy_screen') + system.save_run(0, gold, {}, passives, run_passive_pool_by_tiers) main:go_to('buy_screen', 0, {}, passives) end, text = Text({{text = '[wavy, bg]restarting...', font = pixul_font, alignment = 'center'}}, global_text_tags)} end @@ -525,6 +527,7 @@ function Arena:quit() } max_units = 7 + new_game_plus main:add(BuyScreen'buy_screen') + system.save_run(0, gold, {}, passives, run_passive_pool_by_tiers) main:go_to('buy_screen', 0, {}, passives) end, text = Text({{text = '[wavy, bg]restarting...', font = pixul_font, alignment = 'center'}}, global_text_tags)} end} @@ -801,6 +804,7 @@ function Arena:die() } max_units = 7 + new_game_plus main:add(BuyScreen'buy_screen') + system.save_run(0, gold, {}, passives, run_passive_pool_by_tiers) main:go_to('buy_screen', 0, {}, passives) end, text = Text({{text = '[wavy, bg]restarting...', font = pixul_font, alignment = 'center'}}, global_text_tags)} end} @@ -876,6 +880,7 @@ function Arena:transition() TransitionEffect{group = main.transitions, x = self.player.x, y = self.player.y, color = self.color, transition_action = function(t) slow_amount = 1 main:add(BuyScreen'buy_screen') + system.save_run(self.level, gold, self.units, passives, run_passive_pool_by_tiers) main:go_to('buy_screen', self.level, self.units, passives) t.t:after(0.1, function() t.text:set_text({ diff --git a/buy_screen.lua b/buy_screen.lua index 94fcc3f..d6b89bc 100644 --- a/buy_screen.lua +++ b/buy_screen.lua @@ -451,6 +451,7 @@ function RestartButton:update(dt) max_units = 7 + new_game_plus system.save_state() main:add(BuyScreen'buy_screen') + system.save_run(0, gold, {}, passives, run_passive_pool_by_tiers) main:go_to('buy_screen', 0, {}, passives) end, text = Text({{text = '[wavy, bg]restarting...', font = pixul_font, alignment = 'center'}}, global_text_tags)} end diff --git a/engine/datastructures/table.lua b/engine/datastructures/table.lua index 825039f..8b4c624 100644 --- a/engine/datastructures/table.lua +++ b/engine/datastructures/table.lua @@ -397,6 +397,8 @@ function table.tostring(t) end if str ~= "{" then return str:sub(1, -3) .. "}" else return str .. "}" end + elseif type(t) == "string" then + return '"' .. tostring(t) .. '"' else return tostring(t) end end diff --git a/engine/system.lua b/engine/system.lua index 668a0ac..9f59e64 100644 --- a/engine/system.lua +++ b/engine/system.lua @@ -137,6 +137,20 @@ function system.load_state() end +function system.save_run(level, gold, units, passives, run_passive_pool_by_tiers) + local run = {level = level, gold = gold, units = units, passives = passives, run_passive_pool_by_tiers = run_passive_pool_by_tiers} + local str = "return " .. table.tostring(run) + love.filesystem.write("run.txt", str) +end + + +function system.load_run() + local chunk = love.filesystem.load("run.txt") + if chunk then return chunk() + else return {} end +end + + function system.get_main_directory() return love.filesystem.getSource() end diff --git a/main.lua b/main.lua index 3d96469..2750bc3 100644 --- a/main.lua +++ b/main.lua @@ -1157,15 +1157,16 @@ function init() [25] = {'speed_booster', 'exploder', 'headbutter', 'tank', 'shooter', 'spawner'}, } - run_passive_pool_by_tiers = { + local run = system.load_run() + run_passive_pool_by_tiers = run.passive_pool_by_tiers or { [1] = { 'wall_echo', 'wall_rider', 'centipede', 'temporal_chains', 'amplify', 'amplify_x', 'ballista', 'ballista_x', 'blunt_arrow', 'berserking', 'unwavering_stance', 'assassination', 'unleash', 'blessing', 'hex_master', 'force_push', 'spawning_pool'}, [2] = {'ouroboros_technique_r', 'ouroboros_technique_l', 'intimidation', 'vulnerability', 'resonance', 'point_blank', 'longshot', 'explosive_arrow', 'chronomancy', 'awakening', 'ultimatum', 'echo_barrage', 'reinforce', 'payback', 'whispers_of_doom', 'heavy_impact', 'immolation', 'call_of_the_void'}, [3] = {'divine_machine_arrow', 'divine_punishment', 'flying_daggers', 'crucio', 'hive', 'void_rift'}, } - gold = 2 - passives = {} + gold = run.gold or 2 + passives = run.passives or {} steam.userStats.requestCurrentStats() new_game_plus = state.new_game_plus or 0 if not state.new_game_plus then state.new_game_plus = new_game_plus end @@ -1173,10 +1174,12 @@ function init() main = Main() - -- main_song_instance = _G[random:table{'song1', 'song2', 'song3', 'song4', 'song5'}]:play{volume = 0.5} + if run.level ~= 0 then + main_song_instance = _G[random:table{'song1', 'song2', 'song3', 'song4', 'song5'}]:play{volume = 0.5} + end main:add(BuyScreen'buy_screen') - main:go_to('buy_screen', 0, {}, passives) + main:go_to('buy_screen', run.level or 0, run.units or {}, passives) --[[ main:add(Arena'arena') diff --git a/todo b/todo index cb1dc94..09d8351 100644 --- a/todo +++ b/todo @@ -1,15 +1,11 @@ -* Lich buff -> increased projectile speed -* Highlander buff -> increased area size -* Change Cannoneer's Lv.3 to 7 repeats, and each repeat should be slightly slower * -* Wizard chains 3 times -* Saboteur area fix -* NG+ snake size fix -* Change Divine Machine Arrow to pierce 4 times -* Rogue buff -> chance to crit 15/30 -* Psyker buff -> 10% bonus -* Concentrated Fire change to "chance to create secondary AoEs on AoE hit" (like Cannoneer's Lv.3) -* Decreased difficulty slightly for NG+ levels -* Remove repeat passives -* restart button on end game -* fixed interest above 5 -* fixed fast passive buy bug +Curser buff - change all cursers to trigger like the infestor does and for the effects to be on-death effects +Forcer buff - change all forcers to have a bigger area or to trigger their effects via projectiles (like the hunter) +Conjurer buff - buff saboteur, buff engineer +Vagrant buff - increase "active set" bonuses +Save runs +Move units +Endless mode +Lock shop button +Harder difficulty on NG+0 +Lower difficulty on NG+4/5 +Increase boss HP on levels 24 and 25