-- Original Script By Aoldri, Majorly fucked up my BarryBogs. function play_sound_from_anm(anm_name, section, sound_name) local snd_path = SYS_GetParam(0, section, sound_name or anm_name:gsub("anm_", "snd_".. section .. "_"), "$no_sound") if snd_path and ini_sys:section_exist(snd_path) then n = ini_sys:line_count(snd_path) or 0 for i=0,n-1 do result, id, value = ini_sys:r_line_ex(snd_path,i,"","") local snd_layer = xr_sound.get_safe_sound_object( value ) if snd_layer then --snd_layer:play(db.actor, 0, sound_object.s2d) --snd_layer:play_at_pos(db.actor,db.actor:position(),0,sound_object.s2d) -- sound_object.s3d? utils_obj.play_sound(value) end end elseif snd_path then local snd_obj = xr_sound.get_safe_sound_object( snd_path ) if snd_obj then snd_obj:play(db.actor, 0, sound_object.s2d) --snd_obj:play_at_pos(db.actor,db.actor:position(),0,sound_object.s2d) end end end local valid_anms = { ["anm_shot_l"] = true, ["anm_shots"] = true, } function actor_on_hud_animation_play(anm_table, item) --local item = db.actor:active_item() if not item then return end local parent_section = SYS_GetParam(0, item:section(), "parent_section", item:section()) -- printf("parent_section: " .. parent_section ) if parent_section and parent_section == "wpn_vssk" then --printf("Vssk anm: " .. anm_table.anm_name) if valid_anms[anm_table.anm_name] then --printf("playsound") play_sound_from_anm(anm_table.anm_name, parent_section) end if anm_table.anm_name == "anm_reload_misfire" and item:get_ammo_in_magazine() == 0 then anm_table.anm_name = "anm_reload_misfire_empty" -- Switches animation to the misfire_empty play_sound_from_anm(anm_table.anm_name, parent_section) elseif anm_table.anm_name == "anm_reload_misfire" then play_sound_from_anm(anm_table.anm_name, parent_section) -- Play variations of anm_bore animations elseif anm_table.anm_name == "anm_bore" then local bore_anims = {} table.insert(bore_anims, {anm = "anm_bore"}) table.insert(bore_anims, {anm = "anm_ammo_check", snd = "snd_ammo_check"}) local picked_anim = bore_anims[math.random(#bore_anims)] if picked_anim.anm ~= "anm_bore" then anm_table.anm_name = picked_anim.anm play_sound_from_anm(anm_table.anm_name, parent_section, picked_anim.snd) end -- Play variations of anm_bore_empty animations elseif anm_table.anm_name == "anm_bore_empty" then local bore_anims = {} table.insert(bore_anims, {anm = "anm_bore_empty"}) table.insert(bore_anims, {anm = "anm_ammo_check_empty", snd = "snd_ammo_check"}) local picked_anim = bore_anims[math.random(#bore_anims)] if picked_anim.anm ~= "anm_bore_empty" then anm_table.anm_name = picked_anim.anm play_sound_from_anm(anm_table.anm_name, parent_section, picked_anim.snd) end end end end function on_key_press(key) local weapon = db.actor:active_item() if key == DIK_keys.MOUSE_2 and arti_jamming and weapon and weapon:get_state() == 4 then weapon:switch_state(0) end end function on_game_start() -- RegisterScriptCallback("actor_on_weapon_fired",actor_on_weapon_fired) RegisterScriptCallback("actor_on_hud_animation_play",actor_on_hud_animation_play) RegisterScriptCallback("on_key_press", on_key_press) end