Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local take_sound
- feature_is_active, hide_delay = nil, nil
- function activate_feature()
- if (feature_is_active) then
- return
- end
- feature_is_active = true
- hide_delay = 0
- RegisterScriptCallback("actor_on_item_take",actor_on_item_take)
- RegisterScriptCallback("actor_on_weapon_reload",actor_on_weapon_reload)
- end
- function deactivate_feature()
- if not (feature_is_active) then
- return
- end
- feature_is_active = false
- hide_delay = nil
- take_sound = nil
- UnregisterScriptCallback("actor_on_item_take",actor_on_item_take)
- UnregisterScriptCallback("on_game_load",on_game_load)
- end
- local function opt_menu_on_init(menu)
- -- item_take
- menu.gameplay_options["item_take"] = {default=false, debug_only=false, typ="check",
- on_accept=function(handler,optMgr,ctrl)
- if (level.present()) then
- if (ctrl:GetCheck()) then
- activate_feature()
- else
- deactivate_feature()
- end
- end
- end
- }
- end
- function on_game_start()
- RegisterScriptCallback("opt_menu_on_init",opt_menu_on_init)
- if (axr_main.config:r_value("mm_options","enable_item_take",1,false) == false) then return end
- local function actor_on_first_update()
- activate_feature()
- end
- RegisterScriptCallback("actor_on_first_update",actor_on_first_update)
- end
- function actor_on_weapon_reload(wpn,ammo)
- hide_delay = 0
- end
- function hide_wpn()
- if db.actor_binder.weapon_hide == true then
- db.actor_binder.weapon_hide = false
- db.actor:restore_weapon()
- end
- return true
- end
- function actor_on_item_take(obj)
- local inv_hud = ActorMenu.get_actor_menu()
- local as = db.actor:active_slot()
- xr_sound.set_sound_play(db.actor:id(), get_take_sound(obj))
- if (inv_hud and inv_hud:IsShown()) then return end
- if (as == 0) or ((as <= 6) and (db.actor:item_in_slot(as) == nil)) then return end
- if hide_delay == 0 then CreateTimeEvent(0,"delay",5,function() hide_delay = 4 return true end) return end
- if (db.actor_binder.weapon_hide == false) then
- level.add_cam_effector("camera_effects\\actor_move\\go_down_4s_old.anm")
- db.actor:hide_weapon()
- db.actor_binder.weapon_hide = true
- CreateTimeEvent(0,"hide_weapon",hide_delay,hide_wpn)
- end
- end
- function get_take_sound(itm)
- local cls = itm:clsid()
- local bottle = (cls == clsid.obj_food_s) and system_ini():r_string_ex(itm:section(),"use_sound")
- --if bottle then news_manager.send_tip(db.actor, tostring(bottle:match(".inv_[drink]*[_]?([%w_]+)")), nil, nil, nil, 10000) end
- --cls = bottle and bottle:match(".inv_[drink]*[_]?([%w_]+)")
- cls = bottle and (bottle:find("inv_drink_") or bottle:find("inv_softdrink") or bottle:find("inv_vodka")) and "bottle" or cls
- if not take_sound then
- take_sound = {
- rifle_take = {clsid.wpn_bm16_s, clsid.wpn_groza_s,clsid.wpn_svd_s,clsid.wpn_ak74_s,clsid.wpn_lr300_s,clsid.wpn_rg6_s,clsid.wpn_rpg7_s,clsid.wpn_shotgun_s,clsid.wpn_auto_shotgun_s,clsid.wpn_magazined_s,clsid.wpn_svu_s,clsid.wpn_val_s,clsid.wpn_vintorez_s},
- pistol_take = {clsid.wpn_hpsa_s,clsid.wpn_pm_s,clsid.wpn_walther_s,clsid.wpn_usp45_s},
- documents_take = {clsid.obj_docs_s},
- key_take = {clsid.obj_key_s},
- outfit_take = {clsid.equ_stalker_s,clsid.equ_helmet_s},
- pills_take = {clsid.obj_medkit_s,clsid.obj_bandage_s,clsid.obj_antirad_s},
- pda_take = {clsid.detector_scientific_s,clsid.detector_elite_s,clsid.detector_advanced_s,clsid.detector_simple_s,clsid.wpn_scope_s,clsid.wpn_silencer_s,clsid.wpn_grenade_launcher_s,clsid.obj_pda_s},
- bottle_take = {"bottle"},
- --bottle_take = {"softdrink","vodka","can2","flask_effect","tea","flask_2","flask_beer"},
- artefact_take = {clsid.artefact_s},
- ammo_take = {clsid.wpn_ammo_s,clsid.wpn_ammo_vog25_s,clsid.wpn_ammo_og7b_s,clsid.wpn_ammo_m209_s},
- instrum_take = {clsid.obj_instrum_s},
- grenade_take = {clsid.wpn_grenade_f1_s,clsid.wpn_grenade_rgd5_s},
- food_take = {clsid.obj_food_s}
- }
- end
- for sound, cl in pairs(take_sound) do
- for i=1,#cl do
- if cl[i] == cls then
- return sound
- end
- end
- end
- return "ammo_take"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement