Advertisement
spinsquad

no visual recoil w/ nospread

Mar 24th, 2015
1,097
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. local Angle = Angle;
  2. local pcall = pcall;
  3. local require = require;
  4. local print = print;
  5. local Vector = Vector;
  6. local math = math;
  7. local me = LocalPlayer();
  8.  
  9. local em = FindMetaTable("Entity");
  10.  
  11. local fa;
  12.  
  13. local e, err = pcall(function() require("dickwrap") end);
  14.  
  15. if(err) then print("nononono"); return; end
  16.  
  17. local ofb = em.FireBullets;
  18.  
  19. local cones = {};
  20. local nullvec = Vector() * -1;
  21.  
  22. function em.FireBullets(p, data)
  23.     local spread = data.Spread * -1;
  24.     local class = p:GetActiveWeapon():GetClass();
  25.     if (spread != cones[class] && spread != nullvec) then
  26.         cones[class] = spread;
  27.     end
  28.     return(ofb(p, data));
  29. end
  30.  
  31. local function PredictSpread(ucmd, ang)
  32.     local w = me:GetActiveWeapon();
  33.     if (!w || !w:IsValid() || !cones[w:GetClass()]) then return ang; end
  34.     local ang = (dickwrap.Predict(ucmd, ang:Forward(), cones[w:GetClass()])):Angle();
  35.     ang.y, ang.x = math.NormalizeAngle(ang.y), math.NormalizeAngle(ang.x);
  36.     return(ang);
  37. end
  38.  
  39. hook.Add("CalcView", "", function(p, o, a, f)
  40.     local view = {};
  41.     view.angles = (fa && fa || a);
  42.     view.fov = f;
  43.     view.origin = o;
  44.     return view;
  45. end);
  46.  
  47. hook.Add("CreateMove", "", function(ucmd)
  48.     if(!fa) then fa = ucmd:GetViewAngles(); end
  49.    
  50.     fa = fa + Angle(ucmd:GetMouseY() * .023, ucmd:GetMouseX() * -.023, 0);
  51.     fa.p, fa.y, fa.x = math.Clamp(fa.p, -89, 89), math.NormalizeAngle(fa.y), math.NormalizeAngle(fa.x);
  52.    
  53.     local ang = fa;
  54.    
  55.     if(ucmd:KeyDown(IN_ATTACK)) then
  56.         ang = PredictSpread(ucmd, ang);
  57.     end
  58.    
  59.     ucmd:SetViewAngles(ang);
  60. end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement