Advertisement
Guest User

FA:S Fix?

a guest
Dec 22nd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 40.00 KB | None | 0 0
  1. local vm, EP, EA, FT, CT, TargetPos, TargetAng, cos1, cos2, sin1, sin2, vel, att, ang, delta, tan, mod, tr, dist, move, rs, pos, ang, wm, ong, iv, dif1, dif2, VM, ws, x, y
  2. local BlendSpeed, BlendType, ApproachSpeed = 8, 1, 10
  3. local AngMod, PosMod, Vec0, VecDown, BipodVec = Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, 0), Vector(0, 0, -10), Vector(1, 4, -1)
  4. local PeekVec
  5. local SprintPos, SprintAng, AngDif, AngleTable = Vector(4, -2.09, -0.24), Vector(-12.968, 47.729, 0), Angle(0, 0, 0), Angle(0, 0, 0)
  6. local td = {}
  7. local NadeTargetPos, NadeTargetAng
  8. local TargetPos, TargetAng = Vector(0, 0, 0), Vector(0, 0, 0)
  9. local Ang0 = Angle(0, 0, 0)
  10.  
  11. SWEP.PSO1Glass = Material("models/weapons/view/accessories/Lens_EnvSolid")
  12. SWEP.ScopeRT = GetRenderTarget("fas2_scope_rt", 512, 512, false)
  13. SWEP.AngleDelta2 = Angle(0, 0, 0)
  14.  
  15. local math, draw, surface, cam, render = math, draw, surface, cam, render -- local look-ups are faster than global look-ups, saves a couple of milliseconds, M-MUH PERFORMANCE
  16. local ps2 = render.SupportsPixelShaders_2_0()
  17.  
  18. local _Material         = Material("pp/toytown-top")
  19. _Material:SetTexture("$fbtexture", render.GetScreenEffectTexture())
  20.  
  21. local reg = debug.getregistry()
  22. local Right = reg.Angle.Right
  23. local Up = reg.Angle.Up
  24. local Forward = reg.Angle.Forward
  25. local RotateAroundAxis = reg.Angle.RotateAroundAxis
  26. local GetBonePosition = reg.Entity.GetBonePosition
  27. local GetSequence = reg.Entity.GetSequence
  28. local GetSequenceName = reg.Entity.GetSequenceName
  29.  
  30. local trace
  31.  
  32. local Lerp, LerpVector, LerpAngle, EyePos, EyeAngles, FrameTime, CurTime, GetConVarNumber = Lerp, LerpVector, LerpAngle, EyePos, EyeAngles, FrameTime, CurTime, GetConVarNumber
  33. local blur = Material("pp/bokehblur")
  34. SWEP.BlurDist = 0
  35. SWEP.BlurStrength = 0
  36.    
  37. function SWEP:PreDrawViewModel()
  38.     if GetConVarNumber("fas2_blureffects") > 0 and ps2 then
  39.         FT, CT = FrameTime(), CurTime()
  40.        
  41.         if GetConVarNumber("fas2_blureffects_depth") > 0 then
  42.             if self.dt.Status == FAS_STAT_ADS then
  43.                 if (self.BlurOnAim and self.Peeking) or not self.BlurOnAim then
  44.                     pos = self.Owner:GetShootPos()
  45.                     trace = util.QuickTrace(pos, EyeAngles():Forward() * 4096, self.Owner)
  46.                     self.BlurDist = math.Approach(self.BlurDist, trace.HitPos:Distance(pos) / 4096, FT * 3)
  47.                     self.BlurStrength = math.Approach(self.BlurStrength, 5, FT * 10)
  48.                 else
  49.                     self.BlurStrength = math.Approach(self.BlurStrength, 0, FT * 10)
  50.                 end
  51.             else
  52.                 self.BlurStrength = math.Approach(self.BlurStrength, 0, FT * 10)
  53.             end
  54.            
  55.             if self.BlurStrength > 0 then
  56.                 render.UpdateScreenEffectTexture()
  57.  
  58.                 blur:SetTexture("$BASETEXTURE", render.GetScreenEffectTexture())
  59.                 blur:SetTexture("$DEPTHTEXTURE", render.GetResolvedFullFrameDepth())
  60.  
  61.                 blur:SetFloat("$size", self.BlurStrength)
  62.                 blur:SetFloat("$focus", self.BlurDist)
  63.                 blur:SetFloat("$focusradius", 2)
  64.  
  65.                 render.SetMaterial(blur)
  66.                 render.DrawScreenQuad()
  67.             end
  68.         end
  69.        
  70.         if self.dt.Status == FAS_STAT_ADS and not self.Peeking then
  71.             if self.AimPos == self.ACOGPos or self.AimPos == self.PSO1Pos or self.AimPos == self.ELCANPos or self.AimPos == self.LeupoldPos or self.BlurOnAim then
  72.                 self.BlurAmount = math.Approach(self.BlurAmount, 10, FT * 20)
  73.             else
  74.                 self.BlurAmount = math.Approach(self.BlurAmount, 0, FT * 40)
  75.             end
  76.         elseif self.dt.Status == FAS_STAT_CUSTOMIZE then
  77.             self.BlurAmount = math.Approach(self.BlurAmount, 10, FT * 20)
  78.         else
  79.             if not self.MagCheck then
  80.                 if self.HealTime and CT + 0.3 < self.HealTime then
  81.                     self.BlurAmount = math.Approach(self.BlurAmount, 20, FT * 20)
  82.                 else
  83.                     self.BlurAmount = math.Approach(self.BlurAmount, 0, FT * 20 * (self.Peeking and 2 or 1))
  84.                 end
  85.             end
  86.         end
  87.        
  88.         x, y = ScrW(), ScrH()
  89.  
  90.         cam.Start2D()
  91.             surface.SetMaterial(_Material)
  92.             surface.SetDrawColor(255, 255, 255, 255)
  93.            
  94.             for i = 1, self.BlurAmount do
  95.                 render.UpdateScreenEffectTexture()
  96.                 surface.DrawTexturedRect(0, 0, x, y * 2)
  97.             end
  98.  
  99.         cam.End2D()
  100.     else
  101.         DOFModeHack(false)
  102.     end
  103.    
  104.     render.SetBlend(0)
  105. end
  106.  
  107. hook.Add("NeedsDepthPass", "FAS2_NeedsDepthPass", function()
  108.     if not ps2 or GetConVarNumber("fas2_blureffects") <= 0 or GetConVarNumber("fas2_blureffects_depth") <= 0 then
  109.         return false
  110.     end
  111.    
  112.     ply = LocalPlayer()
  113.    
  114.     if ply:Alive() then
  115.         wep = ply:GetActiveWeapon()
  116.        
  117.         if IsValid(wep) and wep.IsFAS2Weapon then
  118.             if wep.BlurStrength > 0 then
  119.                 DOFModeHack(true)
  120.                 return true
  121.             end
  122.         end
  123.     end
  124.    
  125.     return false
  126. end)
  127.  
  128. local veldepend = {pitch = 0, yaw = 0, roll = 0}
  129. local len
  130.    
  131. function SWEP:PostDrawViewModel()
  132.     render.SetBlend(1)
  133.     VM, EP, EA, FT, CT = self.Owner:GetViewModel(), EyePos(), EyeAngles(), FrameTime(), CurTime()
  134.     vel, ong = self.Owner:GetVelocity(), self.Owner:OnGround()
  135.     len = vel:Length()
  136.     vm = self.Nade
  137.    
  138.     AngleTable.p = EA.P
  139.     AngleTable.y = EA.Y
  140.     delta = AngleTable - self.OldDelta
  141.        
  142.     self.OldDelta.p = EA.p
  143.     self.OldDelta.y = EA.y
  144.    
  145.     if not self.dt.Bipod then
  146.         if self.SwayInterpolation == "linear" then
  147.             self.AngleDelta = LerpAngle(math.Clamp(FT * 15, 0, 1), self.AngleDelta, delta)
  148.             self.AngleDelta.y = math.Clamp(self.AngleDelta.y, -15, 15)
  149.         else
  150.             delta.p = math.Clamp(delta.p, -5, 5)
  151.             self.AngleDelta2 = LerpAngle(math.Clamp(FT * 12, 0, 1), self.AngleDelta2, self.AngleDelta)
  152.             AngDif.x = (self.AngleDelta.p - self.AngleDelta2.p)
  153.             AngDif.y = (self.AngleDelta.y - self.AngleDelta2.y)
  154.             self.AngleDelta = LerpAngle(math.Clamp(FT * 15, 0, 1), self.AngleDelta, delta + AngDif)
  155.             self.AngleDelta.y = math.Clamp(self.AngleDelta.y, -25, 25)
  156.         end
  157.     else
  158.         self.AngleDelta = LerpAngle(math.Clamp(FT * 15, 0, 1), self.AngleDelta, Ang0)
  159.     end
  160.    
  161.     if IsValid(vm) then
  162.         if CT < vm.LifeTime then
  163.             NadeTargetPos = Vec0 * 1
  164.             NadeTargetAng = Vec0 * 1
  165.            
  166.             if ong then
  167.                 ws = self.Owner:GetWalkSpeed()
  168.  
  169.                 if len > 30 and len < ws * 1.3 then
  170.                     move = math.Clamp(len / ws, 0, 1)
  171.                        
  172.                     if self.Owner:Crouching() then
  173.                         cos1, sin1 = math.cos(CT * 5), math.sin(CT * 5)
  174.                         tan = math.atan(cos1 * sin1, cos1 * sin1)
  175.                     else
  176.                         cos1, sin1 = math.cos(CT * 7), math.sin(CT * 7)
  177.                         tan = math.atan(cos1 * sin1, cos1 * sin1)
  178.                     end
  179.  
  180.                     NadeTargetAng[1] = NadeTargetAng[1] + tan * 2 * move
  181.                     NadeTargetAng[2] = NadeTargetAng[2] + cos1 * move
  182.                     NadeTargetAng[3] = NadeTargetAng[3] + sin1 * move
  183.                                
  184.                     NadeTargetPos[1] = NadeTargetPos[1] + sin1 * 0.1 * move
  185.                     NadeTargetPos[2] = NadeTargetPos[2] + tan * 0.2 * move
  186.                     NadeTargetPos[3] = NadeTargetPos[3] + tan * 0.1 * move
  187.                 elseif self.Owner:KeyDown(IN_SPEED) and len >= ws * 1.3 then
  188.                     tan = math.atan(cos1 * sin1, cos1 * sin1)
  189.                    
  190.                     rs = self.Owner:GetRunSpeed()
  191.                     cos1, sin1 = math.cos(CT * (7 + rs / 100)), math.sin(CT * (7 + rs / 100))
  192.                     move = math.Clamp(len / rs, 0, 1)
  193.                    
  194.                     NadeTargetAng[1] = NadeTargetAng[1] + tan * 4 * move
  195.                     NadeTargetAng[2] = NadeTargetAng[2] + cos1 * 5 * move
  196.                     NadeTargetAng[3] = NadeTargetAng[3] + sin1 * 4 * move
  197.                    
  198.                     NadeTargetPos[1] = NadeTargetPos[1] + sin1 * 0.75 * move
  199.                     NadeTargetPos[2] = NadeTargetPos[2] + tan * 0.6 * move
  200.                     NadeTargetPos[3] = NadeTargetPos[3] + tan * move
  201.                 end
  202.             end
  203.            
  204.             self.NadeBlendPos = LerpVector(FT * 8, self.NadeBlendPos, NadeTargetPos)
  205.             self.NadeBlendAng = LerpVector(FT * 8, self.NadeBlendAng, NadeTargetAng)
  206.            
  207.             EA = EA * 1
  208.             RotateAroundAxis(EA, Right(EA), self.NadeBlendAng[1] + self.AngleDelta.y * 0.075)
  209.             RotateAroundAxis(EA, Up(EA), self.NadeBlendAng[2])
  210.             RotateAroundAxis(EA, Forward(EA), self.NadeBlendAng[3] + self.AngleDelta.y * 0.05)
  211.                
  212.             EP = EP + (self.NadeBlendPos[1] - self.AngleDelta.p * 0.1) * Right(EA)  
  213.             EP = EP + (self.NadeBlendPos[2] + self.AngleDelta.y * 0.1) * Forward(EA)
  214.             EP = EP + (self.NadeBlendPos[3] + self.AngleDelta.y * 0.1) * Up(EA)
  215.            
  216.             vm:SetRenderOrigin(EP - self.Owner:GetAimVector() * 2)
  217.             vm:SetRenderAngles(EA)
  218.             vm:FrameAdvance(FT)
  219.             vm:SetupBones()
  220.             vm:SetParent(VM)
  221.             vm:DrawModel()
  222.         end
  223.     end
  224.    
  225.     vm = self.Wep
  226.    
  227.     EP, EA = EyePos(), EyeAngles() -- fresh eye angles and shit because we're going to modify shit
  228.        
  229.     if IsValid(vm) then
  230.         iv = self.Owner.InVehicle and self.Owner:InVehicle() -- what retard overrides or removes InVehicle?
  231.        
  232.         if self.FirstDeploy then
  233.             FAS2_PlayAnim(self, self.Anims.Draw_First, 1, 0)
  234.             self.FirstDeploy = false
  235.         end
  236.        
  237.         if self.Owner.CurClass then
  238.             if self.Owner.CurClass != self.Class then
  239.                 if not self.FirstDeploy then
  240.                     if GetSequenceName(vm, GetSequence(vm)) != self.Anims.Draw_First then
  241.                         self:PlayDeployAnim()
  242.                     end
  243.                 end
  244.             end
  245.         end
  246.        
  247.         self.Owner.CurClass = self.Class
  248.        
  249.         if iv then
  250.             if not self.Vehicle then
  251.                 self:PlayHolsterAnim()
  252.                 self.Vehicle = true
  253.                 self:EmitSound("weapons/weapon_holster" .. math.random(1, 3) .. ".wav", 50, 100)
  254.             end
  255.         else
  256.             if self.Vehicle then
  257.                 self:PlayDeployAnim()
  258.                 self.Vehicle = false
  259.             end
  260.         end
  261.        
  262.         if self.dt.Status == FAS_STAT_ADS then
  263.             self.ViewModelFOV = Lerp(FT * 10, self.ViewModelFOV, self.TargetViewModelFOV)
  264.         else
  265.             self.ViewModelFOV = Lerp(FT * 10, self.ViewModelFOV, self.ViewModelFOV_Orig)
  266.         end
  267.        
  268.         if self.dt.Status != FAS_STAT_SPRINT then
  269.             TargetPos = Vec0 * 1
  270.             TargetAng = Vec0 * 1
  271.             ApproachSpeed = 10
  272.         end
  273.        
  274.         self.NearWall = false
  275.        
  276.         if self.dt.Status == FAS_STAT_ADS then
  277.             if self.CanPeek and self.Peeking then
  278.                 if self.dt.Bipod then
  279.                     if self[self.AimPosName .. "_Bipod"] then
  280.                         TargetPos = (self[self.AimPosName .. "_Bipod"] + BipodVec) *1
  281.                     else
  282.                         TargetPos = (self.AimPos + BipodVec) * 1
  283.                     end
  284.                 else
  285.                     TargetPos = (self.AimPos + BipodVec) * 1
  286.                 end
  287.             else
  288.                 TargetPos = (self.dt.Bipod and self[self.AimPosName .. "_Bipod"] or self.AimPos) * 1
  289.             end
  290.            
  291.             TargetAng = (self.dt.Bipod and self[self.AimAngName .. "_Bipod"] or self.AimAng) * 1
  292.            
  293.             BlendSpeed = Lerp(FT * 3, BlendSpeed, 15)
  294.             self.SlowDownBlend = true
  295.             move = math.Clamp(len / self.Owner:GetWalkSpeed(), 0, 1)
  296.            
  297.             if len > 30 and ong then
  298.                 cos1, sin1 = math.cos(CT * 8), math.sin(CT * 8)
  299.                 tan = math.atan(cos1 * sin1, cos1 * sin1)
  300.                
  301.                 TargetAng[1] = TargetAng[1] + tan * 0.5 * move
  302.                 TargetAng[2] = TargetAng[2] + cos1 * 0.25 * move
  303.                 TargetAng[3] = TargetAng[3] + sin1 * 0.25 * move
  304.                        
  305.                 TargetPos[1] = TargetPos[1] + sin1 * 0.05 * move
  306.                 TargetPos[2] = TargetPos[2] + tan * 0.1 * move
  307.                 TargetPos[3] = TargetPos[3] + tan * 0.05 * move
  308.             end
  309.            
  310.             AngMod = LerpVector(FT * 10, AngMod, Vec0)
  311.             PosMod = LerpVector(FT * 10, PosMod, Vec0)
  312.         elseif self.dt.Status == FAS_STAT_QUICKGRENADE then
  313.             BlendSpeed = 2
  314.             TargetPos = VecDown * 1
  315.             TargetAng = Vec0 * 1
  316.         elseif self.dt.Status == FAS_STAT_SPRINT then
  317.             if self.SlowDownBlend then
  318.                 self.SlowDownBlend = false
  319.                 BlendSpeed = 5
  320.             end
  321.            
  322.             rs = self.Owner:GetRunSpeed()
  323.            
  324.             if self.FireMode == "safe" then
  325.                 cos1, sin1 = math.cos(CT * (8 + rs / 100)), math.sin(CT * (8 + rs / 100))
  326.             else
  327.                 if self.MagCheck then
  328.                     cos1, sin1 = math.cos(CT * (8 + rs / 100)), math.sin(CT * (8 + rs / 100))
  329.                 else
  330.                     if self.MoveType == 2 or self.MoveType == 3 then
  331.                         cos1, sin1 = math.cos(CT * (8 + rs / 100)), math.sin(CT * (8 + rs / 100))
  332.                     else
  333.                         cos1, sin1 = math.cos(CT * (7 + rs / 100)), math.sin(CT * (7 + rs / 100))
  334.                     end
  335.                 end
  336.             end
  337.            
  338.             move = math.Clamp(len / rs, 0, 1)
  339.            
  340.             if self.MagCheck then
  341.                 BlendSpeed = Lerp(FT * 3, BlendSpeed, 5)
  342.                 tan = math.atan(cos1 * sin1, cos1 * sin1)
  343.                
  344.                 TargetPos = Vec0 * 1
  345.                 TargetAng = Vec0 * 1
  346.                 ApproachSpeed = 10
  347.  
  348.                 TargetAng[1] = TargetAng[1] + tan * 4 * move
  349.                 TargetAng[2] = TargetAng[2] + cos1 * 5 * move
  350.                 TargetAng[3] = TargetAng[3] + sin1 * 4 * move
  351.                
  352.                 TargetPos[1] = TargetPos[1] + sin1 * 0.75 * move
  353.                 TargetPos[2] = TargetPos[2] + tan * 0.6 * move
  354.                 TargetPos[3] = TargetPos[3] + tan * move
  355.             else
  356.                 BlendSpeed = Lerp(FT * 3, BlendSpeed, 9)
  357.                
  358.                 --TargetPos = (self.SprintPos and self.SprintPos or Vector(4, -2.09, -0.24)) * 1
  359.                 --TargetAng = (self.SprintAng and self.SprintAng or Vector(-12.968, 47.729, 0)) * 1
  360.                
  361.                 if self.FireMode == "safe" then
  362.                     tan = math.atan(cos1 * sin1, cos1 * sin1)
  363.                     AngMod[1] = Lerp(FT * 15, AngMod[1], tan * 7.5 * move)
  364.                     AngMod[2] = Lerp(FT * 15, AngMod[2], sin1 * 3 * move)
  365.                     AngMod[3] = Lerp(FT * 15, AngMod[3], tan * -5 * move)
  366.                     PosMod[1] = Lerp(FT * 15, PosMod[1], tan * 2.5 * move)
  367.                     PosMod[2] = Lerp(FT * 15, PosMod[2], sin1 * 2 * move)
  368.                     PosMod[3] = Lerp(FT * 15, PosMod[3], math.atan(cos1, sin1) * 5 * move)
  369.                    
  370.                     if self.SafePosType == "pistol" then
  371.                         TargetPos = self.PistolSafePos * 1
  372.                         TargetAng = self.PistolSafeAng * 1
  373.                     else
  374.                         TargetPos = self.RifleSafePos * 1
  375.                         TargetAng = self.RifleSafeAng * 1
  376.                     end
  377.                 else
  378.                     if self.MoveType == 2 then
  379.                         tan = math.atan(cos1 * sin1, cos1 * sin1)
  380.                        
  381.                         AngMod[1] = Lerp(FT * 15, AngMod[1], tan * 6 * move)
  382.                         AngMod[2] = Lerp(FT * 15, AngMod[2], cos1 * 1.5 * move)
  383.                         AngMod[3] = Lerp(FT * 15, AngMod[3], cos1 * -4 * move)
  384.                         PosMod[1] = Lerp(FT * 15, PosMod[1], tan * 4 * move)
  385.                         PosMod[2] = Lerp(FT * 15, PosMod[2], cos1 * 2 * move)
  386.                         PosMod[3] = Lerp(FT * 15, PosMod[3], math.atan(cos1, sin1) * 5 * move)
  387.                     elseif self.MoveType == 3 then
  388.                         tan = math.atan(cos1 * sin1, cos1 * sin1)
  389.                         AngMod[1] = Lerp(FT * 15, AngMod[1], tan * 4 * move)
  390.                         AngMod[2] = Lerp(FT * 15, AngMod[2], sin1 * 1.5 * move)
  391.                         AngMod[3] = Lerp(FT * 15, AngMod[3], tan * -4 * move)
  392.                         PosMod[1] = Lerp(FT * 15, PosMod[1], tan * 2 * move)
  393.                         PosMod[2] = Lerp(FT * 15, PosMod[2], sin1 * 2 * move)
  394.                         PosMod[3] = Lerp(FT * 15, PosMod[3], math.atan(cos1, sin1) * 5 * move)
  395.                     else
  396.                         AngMod[1] = Lerp(FT * 15, AngMod[1], cos1 * -2.5 * move)
  397.                         AngMod[2] = Lerp(FT * 15, AngMod[2], sin1 * -1.5 * move)
  398.                         AngMod[3] = Lerp(FT * 15, AngMod[3], sin1 * -1.5 * move)
  399.                         PosMod[1] = Lerp(FT * 15, PosMod[1], math.atan(cos1, sin1) * 3 * move)
  400.                         PosMod[2] = Lerp(FT * 15, PosMod[2], cos1 * 5 * move)
  401.                         PosMod[3] = Lerp(FT * 15, PosMod[3], sin1 * cos1 * 9 * move)
  402.                     end
  403.  
  404.                     if self.MoveType == 1 then
  405.                         TargetPos[1] = math.Approach(TargetPos[1], (self.SprintPos and self.SprintPos[1] or 4), FT * 25 + math.Clamp(tan, -0.4, 0.1))
  406.                         TargetPos[2] = math.Approach(TargetPos[2], (self.SprintPos and self.SprintPos[2] or -2.09), FT * 25 + math.Clamp(cos1, 0, 0.2))
  407.                         TargetPos[3] = math.Approach(TargetPos[3], (self.SprintPos and self.SprintPos[3] or -0.24), FT * 25 + math.Clamp(cos1, 0, 0.4))
  408.                    
  409.                         TargetAng[1] = math.Approach(TargetAng[1], (self.SprintAng and self.SprintAng[1] or -12.968), FT * ApproachSpeed)
  410.                         TargetAng[2] = math.Approach(TargetAng[2], (self.SprintAng and self.SprintAng[2] or 47.729), FT * ApproachSpeed)
  411.                         TargetAng[3] = math.Approach(TargetAng[3], (self.SprintAng and self.SprintAng[3] or 0), FT * ApproachSpeed)
  412.                         ApproachSpeed = math.Approach(ApproachSpeed, 100, FT * 200)
  413.                     elseif self.MoveType == 2 then
  414.                         TargetPos[1] = math.Approach(TargetPos[1], (self.SprintPos and self.SprintPos[1] or 4), FT * 15)
  415.                         TargetPos[2] = math.Approach(TargetPos[2], (self.SprintPos and self.SprintPos[2] or -2.09), FT * 15)
  416.                         TargetPos[3] = math.Approach(TargetPos[3], (self.SprintPos and self.SprintPos[3] or -0.24), FT * 21)
  417.                    
  418.                         TargetAng[1] = math.Approach(TargetAng[1], (self.SprintAng and self.SprintAng[1] or -12.968), FT * ApproachSpeed)
  419.                         TargetAng[2] = math.Approach(TargetAng[2], (self.SprintAng and self.SprintAng[2] or 47.729), FT * ApproachSpeed)
  420.                         TargetAng[3] = math.Approach(TargetAng[3], (self.SprintAng and self.SprintAng[3] or 0), FT * ApproachSpeed)
  421.                         ApproachSpeed = math.Approach(ApproachSpeed, 300, FT * 600)
  422.                     else
  423.                         TargetPos = (self.SprintPos and self.SprintPos or SprintPos) * 1
  424.                         TargetAng = (self.SprintAng and self.SprintAng or SprintAng) * 1
  425.                     end
  426.                 end
  427.                
  428.                 //AngMod[1] = Lerp(FT * 15, AngMod[1], cos1 * -2.5)
  429.                 //AngMod[2] = Lerp(FT * 15, AngMod[2], sin1 * -1.5)
  430.                 //AngMod[3] = Lerp(FT * 15, AngMod[3], sin1 * -1.5)
  431.                 //PosMod[1] = Lerp(FT * 15, PosMod[1], math.atan(cos1, sin1) * 3)
  432.                 //PosMod[2] = Lerp(FT * 15, PosMod[2], cos1 * 5)
  433.                 //PosMod[3] = Lerp(FT * 15, PosMod[3], sin1 * cos1 * 9)
  434.             end
  435.         else
  436.             if self.dt.Status == FAS_STAT_CUSTOMIZE then
  437.                 TargetPos = self.CustomizePos * 1
  438.                 TargetAng = self.CustomizeAng * 1
  439.             else
  440.                 if self.FireMode == "safe" then
  441.                     if self.SafePosType == "pistol" then
  442.                         TargetPos = self.PistolSafePos * 1
  443.                         TargetAng = self.PistolSafeAng * 1
  444.                     else
  445.                         TargetPos = self.RifleSafePos * 1
  446.                         TargetAng = self.RifleSafeAng * 1
  447.                     end
  448.                 else
  449.                     if GetConVarNumber("fas2_differentorigins") > 0 then
  450.                         TargetPos[1] = TargetPos[1] - 0.5
  451.                         TargetPos[3] = TargetPos[3] + 0.25
  452.                     end
  453.                 end
  454.             end
  455.            
  456.             if self.dt.Status != FAS_STAT_CUSTOMIZE and not self.NoNearWall and self.FireMode != "safe" then
  457.                 td.start = self.Owner:GetShootPos()
  458.                 td.endpos = td.start + self.Owner:GetAimVector() * 30
  459.                 td.filter = self.Owner
  460.                
  461.                 tr = util.TraceLine(td)
  462.                
  463.                 if tr.Hit then
  464.                     self.NearWall = true
  465.                     dist = tr.HitPos:Distance(td.start)
  466.                    
  467.                     TargetAng[1] = TargetAng[1] - math.Clamp((30 - dist), 0, 10)
  468.                     TargetAng[2] = TargetAng[2] + math.Clamp((30 - dist) * 2, 0, 20)
  469.                     TargetPos[2] = TargetPos[2] + math.Clamp((30 - dist) * 0.1, 0, 1)
  470.                 end
  471.             end
  472.            
  473.             BlendSpeed = Lerp(FT * 3, BlendSpeed, 12)
  474.            
  475.             if len > 30 and ong then
  476.                 move = math.Clamp(len / self.Owner:GetWalkSpeed(), 0, 1)
  477.                
  478.                 if self.Owner:Crouching() then
  479.                     cos1, sin1 = math.cos(CT * 6), math.sin(CT * 6)
  480.                     tan = math.atan(cos1 * sin1, cos1 * sin1)
  481.                 else
  482.                     cos1, sin1 = math.cos(CT * 8.5), math.sin(CT * 8.5)
  483.                     tan = math.atan(cos1 * sin1, cos1 * sin1)
  484.                 end
  485.                
  486.                 TargetAng[1] = TargetAng[1] + tan * 2 * move
  487.                 TargetAng[2] = TargetAng[2] + cos1 * move
  488.                 TargetAng[3] = TargetAng[3] + sin1 * move
  489.                        
  490.                 TargetPos[1] = TargetPos[1] + sin1 * 0.1 * move
  491.                 TargetPos[2] = TargetPos[2] + tan * 0.2 * move
  492.                 TargetPos[3] = TargetPos[3] + tan * 0.1 * move
  493.                
  494.                 /*AngMod[1] = Lerp(FT * 15, AngMod[1], cos1 * sin1 * 0.5)
  495.                 AngMod[2] = Lerp(FT * 15, AngMod[2], math.atan(cos1, sin1) * 0.35)
  496.                 AngMod[3] = Lerp(FT * 15, AngMod[3], cos1 * -0.5)
  497.                 PosMod[1] = Lerp(FT * 15, PosMod[1], cos1 * sin1)
  498.                 PosMod[2] = Lerp(FT * 15, PosMod[2], cos1)
  499.                 PosMod[3] = Lerp(FT * 15, PosMod[3], cos1 * 0.5)*/
  500.             else
  501.                 if self.dt.Status != FAS_STAT_ADS and not self.dt.Bipod then
  502.                     cos1, sin1 = math.cos(CT), math.sin(CT)
  503.                     tan = math.atan(cos1 * sin1, cos1 * sin1)
  504.                        
  505.                     TargetAng[1] = TargetAng[1] + tan * 1.15
  506.                     TargetAng[2] = TargetAng[2] + cos1 * 0.4
  507.                     TargetAng[3] = TargetAng[3] + tan
  508.                        
  509.                     TargetPos[2] = TargetPos[2] + tan * 0.2
  510.                 end
  511.             end
  512.            
  513.             AngMod = LerpVector(FT * 10, AngMod, Vec0)
  514.             PosMod = LerpVector(FT * 10, PosMod, Vec0)
  515.         end
  516.        
  517.         mod = 1
  518.        
  519.         if self.dt.Status == FAS_STAT_ADS then
  520.             mod = 0.25
  521.         end
  522.        
  523.         if ong and (self.Owner:Crouching() or self.Owner:KeyDown(IN_DUCK)) and self.dt.Status != FAS_STAT_ADS and self.dt.Status != FAS_STAT_CUSTOMIZE then
  524.             TargetPos[3] = TargetPos[3] - 0.5
  525.             TargetPos[1] = TargetPos[1] - 0.5
  526.             TargetPos[2] = TargetPos[2] - 0.5
  527.         end
  528.        
  529.         dif1, dif2 = 0, 0
  530.        
  531.         if GetConVarNumber("fas2_alternatebipod") > 0 then
  532.             if self.dt.Bipod and self.DeployAngle and self.dt.Status == FAS_STAT_IDLE then
  533.                 dif1 = math.AngleDifference(self.DeployAngle.y, EA.y)
  534.                 dif2 = math.AngleDifference(self.DeployAngle.p, EA.p)
  535.                 TargetPos[3] = TargetPos[3] - 1
  536.                 TargetPos[2] = TargetPos[2] + 2
  537.                
  538.                 if CT < self.BipodMoveTime then
  539.                     self.BipodPos[1] = math.Approach(self.BipodPos[1], dif1 * 0.3, FT * 50)
  540.                     self.BipodPos[3] = math.Approach(self.BipodPos[3], dif2 * 0.3 --[[+ 1]], FT * 50)
  541.                    
  542.                     self.BipodAng[1] = math.Approach(self.BipodAng[1], dif1 * 0.1, FT * 50)
  543.                     self.BipodAng[3] = math.Approach(self.BipodAng[3], dif2 * 0.1, FT * 50)
  544.                 else
  545.                     self.BipodPos[1] = dif1 * 0.3
  546.                     self.BipodPos[3] = dif2 * 0.3 // + 1
  547.                    
  548.                     self.BipodAng[1] = dif1 * 0.1
  549.                     self.BipodAng[3] = dif2 * 0.1
  550.                 end
  551.             else
  552.                 self.BipodPos = LerpVector(FT * 10, self.BipodPos, Vec0)
  553.                 self.BipodAng = LerpVector(FT * 10, self.BipodAng, Vec0)
  554.                 self.BipodMoveTime = CT + 0.2
  555.             end
  556.         else
  557.             self.BipodPos[1] = 0
  558.             self.BipodPos[3] = 0
  559.                    
  560.             self.BipodAng[1] = 0
  561.             self.BipodAng[3] = 0
  562.         end
  563.        
  564.         veldepend.roll = math.Clamp((vel:DotProduct(EA:Right()) * 0.04) * len / self.Owner:GetWalkSpeed(), -5, 5)
  565.        
  566.         self.BlendPos[1] = Lerp(FT * BlendSpeed, self.BlendPos[1], TargetPos[1] + self.AngleDelta.y * (0.15 * mod))
  567.         self.BlendPos[2] = Lerp(FT * BlendSpeed * 0.6, self.BlendPos[2], TargetPos[2])
  568.         self.BlendPos[3] = Lerp(FT * BlendSpeed * 0.75, self.BlendPos[3], TargetPos[3] + self.AngleDelta.p * (0.2 * mod) + math.abs(self.AngleDelta.y) * (0.02 * mod))
  569.            
  570.         self.BlendAng[1] = Lerp(FT * BlendSpeed * 0.75, self.BlendAng[1], TargetAng[1] + AngMod[1] - self.AngleDelta.p * (1.5 * mod))
  571.         self.BlendAng[2] = Lerp(FT * BlendSpeed, self.BlendAng[2], TargetAng[2] + AngMod[2] + self.AngleDelta.y * (0.3 * mod))
  572.         self.BlendAng[3] = Lerp(FT * BlendSpeed, self.BlendAng[3], TargetAng[3] + AngMod[3] + self.AngleDelta.y * (0.6 * mod) + veldepend.roll)
  573.        
  574.         EA = EA * 1
  575.         RotateAroundAxis(EA, Right(EA), self.BlendAng[1] + PosMod[1] + self.BipodAng[3])
  576.         RotateAroundAxis(EA, Up(EA), self.BlendAng[2] + PosMod[2] - self.BipodAng[1])
  577.         RotateAroundAxis(EA, Forward(EA), self.BlendAng[3] + PosMod[3])
  578.        
  579.         EP = EP + (self.BlendPos[1] - self.BipodPos[1]) * Right(EA)  
  580.         EP = EP + self.BlendPos[2] * Forward(EA)
  581.         EP = EP + (self.BlendPos[3] - self.BipodPos[3]) * Up(EA)
  582.        
  583.         /*EA:RotateAroundAxis(EA:Right(), self.BlendAng[1] + PosMod[1] + (self.dt.Bipod and math.AngleDifference(self.DeployAngle.p, EA.p) or 0) * 0.1)
  584.         EA:RotateAroundAxis(EA:Up(), self.BlendAng[2] + PosMod[2] - (self.dt.Bipod and math.AngleDifference(self.DeployAngle[2], EA[2]) or 0) * 0.1)
  585.         EA:RotateAroundAxis(EA:Forward(), self.BlendAng[3] + PosMod[3])
  586.        
  587.         EP = EP + (self.BlendPos[1] - (self.dt.Bipod and math.AngleDifference(self.DeployAngle[2], EA[2]) or 0) * 0.3) * EA:Right()  
  588.         EP = EP + self.BlendPos[2] * EA:Forward()
  589.         EP = EP + (self.BlendPos[3] - (self.dt.Bipod and math.AngleDifference(self.DeployAngle.p, EA.p) or 0) * 0.3) * EA:Up()*/
  590.        
  591.         vm:SetRenderOrigin(EP)
  592.         vm:SetRenderAngles(EA)
  593.         vm:FrameAdvance(FT)
  594.         vm:SetupBones()
  595.         vm:SetParent(VM)
  596.         vm:DrawModel()
  597.        
  598.         self:Draw3D2DCamera()
  599.     end
  600. end
  601.  
  602. function SWEP:DrawWorldModel()
  603.     if not self.HideWorldModel then
  604.         self:DrawModel()
  605.     end
  606.    
  607.     if self.dt.Status == FAS_STAT_SPRINT or self.dt.Holstered then
  608.         self:SetWeaponHoldType(self.RunHoldType)
  609.     else
  610.         self:SetWeaponHoldType(self.HoldType)
  611.     end
  612.    
  613.     wm = self.W_Wep
  614.    
  615.     if IsValid(wm) then
  616.         if IsValid(self.Owner) then
  617.             if self.Owner:InVehicle() then
  618.                 return
  619.             end
  620.            
  621.             if self.Owner:LookupBone("ValveBiped.Bip01_R_Hand") then
  622.                 pos, ang = GetBonePosition( self.Owner, self.Owner:LookupBone("ValveBiped.Bip01_R_Hand") )
  623.             else
  624.                 pos, ang = self.Owner:GetPos(), self.Owner:GetAngles()
  625.             end
  626.            
  627.             if pos and ang then
  628.                 RotateAroundAxis(ang, ang:Right(ang), self.WMAng[1])
  629.                 RotateAroundAxis(ang, ang:Up(ang), self.WMAng[2])
  630.                 RotateAroundAxis(ang, Forward(ang), self.WMAng[3])
  631.                
  632.                 pos = pos + self.WMPos[1] * Right(ang)
  633.                 pos = pos + self.WMPos[2] * Forward(ang)
  634.                 pos = pos + self.WMPos[3] * Up(ang)
  635.                
  636.                 wm:SetRenderOrigin(pos)
  637.                 wm:SetRenderAngles(ang)
  638.                 wm:SetModelScale(self.WMScale, 0)
  639.                 wm:DrawModel()
  640.             end
  641.         else
  642.             wm:SetRenderOrigin(self:GetPos())
  643.             wm:SetRenderAngles(self:GetAngles())
  644.             wm:DrawModel()
  645.             wm:DrawShadow()
  646.         end
  647.     end
  648. end
  649.  
  650. local grad = surface.GetTextureID("VGUI/fas2/gradient")
  651. local compm4_reticle = Material("models/weapons/view/accessories/aimpoint_reticle")
  652. local eotech_reticle = Material("sprites/fas2/eotech_reddot")
  653. local seq, cyc, att, t, tex, x, y, y2, diff, mag, dir, dist, namefound
  654. local YOff, XOff = 0
  655.  
  656. SWEP.AnimRecognition = {["Reload1"] = true,
  657.     ["Reload2"] = true,
  658.     ["Reload3"] = true,
  659.     ["Reload4"] = true,
  660.     ["Reload5"] = true,
  661.     ["Reload1_nomen"] = true,
  662.     ["Reload2_nomen"] = true,
  663.     ["Reload3_nomen"] = true,
  664.     ["Reload4_nomen"] = true,
  665.     ["Reload5_nomen"] = true,
  666.     ["Reload_1"] = true,
  667.     ["Reload_2"] = true,
  668.     ["Reload_3"] = true,
  669.     ["Reload_4"] = true,
  670.     ["Reload_1_Nomen"] = true,
  671.     ["Reload_2_Nomen"] = true,
  672.     ["Reload_3_Nomen"] = true,
  673.     ["Reload_4_Nomen"] = true,
  674.     ["Reload_empty"] = true,
  675.     ["Reload"] = true,
  676.     ["Reload_Empty"] = true,
  677.     ["Reload_Nomen"] = true,
  678.     ["Reload_Empty_Nomen"] = true,
  679.     ["Reload_10"] = true,
  680.     ["Reload_10_Nomen"] = true,
  681.     ["Reload_Empty_10"] = true,
  682.     ["Reload_Empty_10_Nomen"] = true,
  683.     ["Reload_20"] = true,
  684.     ["Reload_20_Nomen"] = true,
  685.     ["Reload_Empty_20"] = true,
  686.     ["Reload_Empty_20_Nomen"] = true,
  687.     ["Reload_30"] = true,
  688.     ["Reload_30_Nomen"] = true,
  689.     ["Reload_Empty_30"] = true,
  690.     ["Reload_Empty_30_Nomen"] = true}
  691.    
  692. local White, Black, Grey, Red, Green = Color(255, 255, 255, 255), Color(0, 0, 0, 255), Color(200, 200, 200, 255), Color(255, 137, 119, 255), Color(202, 255, 163, 255)
  693. local MagTextColor = {r = 255, g = 255, b = 255}
  694.  
  695. local GetAttachment = reg.Entity.GetAttachment
  696. local LookupAttachment = reg.Entity.LookupAttachment
  697. local ShadowText
  698.  
  699. timer.Simple(1, function()
  700.     ShadowText = draw.ShadowText
  701. end)
  702.  
  703. function SWEP:Draw3D2DCamera()
  704.     vm = self.Wep
  705.     att = GetAttachment(vm, LookupAttachment(vm, "muzzle"))
  706.    
  707.     if att then
  708.         self.TracePos = att.Pos
  709.     end
  710.    
  711.     if not att then
  712.         return
  713.     end
  714.    
  715.     if self.dt.Status == FAS_STAT_CUSTOMIZE  then
  716.         ang = self.Owner:EyeAngles()
  717.         RotateAroundAxis(ang, Right(ang), 90)
  718.         RotateAroundAxis(ang, Up(ang), -90)
  719.         RotateAroundAxis(ang, Forward(ang), 0)
  720.        
  721.         YOff = 0
  722.        
  723.         cam.Start3D2D(att.Pos + Forward(ang) * -4 + Right(ang) * -2, ang, 0.015 * GetConVarNumber("fas2_textsize"))
  724.             cam.IgnoreZ(true)
  725.                 if not self.ShowStats then
  726.                     for k, v in ipairs(self.Attachments) do
  727.                         x = v.x and v.x or 0
  728.                         y = v.y and v.y or 0
  729.                         y2 = 0
  730.                         XOff = 0
  731.                        
  732.                         surface.SetDrawColor(0, 0, 0, 225)
  733.                         surface.SetTexture(grad)
  734.                         surface.DrawTexturedRect(0 + x, 2 + YOff + y, 200, 52)
  735.                         ShadowText(self:GetKeyBind("slot" .. k) .. " " .. v.header, "FAS2_HUD48", 0 + x, YOff + y, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  736.                        
  737.                         for k2, v2 in ipairs(v.atts) do
  738.                             t = FAS2_Attachments[v2]
  739.                            
  740.                             if v.active == t.key then
  741.                                 surface.SetTexture(grad)
  742.                                 surface.SetDrawColor(0, 0, 0, 225)
  743.                                 surface.DrawTexturedRect(0 + XOff + x, 175 + YOff + y, 300, 25 + #t.desc * 25)
  744.                                
  745.                                 ShadowText(t.namefull, "FAS2_HUD24", 0 + XOff + x, 175 + YOff + y, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  746.                                
  747.                                 for k3, v3 in ipairs(t.desc) do
  748.                                     ShadowText(v3.t, "FAS2_HUD24", 0 + XOff + x, 175 + YOff + y + k3 * 25, v3.c, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  749.                                 end
  750.                                
  751.                                 surface.SetDrawColor(0, 255, 0, 255)
  752.                             else
  753.                                 if not table.HasValue(FAS2AttOnMe, t.key) then
  754.                                     surface.SetDrawColor(255, 108, 91, 255)
  755.                                 else
  756.                                     surface.SetDrawColor(107, 149, 255, 255)
  757.                                 end
  758.                             end
  759.                            
  760.                             surface.DrawOutlinedRect(0 + XOff + x, 60 + YOff + y, 90, 90)
  761.                             surface.DrawOutlinedRect(1 + XOff + x, 61 + YOff + y, 88, 88)
  762.                            
  763.                             if v.active == t.key then
  764.                                 surface.SetDrawColor(0, 0, 0, 225)
  765.                             else
  766.                                 surface.SetDrawColor(0, 0, 0, 150)
  767.                             end
  768.                            
  769.                             surface.DrawRect(0 + XOff + x, 60 + YOff + y, 90, 90)
  770.                            
  771.                             surface.SetDrawColor(White)
  772.                             surface.SetTexture(t.displaytexture)
  773.                             surface.DrawTexturedRect(4 + XOff + x, 63 + YOff + y, 83, 83)
  774.                             ShadowText(t.nameshort, "FAS2_HUD24", 0 + XOff + x, 150 + YOff + y, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  775.                             XOff = XOff + 100
  776.                         end
  777.                        
  778.                         YOff = YOff + 180
  779.                     end
  780.                 else
  781.                     ShadowText("STAT", "FAS2_HUD24", 0, -30, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  782.                    
  783.                     ShadowText("DAMAGE", "FAS2_HUD28", 0, 5, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  784.                     ShadowText("HIP SPREAD", "FAS2_HUD28", 0, 35, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  785.                     ShadowText("ACCURACY", "FAS2_HUD28", 0, 65, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  786.                     ShadowText("RECOIL", "FAS2_HUD28", 0, 95, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  787.                     ShadowText("MOBILITY", "FAS2_HUD28", 0, 125, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  788.                     ShadowText("FIRERATE", "FAS2_HUD28", 0, 155, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  789.                     ShadowText("SPREAD INC", "FAS2_HUD28", 0, 185, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  790.                     ShadowText("MAX SPREAD", "FAS2_HUD28", 0, 215, White, Black, 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  791.                     surface.SetDrawColor(0, 0, 0, 150)
  792.                     surface.DrawRect(175, 0, 80, 250)
  793.                     surface.DrawRect(270, 0, 80, 250)
  794.                    
  795.                     ShadowText("BASE", "FAS2_HUD24", 215, -30, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  796.                     ShadowText("CUR", "FAS2_HUD24", 310, -30, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  797.                    
  798.                     ShadowText(self.Damage_Orig, "FAS2_HUD28", 215, 5, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  799.                     ShadowText(math.Round(self.HipCone_Orig * 1000) .. "%", "FAS2_HUD28", 215, 35, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  800.                     ShadowText(math.Round(100 - self.AimCone_Orig * 1000) .. "%", "FAS2_HUD28", 215, 65, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  801.                     ShadowText(math.Round(self.Recoil_Orig * 100) .. "%", "FAS2_HUD24", 215, 95, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  802.                     ShadowText(math.Round(100 - self.VelocitySensitivity_Orig / 3 * 100) .. "%", "FAS2_HUD28", 215, 125, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  803.                     ShadowText(math.Round(60 / self.FireDelay_Orig), "FAS2_HUD28", 215, 155, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  804.                     ShadowText("+" .. math.Round(self.SpreadPerShot_Orig * 1000) .. "%", "FAS2_HUD24", 215, 185, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  805.                     ShadowText("+" .. math.Round(self.MaxSpreadInc_Orig * 1000) .. "%", "FAS2_HUD24", 215, 215, Grey, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  806.                    
  807.                     if self.Damage > self.Damage_Orig then
  808.                         ShadowText(math.Round(self.Damage), "FAS2_HUD28", 310, 5, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  809.                     elseif self.Damage < self.Damage_Orig then
  810.                         ShadowText(math.Round(self.Damage), "FAS2_HUD28", 310, 5, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  811.                     else
  812.                         ShadowText(math.Round(self.Damage), "FAS2_HUD28", 310, 5, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  813.                     end
  814.                    
  815.                     if self.HipCone < self.HipCone_Orig then
  816.                         ShadowText(math.Round(self.HipCone * 1000) .. "%", "FAS2_HUD28", 310, 35, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  817.                     elseif self.HipCone > self.HipCone_Orig then
  818.                         ShadowText(math.Round(self.HipCone * 1000) .. "%", "FAS2_HUD28", 310, 35, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  819.                     else
  820.                         ShadowText(math.Round(self.HipCone * 1000) .. "%", "FAS2_HUD28", 310, 35, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  821.                     end
  822.                    
  823.                     if self.AimCone < self.AimCone_Orig then
  824.                         ShadowText(math.Round(100 - self.AimCone * 1000) .. "%", "FAS2_HUD28", 310, 65, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  825.                     elseif self.AimCone > self.AimCone_Orig then
  826.                         ShadowText(math.Round(100 - self.AimCone * 1000) .. "%", "FAS2_HUD28", 310, 65, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  827.                     else
  828.                         ShadowText(math.Round(100 - self.AimCone * 1000) .. "%", "FAS2_HUD28", 310, 65, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  829.                     end
  830.                    
  831.                     if self.Recoil < self.Recoil_Orig then
  832.                         ShadowText(math.Round(self.Recoil * 100) .. "%", "FAS2_HUD24", 310, 95, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  833.                     elseif self.Recoil > self.Recoil_Orig then
  834.                         ShadowText(math.Round(self.Recoil * 100) .. "%", "FAS2_HUD24", 310, 95, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  835.                     else
  836.                         ShadowText(math.Round(self.Recoil * 100) .. "%", "FAS2_HUD24", 310, 95, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  837.                     end
  838.                    
  839.                     if self.VelocitySensitivity < self.VelocitySensitivity_Orig then
  840.                         ShadowText(math.Round(100 - self.VelocitySensitivity / 3 * 100) .. "%", "FAS2_HUD28", 310, 125, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  841.                     elseif self.VelocitySensitivity > self.VelocitySensitivity_Orig then
  842.                         ShadowText(math.Round(100 - self.VelocitySensitivity / 3 * 100) .. "%", "FAS2_HUD28", 310, 125, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  843.                     else
  844.                         ShadowText(math.Round(100 - self.VelocitySensitivity / 3 * 100) .. "%", "FAS2_HUD28", 310, 125, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  845.                     end
  846.                    
  847.                     if self.FireDelay < self.FireDelay_Orig then
  848.                         ShadowText(math.Round(60 / self.FireDelay), "FAS2_HUD28", 310, 155, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  849.                     elseif self.FireDelay > self.FireDelay_Orig then
  850.                         ShadowText(math.Round(60 / self.FireDelay), "FAS2_HUD28", 310, 155, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  851.                     else
  852.                         ShadowText(math.Round(60 / self.FireDelay), "FAS2_HUD28", 310, 155, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  853.                     end
  854.                    
  855.                     if self.SpreadPerShot < self.SpreadPerShot_Orig then
  856.                         ShadowText("+" .. math.Round(self.SpreadPerShot * 1000) .. "%", "FAS2_HUD24", 310, 185, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  857.                     elseif self.SpreadPerShot > self.SpreadPerShot_Orig then
  858.                         ShadowText("+" .. math.Round(self.SpreadPerShot * 1000) .. "%", "FAS2_HUD24", 310, 185, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  859.                     else
  860.                         ShadowText("+" .. math.Round(self.SpreadPerShot * 1000) .. "%", "FAS2_HUD24", 310, 185, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  861.                     end
  862.                    
  863.                     if self.MaxSpreadInc < self.MaxSpreadInc_Orig then
  864.                         ShadowText("+" .. math.Round(self.MaxSpreadInc * 1000) .. "%", "FAS2_HUD24", 310, 215, Green, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  865.                     elseif self.MaxSpreadInc > self.MaxSpreadInc then
  866.                         ShadowText("+" .. math.Round(self.MaxSpreadInc * 1000) .. "%", "FAS2_HUD24", 310, 215, Red, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  867.                     else
  868.                         ShadowText("+" .. math.Round(self.MaxSpreadInc * 1000) .. "%", "FAS2_HUD24", 310, 215, White, Black, 2, TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT)
  869.                     end
  870.                 end
  871.             cam.IgnoreZ(false)
  872.         cam.End3D2D()
  873.        
  874.         return
  875.     end
  876.    
  877.     if self.dt.Status == FAS_STAT_ADS then
  878.         if self.AimPos == self.CompM4Pos then
  879.             diff = (self.BlendPos[1] + self.BlendPos[3]) / (self.CompM4Pos[1] + self.CompM4Pos[3])
  880.                
  881.             if diff > 0.9 and diff < 1.1 then
  882.                 cam.IgnoreZ(true)
  883.                     render.SetMaterial(compm4_reticle)
  884.                     dist = math.Clamp(math.Distance(1, 1, diff, diff), 0, 0.13)
  885.                    
  886.                     render.DrawSprite(EyePos() + EyeAngles():Forward() * 100, 0.7, 0.7, Color(255, 255, 255, (0.13 - dist) / 0.13 * 255))
  887.                 cam.IgnoreZ(false)
  888.             end
  889.         elseif self.AimPos == self.EoTechPos then
  890.             diff = (self.BlendPos[1] + self.BlendPos[3]) / (self.EoTechPos[1] + self.EoTechPos[3])
  891.            
  892.             if diff > 0.9 and diff < 1.1 then
  893.                 cam.IgnoreZ(true)
  894.                     render.SetMaterial(eotech_reticle)
  895.                     dist = math.Clamp(math.Distance(1, 1, diff, diff), 0, 0.1)
  896.                    
  897.                     render.DrawSprite(EyePos() + EyeAngles():Forward() * 100, 4, 4, Color(255, 255, 255, (0.13 - dist) / 0.1 * 255))
  898.                 cam.IgnoreZ(false)
  899.             end
  900.         end
  901.     end
  902.    
  903.     vm = self.Wep
  904.     seq = GetSequenceName(vm, GetSequence(vm))
  905.     cyc = vm:GetCycle()
  906.            
  907.     FT = FrameTime()
  908.     animfound = self.CurAnim:find("reload")
  909.    
  910.     if (animfound or self.AnimOverride and self.AnimOverride[self.CurAnim]) and cyc <= self.ReloadCycleTime and self.dt.Status != FAS_STAT_ADS or (self.Owner:KeyDown(IN_RELOAD) and self.dt.Status == FAS_STAT_ADS) then
  911.         self.MagCheckAlpha = math.Approach(self.MagCheckAlpha, 255, FT * 500)
  912.  
  913.         if not self.NoBlurOnPump or animfound then
  914.             self.BlurAmount = math.Approach(self.BlurAmount, 10, FT * 20)
  915.         end
  916.        
  917.         self.CheckTime = CT + 1
  918.         self.MagCheck = true
  919.     else
  920.         CT = CurTime()
  921.            
  922.         if (CT < self.CheckTime and self.dt.Status != FAS_STAT_ADS) or CT < self.FireModeSwitchTime then
  923.             self.MagCheckAlpha = math.Approach(self.MagCheckAlpha, 255, FT * 500)
  924.         else
  925.             self.MagCheckAlpha = math.Approach(self.MagCheckAlpha, 0, FT * 500)
  926.         end
  927.        
  928.         if self.dt.Status != FAS_STAT_ADS and self.dt.Status != FAS_STAT_CUSTOMIZE then
  929.             self.BlurAmount = math.Approach(self.BlurAmount, 0, FT * 20)
  930.         end
  931.        
  932.         self.MagCheck = false
  933.     end
  934.    
  935.     if GetConVarNumber("fas2_nohud") <= 0 and GetConVarNumber("fas2_customhud") > 0 then
  936.         if self.CockRemindTime > CT then
  937.             self.CockRemindAlpha = math.Approach(self.CockRemindAlpha, 255, FT * 500)
  938.         else   
  939.             self.CockRemindAlpha = math.Approach(self.CockRemindAlpha, 0, FT * 500)
  940.         end
  941.        
  942.         if self.MagCheckAlpha > 0 or self.CockRemindAlpha > 0 then
  943.             att = GetAttachment(vm, LookupAttachment(vm, (self.MuzzleName and self.MuzzleName or "muzzle")))
  944.             ang = self.Owner:EyeAngles()
  945.             RotateAroundAxis(ang, Right(ang), 90)
  946.             RotateAroundAxis(ang, Up(ang), -90)
  947.             RotateAroundAxis(ang, Forward(ang), 0)
  948.            
  949.             if att then
  950.                 cam.Start3D2D(att.Pos + Forward(ang) * self.Text3DForward + Right(ang) * self.Text3DRight, ang, self.Text3DSize * GetConVarNumber("fas2_textsize"))
  951.                     cam.IgnoreZ(true)
  952.                         if self.CockRemindAlpha > 0 then
  953.                             ShadowText(self.BoltReminderText, "FAS2_HUD48", 0, -40, Color(255, 255, 255, self.CockRemindAlpha), Color(0, 0, 0, self.CockRemindAlpha), 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  954.                         end
  955.                        
  956.                         if self.MagCheckAlpha > 0 then
  957.                             mag = self:Clip1()
  958.                            
  959.                             if mag <= self.Primary.ClipSize * 0.3 then
  960.                                 MagTextColor.g = Lerp(FT * 5, MagTextColor.g, 125)
  961.                                 MagTextColor.b = Lerp(FT * 5, MagTextColor.b, 125)
  962.                             else
  963.                                 MagTextColor.g = Lerp(FT * 5, MagTextColor.g, 255)
  964.                                 MagTextColor.b = Lerp(FT * 5, MagTextColor.b, 255)
  965.                             end
  966.                            
  967.                             if mag > self.Primary.ClipSize then
  968.                                 ShadowText(self.MagText .. self.Primary.ClipSize .. " + " .. mag - self.Primary.ClipSize, "FAS2_HUD72", 0, 0, Color(MagTextColor.r, MagTextColor.g, MagTextColor.b, self.MagCheckAlpha), Color(0, 0, 0, self.MagCheckAlpha), 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  969.                             else
  970.                                 ShadowText(self.MagText .. mag, "FAS2_HUD72", 0, 0, Color(MagTextColor.r, MagTextColor.g, MagTextColor.b, self.MagCheckAlpha), Color(0, 0, 0, self.MagCheckAlpha), 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  971.                             end
  972.                                
  973.                             ShadowText("RESERVE " .. self.Owner:GetAmmoCount(self.Primary.Ammo), "FAS2_HUD48", 0, 60, Color(255, 255, 255, self.MagCheckAlpha), Color(0, 0, 0, self.MagCheckAlpha), 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  974.                             ShadowText(self.FireModeDisplay, "FAS2_HUD36", 0, 105, Color(255, 255, 255, self.MagCheckAlpha), Color(0, 0, 0, self.MagCheckAlpha), 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  975.                             ShadowText(self.Primary.Ammo, "FAS2_HUD24", 0, 140, Color(255, 255, 255, self.MagCheckAlpha), Color(0, 0, 0, self.MagCheckAlpha), 2, TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT)
  976.                                
  977.                             if self.MagCheck then
  978.                                 if animfound and cyc < 0.99 then
  979.                                     surface.SetDrawColor(0, 0, 0, self.MagCheckAlpha)
  980.                                     surface.DrawRect(3, 175, 270, 10)
  981.                                        
  982.                                     surface.SetDrawColor(255, 255, 255, self.MagCheckAlpha)
  983.                                     surface.DrawRect(2, 175, 300 * cyc, 8)
  984.                                 end
  985.                             end
  986.                         end
  987.                     cam.IgnoreZ(false)
  988.                 cam.End3D2D()
  989.             end
  990.         end
  991.     end
  992. end
  993.  
  994. function SWEP:GetViewModelPosition(pos, ang)
  995.     pos = pos + ang:Up() * 100
  996.     return pos, ang
  997. end
  998.  
  999. local pos, dir
  1000.  
  1001. function SWEP:GetTracerOrigin()
  1002.     if self.TracePos then
  1003.         return self.TracePos
  1004.     end
  1005.    
  1006.     pos = self.Owner:GetShootPos()
  1007.     dir = self.Owner:EyeAngles()
  1008.     pos = pos + Forward(dir) * 10
  1009.     pos = pos + Right(dir) * 5
  1010.  
  1011.     return
  1012. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement