SHARE
TWEET

Untitled

a guest Jun 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local yawOffset = 0
  2. local targetId = nil
  3.  
  4. function Player:OverrideInput(input)
  5.  
  6.     if self.timeClosedMenu and (Shared.GetTime() < self.timeClosedMenu + .25) then
  7.         local removePrimaryAttackMask = bit.bxor(0xFFFFFFFF, Move.PrimaryAttack)
  8.         input.commands = bit.band(input.commands, removePrimaryAttackMask)
  9.     end
  10.    
  11.     if self.shortcircuitInput then
  12.         input.commands = 0x00000000
  13.         input.move = Vector(0,0,0)
  14.     end
  15.  
  16.     self.shortcircuitInput = MainMenu_GetIsOpened()
  17.    
  18.     ClampInputPitch(input)
  19.  
  20.     if (Client) then
  21.         if (bit.bor(bit.band(input.commands,Move.SecondaryAttack),bit.band(input.commands,Move.PrimaryAttack)) ~= 0) then //bit.band(input.commands, Move.Weapon1) ~= 0 and
  22.             if false and self:isa("Alien") then
  23.                 local enemy = GetEntitiesForTeamWithinRange("Player", GetEnemyTeamNumber(self:GetTeamNumber()), self:GetEyePos(), 2)[1]
  24.                 if enemy ~= nil then
  25.                     local lookAtPoint = enemy:GetOrigin() + Vector(0,0.7,0)
  26.                     local toTechPoint = GetNormalizedVector(lookAtPoint - self:GetViewCoords().origin)
  27.                     local angles = Angles(GetPitchFromVector(toTechPoint), GetYawFromVector(toTechPoint), 0)
  28.                     input.yaw = angles.yaw
  29.                     input.pitch = angles.pitch
  30.                 end
  31.             elseif self:isa("Marine") and false then
  32.                 local enemies = GetEntitiesForTeamWithinRange("Player", GetEnemyTeamNumber(self:GetTeamNumber()), self:GetEyePos(), 300)--GetEnemyTeamNumber()
  33.                
  34.                 if targetId == nil then
  35.                     for e = 1, #enemies do
  36.                         local v = enemies[e]
  37.                         if v:GetIsAlive() then
  38.                             local min, max = v:GetModelExtents()
  39.                             local size = Vector((max.x - min.x)/2, (max.y - min.y)/2, (max.z - min.z)/2)
  40.                             local lookAtPoint = v:GetOrigin() + Vector(0,size.y,0)
  41.                             local aimangles = AimAngles(self,Vector(self:GetViewCoords().origin - lookAtPoint))
  42.                             local fov = GetFov(aimangles, Angles(input.pitch, input.yaw, 0))
  43.                             if fov <= 5 then
  44.                                 local trace = Shared.TraceRay(self:GetViewCoords().origin, lookAtPoint, CollisionRep.Damage, PhysicsMask.Bullets, EntityFilterTwo(self,v))
  45.                                 if trace.fraction >= 0.9 then
  46.                                     targetId = v:GetId()
  47.                                     break
  48.                                 end
  49.                             end
  50.                         end
  51.                     end
  52.                 end
  53.                
  54.                 if targetId ~= nil then
  55.                     local target = Shared.GetEntity(targetId)
  56.                     if not target or not target:GetIsAlive() then
  57.                         targetId = nil
  58.                         return input
  59.                     end
  60.  
  61.                     local min, max = target:GetModelExtents()
  62.                     local size = Vector((max.x - min.x)/2, (max.y - min.y)/2, (max.z - min.z)/2)
  63.                     local lookAtPoint = target:GetOrigin() + Vector(0,size.y,0)
  64.  
  65.                     local trace = Shared.TraceRay(self:GetViewCoords().origin, lookAtPoint, CollisionRep.Damage, PhysicsMask.Bullets, EntityFilterTwo(self,v))
  66.                     if trace.fraction < 0.9 then
  67.                         targetId = nil
  68.                         return input
  69.                     end
  70.  
  71.                     local aimangles = AimAngles(self,Vector(self:GetViewCoords().origin - lookAtPoint))
  72.                     //local fov = GetFov(aimangles, Angles(input.pitch, input.yaw, 0))
  73.  
  74.                     DebugBox(lookAtPoint, lookAtPoint, Vector(0.05,0.05,0.05), .05, 1, 1, 0, 1)
  75.  
  76.                     local yaw = RadiansTo2PiRange(aimangles.yaw)
  77.                     local aimSpeed = 0.1
  78.  
  79.                     input.pitch = (input.pitch + (aimangles.pitch * aimSpeed))/(aimSpeed+1)
  80.                     input.yaw = (input.yaw + (yaw * aimSpeed))/(aimSpeed+1)
  81.  
  82.                     Client.SetPitch(input.pitch)
  83.                     Client.SetYaw(input.yaw)
  84.                 end
  85.             end
  86.         end
  87.     end
  88.  
  89.     return input
  90.    
  91. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top