function moveFreeFall()RightShoulder.MaxVelocity=.4 LeftShoulder.MaxVelocity=.4 RightShoulder:SetDesiredAngle(3.14)LeftShoulder:SetDesiredAngle(-3.14)RightHip:SetDesiredAngle(0)LeftHip:SetDesiredAngle(0)wait(.8)end function moveSit()RightShoulder.MaxVelocity=.15 LeftShoulder.MaxVelocity=.15 RightShoulder:SetDesiredAngle(1.57)LeftShoulder:SetDesiredAngle(-1.57)RightHip:SetDesiredAngle(1.57)LeftHip:SetDesiredAngle(-1.57)end function getTool()for z,j in ipairs(Figure:GetChildren())do if j.className=="\084\111\111\108"then return j end end return nil end function getToolAnim(z)for z,j in ipairs(z:GetChildren())do if j.Name=="\116\111\111\108\097\110\105\109"and j.className=="\083\116\114\105\110\103\086\097\108\117\101"then return j end end return nil end function animateTool()if toolAnim=="\078\111\110\101"then RightShoulder:SetDesiredAngle(1.57)return end if toolAnim=="\083\108\097\115\104"then RightShoulder.MaxVelocity=.5 RightShoulder:SetDesiredAngle(0)return end if toolAnim=="\076\117\110\103\101"then RightShoulder.MaxVelocity=.5 LeftShoulder.MaxVelocity=.5 RightHip.MaxVelocity=.5 LeftHip.MaxVelocity=.5 RightShoulder:SetDesiredAngle(1.57)LeftShoulder:SetDesiredAngle(1.0)RightHip:SetDesiredAngle(1.57)LeftHip:SetDesiredAngle(1.0)return end end function move(z)local j local I 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 Z=0 if pose=="\082\117\110\110\105\110\103"then RightShoulder.MaxVelocity=.1 LeftShoulder.MaxVelocity=.1 j=1 I=9 elseif pose=="\067\108\105\109\098\105\110\103"then RightShoulder.MaxVelocity=.3 LeftShoulder.MaxVelocity=.3 j=0 I=0 Z=-3.14 else j=.1 I=1 end desiredAngle=j*math.sin(z*I)RightShoulder:SetDesiredAngle(desiredAngle+Z)LeftShoulder:SetDesiredAngle(desiredAngle-Z)RightHip:SetDesiredAngle(-desiredAngle)LeftHip:SetDesiredAngle(-desiredAngle)local O=getTool()if O then animStringValueObject=getToolAnim(O)if animStringValueObject then toolAnim=animStringValueObject.Value animStringValueObject.Parent=nil toolAnimTime=z+.3 end if z>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.4
	LeftShoulder.MaxVelocity = 0.4
	RightShoulder:SetDesiredAngle(3.14)
	LeftShoulder:SetDesiredAngle(-3.14)
	RightHip:SetDesiredAngle(0)
	LeftHip:SetDesiredAngle(0)
	wait(0.8)
end

function moveSit()
	RightShoulder.MaxVelocity = 0.15
	LeftShoulder.MaxVelocity = 0.15
	RightShoulder:SetDesiredAngle(3.14 / 2)
	LeftShoulder:SetDesiredAngle(-3.14 / 2)
	RightHip:SetDesiredAngle(3.14 / 2)
	LeftHip:SetDesiredAngle(-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
		RightShoulder:SetDesiredAngle(1.57)
		return
	end

	if toolAnim == "Slash" then
		RightShoulder.MaxVelocity = 0.5
		RightShoulder:SetDesiredAngle(0)
		return
	end

	if toolAnim == "Lunge" then
		RightShoulder.MaxVelocity = 0.5
		LeftShoulder.MaxVelocity = 0.5
		RightHip.MaxVelocity = 0.5
		LeftHip.MaxVelocity = 0.5
		RightShoulder:SetDesiredAngle(1.57)
		LeftShoulder:SetDesiredAngle(1.0)
		RightHip:SetDesiredAngle(1.57)
		LeftHip:SetDesiredAngle(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.1
		LeftShoulder.MaxVelocity = 0.1
		amplitude = 1
		frequency = 9
	elseif pose == "Climbing" then
		RightShoulder.MaxVelocity = 0.3
		LeftShoulder.MaxVelocity = 0.3
		amplitude = 0
		frequency = 0
		climbFudge = -3.14
	else
		amplitude = 0.1
		frequency = 1
	end

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

	RightShoulder:SetDesiredAngle(desiredAngle + climbFudge)
	LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
	RightHip:SetDesiredAngle(-desiredAngle)
	LeftHip:SetDesiredAngle(-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
