From ed57668c4143e02eb3acdd7ca2d48f39202ddfc0 Mon Sep 17 00:00:00 2001 From: Nicholas Hayashi Date: Sat, 8 Jan 2022 23:16:55 -0500 Subject: [PATCH] fix redeye bug --- src/game.lua | 2 +- src/tower.lua | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/game.lua b/src/game.lua index 797b6d3..69834e3 100644 --- a/src/game.lua +++ b/src/game.lua @@ -687,7 +687,7 @@ local function game_scene() -- dangling actions run before the main action scene:late_action(game_action) - --play_track(SOUNDS.MAIN_THEME) + play_track(SOUNDS.MAIN_THEME) return scene end diff --git a/src/tower.lua b/src/tower.lua index efb2157..b0ec859 100644 --- a/src/tower.lua +++ b/src/tower.lua @@ -262,7 +262,23 @@ function init_tower_specs() placement_f = function(blocked, has_water, has_mountain, has_ground, hex) return not blocked and has_mountain end, - update_f = default_tower_update_f + update_f = function(tower, tower_index) + if not tower.target_index then + -- try and acquire a target + default_weapon_target_acquisition_f(tower, tower_index) + + else + -- check if our current target is invalidated + local mob = game_state.mobs[tower.target_index] + if not mob then + tower.target_index = false + + else + -- do what we should do with the target + default_handle_target_f(tower, tower_index, mob) + end + end + end }, { id = "MOAT", @@ -404,6 +420,7 @@ function init_tower_specs() if not t.height then t.height = 1 end if not t.update_f then + -- is this good? t.update_f = default_tower_update_f end if not t.placement_f then