Advertisement
offyerrocker

AFSF 6-24-17

Jul 3rd, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Header comment that will likely be deleted. This was made by 90e.
  2. --24 June 2017, fixed Little Friend 7.62/contrabandm203 using single fire bullet shot when using underbarrel grenade launcher mode
  3. -- <3 Offy
  4.  
  5. -- Don't play a sound conventionally (unless using the saw which lacks a single fire sound)
  6.  
  7. local base_fire_sound = RaycastWeaponBase._fire_sound
  8.  
  9. function RaycastWeaponBase:_fire_sound()
  10.     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
  11.         base_fire_sound(self)
  12.     end --to delete?
  13. end
  14.  
  15. -- Instead play the single fire noise here
  16.  
  17. local old_fire = RaycastWeaponBase.fire
  18. function RaycastWeaponBase:fire(...)
  19.     local result = old_fire(self, ...)
  20.  
  21.     -- Don't try playing the single fire sound with the saw; minigun = m134
  22.     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
  23.         return result
  24.     end
  25.  
  26.     if result and not self:gadget_overrides_weapon_functions() then
  27.         self:play_tweak_data_sound("fire_single", "fire")
  28.     elseif self:gadget_overrides_weapon_functions() then
  29.         self:play_tweak_data_sound(self:fire_mode() == "auto" and "fire_auto" or "fire_single", "fire")
  30.     end
  31.     return result
  32. end
  33.  
  34. function RaycastWeaponBase:play_tweak_data_sound(event, alternative_event)
  35.     local sounds = tweak_data.weapon[self._name_id].sounds
  36.    
  37.     --overrides and uses vanilla method to determine "event" if using the little friend underbarrel mode
  38.     --clumsy method of determining which way to get event and play_sound, will fix that later probably
  39.     if self:gadget_overrides_weapon_functions() then
  40.     local event = self:_get_sound_event(event, alternative_event)
  41.         self:play_sound(event)
  42.     elseif event then
  43.         local event = (sounds and (sounds[event] or sounds[alternative_event])) --otherwise uses AFSF's singlefire override
  44.         self:play_sound(event)
  45.     end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement