Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local yawOffset = 0
- local targetId = nil
- function Player:OverrideInput(input)
- if self.timeClosedMenu and (Shared.GetTime() < self.timeClosedMenu + .25) then
- local removePrimaryAttackMask = bit.bxor(0xFFFFFFFF, Move.PrimaryAttack)
- input.commands = bit.band(input.commands, removePrimaryAttackMask)
- end
- if self.shortcircuitInput then
- input.commands = 0x00000000
- input.move = Vector(0,0,0)
- end
- self.shortcircuitInput = MainMenu_GetIsOpened()
- ClampInputPitch(input)
- if (Client) then
- 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
- if false and self:isa("Alien") then
- local enemy = GetEntitiesForTeamWithinRange("Player", GetEnemyTeamNumber(self:GetTeamNumber()), self:GetEyePos(), 2)[1]
- if enemy ~= nil then
- local lookAtPoint = enemy:GetOrigin() + Vector(0,0.7,0)
- local toTechPoint = GetNormalizedVector(lookAtPoint - self:GetViewCoords().origin)
- local angles = Angles(GetPitchFromVector(toTechPoint), GetYawFromVector(toTechPoint), 0)
- input.yaw = angles.yaw
- input.pitch = angles.pitch
- end
- elseif self:isa("Marine") and false then
- local enemies = GetEntitiesForTeamWithinRange("Player", GetEnemyTeamNumber(self:GetTeamNumber()), self:GetEyePos(), 300)--GetEnemyTeamNumber()
- if targetId == nil then
- for e = 1, #enemies do
- local v = enemies[e]
- if v:GetIsAlive() then
- local min, max = v:GetModelExtents()
- local size = Vector((max.x - min.x)/2, (max.y - min.y)/2, (max.z - min.z)/2)
- local lookAtPoint = v:GetOrigin() + Vector(0,size.y,0)
- local aimangles = AimAngles(self,Vector(self:GetViewCoords().origin - lookAtPoint))
- local fov = GetFov(aimangles, Angles(input.pitch, input.yaw, 0))
- if fov <= 5 then
- local trace = Shared.TraceRay(self:GetViewCoords().origin, lookAtPoint, CollisionRep.Damage, PhysicsMask.Bullets, EntityFilterTwo(self,v))
- if trace.fraction >= 0.9 then
- targetId = v:GetId()
- break
- end
- end
- end
- end
- end
- if targetId ~= nil then
- local target = Shared.GetEntity(targetId)
- if not target or not target:GetIsAlive() then
- targetId = nil
- return input
- end
- local min, max = target:GetModelExtents()
- local size = Vector((max.x - min.x)/2, (max.y - min.y)/2, (max.z - min.z)/2)
- local lookAtPoint = target:GetOrigin() + Vector(0,size.y,0)
- local trace = Shared.TraceRay(self:GetViewCoords().origin, lookAtPoint, CollisionRep.Damage, PhysicsMask.Bullets, EntityFilterTwo(self,v))
- if trace.fraction < 0.9 then
- targetId = nil
- return input
- end
- local aimangles = AimAngles(self,Vector(self:GetViewCoords().origin - lookAtPoint))
- //local fov = GetFov(aimangles, Angles(input.pitch, input.yaw, 0))
- DebugBox(lookAtPoint, lookAtPoint, Vector(0.05,0.05,0.05), .05, 1, 1, 0, 1)
- local yaw = RadiansTo2PiRange(aimangles.yaw)
- local aimSpeed = 0.1
- input.pitch = (input.pitch + (aimangles.pitch * aimSpeed))/(aimSpeed+1)
- input.yaw = (input.yaw + (yaw * aimSpeed))/(aimSpeed+1)
- Client.SetPitch(input.pitch)
- Client.SetYaw(input.yaw)
- end
- end
- end
- end
- return input
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement