--==============( Ported from CoC 1.5, used for Azazel mode & invulnerability time )==============-- --[[ bind_stalker_ext.script Extends the functionality of bind_stalker.script without filling it with clutter by: Alundaio --]] local K_CTRL = DIK_keys.DIK_LCONTROL local K_SHIFT = DIK_keys.DIK_LSHIFT local K_ALT = DIK_keys.DIK_LMENU ------------------- -- 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) AddUniqueCall(ProcessEventQueue) end ------------------- -- actor_on_net_spawn ------------------- function actor_on_net_spawn() if (ui_options.get("gameplay/general/hardcore_ai_aim")) then exec_console_cmd("ai_aim_max_angle 25.0") exec_console_cmd("ai_aim_min_angle 20.0") exec_console_cmd("ai_aim_min_speed 2.5") exec_console_cmd("ai_aim_predict_time 0.15") else exec_console_cmd("ai_aim_max_angle 25.0") exec_console_cmd("ai_aim_min_angle 20.0") exec_console_cmd("ai_aim_min_speed 2.5") exec_console_cmd("ai_aim_predict_time 0.15") end -- some hacks local sim = alife() local remove_outfits = not db.actor:has_info("remove_outfits_hack") for i=1,65534 do local se_obj = sim:object(i) if (se_obj) then -- hack to remove phantoms if (se_obj:clsid() == clsid.phantom) then --printf("release phantom hack!") safe_release_manager.release(se_obj) end end end if (remove_outfits) then db.actor:give_info_portion("remove_outfits_hack") 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) invulnerable_time = invulnerable_time or time_global() + 7000 SendScriptCallback("actor_on_first_update",binder,delta) end function actor_on_update(binder,delta) if not (db.actor:alive()) then return end -- 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 = 0 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_fire(actor,wpn,elapsed) ------------------- function actor_on_weapon_fired(binder,obj,wpn,ammo_elapsed,grenade_elapsed,ammo_type,grenade_type) SendScriptCallback("actor_on_weapon_fired",obj,wpn,ammo_elapsed,grenade_elapsed,ammo_type,grenade_type) 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_anabiotic") then xr_effects.disable_ui_only(db.actor, nil) level.add_cam_effector("camera_effects\\surge_02.anm", 10, false, "bind_stalker_ext.anabiotic_callback") level.add_pp_effector("surge_fade.ppe", 11, false) give_info("anabiotic_in_process") _G.mus_vol = get_console_cmd(2,"snd_volume_music") _G.amb_vol = get_console_cmd(2,"snd_volume_eff") exec_console_cmd("snd_volume_music 0") exec_console_cmd("snd_volume_eff 0") elseif (sec == "drug_psy_blockade" or sec == "drug_radioprotector" or sec == "drug_antidot") then local boost_time = ini_sys:r_float_ex(sec,"boost_time") save_var(db.actor,sec.."_expiration",utils_data.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") --task_manager.get_task_manager():set_task_cancelled("faction_base_defense") -->> LD SendScriptCallback("on_level_changing") end if (treasure_manager) then 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 (treasure_manager) then treasure_manager.load(packet) end surge_manager.actor_on_load(binder,packet) psi_storm_manager.actor_on_load(binder,packet) end local flags = { ret_value = true } function actor_on_item_before_pickup(item) -- called from engine! -- Called when actor is pressing use key to pick up an item -- return false will prevent actor from pickup the item SendScriptCallback("actor_on_item_before_pickup",item,flags) return flags.ret_value end --------------------------------------------- -- on_key_press --------------------------------------------- function on_key_press(binder,key) if (not KEYS_UNLOCK) then if key == K_CTRL or key == K_SHIFT or key == K_ALT then else return end end SendScriptCallback("on_key_press",key) end --------------------------------------------- -- on_key_release --------------------------------------------- function on_key_release(binder,key) if (not KEYS_UNLOCK) then if key == K_CTRL or key == K_SHIFT or key == K_ALT then else return end end SendScriptCallback("on_key_release",key) end --------------------------------------------- -- on_key_hold --------------------------------------------- function on_key_hold(binder,key) --[[ if (not KEYS_UNLOCK) then if key == K_CTRL or key == K_SHIFT or key == K_ALT then else return end end --]] 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 alife_release_id(obj:id()) alife_create_item("itm_deployable_mgun", db.actor) 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(db.actor, nil) exec_console_cmd("snd_volume_music "..tostring(_G.mus_vol)) exec_console_cmd("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) --printf("info_id = %s",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 (ui_options.get("gameplay/general/outfit_portrait") == true) then local outfit = db.actor:item_in_slot(7) if (outfit and outfit:id() == obj:id()) then local icon = ini_sys: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 (ui_options.get("gameplay/general/outfit_portrait") == 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,actor,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_lowered(binder,wpn) SendScriptCallback("actor_on_weapon_lower",wpn) end function actor_on_weapon_raised(binder,wpn) SendScriptCallback("actor_on_weapon_raise",wpn) 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 function actor_on_foot_step(binder,obj,power,b_play,b_on_ground,b_hud_view) SendScriptCallback("actor_on_foot_step",obj,power,b_play,b_on_ground,b_hud_view) end