PostpCircleStrafe in Lua

Posts 1–12 of 12 · Page 1 of 1
pCircleStrafe in Lua
Made this for Bee T. Gee because he wanted to know how proper Circle Strafe worked.
Releasing it because I don't need it as my hack is C++.

Tested and Working. Includes Movement Fix and Movement Clamp.

To change the Bind set the Key Value for CSBOI._G.input.IsKeyDown in function CSBOI.CircleStrafe.
By default I set it to KEY_F.

Code:
// pCircleStrafe BOI! GET YOU SOME!

local CSBOI = {}
CSBOI.CircleStrafeVal = 0
CSBOI._G = table.Copy(_G)
CSBOI.localply = CSBOI._G.LocalPlayer()
CSBOI.cl_forwardspeed_cvar = CSBOI._G.GetConVar("cl_forwardspeed")
CSBOI.cl_forwardspeed_value = 10000
if (CSBOI.cl_forwardspeed_cvar) then
	CSBOI.cl_forwardspeed_value = CSBOI.cl_forwardspeed_cvar:GetFloat()
end
CSBOI.cl_sidespeed_cvar = CSBOI._G.GetConVar("cl_sidespeed")
CSBOI.cl_sidespeed_value = 10000
if (CSBOI.cl_sidespeed_cvar) then
	CSBOI.cl_sidespeed_value = CSBOI.cl_sidespeed_cvar:GetFloat()
end

function CSBOI.ClampMove(cmd)
	if (cmd:GetForwardMove() > CSBOI.cl_forwardspeed_value) then
		cmd:SetForwardMove(CSBOI.cl_forwardspeed_value)
	end
	if (cmd:GetSideMove() > CSBOI.cl_sidespeed_value) then
		cmd:SetSideMove(CSBOI.cl_sidespeed_value)
	end
end

function CSBOI.FixMove(cmd, rotation)
	local rot_cos = CSBOI._G.math.cos(rotation)
	local rot_sin = CSBOI._G.math.sin(rotation)
	local cur_forwardmove = cmd:GetForwardMove()
	local cur_sidemove = cmd:GetSideMove()
	cmd:SetForwardMove(((rot_cos * cur_forwardmove) - (rot_sin * cur_sidemove)))
	cmd:SetSideMove(((rot_sin * cur_forwardmove) + (rot_cos * cur_sidemove)))
end

CSBOI.CircleStrafeSpeed = 3
function CSBOI.CircleStrafe(cmd)
	if (CSBOI._G.input.IsKeyDown(KEY_F)) then
		CSBOI.CircleStrafeVal = CSBOI.CircleStrafeVal + CSBOI.CircleStrafeSpeed
		if ((CSBOI.CircleStrafeVal > 0) and ((CSBOI.CircleStrafeVal / CSBOI.CircleStrafeSpeed) > 361)) then
			CSBOI.CircleStrafeVal = 0
		end
		CSBOI.FixMove(cmd, CSBOI._G.math.rad((CSBOI.CircleStrafeVal - CSBOI._G.engine.TickInterval())))
		return false
	else
		CSBOI.CircleStrafeVal = 0
	end
	return true
end

function CSBOI.RunIt(cmd)
	if (CSBOI.localply) then
		if (cmd:KeyDown(IN_JUMP)) then
			local local_velocity = CSBOI.localply:GetVelocity()
			if (local_velocity:Length2D() < 50) then
				cmd:SetForwardMove(CSBOI.cl_forwardspeed_value)
			end
			local shouldautostrafe = CSBOI.CircleStrafe(cmd)		
			if (!CSBOI.localply:OnGround()) then
				if (shouldautostrafe) then
					// Do your AutoStrafe Here
				end
				cmd:SetButtons(cmd:GetButtons() - IN_JUMP)
			end
		else
			CSBOI.CircleStrafeVal = 0
		end
	end
	CSBOI.ClampMove(cmd)
end
CSBOI._G.hook.Add("CreateMove", "CSBOI", CSBOI.RunIt)
I have never seen a circle strafe aimbot, has anyone got a video of them using one?
this is fucking gay you can do it better in ~3 lines retard
Quote Originally Posted by kaliii View Post
this is fucking gay you can do it better in ~3 lines retard
You mean by adding a static never changing value to your View Angles?
Good luck getting it to work correctly when you Lag.

