local effect = require(mod_name .. ".lualib.effects") local check = require(mod_name .. ".lualib.check") local attacks = require(mod_name .. ".lualib.attacks") local colony_controller = require(mod_name .. ".lualib.colony_controller") local waves = require 'waves' local story = require("story_2") local story_updates = {} story_updates['prepare'] = function() effect.turn_biters_around({'safe-1','safe-2','safe-3'},'crash-site') end story_updates['packup'] = function() effect.turn_biters_around({'safe-1','safe-2','safe-3'},'crash-site') end story_updates['leave'] = function() if story.check_minutes_passed("main_story", 10) then attacks.check_spawn_wave(waves['packup-2'],'enemy') else attacks.check_spawn_wave(waves['packup-1'],'enemy') end effect.turn_biters_around({'safe-1','safe-2','safe-3'},'crash-site') end story_updates['reach-pond'] = function() effect.turn_biters_around({'safe-1','safe-2','safe-3','safe-4'},'crash-site') end story_updates['rebuild'] = function() local attack_wave = nil if colony_controller.is_populated('crashsite-nest-1') == false then attack_wave = 'crash-site-colony-1' elseif colony_controller.is_populated('crashsite-nest-2') == false then attack_wave = 'crash-site-colony-2' elseif colony_controller.is_populated('crashsite-nest-3') == false then attack_wave = 'crash-site-colony-3' elseif colony_controller.is_populated('crashsite-nest-4') == false then attack_wave = 'crash-site-colony-4' elseif colony_controller.is_populated('crashsite-nest-5') == false then attack_wave = 'crash-site-colony-5' end if attack_wave then attacks.check_spawn_wave(waves[attack_wave]) end end story_updates['military'] = function() local attack_wave = nil if colony_controller.is_populated('crashsite-nest-1') == false then attack_wave = 'crash-site-colony-1' elseif colony_controller.is_populated('crashsite-nest-2') == false then attack_wave = 'crash-site-colony-2' elseif colony_controller.is_populated('crashsite-nest-3') == false then attack_wave = 'crash-site-colony-3' elseif colony_controller.is_populated('crashsite-nest-4') == false then attack_wave = 'crash-site-colony-4' elseif colony_controller.is_populated('crashsite-nest-5') == false then attack_wave = 'crash-site-colony-5' end if attack_wave then attacks.check_spawn_wave(waves[attack_wave]) end end story_updates['entrench'] = function() attacks.check_spawn_wave(waves['pistol-1']) end story_updates['trigger-second-wave'] = function() attacks.check_spawn_wave(waves['one-turret-one-vector']) end story_updates['fortify'] = function() local lowest_turret_number = check.lowest_number_of_turrets_in_areas({'defend-1','defend-2'}) if lowest_turret_number > 3 then attacks.check_spawn_wave(waves['fortify-4']) elseif lowest_turret_number == 3 then attacks.check_spawn_wave(waves['fortify-3']) elseif lowest_turret_number == 2 then attacks.check_spawn_wave(waves['fortify-2']) elseif lowest_turret_number < 2 then attacks.check_spawn_wave(waves['fortify-1']) end end story_updates['survive'] = function() if game.tick % 60 ~= 0 then return end local lowest_turret_number = check.lowest_number_of_turrets_in_areas({'defend-1','defend-2'}) if lowest_turret_number > 3 then attacks.check_spawn_wave(waves['survive-4']) elseif lowest_turret_number == 3 then attacks.check_spawn_wave(waves['survive-3']) elseif lowest_turret_number == 2 then attacks.check_spawn_wave(waves['survive-2']) elseif lowest_turret_number < 2 then attacks.check_spawn_wave(waves['survive-1']) end end return story_updates