local function b()return Player and Player.Character end local function y()local b=findPlayerHumanoid(Player)return b and b.Torso end local function V(b)return b and(b.Parent and b.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")~=nil)end local function S()local S=b()if S==nil then return end local X=findPlayerHumanoid(Player)if X==nil then return end local U=1.5 local G=7.0 local L=y()if L==nil then return end local D=L.CFrame local g=D.lookVector local F=D.p local E=Ray.new(F+Vector3.new(0,-L.Size.Y/2,0),g*U)local k=Ray.new(F+Vector3.new(0,G-L.Size.Y,0),g*U)local m,C=RayCastIgnoreList(workspace,E,{S},false)local f,s=RayCastIgnoreList(workspace,k,{S},false)if m and(f==nil and m.CanCollide==true)then if not V(m)then X.Jump=true end end end local X={[Enum.HumanoidStateType.FallingDown]=false;[Enum.HumanoidStateType.Flying]=false,[Enum.HumanoidStateType.Freefall]=false;[Enum.HumanoidStateType.GettingUp]=false,[Enum.HumanoidStateType.Ragdoll]=false;[Enum.HumanoidStateType.Running]=false,[Enum.HumanoidStateType.Seated]=false;[Enum.HumanoidStateType.Swimming]=false;[Enum.HumanoidStateType.Climbing]=false}local function U()local b=findPlayerHumanoid(Player)local y=b and b:GetState()if y then return X[y]==nil end return false end local function G()return true end local function L(b)return b.magnitude<.05 end
--------------------------PC AUTO JUMPER-------------------------------

local function GetCharacter()
	return Player and Player.Character
end

local function GetTorso()
	local humanoid = findPlayerHumanoid(Player)
	return humanoid and humanoid.Torso
end

local function IsPartAHumanoid(part)
	return part and part.Parent and (part.Parent:FindFirstChild("Humanoid") ~= nil)
end

local function doAutoJump()
	local character = GetCharacter()
	if character == nil then
		return
	end

	local humanoid = findPlayerHumanoid(Player)
	if humanoid == nil then
		return
	end

	local rayLength = 1.5
	-- This is how high a ROBLOXian jumps from the mid point of his torso
	local jumpHeight = 7.0

	local torso = GetTorso()
	if torso == nil then
		return
	end

	local torsoCFrame = torso.CFrame
	local torsoLookVector = torsoCFrame.lookVector
	local torsoPos = torsoCFrame.p

	local torsoRay = Ray.new(torsoPos + Vector3.new(0, -torso.Size.Y / 2, 0), torsoLookVector * rayLength)
	local jumpRay = Ray.new(torsoPos + Vector3.new(0, jumpHeight - torso.Size.Y, 0), torsoLookVector * rayLength)

	local hitPart, _ = RayCastIgnoreList(workspace, torsoRay, { character }, false)
	local jumpHitPart, _ = RayCastIgnoreList(workspace, jumpRay, { character }, false)

	if hitPart and jumpHitPart == nil and hitPart.CanCollide == true then
		-- NOTE: this follow line is not in the C++ impl, but an improvement  in Click to Move
		if not IsPartAHumanoid(hitPart) then
			humanoid.Jump = true
		end
	end
end

local NO_JUMP_STATES = {
	[Enum.HumanoidStateType.FallingDown] = false,
	[Enum.HumanoidStateType.Flying] = false,
	[Enum.HumanoidStateType.Freefall] = false,
	[Enum.HumanoidStateType.GettingUp] = false,
	[Enum.HumanoidStateType.Ragdoll] = false,
	[Enum.HumanoidStateType.Running] = false,
	[Enum.HumanoidStateType.Seated] = false,
	[Enum.HumanoidStateType.Swimming] = false,

	-- Special case to detect if we are on a ladder
	[Enum.HumanoidStateType.Climbing] = false,
}

local function enableAutoJump()
	local humanoid = findPlayerHumanoid(Player)
	local currentState = humanoid and humanoid:GetState()
	if currentState then
		return NO_JUMP_STATES[currentState] == nil
	end
	return false
end

local function getAutoJump()
	return true
end

local function vec3IsZero(vec3)
	return vec3.magnitude < 0.05
end
