SHOW:
|
|
- or go back to the newest paste.
1 | --smoke cigarete tiny | |
2 | ||
3 | --this script is druggy | |
4 | ||
5 | --lykaspars4 replace to your name! | |
6 | ||
7 | ----------------------------------------------------------- | |
8 | ||
9 | - | print 'lykaspars4 using smoked w33d by tiny cigarrete' |
9 | + | print 'gabriel48124 using smoked w33d by tiny cigarrete' |
10 | print 'script sound are playing in tiny cigarrete script' | |
11 | ||
12 | local s = Instance.new("Sound") | |
13 | ||
14 | s.Name = "Sound" | |
15 | s.SoundId = "http://www.roblox.com/asset/?id=168421238" | |
16 | s.Volume = 1 | |
17 | s.Looped = true | |
18 | s.archivable = false | |
19 | ||
20 | s.Parent = game.Workspace | |
21 | ||
22 | wait(3) | |
23 | ||
24 | s:play() | |
25 | ||
26 | function waitForChild(parent, childName) | |
27 | local child = parent:findFirstChild(childName) | |
28 | if child then return child end | |
29 | while true do | |
30 | child = parent.ChildAdded:wait() | |
31 | if child.Name==childName then return child end | |
32 | end | |
33 | end | |
34 | ||
35 | local Figure = script.Parent | |
36 | local Torso = waitForChild(Figure, "Torso") | |
37 | local RightShoulder = waitForChild(Torso, "Right Shoulder") | |
38 | local LeftShoulder = waitForChild(Torso, "Left Shoulder") | |
39 | local RightHip = waitForChild(Torso, "Right Hip") | |
40 | local LeftHip = waitForChild(Torso, "Left Hip") | |
41 | local Neck = waitForChild(Torso, "Neck") | |
42 | local Humanoid = waitForChild(Figure, "Humanoid") | |
43 | local pose = "Standing" | |
44 | ||
45 | local currentAnim = "" | |
46 | local currentAnimTrack = nil | |
47 | local currentAnimKeyframeHandler = nil | |
48 | local currentAnimSpeed = 1.0 | |
49 | local oldAnimTrack = nil | |
50 | local animTable = {} | |
51 | local animNames = { | |
52 | idle = { | |
53 | { id = "0c59a07336e872c359cf557a256b8492", weight = 9 }, | |
54 | { id = "0c59a07336e872c359cf557a256b8492", weight = 1 } | |
55 | }, | |
56 | walk = { | |
57 | { id = "0c59a07336e872c359cf557a256b8492", weight = 10 } | |
58 | }, | |
59 | run = { | |
60 | { id = "run.xml", weight = 10 } | |
61 | }, | |
62 | jump = { | |
63 | { id = "0c59a07336e872c359cf557a256b8492", weight = 10 } | |
64 | }, | |
65 | fall = { | |
66 | { id = "rbxassetid://125750759", weight = 10 } | |
67 | }, | |
68 | climb = { | |
69 | { id = "rbxassetid://125750800", weight = 10 } | |
70 | }, | |
71 | toolnone = { | |
72 | { id = "rbxassetid://125750867", weight = 10 } | |
73 | }, | |
74 | toolslash = { | |
75 | { id = "rbxassetid://129967390", weight = 10 } | |
76 | -- { id = "slash.xml", weight = 10 } | |
77 | }, | |
78 | toollunge = { | |
79 | { id = "rbxassetid://129967478", weight = 10 } | |
80 | }, | |
81 | wave = { | |
82 | { id = "rbxassetid://128777973", weight = 10 } | |
83 | }, | |
84 | point = { | |
85 | { id = "rbxassetid://128853357", weight = 10 } | |
86 | }, | |
87 | dance = { | |
88 | { id = "rbxassetid://130018893", weight = 10 }, | |
89 | { id = "rbxassetid://132546839", weight = 10 }, | |
90 | { id = "rbxassetid://132546884", weight = 10 } | |
91 | }, | |
92 | laugh = { | |
93 | { id = "rbxassetid://129423131", weight = 10 } | |
94 | }, | |
95 | cheer = { | |
96 | { id = "rbxassetid://=129423030", weight = 10 } | |
97 | }, | |
98 | } | |
99 | ||
100 | -- Existance in this list signifies that it is an emote, the value indicates if it is a looping emote | |
101 | local emoteNames = { wave = false, point = false, dance = true, laugh = false, cheer = false} | |
102 | ||
103 | math.randomseed(tick()) | |
104 | ||
105 | -- Setup animation objects | |
106 | for name, fileList in pairs(animNames) do | |
107 | animTable[name] = {} | |
108 | animTable[name].count = 0 | |
109 | animTable[name].totalWeight = 0 | |
110 | ||
111 | -- check for config values | |
112 | local config = script:FindFirstChild(name) | |
113 | if (config ~= nil) then | |
114 | -- print("Loading anims " .. name) | |
115 | local idx = 1 | |
116 | for _, childPart in pairs(config:GetChildren()) do | |
117 | animTable[name][idx] = {} | |
118 | animTable[name][idx].anim = childPart | |
119 | local weightObject = childPart:FindFirstChild("Weight") | |
120 | if (weightObject == nil) then | |
121 | animTable[name][idx].weight = 1 | |
122 | else | |
123 | animTable[name][idx].weight = weightObject.Value | |
124 | end | |
125 | animTable[name].count = animTable[name].count + 1 | |
126 | animTable[name].totalWeight = animTable[name].totalWeight + animTable[name][idx].weight | |
127 | -- print(name .. " [" .. idx .. "] " .. animTable[name][idx].anim.AnimationId .. " (" .. animTable[name][idx].weight .. ")") | |
128 | idx = idx + 1 | |
129 | end | |
130 | end | |
131 | ||
132 | -- fallback to defaults | |
133 | if (animTable[name].count <= 0) then | |
134 | for idx, anim in pairs(fileList) do | |
135 | animTable[name][idx] = {} | |
136 | animTable[name][idx].anim = Instance.new("Animation") | |
137 | animTable[name][idx].anim.Name = name | |
138 | animTable[name][idx].anim.AnimationId = anim.id | |
139 | animTable[name][idx].weight = anim.weight | |
140 | animTable[name].count = animTable[name].count + 1 | |
141 | animTable[name].totalWeight = animTable[name].totalWeight + anim.weight | |
142 | -- print(name .. " [" .. idx .. "] " .. anim.id .. " (" .. anim.weight .. ")") | |
143 | end | |
144 | end | |
145 | end | |
146 | ||
147 | -- ANIMATION | |
148 | ||
149 | -- declarations | |
150 | local toolAnim = "None" | |
151 | local toolAnimTime = 0 | |
152 | ||
153 | local jumpAnimTime = 0 | |
154 | local jumpAnimDuration = 0.175 | |
155 | ||
156 | local toolTransitionTime = 0.1 | |
157 | local fallTransitionTime = 0.2 | |
158 | local jumpMaxLimbVelocity = 0.75 | |
159 | ||
160 | -- functions | |
161 | ||
162 | function stopAllAnimations() | |
163 | local oldAnim = currentAnim | |
164 | ||
165 | -- return to idle if finishing an emote | |
166 | if (emoteNames[oldAnim] ~= nil and emoteNames[oldAnim] == false) then | |
167 | oldAnim = "idle" | |
168 | end | |
169 | ||
170 | currentAnim = "" | |
171 | if (currentAnimKeyframeHandler ~= nil) then | |
172 | currentAnimKeyframeHandler:disconnect() | |
173 | end | |
174 | ||
175 | if (oldAnimTrack ~= nil) then | |
176 | oldAnimTrack:Stop() | |
177 | oldAnimTrack:Destroy() | |
178 | oldAnimTrack = nil | |
179 | end | |
180 | if (currentAnimTrack ~= nil) then | |
181 | currentAnimTrack:Stop() | |
182 | currentAnimTrack:Destroy() | |
183 | currentAnimTrack = nil | |
184 | end | |
185 | return oldAnim | |
186 | end | |
187 | ||
188 | function setAnimationSpeed(speed) | |
189 | if speed ~= currentAnimSpeed then | |
190 | currentAnimSpeed = speed | |
191 | currentAnimTrack:AdjustSpeed(currentAnimSpeed) | |
192 | end | |
193 | end | |
194 | ||
195 | function keyFrameReachedFunc(frameName) | |
196 | if (frameName == "End") then | |
197 | -- print("Keyframe : ".. frameName) | |
198 | local repeatAnim = stopAllAnimations() | |
199 | local animSpeed = currentAnimSpeed | |
200 | playAnimation(repeatAnim, 0.0, Humanoid) | |
201 | setAnimationSpeed(animSpeed) | |
202 | end | |
203 | end | |
204 | ||
205 | -- Preload animations | |
206 | function playAnimation(animName, transitionTime, humanoid) | |
207 | if (animName ~= currentAnim) then | |
208 | ||
209 | if (oldAnimTrack ~= nil) then | |
210 | oldAnimTrack:Stop() | |
211 | oldAnimTrack:Destroy() | |
212 | end | |
213 | ||
214 | currentAnimSpeed = 1.0 | |
215 | local roll = math.random(1, animTable[animName].totalWeight) | |
216 | local origRoll = roll | |
217 | local idx = 1 | |
218 | while (roll > animTable[animName][idx].weight) do | |
219 | roll = roll - animTable[animName][idx].weight | |
220 | idx = idx + 1 | |
221 | end | |
222 | -- print(animName .. " " .. idx .. " [" .. origRoll .. "]") | |
223 | local anim = animTable[animName][idx].anim | |
224 | ||
225 | -- load it to the humanoid; get AnimationTrack | |
226 | oldAnimTrack = currentAnimTrack | |
227 | currentAnimTrack = humanoid:LoadAnimation(anim) | |
228 | ||
229 | -- play the animation | |
230 | currentAnimTrack:Play(transitionTime) | |
231 | currentAnim = animName | |
232 | ||
233 | -- set up keyframe name triggers | |
234 | if (currentAnimKeyframeHandler ~= nil) then | |
235 | currentAnimKeyframeHandler:disconnect() | |
236 | end | |
237 | currentAnimKeyframeHandler = currentAnimTrack.KeyframeReached:connect(keyFrameReachedFunc) | |
238 | end | |
239 | end | |
240 | ||
241 | ------------------------------------------------------------------------------------------- | |
242 | ------------------------------------------------------------------------------------------- | |
243 | ||
244 | local toolAnimName = "" | |
245 | local toolOldAnimTrack = nil | |
246 | local toolAnimTrack = nil | |
247 | local currentToolAnimKeyframeHandler = nil | |
248 | ||
249 | function toolKeyFrameReachedFunc(frameName) | |
250 | if (frameName == "End") then | |
251 | -- print("Keyframe : ".. frameName) | |
252 | local repeatAnim = stopToolAnimations() | |
253 | playToolAnimation(repeatAnim, 0.0, Humanoid) | |
254 | end | |
255 | end | |
256 | ||
257 | ||
258 | function playToolAnimation(animName, transitionTime, humanoid) | |
259 | if (animName ~= toolAnimName) then | |
260 | ||
261 | if (toolAnimTrack ~= nil) then | |
262 | toolAnimTrack:Stop() | |
263 | toolAnimTrack:Destroy() | |
264 | transitionTime = 0 | |
265 | end | |
266 | ||
267 | local roll = math.random(1, animTable[animName].totalWeight) | |
268 | local origRoll = roll | |
269 | local idx = 1 | |
270 | while (roll > animTable[animName][idx].weight) do | |
271 | roll = roll - animTable[animName][idx].weight | |
272 | idx = idx + 1 | |
273 | end | |
274 | -- print(animName .. " * " .. idx .. " [" .. origRoll .. "]") | |
275 | local anim = animTable[animName][idx].anim | |
276 | ||
277 | -- load it to the humanoid; get AnimationTrack | |
278 | toolOldAnimTrack = toolAnimTrack | |
279 | toolAnimTrack = humanoid:LoadAnimation(anim) | |
280 | ||
281 | -- play the animation | |
282 | toolAnimTrack:Play(transitionTime) | |
283 | toolAnimName = animName | |
284 | ||
285 | currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc) | |
286 | end | |
287 | end | |
288 | ||
289 | function stopToolAnimations() | |
290 | local oldAnim = toolAnimName | |
291 | ||
292 | if (currentToolAnimKeyframeHandler ~= nil) then | |
293 | currentToolAnimKeyframeHandler:disconnect() | |
294 | end | |
295 | ||
296 | toolAnimName = "" | |
297 | if (toolAnimTrack ~= nil) then | |
298 | toolAnimTrack:Stop() | |
299 | toolAnimTrack:Destroy() | |
300 | toolAnimTrack = nil | |
301 | end | |
302 | ||
303 | ||
304 | return oldAnim | |
305 | end | |
306 | ||
307 | ------------------------------------------------------------------------------------------- | |
308 | ------------------------------------------------------------------------------------------- | |
309 | ||
310 | ||
311 | function onRunning(speed) | |
312 | if speed>0 then | |
313 | playAnimation("walk", 0.1, Humanoid) | |
314 | pose = "Running" | |
315 | else | |
316 | playAnimation("idle", 0.1, Humanoid) | |
317 | pose = "Standing" | |
318 | end | |
319 | end | |
320 | ||
321 | function onDied() | |
322 | pose = "Dead" | |
323 | end | |
324 | ||
325 | function onJumping() | |
326 | playAnimation("jump", 0.1, Humanoid) | |
327 | jumpAnimTime = jumpAnimDuration | |
328 | pose = "Jumping" | |
329 | end | |
330 | ||
331 | function onClimbing(speed) | |
332 | playAnimation("climb", 0.1, Humanoid) | |
333 | setAnimationSpeed(speed / 12.0) | |
334 | pose = "Climbing" | |
335 | end | |
336 | ||
337 | function onGettingUp() | |
338 | pose = "GettingUp" | |
339 | end | |
340 | ||
341 | function onFreeFall() | |
342 | if (jumpAnimTime <= 0) then | |
343 | playAnimation("fall", fallTransitionTime, Humanoid) | |
344 | end | |
345 | pose = "FreeFall" | |
346 | end | |
347 | ||
348 | function onFallingDown() | |
349 | pose = "FallingDown" | |
350 | end | |
351 | ||
352 | function onSeated() | |
353 | pose = "Seated" | |
354 | end | |
355 | ||
356 | function onPlatformStanding() | |
357 | pose = "PlatformStanding" | |
358 | end | |
359 | ||
360 | function onSwimming(speed) | |
361 | if speed>0 then | |
362 | pose = "Running" | |
363 | else | |
364 | pose = "Standing" | |
365 | end | |
366 | end | |
367 | ||
368 | function getTool() | |
369 | for _, kid in ipairs(Figure:GetChildren()) do | |
370 | if kid.className == "Tool" then return kid end | |
371 | end | |
372 | return nil | |
373 | end | |
374 | ||
375 | function getToolAnim(tool) | |
376 | for _, c in ipairs(tool:GetChildren()) do | |
377 | if c.Name == "toolanim" and c.className == "StringValue" then | |
378 | return c | |
379 | end | |
380 | end | |
381 | return nil | |
382 | end | |
383 | ||
384 | function animateTool() | |
385 | ||
386 | if (toolAnim == "None") then | |
387 | playToolAnimation("toolnone", toolTransitionTime, Humanoid) | |
388 | return | |
389 | end | |
390 | ||
391 | if (toolAnim == "Slash") then | |
392 | playToolAnimation("toolslash", 0, Humanoid) | |
393 | return | |
394 | end | |
395 | ||
396 | if (toolAnim == "Lunge") then | |
397 | playToolAnimation("toollunge", 0, Humanoid) | |
398 | return | |
399 | end | |
400 | end | |
401 | ||
402 | function moveSit() | |
403 | RightShoulder.MaxVelocity = 0.15 | |
404 | LeftShoulder.MaxVelocity = 0.15 | |
405 | RightShoulder:SetDesiredAngle(3.14 /2) | |
406 | LeftShoulder:SetDesiredAngle(-3.14 /2) | |
407 | RightHip:SetDesiredAngle(3.14 /2) | |
408 | LeftHip:SetDesiredAngle(-3.14 /2) | |
409 | end | |
410 | ||
411 | local lastTick = 0 | |
412 | ||
413 | function move(time) | |
414 | local amplitude = 1 | |
415 | local frequency = 1 | |
416 | local deltaTime = time - lastTick | |
417 | lastTick = time | |
418 | ||
419 | local climbFudge = 0 | |
420 | local setAngles = false | |
421 | ||
422 | if (jumpAnimTime > 0) then | |
423 | jumpAnimTime = jumpAnimTime - deltaTime | |
424 | end | |
425 | ||
426 | if (pose == "FreeFall" and jumpAnimTime <= 0) then | |
427 | playAnimation("fall", fallTransitionTime, Humanoid) | |
428 | elseif (pose == "Seated") then | |
429 | stopAllAnimations() | |
430 | moveSit() | |
431 | return | |
432 | elseif (pose == "Running") then | |
433 | playAnimation("walk", 0.1, Humanoid) | |
434 | elseif (pose == "Dead" or pose == "GettingUp" or pose == "FallingDown" or pose == "Seated" or pose == "PlatformStanding") then | |
435 | -- print("Wha " .. pose) | |
436 | amplitude = 0.1 | |
437 | frequency = 1 | |
438 | setAngles = true | |
439 | end | |
440 | ||
441 | if (setAngles) then | |
442 | desiredAngle = amplitude * math.sin(time * frequency) | |
443 | ||
444 | RightShoulder:SetDesiredAngle(desiredAngle + climbFudge) | |
445 | LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge) | |
446 | RightHip:SetDesiredAngle(-desiredAngle) | |
447 | LeftHip:SetDesiredAngle(-desiredAngle) | |
448 | end | |
449 | ||
450 | -- Tool Animation handling | |
451 | local tool = getTool() | |
452 | if tool then | |
453 | ||
454 | animStringValueObject = getToolAnim(tool) | |
455 | ||
456 | if animStringValueObject then | |
457 | toolAnim = animStringValueObject.Value | |
458 | -- message recieved, delete StringValue | |
459 | animStringValueObject.Parent = nil | |
460 | toolAnimTime = time + .3 | |
461 | end | |
462 | ||
463 | if time > toolAnimTime then | |
464 | toolAnimTime = 0 | |
465 | toolAnim = "None" | |
466 | end | |
467 | ||
468 | animateTool() | |
469 | else | |
470 | stopToolAnimations() | |
471 | toolAnim = "None" | |
472 | toolAnimTime = 0 | |
473 | end | |
474 | end | |
475 | ||
476 | -- connect events | |
477 | Humanoid.Died:connect(onDied) | |
478 | Humanoid.Running:connect(onRunning) | |
479 | Humanoid.Jumping:connect(onJumping) | |
480 | Humanoid.Climbing:connect(onClimbing) | |
481 | Humanoid.GettingUp:connect(onGettingUp) | |
482 | Humanoid.FreeFalling:connect(onFreeFall) | |
483 | Humanoid.FallingDown:connect(onFallingDown) | |
484 | Humanoid.Seated:connect(onSeated) | |
485 | Humanoid.PlatformStanding:connect(onPlatformStanding) | |
486 | Humanoid.Swimming:connect(onSwimming) | |
487 | ||
488 | -- setup emote chat hook | |
489 | Game.Players.LocalPlayer.Chatted:connect(function(msg) | |
490 | local emote = "" | |
491 | if (string.sub(msg, 1, 3) == "/e ") then | |
492 | emote = string.sub(msg, 4) | |
493 | elseif (string.sub(msg, 1, 7) == "/emote ") then | |
494 | emote = string.sub(msg, 8) | |
495 | end | |
496 | ||
497 | if (pose == "Standing" and emoteNames[emote] ~= nil) then | |
498 | playAnimation(emote, 0.1, Humanoid) | |
499 | end | |
500 | -- print("===> " .. string.sub(msg, 1, 3) .. "(" .. emote .. ")") | |
501 | end) | |
502 | ||
503 | ||
504 | -- main program | |
505 | ||
506 | local runService = game:service("RunService"); | |
507 | ||
508 | -- initialize to idle | |
509 | playAnimation("idle", 0.1, Humanoid) | |
510 | pose = "Standing" | |
511 | ||
512 | while Figure.Parent~=nil do | |
513 | local _, time = wait(0.1) | |
514 | move(time) | |
515 | end |