Advertisement
Guest User

tfa nospread "pseudo"code

a guest
Jun 9th, 2019
1,506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. local function PredictSpread(pCmd, ang)
  2. // engine nospread (previously posted somewhere)
  3.  
  4. if (wep.Base && string.StartWith(wep.Base, "tfa_")) then // remove view punch angles on tfa, this impacts our shoot pos
  5. local viewPAngles = me:GetViewPunchAngles()
  6. spreadAngles = spreadAngles - viewPAngles
  7. end
  8.  
  9. spreadAngles:Normalize()
  10.  
  11. return spreadAngles:Forward()
  12.  
  13. end
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. hook.Add("CreateMove", "nospread", function(pCmd)
  22.  
  23. if(pCmd:CommandNumber() == 0 or pCmd == nil) then
  24. return
  25. end
  26.  
  27. local wep = ply:GetActiveWeapon()
  28.  
  29.  
  30. if (IsValid(wep) && wep.Base && string.StartWith(wep.Base, "tfa_")) then
  31.  
  32. local cone, recoil = wep:CalculateConeRecoil()
  33.  
  34. if (!cone) then return end
  35.  
  36. spread[wep:GetClass()] = {
  37. x = cone,
  38. y = cone
  39. }
  40.  
  41. end
  42.  
  43.  
  44. if (IsValid(wep) && spread[wep:GetClass()]) then // constant nospread
  45.  
  46.  
  47. local ang = PredictSpread(pCmd, fa):Angle()
  48.  
  49. pCmd:SetViewAngles(ang)
  50.  
  51. end
  52.  
  53. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement