Advertisement
WeltEnSTurm

ugliest code ever

Jul 14th, 2012
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.96 KB | None | 0 0
  1. wac.hook("CalcView", "wac_weapons_cview", function(p, pos, ang, fov)
  2.     local pl=LocalPlayer()
  3.     if pl:InVehicle() or !pl:Alive() then return end
  4.     local self=p:GetActiveWeapon()
  5.     if GetGlobalBool("WAC_DISABLE_AIM") or self.wac_weaponview_ignore then return end
  6.     if !ValidEntity(self) then return end
  7.     if !CheckAllow(self, pl) then
  8.         viewang=ang
  9.         oldang=ang
  10.         viewang.r=0
  11.         oldang.r=0
  12.         return
  13.     end
  14.     if CheckSwep(self) then return end
  15.     local vel=pl:GetVelocity()
  16.     local lvel=vel:Length()
  17.     local FrT=FrameTime()
  18.     local crt = CurTime()
  19.     viewang=viewang or ang
  20.     oldang=oldang or ang
  21.     local PDiff = math.AngleDifference(viewang.p, ang.p)
  22.     local YDiff = math.AngleDifference(viewang.y, ang.y)
  23.     local aPDiff=math.AngleDifference(oldang.p,ang.p)
  24.     local aYDiff=math.AngleDifference(oldang.y,ang.y)
  25.     viewang.p = viewang.p-((PDiff*math.Clamp(math.abs(PDiff),self.AngM,self.AngMax)*0.01)*(1-f_smZ)+(PDiff*math.Clamp(math.abs(PDiff),self.AngMz,self.AngMaxz)*0.1)*f_smZ)
  26.     viewang.y = viewang.y-((YDiff*math.Clamp(math.abs(YDiff),self.AngM,self.AngMax)*0.01)*(1-f_smZ)+(YDiff*math.Clamp(math.abs(YDiff),self.AngMz,self.AngMaxz)*0.1)*f_smZ)
  27.     viewang.r=0
  28.     VMPosAdd.x = math.Clamp(VMPosAdd.x - (1-math.abs(VMPosAdd.x)/self.VMPosMax.x)*aYDiff*(self.VMPosM.x*(1-f_smZ)+self.VMPosMz.x*f_smZ)*math.Clamp(70-math.abs(ang.p),-30,30)/30 - VMPosAdd.x*(self.VMPosD.x*(1-f_smZ)+self.VMPosDz.x*f_smZ), -(self.VMPosMax.x*(1-f_smZ)+self.VMPosMaxz.x*f_smZ), self.VMPosMax.x*(1-f_smZ)+self.VMPosMaxz.x*f_smZ)
  29.     VMPosAdd.z = math.Clamp(VMPosAdd.z - (1-math.abs(VMPosAdd.z)/self.VMPosMax.z)*aPDiff*(self.VMPosM.z*(1-f_smZ)+self.VMPosMz.z*f_smZ)*math.Clamp(70-math.abs(ang.p),-30,30)/30 - VMPosAdd.z*(self.VMPosD.z*(1-f_smZ)+self.VMPosDz.z*f_smZ), -(self.VMPosMax.z*(1-f_smZ)+self.VMPosMaxz.z*f_smZ), self.VMPosMax.z*(1-f_smZ)+self.VMPosMaxz.z*f_smZ)
  30.     if (f_smZ >= 0.9 and zoomed(self) and self.ZoomOverlay and !self.zmFull) then
  31.         self.zmFull = true
  32.         self.zoomBlack=255
  33.         pl:GetViewModel():SetNoDraw(true)
  34.     elseif self.zmFull and f_smZ < 0.9 then
  35.         self.zmFull = false
  36.         pl:GetViewModel():SetNoDraw(false)
  37.     end
  38.     local ri = viewang:Right()
  39.     local up = viewang:Up()
  40.     local fwd = viewang:Forward()
  41.     local VMFlip = (self.ViewModelFlip)and(-1)or(1)
  42.     local VMFlop = 0-VMFlip
  43.     local pvel=pl:WorldToLocal(pl:GetPos()+(pos-lastpos)*100)
  44.     lastpos=pos
  45.     local runsinx=math.sin(viewtime*14)*f_smGr
  46.     local runsiny=math.sin(viewtime*7)*f_smGr
  47.     local tr=util.QuickTrace(pos,ang:Forward()*23,self.Owner)
  48.     SmoothVars(lvel, self, FrT, crt, tr, pvel, viewang, ang, VMFlip, lastdelta)
  49.     fwd.z=math.Clamp(fwd.z,-1,(1-f_smSpr))
  50.     local m=(0.1*math.Clamp(1-f_smZ,0.01,1)*(p:KeyDown(IN_DUCK) and 0.1 or 1))
  51.     pos=pos+runsinx*up*3*math.Clamp(lvel*lvel*0.00001,m,10)*CVars.bounce:GetFloat()+ri*runsiny*3*math.Clamp(lvel*lvel*0.00001, m, 10)*CVars.bounce:GetFloat()
  52.     --[[local eyes=p:GetAttachment(p:LookupAttachment("eyes"))
  53.     pos=eyes.Pos]]
  54.     view.origin=pos
  55.     view.fov = math.Clamp(fov - (self.zoomStart+((f_smZol+20+(fov-90))*((f_smZ>=0.9 and self.zoomEnd) and 1 or 0)))*f_smZ+CVars.fov:GetFloat(), 1.5, 100)
  56.     if self.ScopeModel then
  57.         self.ScopeModel:SetPos(pos+v_smSpd.x*fwd*-0.01+v_smSpd.y*ri*0.002+v_smSpd.z*up*-0.002)
  58.         self.ScopeModel:SetAngles(viewang-Angle(a_smAngAdd.p,a_smAngAdd.y*VMFlip,a_smAngAdd.r))
  59.         self.ScopeModel:SetModelScale(Vector(0.5, view.fov/100, view.fov/100))
  60.     end
  61.     --local vmang=viewang-a_smAngAdd*0.7+Angle(self.RunAng.p*f_smSpr-ang.p*f_smSpr, self.RunAng.y*f_smSpr*VMFlop+ang.p*f_smSpr*0.4*VMFlip, ang.p*f_smSpr*0.5*VMFlip)*(1-f_smHs)
  62.     local vmang=viewang-a_smAngAdd*0.7+Angle(self.RunAng.p*f_smSpr, self.RunAng.y*f_smSpr*VMFlop, self.RunAng.r*f_smSpr)*(1-f_smHs)
  63.     vmang=vmang+Angle((a_smAng.p+self.AimAng.p*f_smZ)*(1-f_smSpr), (a_smAng.y+self.AimAng.y*f_smZ)*VMFlip*(1-f_smSpr), self.AimAng.r*f_smZ*(1-f_smSpr))*(1-f_smHs)+Angle(f_smHs*90,(f_smHs*-90+runsiny*2*f_smSpr)*VMFlip+runsiny*5*f_smSpr*VMFlop,0)
  64.     pos=pos+ri*(runsiny*-m*VMFlip+runsiny*lvel*0.001+self.VMPosOffset.x*(1-f_smSpr)*(1-f_smZ) +math.Clamp(ang.p*0.05*f_smSpr,0,30)*VMFlip +v_smSpd.y*VMFlip*(1.5-f_smZ)*0.004 +VMPosAdd.x*VMFlip + VMFlip*(self.VMAngAdd.y)*(1-f_smZ)*0.1 +self.RunPos.x*f_smSpr*VMFlop +runsiny*f_smSpr +self.AimPos.x*f_smZ-runsiny*f_smSpr)
  65.     pos=pos+fwd*(CVars.OffsetY:GetFloat()*(1-f_smZ)*(1-f_smSpr)+self.VMPosOffset.y*(1-f_smSpr)*(1-f_smZ) -v_smSpd.x*(1.5-f_smZ)*0.004 -f_smHs*10+VMPosAdd.y +self.RunPos.y*f_smSpr +self.AimPos.y*f_smZ-runsiny*f_smSpr)
  66.     pos=pos+up*(runsinx*-m+runsinx*lvel*0.001+self.VMPosOffset.z*(1-f_smSpr)*(1-f_smZ) -math.Clamp(ang.p*0.05*f_smSpr,0,30) -v_smSpd.z*(2-f_smZ)*0.004 +VMPosAdd.z -v_smSpd:Length()*0.002*(1-f_smZ) +(self.VMAngAdd.p)*(1-f_smZ)*0.1 +self.RunPos.z*f_smSpr +runsinx*0.5*f_smSpr +self.AimPos.z*f_smZ)
  67.     --view.angles=ang+Angle(runsinx*math.Clamp(lvel/300*f_smGr, 0.1, 1), runsiny*math.Clamp(lvel/300*f_smGr, 0.1, 1), 0)
  68.     view.angles=viewang+Angle(0+runsinx*0,0,v_smSpd.y*-0.0125)*(lvel/250)*f_smGr*CVars.bounce:GetFloat()
  69.     view.vm_angles=vmang
  70.     view.vm_origin=pos-v_smWall*(1-f_smZ)
  71.     view.znear=1
  72.     return view
  73. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement