-- DESCRIPTION: Gunfire shake effect -- DESCRIPTION: [Trauma#=25(0,100)] -- DESCRIPTION: [Fade#=2(2,10)] -- DESCRIPTION: [Period#=50(1,200)] local trauma = 25 local fade = 2 local period = 50 function gunfire_shake_properties( e, t, f, p ) trauma = t fade = f period = p end function gunfire_shake_init( e ) end local oldWeapon = nil local currWpnIndex = nil local oldAmmo = 0 local function shotFired() local wid = GetPlayerWeaponID() -- no weapon equipped so do nothing if wid == 0 then return false end -- check if player changes weapon if wid ~= oldWeapon then for a = 0,9 do if wid == GetWeaponSlot( a ) then currWpnIndex = a break end end oldWeapon = wid oldAmmo = GetWeaponAmmo( currWpnIndex ) return end -- ammo counter logic local currentammo = GetWeaponAmmo( currWpnIndex ) -- if ammo goes down we fired if currentammo < oldAmmo then oldAmmo = currentammo return true -- if ammo goes up we reloaded elseif currentammo > oldAmmo then oldAmmo = currentammo end end function gunfire_shake_main( e ) -- early return if not compatible gameplayercontrol available if GamePlayerControlSetShakeTrauma == nil then return end if shotFired() then GamePlayerControlAddShakeTrauma( trauma ) GamePlayerControlAddShakePeriod( period ) GamePlayerControlAddShakeFade( fade, true ) end end