--- Original Author(s) : xcvb, ComradeCatilina --- Edited : NLTP_ASHES --- Date : 15/05/2023 --- --- Timer script for Brotherhood. Courtesy of xcvb -- --------------------------------------------------------------------------------------------------------------------- -- Constants, global variables and imported functions -- --------------------------------------------------------------------------------------------------------------------- -- Imported functions local HI = has_alife_info local GI = give_info local DI = disable_info local NI = function(str) return not (has_alife_info(str)) end local ctime_to_t = utils_data.CTime_to_table local ctime_from_t = utils_data.CTime_from_table -- Variables local time_to_poof_1 local time_to_poof_2 local time_to_poof_3 local time_to_poof_4 local time_to_poof_5 local time_to_poof_6 local time_to_poof_7 local time_to_poof_8 local time_to_poof_9 local time_to_poof_10 local time_to_poof_11 local time_to_poof_12 local time_to_poof_13 local time_to_poof_14 local time_to_poof_15 local time_to_poof_16 local time_to_poof_17 local time_to_poof_18 local time_to_poof_19 local time_to_poof_20 local time_to_poof_21 local time_to_poof_22 local tmr_1 = 0 local tmr_2 = 0 local tmr_3 = 0 local tmr_4 = 0 local tmr_5 = 0 local tmr_6 = 0 local tmr_7 = 0 local tmr_8 = 0 local tmr_9 = 0 local tmr_10 = 0 local tmr_11 = 0 local tmr_12 = 0 local tmr_13 = 0 local tmr_14 = 0 local tmr_15 = 0 local tmr_16 = 0 local tmr_17 = 0 local tmr_18 = 0 local tmr_19 = 0 local tmr_20 = 0 local tmr_21 = 0 local tmr_22 = 0 -- --------------------------------------------------------------------------------------------------------------------- -- General functions -- --------------------------------------------------------------------------------------------------------------------- -- Alyosha Karmov -- Help 1 function alyosha_shyogolov_help_random() if not time_to_poof_1 then time_to_poof_1 = ctime_to_t(game.get_game_time()) end end function actor_on_update_1() local poof_timer_1 = 86400 local tg = time_global() if tg < tmr_1 then return end tmr_1 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_1 and cur_time:diffSec(ctime_from_t(time_to_poof_1)) > poof_timer_1 then DI("help_alyosha_shyogolov_random") time_to_poof_1 = nil end end -- What a night -- Time 2 function create_stash_1() if not time_to_poof_2 then time_to_poof_2 = ctime_to_t(game.get_game_time()) end end function actor_on_update_2() local poof_timer_2 = 0.5 local tg = time_global() if tg < tmr_2 then return end tmr_2 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_2 and cur_time:diffSec(ctime_from_t(time_to_poof_2)) > poof_timer_2 then dialogs_brotherhood.create_stash_and_transfer_items() dialogs_brotherhood.blackout_drink() dialogs_brotherhood.give_what_a_night() this.blackout_drink_time() time_to_poof_2 = nil end end -- Time 3 function blackout_drink_time() if not time_to_poof_3 then time_to_poof_3 = ctime_to_t(game.get_game_time()) end end function actor_on_update_3() local poof_timer_3 = 1 local tg = time_global() if tg < tmr_3 then return end tmr_3 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_3 and cur_time:diffSec(ctime_from_t(time_to_poof_3)) > poof_timer_3 then dialogs_brotherhood.blackout_teleportation() time_to_poof_3 = nil end end -- Time 4 and 5 -- Calydonian Boar Hunting Season function butcher_legendary_hunting_season_1() if not time_to_poof_7 then time_to_poof_7 = ctime_to_t(game.get_game_time()) end end function actor_on_update_7() local poof_timer_7 = math.random(4500,200000) local tg = time_global() if tg < tmr_7 then return end tmr_7 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_7 and cur_time:diffSec(ctime_from_t(time_to_poof_7)) > poof_timer_7 then news_manager.send_tip(db.actor, game.translate_string("st_butcher_legendary_hunting_season_1"), 0, "stalker", 11000, 1) dialogs_brotherhood.give_butcher_legendary_1() time_to_poof_7 = nil end end function dolg_bloodsucker_voronin_1() if not time_to_poof_4 then time_to_poof_4 = ctime_to_t(game.get_game_time()) end end function actor_on_update_4() local poof_timer_4 = 86400 local tg = time_global() if tg < tmr_4 then return end tmr_4 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_4 and cur_time:diffSec(ctime_from_t(time_to_poof_4)) > poof_timer_4 then news_manager.send_tip(db.actor, game.translate_string("st_dolg_voronin_bloodsucker_news_0"), 0, "dolg", 11000, 1) dialogs_brotherhood.give_meet_voronin_quest_1() dialogs_brotherhood.spawn_artyom_bloodsucker_wounded() GI("voronin_bloodsucker_botched_start") time_to_poof_4 = nil end end -- Dolg snitches get stitches function dolg_bloodsucker_aspirin_1() if not time_to_poof_5 then time_to_poof_5 = ctime_to_t(game.get_game_time()) end end function actor_on_update_5() local poof_timer_5 = 86400 local tg = time_global() if tg < tmr_5 then return end tmr_5 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_5 and cur_time:diffSec(ctime_from_t(time_to_poof_5)) > poof_timer_5 then news_manager.send_tip(db.actor, game.translate_string("st_dolg_aspirin_bloodsucker_news_0"), 0, "dolg", 11000, 1) dialogs_brotherhood.give_meet_aspirin_quest_2() GI("meet_aspirin_snitches_stitches") time_to_poof_5 = nil end end function dolg_bloodsucker_aspirin_2() if not time_to_poof_6 then time_to_poof_6 = ctime_to_t(game.get_game_time()) end end -- Dolg Aspirin quest 2 function actor_on_update_6() local poof_timer_6 = 86400 local tg = time_global() if tg < tmr_6 then return end tmr_6 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_6 and cur_time:diffSec(ctime_from_t(time_to_poof_6)) > poof_timer_6 then news_manager.send_tip(db.actor, game.translate_string("st_dolg_aspirin_bloodsucker_news_1"), 0, "dolg", 11000, 1) dialogs_brotherhood.give_meet_aspirin_quest_2() time_to_poof_6 = nil end end -- Vybegallo Satisfied Man function vybegallo_help_satisfied_man() if not time_to_poof_8 then time_to_poof_8 = ctime_to_t(game.get_game_time()) end end function actor_on_update_8() local poof_timer_8 = 86400*7 local tg = time_global() if tg < tmr_8 then return end tmr_8 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_8 and cur_time:diffSec(ctime_from_t(time_to_poof_8)) > poof_timer_8 then if NI("vybegallo_dead") then news_manager.send_tip(db.actor, game.translate_string("st_vybegallo_help_satisfied_man_info"), 0, "ecolog", 11000, 1) dialogs_brotherhood.give_meet_vybegallo_quest() GI("vybegallo_request_help_satisfied_man") end time_to_poof_8 = nil end end -- Brotherhood Quest 5 function butcher_brotherhood_help() if not time_to_poof_9 then time_to_poof_9 = ctime_to_t(game.get_game_time()) end end function actor_on_update_9() local poof_timer_9 = 86400*3 local tg = time_global() if tg < tmr_9 then return end tmr_9 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_9 and cur_time:diffSec(ctime_from_t(time_to_poof_9)) > poof_timer_9 then if NI("bellerophon_dead") then news_manager.send_tip(db.actor, game.translate_string("st_butcher_5_help_info"), 0, "stalker", 11000, 1) dialogs_brotherhood.give_rescue_orion_quest() dialogs_brotherhood.relocation_ilya_1() GI("butcher_5_help") elseif HI("bellerophon_dead") then news_manager.send_tip(db.actor, game.translate_string("st_butcher_5_alt_help_info"), 0, "stalker", 11000, 1) dialogs_brotherhood.give_rescue_orion_quest() GI("butcher_5_help") dialogs_brotherhood.spawn_sarpedon() end time_to_poof_9 = nil end end --- Market Share Quests --- -- An ominous invitation-- function market_share_beginning_1() if not time_to_poof_10 then time_to_poof_10 = ctime_to_t(game.get_game_time()) end end function actor_on_update_10() local poof_timer_10 = 56400 local tg = time_global() if tg < tmr_10 then return end tmr_10 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_10 and cur_time:diffSec(ctime_from_t(time_to_poof_10)) > poof_timer_10 then news_manager.send_tip(db.actor, game.translate_string("st_marlo_chris_invitation_info"), 0, "stalker", 11000, 1) dialogs_brotherhood.give_meet_marlo_chris_quest_1() GI("market_share_the_beginning") time_to_poof_10 = nil end end -- The courriers are on their way -- function market_share_quest_2() if not time_to_poof_11 then time_to_poof_11 = ctime_to_t(game.get_game_time()) end end function actor_on_update_11() local poof_timer_11 = 86400 local tg = time_global() if tg < tmr_11 then return end tmr_11 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_11 and cur_time:diffSec(ctime_from_t(time_to_poof_11)) > poof_timer_11 then news_manager.send_tip(db.actor, game.translate_string("st_chris_key_interception_info"), 0, "stalker", 11000, 1) dialogs_brotherhood.give_meet_marlo_chris_quest_2() GI("market_share_quest_2_init") time_to_poof_11 = nil end end -- The resupply is on their way -- function market_share_quest_3() if not time_to_poof_12 then time_to_poof_12 = ctime_to_t(game.get_game_time()) end end function actor_on_update_12() local poof_timer_12 = 86400*3 local tg = time_global() if tg < tmr_12 then return end tmr_12 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_12 and cur_time:diffSec(ctime_from_t(time_to_poof_12)) > poof_timer_12 then news_manager.send_tip(db.actor, game.translate_string("st_chris_asset_interception_info"), 0, "stalker", 11000, 1) dialogs_brotherhood.give_meet_marlo_chris_quest_3() GI("market_share_quest_3_init") time_to_poof_12 = nil end end --- Timer 13 NOT USED --- function calydonian_boar_reinforcment_init() if not time_to_poof_13 then time_to_poof_13 = ctime_to_t(game.get_game_time()) end end function actor_on_update_13() local poof_timer_13 = 10 local tg = time_global() if tg < tmr_13 then return end tmr_13 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_13 and cur_time:diffSec(ctime_from_t(time_to_poof_13)) > poof_timer_13 then GI("calydonian_boar_reinforcment_init") time_to_poof_13 = nil end end --- Timer 14 reset Bezsonik timer function bezsonik_init_random() if not time_to_poof_14 then time_to_poof_14 = ctime_to_t(game.get_game_time()) end end function actor_on_update_14() local poof_timer_14 = 80000 local tg = time_global() if tg < tmr_14 then return end tmr_14 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_14 and cur_time:diffSec(ctime_from_t(time_to_poof_14)) > poof_timer_14 then DI("nr_bezsonik_init_random") time_to_poof_14 = nil end end --- Timer 15 reset Butcher Timer function butcher_troubble_init_random() if not time_to_poof_15 then time_to_poof_15 = ctime_to_t(game.get_game_time()) end end function actor_on_update_15() local poof_timer_15 = 80000 local tg = time_global() if tg < tmr_15 then return end tmr_15 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_15 and cur_time:diffSec(ctime_from_t(time_to_poof_15)) > poof_timer_15 then DI("butcher_troubble_init_random") time_to_poof_15 = nil end end --- Timer 16 reset Gutalin Timer function meet_gutalin_init_random() if not time_to_poof_16 then time_to_poof_16 = ctime_to_t(game.get_game_time()) end end function actor_on_update_16() local poof_timer_16 = 80000 local tg = time_global() if tg < tmr_16 then return end tmr_16 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_16 and cur_time:diffSec(ctime_from_t(time_to_poof_16)) > poof_timer_16 then DI("meet_gutalin_init_random") time_to_poof_16 = nil end end --- Timer 17 Trapper Chimera 2 recroding function trapper_chimera_2_recording() if not time_to_poof_17 then time_to_poof_17 = ctime_to_t(game.get_game_time()) end end function actor_on_update_17() local poof_timer_17 = 100 local tg = time_global() if tg < tmr_17 then return end tmr_17 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_17 and cur_time:diffSec(ctime_from_t(time_to_poof_17)) > poof_timer_17 then GI("trapper_chimera_2_recording_done") time_to_poof_17 = nil end end --- Timer 18 Calydonian Boar spawns function butcher_calydonian_init() if not time_to_poof_18 then time_to_poof_18 = ctime_to_t(game.get_game_time()) end end function actor_on_update_18() local poof_timer_18 = math.random(50000,100000) local tg = time_global() if tg < tmr_18 then return end tmr_18 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_18 and cur_time:diffSec(ctime_from_t(time_to_poof_18)) > poof_timer_18 then GI("butcher_calydonian_init") news_manager.send_tip(db.actor, game.translate_string("st_butcher_legendary_hunting_season_1"), 0, "stalker", 11000, 1) news_manager.send_tip(db.actor, game.translate_string("st_butcher_legendary_hunting_season_2"), 5, "stalker", 11000, 1) news_manager.send_tip(db.actor, game.translate_string("st_butcher_legendary_hunting_season_3"), 10, "stalker", 11000, 1) news_manager.send_tip(db.actor, game.translate_string("st_butcher_legendary_hunting_season_4"), 15, "stalker", 11000, 1) time_to_poof_18 = nil end end ---- reset Controller Ambush random event function nr_primakov_random() if not time_to_poof_19 then time_to_poof_19 = ctime_to_t(game.get_game_time()) end end function actor_on_update_19() local poof_timer_19 = 24000 local tg = time_global() if tg < tmr_19 then return end tmr_19 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_19 and cur_time:diffSec(ctime_from_t(time_to_poof_19)) > poof_timer_19 then DI("nr_primankov_random") time_to_poof_19 = nil end end ---- Shlitzer 1 Fail function bh_shlitzer_fail_1() if not time_to_poof_20 then time_to_poof_20 = ctime_to_t(game.get_game_time()) end end function actor_on_update_20() local poof_timer_20 = 518400 local tg = time_global() if tg < tmr_20 then return end tmr_20 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_20 and cur_time:diffSec(ctime_from_t(time_to_poof_20)) > poof_timer_20 then if NI("bh_badger_smuggling_transfer_done") then GI("bh_shlitzer_fail_1") end time_to_poof_20 = nil end end --- Baltun random reset function nr_baltunov_init_random() if not time_to_poof_21 then time_to_poof_21 = ctime_to_t(game.get_game_time()) end end function actor_on_update_21() local poof_timer_21 = 24000 local tg = time_global() if tg < tmr_21 then return end tmr_21 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_21 and cur_time:diffSec(ctime_from_t(time_to_poof_21)) > poof_timer_21 then DI("nr_baltunov_init_random") time_to_poof_21 = nil end end --- Murdered Starik random reset function nr_starik_1_init_random() if not time_to_poof_22 then time_to_poof_22 = ctime_to_t(game.get_game_time()) end end function actor_on_update_22() local poof_timer_22 = 24000 local tg = time_global() if tg < tmr_22 then return end tmr_22 = tg + 1000 local cur_time = game.get_game_time() if time_to_poof_22 and cur_time:diffSec(ctime_from_t(time_to_poof_22)) > poof_timer_22 then DI("nr_starik_1_init_random") time_to_poof_22 = nil end end -- --------------------------------------------------------------------------------------------------------------------- -- Data persistence -- --------------------------------------------------------------------------------------------------------------------- --- Function used to store information in the save file. --- @param m_data table --- @return nil function save_state(m_data) m_data.time_to_poof_1 = time_to_poof_1 m_data.time_to_poof_2 = time_to_poof_2 m_data.time_to_poof_3 = time_to_poof_3 m_data.time_to_poof_4 = time_to_poof_4 m_data.time_to_poof_5 = time_to_poof_5 m_data.time_to_poof_6 = time_to_poof_6 m_data.time_to_poof_7 = time_to_poof_7 m_data.time_to_poof_8 = time_to_poof_8 m_data.time_to_poof_9 = time_to_poof_9 m_data.time_to_poof_10 = time_to_poof_10 m_data.time_to_poof_11 = time_to_poof_11 m_data.time_to_poof_12 = time_to_poof_12 m_data.time_to_poof_13 = time_to_poof_13 m_data.time_to_poof_14 = time_to_poof_14 m_data.time_to_poof_15 = time_to_poof_15 m_data.time_to_poof_16 = time_to_poof_16 m_data.time_to_poof_17 = time_to_poof_17 m_data.time_to_poof_18 = time_to_poof_18 m_data.time_to_poof_19 = time_to_poof_19 m_data.time_to_poof_20 = time_to_poof_20 m_data.time_to_poof_21 = time_to_poof_21 m_data.time_to_poof_22 = time_to_poof_22 end --- Function used to load information stored in the save file. --- @param m_data table --- @return nil function load_state(m_data) time_to_poof_1 = m_data.time_to_poof_1 time_to_poof_2 = m_data.time_to_poof_2 time_to_poof_3 = m_data.time_to_poof_3 time_to_poof_4 = m_data.time_to_poof_4 time_to_poof_5 = m_data.time_to_poof_5 time_to_poof_6 = m_data.time_to_poof_6 time_to_poof_7 = m_data.time_to_poof_7 time_to_poof_8 = m_data.time_to_poof_8 time_to_poof_9 = m_data.time_to_poof_9 time_to_poof_10 = m_data.time_to_poof_10 time_to_poof_11 = m_data.time_to_poof_11 time_to_poof_12 = m_data.time_to_poof_12 time_to_poof_13 = m_data.time_to_poof_13 time_to_poof_14 = m_data.time_to_poof_14 time_to_poof_15 = m_data.time_to_poof_15 time_to_poof_16 = m_data.time_to_poof_16 time_to_poof_17 = m_data.time_to_poof_17 time_to_poof_18 = m_data.time_to_poof_18 time_to_poof_19 = m_data.time_to_poof_19 time_to_poof_20 = m_data.time_to_poof_20 time_to_poof_21 = m_data.time_to_poof_21 time_to_poof_22 = m_data.time_to_poof_22 end -- --------------------------------------------------------------------------------------------------------------------- -- Callbacks registration -- --------------------------------------------------------------------------------------------------------------------- --- Function used to register callbacks. --- @return nil function on_game_start() RegisterScriptCallback("save_state", save_state) RegisterScriptCallback("load_state", load_state) RegisterScriptCallback("actor_on_update", actor_on_update_1) RegisterScriptCallback("actor_on_update", actor_on_update_2) RegisterScriptCallback("actor_on_update", actor_on_update_3) RegisterScriptCallback("actor_on_update", actor_on_update_4) RegisterScriptCallback("actor_on_update", actor_on_update_5) RegisterScriptCallback("actor_on_update", actor_on_update_6) RegisterScriptCallback("actor_on_update", actor_on_update_7) RegisterScriptCallback("actor_on_update", actor_on_update_8) RegisterScriptCallback("actor_on_update", actor_on_update_9) RegisterScriptCallback("actor_on_update", actor_on_update_10) RegisterScriptCallback("actor_on_update", actor_on_update_11) RegisterScriptCallback("actor_on_update", actor_on_update_12) RegisterScriptCallback("actor_on_update", actor_on_update_13) RegisterScriptCallback("actor_on_update", actor_on_update_14) RegisterScriptCallback("actor_on_update", actor_on_update_15) RegisterScriptCallback("actor_on_update", actor_on_update_16) RegisterScriptCallback("actor_on_update", actor_on_update_17) RegisterScriptCallback("actor_on_update", actor_on_update_18) RegisterScriptCallback("actor_on_update", actor_on_update_19) RegisterScriptCallback("actor_on_update", actor_on_update_20) end