Novetus_src/clients/2007M-Shaders/content/fonts/humanoidAnimate.rbxm

13 lines
10 KiB
Plaintext

<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
<External>null</External>
<External>nil</External>
<Item class="Script" referent="RBX0">
<Properties>
<bool name="Disabled">false</bool>
<Content name="LinkedSource"><null></null></Content>
<string name="Name">Animate</string>
<string name="Source">-- Now with exciting TeamColors HACK!&#13;&#10;&#13;&#10;function waitForChild(parent, childName)&#13;&#10;&#9;while true do&#13;&#10;&#9;&#9;local child = parent:findFirstChild(childName)&#13;&#10;&#9;&#9;if child then&#13;&#10;&#9;&#9;&#9;return child&#13;&#10;&#9;&#9;end&#13;&#10;&#9;&#9;parent.ChildAdded:wait()&#13;&#10;&#9;end&#13;&#10;end&#13;&#10;&#13;&#10;&#13;&#10;----------------------------- TEAM COLORS&#13;&#10;&#13;&#10;&#13;&#10;function onTeamChanged(player)&#13;&#10;&#13;&#10;&#9;wait(1)&#13;&#10;&#13;&#10;&#9;local char = player.Character&#13;&#10;&#9;if char == nil then return end&#13;&#10;&#13;&#10;&#9;if (player.Neutral == true) then &#13;&#10;&#9;&#9;-- Replacing the current BodyColor object will force a reset&#13;&#10;&#9;&#9;local old = char:findFirstChild(&quot;Body Colors&quot;)&#13;&#10;&#9;&#9;if (old == nil) then return end&#13;&#10;&#9;&#9;old:clone().Parent = char&#13;&#10;&#9;&#9;old.Parent = nil&#13;&#10;&#9;else&#13;&#10;&#9;&#9;local head = char:findFirstChild(&quot;Head&quot;)&#13;&#10;&#9;&#9;local torso = char:findFirstChild(&quot;Torso&quot;) &#13;&#10;&#9;&#9;local left_arm = char:findFirstChild(&quot;Left Arm&quot;) &#13;&#10;&#9;&#9;local right_arm = char:findFirstChild(&quot;Right Arm&quot;) &#13;&#10;&#9;&#9;local left_leg = char:findFirstChild(&quot;Left Leg&quot;) &#13;&#10;&#9;&#9;local right_leg = char:findFirstChild(&quot;Right Leg&quot;) &#13;&#10;&#13;&#10;&#9;&#9;if head ~= nil then head.BrickColor = BrickColor.new(24) end&#13;&#10;&#9;&#9;if torso ~= nil then torso.BrickColor = player.TeamColor end&#13;&#10;&#9;&#9;if left_arm ~= nil then left_arm.BrickColor = BrickColor.new(26) end&#13;&#10;&#9;&#9;if right_arm ~= nil then right_arm.BrickColor = BrickColor.new(26) end&#13;&#10;&#9;&#9;if left_leg ~= nil then left_leg.BrickColor = BrickColor.new(26) end&#13;&#10;&#9;&#9;if right_leg ~= nil then right_leg.BrickColor = BrickColor.new(26) end&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#9;&#13;&#10;&#13;&#10;end&#13;&#10;&#13;&#10;function onPlayerPropChanged(property, player)&#13;&#10;&#9;if property == &quot;Character&quot; then&#13;&#10;&#9;&#9;onTeamChanged(player)&#13;&#10;&#9;end&#13;&#10;&#9;if property== &quot;TeamColor&quot; or property == &quot;Neutral&quot; then&#13;&#10;&#9;&#9;onTeamChanged(player)&#13;&#10;&#9;end&#13;&#10;end&#13;&#10;&#13;&#10;&#13;&#10;local cPlayer = game.Players:GetPlayerFromCharacter(script.Parent)&#13;&#10;cPlayer.Changed:connect(function(property) onPlayerPropChanged(property, cPlayer) end )&#13;&#10;onTeamChanged(cPlayer)&#13;&#10;&#13;&#10;&#13;&#10;----------------------------- ANIMATION&#13;&#10;&#13;&#10;-- declarations&#13;&#10;&#13;&#10;local Figure = script.Parent&#13;&#10;local Torso = waitForChild(Figure, &quot;Torso&quot;)&#13;&#10;local RightShoulder = waitForChild(Torso, &quot;Right Shoulder&quot;)&#13;&#10;local LeftShoulder = waitForChild(Torso, &quot;Left Shoulder&quot;)&#13;&#10;local RightHip = waitForChild(Torso, &quot;Right Hip&quot;)&#13;&#10;local LeftHip = waitForChild(Torso, &quot;Left Hip&quot;)&#13;&#10;local Neck = waitForChild(Torso, &quot;Neck&quot;)&#13;&#10;local Humanoid = waitForChild(Figure, &quot;Humanoid&quot;)&#13;&#10;local pose = &quot;Standing&quot;&#13;&#10;&#13;&#10;local toolAnim = &quot;None&quot;&#13;&#10;local toolAnimTime = 0&#13;&#10;&#13;&#10;local isSeated = false&#13;&#10;&#13;&#10;-- functions&#13;&#10;&#13;&#10;function onRunning(speed)&#13;&#10;&#9;if isSeated then return end&#13;&#10;&#13;&#10;&#9;if speed&gt;0 then&#13;&#10;&#9;&#9;pose = &quot;Running&quot;&#13;&#10;&#9;else&#13;&#10;&#9;&#9;pose = &quot;Standing&quot;&#13;&#10;&#9;end&#13;&#10;end&#13;&#10;&#13;&#10;function onDied()&#13;&#10;&#9;pose = &quot;Dead&quot;&#13;&#10;end&#13;&#10;&#13;&#10;function onJumping()&#13;&#10;&#9;isSeated = false&#13;&#10;&#9;pose = &quot;Jumping&quot;&#13;&#10;end&#13;&#10;&#13;&#10;function onClimbing()&#13;&#10;&#9;pose = &quot;Climbing&quot;&#13;&#10;end&#13;&#10;&#13;&#10;function onGettingUp()&#13;&#10;&#9;pose = &quot;GettingUp&quot;&#13;&#10;end&#13;&#10;&#13;&#10;function onFreeFall()&#13;&#10;&#9;pose = &quot;FreeFall&quot;&#13;&#10;end&#13;&#10;&#13;&#10;function onFallingDown()&#13;&#10;&#9;pose = &quot;FallingDown&quot;&#13;&#10;end&#13;&#10;&#13;&#10;function onSeated()&#13;&#10;&#9;isSeated = true&#13;&#10;&#9;pose = &quot;Seated&quot;&#13;&#10;end&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;function moveJump()&#13;&#10;&#9;RightShoulder.MaxVelocity = 0.5&#13;&#10;&#9;LeftShoulder.MaxVelocity = 0.5&#13;&#10;&#9;RightShoulder.DesiredAngle = 3.14&#13;&#10;&#9;LeftShoulder.DesiredAngle = -3.14&#13;&#10;&#9;RightHip.DesiredAngle = 0&#13;&#10;&#9;LeftHip.DesiredAngle = 0&#13;&#10;end&#13;&#10;&#13;&#10;function moveFreeFall()&#13;&#10;&#9;RightShoulder.MaxVelocity = 0.5&#13;&#10;&#9;LeftShoulder.MaxVelocity = 0.5&#13;&#10;&#9;RightShoulder.DesiredAngle = 1&#13;&#10;&#9;LeftShoulder.DesiredAngle = -1&#13;&#10;&#9;RightHip.DesiredAngle = 0&#13;&#10;&#9;LeftHip.DesiredAngle = 0&#13;&#10;end&#13;&#10;&#13;&#10;&#13;&#10;function moveClimb()&#13;&#10;&#9;RightShoulder.MaxVelocity = 0.5&#13;&#10;&#9;LeftShoulder.MaxVelocity = 0.5&#13;&#10;&#9;RightShoulder.DesiredAngle = -3.14&#13;&#10;&#9;LeftShoulder.DesiredAngle = 3.14&#13;&#10;&#9;RightHip.DesiredAngle = 0&#13;&#10;&#9;LeftHip.DesiredAngle = 0&#13;&#10;end&#13;&#10;&#13;&#10;function moveSit()&#13;&#10;&#9;RightShoulder.MaxVelocity = 0.15&#13;&#10;&#9;LeftShoulder.MaxVelocity = 0.15&#13;&#10;&#9;RightShoulder.DesiredAngle = 3.14 /2&#13;&#10;&#9;LeftShoulder.DesiredAngle = -3.14 /2&#13;&#10;&#9;RightHip.DesiredAngle = 3.14 /2&#13;&#10;&#9;LeftHip.DesiredAngle = -3.14 /2&#13;&#10;end&#13;&#10;&#13;&#10;function getTool()&#13;&#10;&#9;&#13;&#10;&#9;kidTable = Figure:children()&#13;&#10;&#9;if (kidTable ~= nil) then&#13;&#10;&#9;&#9;numKids = #kidTable&#13;&#10;&#9;&#9;for i=1,numKids do&#13;&#10;&#9;&#9;&#9;if (kidTable[i].className == &quot;Tool&quot;) then return kidTable[i] end&#13;&#10;&#9;&#9;end&#13;&#10;&#9;end&#13;&#10;&#9;&#13;&#10;&#9;return nil&#13;&#10;end&#13;&#10;&#13;&#10;function getToolAnim(tool)&#13;&#10;&#13;&#10;&#9;c = tool:children()&#13;&#10;&#9;for i=1,#c do&#13;&#10;&#9;&#9;if (c[i].Name == &quot;toolanim&quot; and c[i].className == &quot;StringValue&quot;) then&#13;&#10;&#9;&#9;&#9;return c[i]&#13;&#10;&#9;&#9;end&#13;&#10;&#9;end&#13;&#10;&#9;return nil&#13;&#10;end&#13;&#10;&#13;&#10;function animateTool()&#13;&#10;&#9;&#13;&#10;&#9;if (toolAnim == &quot;None&quot;) then&#13;&#10;&#9;&#9;RightShoulder.DesiredAngle = 1.57&#13;&#10;&#9;&#9;return&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#9;if (toolAnim == &quot;Slash&quot;) then&#13;&#10;&#9;&#9;RightShoulder.MaxVelocity = 0.5&#13;&#10;&#9;&#9;RightShoulder.DesiredAngle = 0&#13;&#10;&#9;&#9;return&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#9;if (toolAnim == &quot;Lunge&quot;) then&#13;&#10;&#9;&#9;RightShoulder.MaxVelocity = 0.5&#13;&#10;&#9;&#9;LeftShoulder.MaxVelocity = 0.5&#13;&#10;&#9;&#9;RightHip.MaxVelocity = 0.5&#13;&#10;&#9;&#9;LeftHip.MaxVelocity = 0.5&#13;&#10;&#9;&#9;RightShoulder.DesiredAngle = 1.57&#13;&#10;&#9;&#9;LeftShoulder.DesiredAngle = 1.0&#13;&#10;&#9;&#9;RightHip.DesiredAngle = 1.57&#13;&#10;&#9;&#9;LeftHip.DesiredAngle = 1.0&#13;&#10;&#9;&#9;return&#13;&#10;&#9;end&#13;&#10;end&#13;&#10;&#13;&#10;function move(time)&#13;&#10;&#9;local amplitude&#13;&#10;&#9;local frequency&#13;&#10;&#13;&#10;&#9;if (pose == &quot;Jumping&quot;) then&#13;&#10;&#9;&#9;moveJump()&#13;&#10;&#9;&#9;return&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#9;if (pose == &quot;FreeFall&quot;) then&#13;&#10;&#9;&#9;moveFreeFall()&#13;&#10;&#9;&#9;return&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#9;if (pose == &quot;Climbing&quot;) then&#13;&#10;&#9;&#9;moveClimb()&#13;&#10;&#9;&#9;return&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#9;if (pose == &quot;Seated&quot;) then&#13;&#10;&#9;&#9;moveSit()&#13;&#10;&#9;&#9;return&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#13;&#10;&#9;RightShoulder.MaxVelocity = 0.15&#13;&#10;&#9;LeftShoulder.MaxVelocity = 0.15&#13;&#10;&#9;if (pose == &quot;Running&quot;) then&#13;&#10;&#9;&#9;amplitude = 1&#13;&#10;&#9;&#9;frequency = 9&#13;&#10;&#9;else&#13;&#10;&#9;&#9;amplitude = 0.1&#13;&#10;&#9;&#9;frequency = 1&#13;&#10;&#9;end&#13;&#10;&#13;&#10;&#9;desiredAngle = amplitude * math.sin(time*frequency)&#13;&#10;&#13;&#10;&#9;RightShoulder.DesiredAngle = desiredAngle&#13;&#10;&#9;LeftShoulder.DesiredAngle = desiredAngle&#13;&#10;&#9;RightHip.DesiredAngle = -desiredAngle&#13;&#10;&#9;LeftHip.DesiredAngle = -desiredAngle&#13;&#10;&#13;&#10;&#13;&#10;&#9;local tool = getTool()&#13;&#10;&#13;&#10;&#9;if tool ~= nil then&#13;&#10;&#9;&#13;&#10;&#9;&#9;animStringValueObject = getToolAnim(tool)&#13;&#10;&#13;&#10;&#9;&#9;if animStringValueObject ~= nil then&#13;&#10;&#9;&#9;&#9;toolAnim = animStringValueObject.Value&#13;&#10;&#9;&#9;&#9;-- message recieved, delete StringValue&#13;&#10;&#9;&#9;&#9;animStringValueObject.Parent = nil&#13;&#10;&#9;&#9;&#9;toolAnimTime = time + .3&#13;&#10;&#9;&#9;end&#13;&#10;&#13;&#10;&#9;&#9;if time &gt; toolAnimTime then&#13;&#10;&#9;&#9;&#9;toolAnimTime = 0&#13;&#10;&#9;&#9;&#9;toolAnim = &quot;None&quot;&#13;&#10;&#9;&#9;end&#13;&#10;&#13;&#10;&#9;&#9;animateTool()&#13;&#10;&#13;&#10;&#9;&#9;&#13;&#10;&#9;else&#13;&#10;&#9;&#9;toolAnim = &quot;None&quot;&#13;&#10;&#9;&#9;toolAnimTime = 0&#13;&#10;&#9;end&#13;&#10;end&#13;&#10;&#13;&#10;&#13;&#10;-- connect events&#13;&#10;&#13;&#10;Humanoid.Died:connect(onDied)&#13;&#10;Humanoid.Running:connect(onRunning)&#13;&#10;Humanoid.Jumping:connect(onJumping)&#13;&#10;Humanoid.Climbing:connect(onClimbing)&#13;&#10;Humanoid.GettingUp:connect(onGettingUp)&#13;&#10;Humanoid.FreeFalling:connect(onFreeFall)&#13;&#10;Humanoid.FallingDown:connect(onFallingDown)&#13;&#10;Humanoid.Seated:connect(onSeated)&#13;&#10;&#13;&#10;-- main program&#13;&#10;&#13;&#10;local nextTime = 0&#13;&#10;local runService = game:service(&quot;RunService&quot;);&#13;&#10;&#13;&#10;while Figure.Parent~=nil do&#13;&#10;&#9;time = runService.Stepped:wait()&#13;&#10;&#9;if time &gt; nextTime then&#13;&#10;&#9;&#9;move(time)&#13;&#10;&#9;&#9;nextTime = time + 0.1&#13;&#10;&#9;end&#13;&#10;end&#13;&#10;</string>
<bool name="archivable">true</bool>
</Properties>
</Item>
</roblox>