Also if you would read what I had posted I included a lot more than just the pCircleStrafe.
Only idiots don't read OP.
Quote Originally Posted by Herp Derpinstine View Post
You mean by adding a static never changing value to your View Angles?
Good luck getting it to work correctly when you Lag.

Also if you would read what I had posted I included a lot more than just the pCircleStrafe.
Only idiots don't read OP.
Code:
function ok.AutoGain(cmd)
	if !ok.vars["misc"]["autogain"]:GetBool() or cmd:CommandNumber() == 0 then return end
	local min = ok.vars["misc"]["autogainmin"]:GetFloat()
	local max = ok.vars["misc"]["autogainmax"]:GetFloat()
	local mult = ok.vars["misc"]["autogainmult"]:GetFloat()
	ok.ga_y = ok.ga_y + math.Clamp((me:GetVelocity():Length2D() * mult), min, max)
	math.NormalizeAngle(ok.ga_y)

	local key = _G["KEY_" .. string.upper(ok.vars["misc"]["autogainkey"]:GetString())] or KEY_F
	if input.IsKeyDown(key) then
		cmd:SetForwardMove(10^4)
		cmd:SetSideMove(0)
		ok.FixMove(cmd, Angle(ok.fa.p, ok.ga_y, 0))
	end
end
this works just fine
Quote Originally Posted by kaliii View Post
Code:
function ok.AutoGain(cmd)
	if !ok.vars["misc"]["autogain"]:GetBool() or cmd:CommandNumber() == 0 then return end
	local min = ok.vars["misc"]["autogainmin"]:GetFloat()
	local max = ok.vars["misc"]["autogainmax"]:GetFloat()
	local mult = ok.vars["misc"]["autogainmult"]:GetFloat()
	ok.ga_y = ok.ga_y + math.Clamp((me:GetVelocity():Length2D() * mult), min, max)
	math.NormalizeAngle(ok.ga_y)

	local key = _G["KEY_" .. string.upper(ok.vars["misc"]["autogainkey"]:GetString())] or KEY_F
	if input.IsKeyDown(key) then
		cmd:SetForwardMove(10^4)
		cmd:SetSideMove(0)
		ok.FixMove(cmd, Angle(ok.fa.p, ok.ga_y, 0))
	end
end
this works just fine
mine works better
yours doesn't even draw anything

Code:
local function pCircle(x, y, diameter, col)
	local circle = {}
	
	local centre = Vector(x, y, 0)
	local scale = Vector(diameter, diameter, 0)
	local segmentdist = 360 / (2 * math.pi * math.max(scale.x, scale.y) * .5)
	
	for i = 0, 360 - segmentdist, segmentdist do
		circle[#circle + 1] = {x = centre.x + math.cos(math.rad(i)) * scale.x, y = centre.y - math.sin(math.rad(i)) * scale.y}
	end
	
	surface.SetDrawColor(col)
	surface.DrawPoly(circle)
end
Quote Originally Posted by Cyaegha View Post
mine works better
yours doesn't even draw anything

Code:
local function pCircle(x, y, diameter, col)
	local circle = {}
	
	local centre = Vector(x, y, 0)
	local scale = Vector(diameter, diameter, 0)
	local segmentdist = 360 / (2 * math.pi * math.max(scale.x, scale.y) * .5)
	
	for i = 0, 360 - segmentdist, segmentdist do
		circle[#circle + 1] = {x = centre.x + math.cos(math.rad(i)) * scale.x, y = centre.y - math.sin(math.rad(i)) * scale.y}
	end
	
	surface.SetDrawColor(col)
	surface.DrawPoly(circle)
end
leaked
here's a video of it in action
thanks again Herp, i was curious how circle strafe worked so original code you gave me helped a lot in accomplishing such
Quote Originally Posted by bee_tee_gee View Post
thanks again Herp, i was curious how circle strafe worked so original code you gave me helped a lot in accomplishing such
No problem.
Quote Originally Posted by Herp Derpinstine View Post
No problem.
I'm pretty surprised you'd even release anything to mpgh ever again
Quote Originally Posted by IAmPhage View Post
I'm pretty surprised you'd even release anything to mpgh ever again
I thought it was odd that on HvH only myself and a few other people had proper Circle Strafing.

Lately it has just been the same copypasta/junk recycled that gets posted here. It needed some fresh and original code.

Yeah this will get copied and pasted too but at least it is something new.
Quote Originally Posted by Herp Derpinstine View Post
proper Circle Strafing.
lol, no this is not
Posts 1–12 of 12 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us