function moveFreeFall()RightShoulder.MaxVelocity=.5 LeftShoulder.MaxVelocity=.5 RightShoulder.DesiredAngle=3.14 LeftShoulder.DesiredAngle=-3.14 RightHip.DesiredAngle=0 LeftHip.DesiredAngle=0 end function moveSit()RightShoulder.MaxVelocity=.15 LeftShoulder.MaxVelocity=.15 RightShoulder.DesiredAngle=1.57 LeftShoulder.DesiredAngle=-1.57 RightHip.DesiredAngle=1.57 LeftHip.DesiredAngle=-1.57 end function getTool()for K,D in ipairs(Figure:GetChildren())do if D.className=="\084\111\111\108"then return D end end return nil end function getToolAnim(K)for K,D in ipairs(K:GetChildren())do if D.Name=="\116\111\111\108\097\110\105\109"and D.className=="\083\116\114\105\110\103\086\097\108\117\101"then return D end end return nil end function animateTool()if toolAnim=="\078\111\110\101"then RightShoulderdDesiredAngle=1.57 return end if toolAnim=="\083\108\097\115\104"then RightShoulder.MaxVelocity=.5 RightShoulder.DesiredAngle=0 return end if toolAnim=="\076\117\110\103\101"then RightShoulder.MaxVelocity=.5 LeftShoulder.MaxVelocity=.5 RightHip.MaxVelocity=.5 LeftHip.MaxVelocity=.5 RightShoulder.DesiredAngle=1.57 LeftShoulder.DesiredAngle=0 RightHip.DesiredAngle=1.57 LeftHip.DesiredAngle=1.0 return end end function move(K)local D local C if pose=="\074\117\109\112\105\110\103"then moveJump()return end if pose=="\070\114\101\101\070\097\108\108"then moveFreeFall()return end if pose=="\083\101\097\116\101\100"then moveSit()return end local s=0 if pose=="\082\117\110\110\105\110\103"then RightShoulder.MaxVelocity=.15 LeftShoulder.MaxVelocity=.15 D=1 C=9 elseif pose=="\067\108\105\109\098\105\110\103"then RightShoulder.MaxVelocity=.5 LeftShoulder.MaxVelocity=.5 D=1 C=9 s=3.14 else D=.1 C=1 end desiredAngle=D*math.sin(K*C)RightShoulder.DesiredAngle=desiredAngle+s LeftShoulder.DesiredAngle=desiredAngle-s RightHip.DesiredAngle=-desiredAngle LeftHip.DesiredAngle=-desiredAngle local N=getTool()if N then animStringValueObject=getToolAnim(N)if animStringValueObject then toolAnim=animStringValueObject.Value animStringValueObject.Parent=nil toolAnimTime=K+.3 end if K>toolAnimTime then toolAnimTime=0 toolAnim="\078\111\110\101"end animateTool()else toolAnim="\078\111\110\101"toolAnimTime=0 end end
-- same as jump for now

function moveFreeFall()
	RightShoulder.MaxVelocity = 0.5
	LeftShoulder.MaxVelocity = 0.5
	RightShoulder.DesiredAngle = 3.14
	LeftShoulder.DesiredAngle = -3.14
	RightHip.DesiredAngle = 0
	LeftHip.DesiredAngle = 0
end

function moveSit()
	RightShoulder.MaxVelocity = 0.15
	LeftShoulder.MaxVelocity = 0.15
	RightShoulder.DesiredAngle = 3.14 / 2
	LeftShoulder.DesiredAngle = -3.14 / 2
	RightHip.DesiredAngle = 3.14 / 2
	LeftHip.DesiredAngle = -3.14 / 2
end

function getTool()
	for _, kid in ipairs(Figure:GetChildren()) do
		if kid.className == "Tool" then
			return kid
		end
	end
	return nil
end

function getToolAnim(tool)
	for _, c in ipairs(tool:GetChildren()) do
		if c.Name == "toolanim" and c.className == "StringValue" then
			return c
		end
	end
	return nil
end

function animateTool()
	if toolAnim == "None" then
		RightShoulderdDesiredAngle = 1.57
		return
	end

	if toolAnim == "Slash" then
		RightShoulder.MaxVelocity = 0.5
		RightShoulder.DesiredAngle = 0
		return
	end

	if toolAnim == "Lunge" then
		RightShoulder.MaxVelocity = 0.5
		LeftShoulder.MaxVelocity = 0.5
		RightHip.MaxVelocity = 0.5
		LeftHip.MaxVelocity = 0.5
		RightShoulder.DesiredAngle = 1.57
		LeftShoulder.DesiredAngle = 0
		RightHip.DesiredAngle = 1.57
		LeftHip.DesiredAngle = 1.0
		return
	end
end

function move(time)
	local amplitude
	local frequency

	if pose == "Jumping" then
		moveJump()
		return
	end

	if pose == "FreeFall" then
		moveFreeFall()
		return
	end

	if pose == "Seated" then
		moveSit()
		return
	end

	local climbFudge = 0

	if pose == "Running" then
		RightShoulder.MaxVelocity = 0.15
		LeftShoulder.MaxVelocity = 0.15
		amplitude = 1
		frequency = 9
	elseif pose == "Climbing" then
		RightShoulder.MaxVelocity = 0.5
		LeftShoulder.MaxVelocity = 0.5
		amplitude = 1
		frequency = 9
		climbFudge = 3.14
	else
		amplitude = 0.1
		frequency = 1
	end

	desiredAngle = amplitude * math.sin(time * frequency)

	RightShoulder.DesiredAngle = desiredAngle + climbFudge
	LeftShoulder.DesiredAngle = desiredAngle - climbFudge
	RightHip.DesiredAngle = -desiredAngle
	LeftHip.DesiredAngle = -desiredAngle

	local tool = getTool()

	if tool then
		animStringValueObject = getToolAnim(tool)

		if animStringValueObject then
			toolAnim = animStringValueObject.Value
			-- message recieved, delete StringValue
			animStringValueObject.Parent = nil
			toolAnimTime = time + 0.3
		end

		if time > toolAnimTime then
			toolAnimTime = 0
			toolAnim = "None"
		end

		animateTool()
	else
		toolAnim = "None"
		toolAnimTime = 0
	end
end
