mirror of
https://github.com/sr229/metastruct-experiments.git
synced 2024-09-20 06:30:36 +00:00
9e5616fc7d
Signed-off-by: Ayane Satomi <ayane@vignetteapp.org>
32 lines
No EOL
875 B
Lua
32 lines
No EOL
875 B
Lua
-- Code by Henke and Minori
|
|
-- to remove the hook please run
|
|
-- hook.Remove("StartCommand", "autopilot")
|
|
|
|
local target = eno
|
|
|
|
say("[luadev/Autopilot] Now following " .. tostring(target))
|
|
|
|
|
|
hook.Add("StartCommand", "heatseekingminori", function(ply, cmd)
|
|
if ply ~= LocalPlayer() then return end
|
|
if not target:Alive() then return end
|
|
if target:GetPos():Distance(ply:GetPos()) < 128 then
|
|
return
|
|
end
|
|
|
|
|
|
-- we wanna run if our target is greater than 512 units
|
|
-- that way we can still catch up
|
|
if target:GetPos():Distance(ply:GetPos()) > 512 then
|
|
cmd:AddKey(IN_SPEED)
|
|
cmd:SetForwardMove(ply:GetRunSpeed())
|
|
else
|
|
cmd:SetForwardMove(ply:GetWalkSpeed())
|
|
end
|
|
|
|
local ang = cmd:GetViewAngles()
|
|
local targetAngle = (target:GetShootPos() - ply:GetShootPos()):GetNormalized():Angle()
|
|
targetAngle = LerpAngle(0.1, ang, targetAngle)
|
|
|
|
cmd:SetViewAngles(targetAngle)
|
|
end) |