Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. if not SanicSpeedBoost then
  2.   _G.SanicSpeedBoost = {}
  3.  
  4.   SanicSpeedBoost.volume_fp = 1 -- first person audio volume multiplier
  5.   SanicSpeedBoost.volume_tp = 2 -- third person audio volume multiplier
  6.  
  7.   blt.xaudio.setup()
  8.   -- changed buffer to contain multiple sounds here
  9.   SanicSpeedBoost.buffer = {}
  10.   SanicSpeedBoost.buffer[1] = XAudio.Buffer:new(ModPath .. "sound1.ogg")
  11.   SanicSpeedBoost.buffer[2] = XAudio.Buffer:new(ModPath .. "sound2.ogg")
  12.   SanicSpeedBoost.buffer[3] = XAudio.Buffer:new(ModPath .. "sound3.ogg")
  13.   SanicSpeedBoost.buffer[4] = XAudio.Buffer:new(ModPath .. "sound4.ogg")
  14.   -- till here
  15.  
  16.   function SanicSpeedBoost:play_sound(unit, third_person)
  17.     if not alive(unit) then
  18.       return
  19.     end
  20.     local u_base = unit:base()
  21.     if not u_base._sanic_last_t or u_base._sanic_last_t < Application:time() + 8 then
  22.       u_base._sanic_last_t = Application:time()
  23.       -- changed following line to randomly play one of the sounds
  24.       local src = third_person and XAudio.UnitSource:new(unit, SanicSpeedBoost.buffer[math.random(4)]) or XAudio.Source:new(SanicSpeedBoost.buffer[math.random(4)])
  25.       if not third_person then
  26.         src:set_relative(true)
  27.       end
  28.       src._gain = third_person and SanicSpeedBoost.volume_tp or SanicSpeedBoost.volume_fp
  29.     end
  30.   end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement