Advertisement
Nuor

item_take_enhanced.script

Dec 15th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. local take_sound
  2. feature_is_active, hide_delay = nil, nil
  3.  
  4. function activate_feature()
  5. if (feature_is_active) then
  6. return
  7. end
  8. feature_is_active = true
  9.  
  10. hide_delay = 0
  11. RegisterScriptCallback("actor_on_item_take",actor_on_item_take)
  12. RegisterScriptCallback("actor_on_weapon_reload",actor_on_weapon_reload)
  13. end
  14.  
  15. function deactivate_feature()
  16. if not (feature_is_active) then
  17. return
  18. end
  19. feature_is_active = false
  20.  
  21. hide_delay = nil
  22. take_sound = nil
  23. UnregisterScriptCallback("actor_on_item_take",actor_on_item_take)
  24. UnregisterScriptCallback("on_game_load",on_game_load)
  25. end
  26.  
  27. local function opt_menu_on_init(menu)
  28. -- item_take
  29. menu.gameplay_options["item_take"] = {default=false, debug_only=false, typ="check",
  30. on_accept=function(handler,optMgr,ctrl)
  31. if (level.present()) then
  32. if (ctrl:GetCheck()) then
  33. activate_feature()
  34. else
  35. deactivate_feature()
  36. end
  37. end
  38. end
  39. }
  40. end
  41.  
  42. function on_game_start()
  43. RegisterScriptCallback("opt_menu_on_init",opt_menu_on_init)
  44. if (axr_main.config:r_value("mm_options","enable_item_take",1,false) == false) then return end
  45. local function actor_on_first_update()
  46. activate_feature()
  47. end
  48. RegisterScriptCallback("actor_on_first_update",actor_on_first_update)
  49. end
  50.  
  51. function actor_on_weapon_reload(wpn,ammo)
  52. hide_delay = 0
  53. end
  54.  
  55. function hide_wpn()
  56. if db.actor_binder.weapon_hide == true then
  57. db.actor_binder.weapon_hide = false
  58. db.actor:restore_weapon()
  59. end
  60. return true
  61. end
  62.  
  63. function actor_on_item_take(obj)
  64. local inv_hud = ActorMenu.get_actor_menu()
  65. local as = db.actor:active_slot()
  66. xr_sound.set_sound_play(db.actor:id(), get_take_sound(obj))
  67. if (inv_hud and inv_hud:IsShown()) then return end
  68. if (as == 0) or ((as <= 6) and (db.actor:item_in_slot(as) == nil)) then return end
  69. if hide_delay == 0 then CreateTimeEvent(0,"delay",5,function() hide_delay = 4 return true end) return end
  70. if (db.actor_binder.weapon_hide == false) then
  71. level.add_cam_effector("camera_effects\\actor_move\\go_down_4s_old.anm")
  72. db.actor:hide_weapon()
  73. db.actor_binder.weapon_hide = true
  74. CreateTimeEvent(0,"hide_weapon",hide_delay,hide_wpn)
  75. end
  76.  
  77. end
  78.  
  79. function get_take_sound(itm)
  80. local cls = itm:clsid()
  81. local bottle = (cls == clsid.obj_food_s) and system_ini():r_string_ex(itm:section(),"use_sound")
  82. --if bottle then news_manager.send_tip(db.actor, tostring(bottle:match(".inv_[drink]*[_]?([%w_]+)")), nil, nil, nil, 10000) end
  83. --cls = bottle and bottle:match(".inv_[drink]*[_]?([%w_]+)")
  84. cls = bottle and (bottle:find("inv_drink_") or bottle:find("inv_softdrink") or bottle:find("inv_vodka")) and "bottle" or cls
  85. if not take_sound then
  86. take_sound = {
  87. 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},
  88. pistol_take = {clsid.wpn_hpsa_s,clsid.wpn_pm_s,clsid.wpn_walther_s,clsid.wpn_usp45_s},
  89. documents_take = {clsid.obj_docs_s},
  90. key_take = {clsid.obj_key_s},
  91. outfit_take = {clsid.equ_stalker_s,clsid.equ_helmet_s},
  92. pills_take = {clsid.obj_medkit_s,clsid.obj_bandage_s,clsid.obj_antirad_s},
  93. 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},
  94. bottle_take = {"bottle"},
  95. --bottle_take = {"softdrink","vodka","can2","flask_effect","tea","flask_2","flask_beer"},
  96. artefact_take = {clsid.artefact_s},
  97. ammo_take = {clsid.wpn_ammo_s,clsid.wpn_ammo_vog25_s,clsid.wpn_ammo_og7b_s,clsid.wpn_ammo_m209_s},
  98. instrum_take = {clsid.obj_instrum_s},
  99. grenade_take = {clsid.wpn_grenade_f1_s,clsid.wpn_grenade_rgd5_s},
  100. food_take = {clsid.obj_food_s}
  101. }
  102. end
  103.  
  104. for sound, cl in pairs(take_sound) do
  105. for i=1,#cl do
  106. if cl[i] == cls then
  107. return sound
  108. end
  109. end
  110. end
  111. return "ammo_take"
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement