Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local walkbot = {LEFT = -1, RIGHT = 1}
- walkbot.WalkKey = KEY_B
- walkbot.MinWallDistance = 200
- walkbot.DefaultStepMult = walkbot.LEFT
- walkbot.StepDegrees = 15
- walkbot.ThreeWallMult = 15 --180 / walkbot.StepDegrees
- walkbot.Debug = false
- walkbot.lp = LocalPlayer()
- walkbot.walking = false
- walkbot.ct = {mask = MASK_PLAYERSOLID}
- walkbot.tr = nil
- walkbot.td = nil
- walkbot.DrawLine = function(tr)
- if (tr.Hit) then surface.SetDrawColor(0,255,0,255)
- else surface.SetDrawColor(255,0,0,255) end
- local start2d = tr.StartPos:ToScreen()
- local hit2d = tr.HitPos:ToScreen()
- surface.DrawLine(start2d.x, start2d.y, hit2d.x, hit2d.y)
- end
- walkbot.GetTurnDir = function()
- local leftt = {mask = MASK_PLAYERSOLID}
- leftt.start = walkbot.lp:GetPos()
- local leftv = Angle(0,walkbot.lp:EyeAngles().y + 90,0):Forward()
- leftt.endpos = leftt.start + (leftv * walkbot.MinWallDistance)
- leftt.filter = walkbot.lp
- local lefttr = util.TraceLine(leftt)
- if (walkbot.Debug) then walkbot.DrawLine(lefttr) end
- local rightt = {mask = MASK_PLAYERSOLID}
- rightt.start = walkbot.lp:GetPos()
- local rightv = Angle(0,walkbot.lp:EyeAngles().y - 90,0):Forward()
- rightt.endpos = rightt.start + (rightv * walkbot.MinWallDistance)
- rightt.filter = walkbot.lp
- local righttr = util.TraceLine(rightt)
- if (walkbot.Debug) then walkbot.DrawLine(righttr) end
- if (lefttr.Hit and righttr.Hit) then
- return walkbot.ThreeWallMult
- elseif (lefttr.Hit) then
- RunConsoleCommand("+moveright")
- timer.Simple(walkbot.MinWallDistance/1000,
- RunConsoleCommand, "-moveright")
- return walkbot.RIGHT
- elseif (righttr.Hit) then
- RunConsoleCommand("+moveleft")
- timer.Simple(walkbot.MinWallDistance/1000,
- RunConsoleCommand, "-moveleft")
- return walkbot.LEFT
- end
- return walkbot.DefaultStepMult
- end
- walkbot.main = function()
- if (input.IsKeyDown(walkbot.WalkKey)) then
- walkbot.GetTurnDir() //FIX WALL DISTANCE
- walkbot.ct.start = walkbot.lp:EyePos()
- walkbot.ct.endpos = walkbot.ct.start + (walkbot.lp:EyeAngles():Forward() * 16384)
- walkbot.ct.filter = walkbot.lp
- walkbot.tr = util.TraceLine(walkbot.ct)
- if (walkbot.Debug) then walkbot.DrawLine(walkbot.tr) end
- if (walkbot.tr.Hit) then
- walkbot.td = walkbot.tr.StartPos:Distance(walkbot.tr.HitPos)
- if (walkbot.td <= walkbot.MinWallDistance) then
- if (walkbot.walking) then RunConsoleCommand("-forward") end
- walkbot.lp:SetEyeAngles(walkbot.lp:EyeAngles() -
- Angle(0,walkbot.StepDegrees*walkbot.GetTurnDir(),0))
- else
- RunConsoleCommand("+forward")
- walkbot.walking = true
- end
- end
- if (input.IsKeyDown(KEY_DELETE)) then
- hook.Remove("HUDPaint", "walkbot.main")
- RunConsoleCommand("-forward")
- walkbot = nil
- end
- elseif (walkbot.walking) then
- RunConsoleCommand("-forward")
- walkbot.walking = false
- end
- end
- hook.Add("HUDPaint", "walkbot.main", walkbot.main)
- print([[ __ ____ _ ___ ______________
- / |/ (_)______________| | / / | / / ____/_ __/
- / /|_/ / // ___/ ___/ __ \ | / / |/ / __/ / /
- / / / / // /__/ / / /_/ / |/ / /| / /___ / /
- /_/ /_/_/ \___/_/ \____/|___/_/ |_/_____/ /_/ ]])
- print("====================WalkBot v1.6=====================")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement