--[[ bind_stalker_ext.script Extends the functionality of bind_stalker.script without filling it with clutter by: Alundaio --]] ------------------- -- actor_on_init ------------------- function actor_on_init(binder) level_weathers.get_weather_manager() SendScriptCallback("actor_on_init",binder) end function actor_on_reinit(binder) SendScriptCallback("actor_on_reinit",binder) local function check_hud_msg() -- Check HudMsg if (ShowMessageTime) then local hud = get_hud() if (hud) then local custom_static = hud:GetCustomStatic("not_enough_money_mine") if custom_static ~= nil and time_global() > ShowMessageTime then hud:RemoveCustomStatic("not_enough_money_mine") ShowMessageTime = nil end end end return false end AddUniqueCall(check_hud_msg) AddUniqueCall(ProcessEventQueue) end ------------------- -- actor_on_net_spawn ------------------- function actor_on_net_spawn() local sim = alife() for i=1,65534 do local se_obj = sim:object(i) if (se_obj and se_obj:clsid() == clsid.phantom) then --printf("release phantom") sim:release(se_obj,true) end end if (axr_main.config:r_value("mm_options","enable_heli_spawn",1,true) == false) then for k,v in pairs(se_heli.se_helicopters) do alife():release(v,true) end end SendScriptCallback("on_game_load",binder) end ------------------------------------- -- actor_on_net_destroy ------------------------------------- function actor_on_net_destroy(binder) SendScriptCallback("actor_on_net_destroy",binder) end ------------------- -- actor_on_update ------------------- invulnerable_time = nil function actor_on_first_update(binder,delta) local m_data = alife_storage_manager.get_state() -- check if artefacts can respawn for this level if (m_data.artefact_respawn_levels and m_data.artefact_respawn_levels[level.name()] == true) then --printf("DEBUG: surge_manager respawn artefacts") surge_manager.get_surge_manager():respawn_artefacts_and_replace_anomaly_zone() m_data.artefact_respawn_levels[level.name()] = false end invulnerable_time = time_global() + 7000 SendScriptCallback("actor_on_first_update",binder,delta) end function actor_on_update(binder,delta) -- WISH GRANTER ZOMBIED-IMMORTALITY if (db.actor:has_info("actor_made_wish_immortal") or invulnerable_time and invulnerable_time > time_global() + 7000) then db.actor.health = 1 db.actor.bleeding = 1 db.actor.psy_health = 1 db.actor.radiation = -1 end --[[ enable if you need it local torch = db.actor:object("device_torch") if (torch and not actor_light and torch:torch_enabled()) then actor_light = true SendScriptCallback("actor_on_torch_enabled") elseif (torch and not torch:torch_enabled()) then if (actor_light) then actor_light = false SendScriptCallback("actor_on_torch_disabled") end end --]] SendScriptCallback("actor_on_update",binder,delta) end ------------------- -- actor_on_weapon_no_ammo(wpn) ------------------- function actor_on_weapon_no_ammo(binder,wpn) SendScriptCallback("actor_on_weapon_no_ammo",wpn) end ------------------- -- actor_on_weapon_zoom_in(wpn) ------------------- function actor_on_weapon_zoom_in(binder,obj,wpn) SendScriptCallback("actor_on_weapon_zoom_in",wpn) end ------------------- -- actor_on_weapon_zoom_out(wpn) ------------------- function actor_on_weapon_zoom_out(binder,obj,wpn) SendScriptCallback("actor_on_weapon_zoom_out",wpn) end ------------------- -- actor_on_item_take(item) ------------------- function actor_on_item_take(binder,item) if not (db.actor) then return -- don't remove, for some reason this callback is triggered before actor is fully loaded end SendScriptCallback("actor_on_item_take",item) end ------------------- -- actor_on_item_take_from_box ------------------- function actor_on_item_take_from_box(binder,box,item) SendScriptCallback("actor_on_item_take_from_box",box,item) end ------------------- -- ------------------- function actor_on_item_drop(binder,item) SendScriptCallback("actor_on_item_drop",item) end ------------------- -- actor_on_item_use(item) ------------------- function actor_on_item_use(binder,item) local sec = item:section() if (sec == "drug_psy_blockade" or sec == "drug_radioprotector" or sec == "drug_antidot") then local boost_time = system_ini():r_float_ex(sec,"boost_time") utils.save_var(db.actor,sec.."_expiration",utils.CTimeAddSec(game.get_game_time(),boost_time*level.get_time_factor())) elseif (sec == "radio_connections_pda") then run_dynamic_element(pda_dialog.pda_dialog_box(),true) end SendScriptCallback("actor_on_item_use",item,sec) end ------------------- -- actor_on_trade(item) ------------------- function actor_on_trade(binder,item,sell_bye,money) -- if sell_bye == true then -- game_stats.money_trade_update (money) -- else -- game_stats.money_trade_update (-money) -- end SendScriptCallback("actor_on_trade",item,sell_bye,money) end ------------------- -- actor_on_save(bind_stalker,packet) -- IMPORTANT: Cannot be used as callback because this needs to be done in specific order, just call script directly! ------------------- function actor_on_save(binder,packet) local sim,gg = alife(),game_graph() local actor_gv = sim and gg:vertex(sim:actor().m_game_vertex_id) if (actor_gv and actor_gv:level_id() ~= sim:level_id()) then --printf("DEBUG: actor changing level") SendScriptCallback("on_level_changing") end if (coc_treasure_manager) then coc_treasure_manager.save(packet) end surge_manager.actor_on_save(binder,packet) psi_storm_manager.actor_on_save(binder,packet) end ------------------- -- actor_on_load(bind_stalker,packet) -- IMPORTANT: Cannot be used as callback because this needs to be done in specific order, just call script directly! ------------------- function actor_on_load(binder,packet) if (coc_treasure_manager) then coc_treasure_manager.load(packet) end surge_manager.actor_on_load(binder,packet) psi_storm_manager.actor_on_load(binder,packet) end --------------------------------------------- -- on_key_press --------------------------------------------- function on_key_press(binder,key) SendScriptCallback("on_key_press",key) end --------------------------------------------- -- on_key_release --------------------------------------------- function on_key_release(binder,key) SendScriptCallback("on_key_release",key) end --------------------------------------------- -- on_key_hold --------------------------------------------- function on_key_hold(binder,key) SendScriptCallback("on_key_hold",key) end --------------------------------------------- -- on_actor_before_death --------------------------------------------- function actor_on_before_death(binder,whoID) local flags = { ret_value = true } SendScriptCallback("actor_on_before_death",whoID,flags) if (flags.ret_value == true) then db.actor:kill(db.actor, true) end end --------------------------------------------- -- on_attach_vehicle --------------------------------------------- function actor_on_attach_vehicle(binder,obj) SendScriptCallback("actor_on_attach_vehicle",obj) end --------------------------------------------- -- on_detach_vehicle --------------------------------------------- function actor_on_detach_vehicle(binder,obj) SendScriptCallback("actor_on_detach_vehicle",obj) if (obj:section() == "deployable_mgun") then local se_obj = alife_object(obj:id()) if (se_obj) then alife():release(se_obj) end alife():create("itm_deployable_mgun",vector(),0,0,0) end end --------------------------------------------- -- on_use_vehicle --------------------------------------------- function actor_on_use_vehicle(binder,obj) SendScriptCallback("actor_on_use_vehicle",obj) end --------------------------------------------- -- actor_on_task_callback --------------------------------------------- function actor_on_task_callback(binder,_task, _state) if _state ~= task.fail then if _state == task.completed then news_manager.send_task(db.actor, "complete", _task) else news_manager.send_task(db.actor, "new", _task) end end task_manager.task_callback(_task, _state) end ------------------------------------------ -- anabiotic_callback ------------------------------------------ function anabiotic_callback() level.add_cam_effector("camera_effects\\surge_01.anm", 10, false, "bind_stalker_ext.anabiotic_callback2") local rnd = math.random(35,45) local m = surge_manager.get_surge_manager() if(m.started) then local tf = level.get_time_factor() local diff_sec = math.ceil(game.get_game_time():diffSec(m.inited_time)/tf) if(rnd>(m.surge_time-diff_sec)*tf/60) then m.time_forwarded = true m.ui_disabled = true m:end_surge() end end m = psi_storm_manager.get_psi_storm_manager() if(m and m.started) then local tf = level.get_time_factor() local diff_sec = math.ceil(game.get_game_time():diffSec(m.inited_time)/tf) if(rnd>(m.psi_storm_duration-diff_sec)*tf/60) then m.time_forwarded = true --m.ui_disabled = true m:finish() end end level.change_game_time(0,0,rnd) level_weathers.get_weather_manager():forced_weather_change() --printf("anabiotic_callback: time forwarded on [%d]", rnd) end function anabiotic_callback2() xr_effects.enable_ui_anabiotic(db.actor, nil) get_console():execute("snd_volume_music "..tostring(_G.mus_vol)) get_console():execute("snd_volume_eff "..tostring(_G.amb_vol)) _G.amb_vol = 0 _G.mus_vol = 0 disable_info("anabiotic_in_process") end function actor_on_info_callback(binder,obj,info_id) SendScriptCallback("actor_on_info_callback",obj,info_id) end function actor_item_to_belt(binder,obj) SendScriptCallback("actor_item_to_belt",obj) end function actor_item_to_slot(binder,obj) if (axr_main.config:r_value("mm_options","enable_outfit_portrait",1,false) == true) then local outfit = db.actor:item_in_slot(7) if (outfit and outfit:id() == obj:id()) then local icon = system_ini():r_string_ex(outfit:section(),"character_portrait") if (icon) then db.actor:set_character_icon(icon) elseif (db.actor_binder.character_icon) then -- use default portrait if no outfit portrait exists db.actor:set_character_icon(db.actor_binder.character_icon) end end end SendScriptCallback("actor_item_to_slot",obj) end function actor_item_to_ruck(binder,obj) if (axr_main.config:r_value("mm_options","enable_outfit_portrait",1,false) == true) and IsOutfit(obj) then local outfit = db.actor:item_in_slot(7) if (outfit == nil and db.actor_binder.character_icon) then db.actor:set_character_icon(db.actor_binder.character_icon) end end SendScriptCallback("actor_item_to_ruck",obj) end function actor_on_weapon_jammed(binder,wpn) SendScriptCallback("actor_on_weapon_jammed",wpn) end function actor_on_weapon_magazine_empty(binder,wpn,ammo_total) --printf("weapon_no_ammo wpn=%s ammo_total=%s",wpn and wpn:name(),ammo_total) SendScriptCallback("actor_on_weapon_no_ammo",wpn,ammo_total) end function actor_on_weapon_reload(binder,wpn,ammo_total) SendScriptCallback("actor_on_weapon_reload",wpn,ammo_total) end function actor_on_hud_animation_end(binder,item,section,motion,state,slot) --printf("hud_animation_end [%s] sec=%s motion=%s state=%s slot=%s",item and item:name(),section,motion,state,slot) SendScriptCallback("actor_on_hud_animation_end",item,section,motion,state,slot) end function actor_on_hit_callback(binder, obj, amount, local_direction, who, bone_index) if (amount <= 0) then return end SendScriptCallback("actor_on_hit_callback",obj, amount, local_direction, who, bone_index) end