offyerrocker

AutoFireSoundFix.lua

Oct 17th, 2016
2,634
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Autofire Soundfix, unofficial hotfix Post-U109
  2. --edit: 17.10.16 fixed! Sorry, uploaded an old version. Now it ACTUALLY works.
  3. local base_fire_sound = RaycastWeaponBase._fire_sound
  4.  
  5. function RaycastWeaponBase:_fire_sound()
  6.     if self:get_name_id() == "saw" or self:get_name_id() == "saw_secondary" or self:get_name_id() == "m134" or self:get_name_id() == "flamethrower_mk2" or self:get_name_id() == "mg42" then
  7.         base_fire_sound(self)
  8.     end --to delete?
  9. end
  10.  
  11. local old_fire = RaycastWeaponBase.fire
  12. function RaycastWeaponBase:fire(...)
  13.     local result = old_fire(self, ...)
  14.  
  15.     if self:get_name_id() == "saw" or self:get_name_id() == "saw_secondary" or self:get_name_id() == "m134" or self:get_name_id() == "flamethrower_mk2" or self:get_name_id() == "mg42" then
  16.         return result
  17.     end
  18.  
  19.     if result then
  20.         self:play_tweak_data_sound("fire_single", "fire")
  21.     end
  22.  
  23.     return result
  24. end
  25.  
  26.  
  27. function RaycastWeaponBase:play_tweak_data_sound(event, alternative_event)
  28.     local sounds = tweak_data.weapon[self._name_id].sounds
  29.     local event = sounds and (sounds[event] or sounds[alternative_event])
  30.     if event then
  31.         self:play_sound(event)
  32.     end
  33. end
RAW Paste Data