Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Ending/EndingPose.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Ending Pose Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value1 : object.logoPos // Not set in this script, but set by the [Ending Control] that spawns this object
14
private alias object.value2 : object.tailFrame
15
16
// This object's states are pretty complex, a single object won't cycle through them all but instead each of the states appear under different scenarios
17
// I tried to note how each state plays into others, sorry if the explanation isn't any good though...
18
19
// These first two states are only encountered in the bad ending, when the player didn't get all emeralds
20
private alias 0 : ENDINGPOSE_INIT
21
private alias 1 : ENDINGPOSE_WAITING
22
23
// These next three states are when P1 poses, each pose frame is its own state
24
// These states are seen in both types of the ending
25
private alias 2 : ENDINGPOSE_POSE_START
26
private alias 3 : ENDINGPOSE_POSE_MID
27
private alias 4 : ENDINGPOSE_POSE_END
28
29
private alias 5 : ENDINGPOSE_HOLDEMERALDS
30
private alias 6 : ENDINGPOSE_EMERALDSSHINE
31
private alias 7 : ENDINGPOSE_LOOKUP
32
private alias 8 : ENDINGPOSE_EMERALDSFLASH_A // Fade-out
33
private alias 9 : ENDINGPOSE_EMERALDSFLASH_B // Fade-in
34
private alias 10 : ENDINGPOSE_LOOKAROUND
35
private alias 11 : ENDINGPOSE_LOOKLEFT
36
// (And then after looking left, P1 goes over to ENDINGPOSE_POSE_START)
37
38
// P2 Tails gets his own little states too, though they aren't as grand as P1's giant poses are
39
private alias 12 : ENDINGPOSE_P2_LOOKAROUND
40
private alias 13 : ENDINGPOSE_P2_LOOKLEFT
41
private alias 14 : ENDINGPOSE_P2_POSE_1
42
private alias 15 : ENDINGPOSE_P2_POSE_2
43
44
45
// Player Aliases
46
private alias object.state : player.state
47
private alias object.xpos : player.xpos
48
private alias object.ypos : player.ypos
49
private alias object.speed : player.speed
50
private alias object.frame : player.frame
51
private alias object.direction : player.direction
52
private alias object.up : player.up
53
private alias object.drawOrder : player.drawOrder
54
private alias object.controlMode : player.controlMode
55
56
// Reserved Object Slot Aliases
57
private alias 1 : SLOT_PLAYER2
58
59
60
// ========================
61
// Function Declarations
62
// ========================
63
64
reserve function EndingPose_UpdateLogo
65
66
67
// ========================
68
// Function Definitions
69
// ========================
70
71
private function EndingPose_UpdateLogo
72
if object.logoPos > 0
73
object.logoPos -= 16
74
end if
75
end function
76
77
78
// ========================
79
// Events
80
// ========================
81
82
event ObjectUpdate
83
switch object.state
84
case ENDINGPOSE_INIT
85
object.state++
86
if stage.playerListPos == PLAYER_TAILS_A
87
// A little extra setup for Tails's tails
88
object.tailFrame = 36
89
end if
90
// Fall-through
91
92
case ENDINGPOSE_WAITING
93
object.timer++
94
if stage.playerListPos == PLAYER_TAILS_A
95
// Animate Tails's tails
96
object.tailFrame = object.timer
97
object.tailFrame >>= 3
98
object.tailFrame %= 5
99
object.tailFrame += 36
100
end if
101
102
if object.timer == 240
103
currentPlayer = SLOT_PLAYER2
104
while currentPlayer < playerCount
105
ResetObjectEntity(currentPlayer, TypeName[Ending Pose], 0, player[currentPlayer].xpos, player[currentPlayer].ypos)
106
player[currentPlayer].drawOrder = 6
107
player[currentPlayer].state = ENDINGPOSE_P2_POSE_1
108
player[currentPlayer].frame = 43
109
player[currentPlayer].direction = FACING_LEFT
110
111
currentPlayer++
112
loop
113
114
object.timer = 0
115
switch stage.playerListPos
116
case PLAYER_SONIC_A
117
case PLAYER_SONIC_TAILS_A
118
object.frame = 1
119
break
120
121
case PLAYER_TAILS_A
122
object.frame = 14
123
break
124
125
case PLAYER_KNUCKLES_A
126
object.frame = 25
127
break
128
129
#platform: USE_ORIGINS
130
case PLAYER_AMY_A
131
object.frame = 45
132
object.frame += 1
133
break
134
#endplatform
135
end switch
136
137
object.state++
138
object.tailFrame = 0
139
else
140
currentPlayer = SLOT_PLAYER2
141
while currentPlayer < playerCount
142
if player[currentPlayer].speed == 0
143
player[currentPlayer].direction = FACING_LEFT
144
end if
145
146
currentPlayer++
147
loop
148
end if
149
break
150
151
case ENDINGPOSE_POSE_START
152
CallFunction(EndingPose_UpdateLogo)
153
object.timer++
154
if object.timer == 12
155
object.timer = 0
156
switch stage.playerListPos
157
case PLAYER_SONIC_A
158
case PLAYER_SONIC_TAILS_A
159
object.frame = 2
160
object.ixpos = camera[0].xpos
161
object.iypos = camera[0].ypos
162
break
163
164
case PLAYER_TAILS_A
165
case PLAYER_KNUCKLES_A
166
break
167
168
#platform: USE_ORIGINS
169
case PLAYER_AMY_A
170
object.frame++
171
object.ixpos = camera[0].xpos
172
object.iypos = camera[0].ypos
173
break
174
#endplatform
175
end switch
176
177
object.state++
178
end if
179
break
180
181
case ENDINGPOSE_POSE_MID
182
CallFunction(EndingPose_UpdateLogo)
183
object.timer++
184
if object.timer == 4
185
object.timer = -1560
186
switch stage.playerListPos
187
case PLAYER_SONIC_A
188
case PLAYER_SONIC_TAILS_A
189
object.frame = 3
190
break
191
192
case PLAYER_TAILS_A
193
object.frame = 15
194
object.ixpos = camera[0].xpos
195
object.iypos = camera[0].ypos
196
break
197
198
case PLAYER_KNUCKLES_A
199
object.frame = 26
200
object.ixpos = camera[0].xpos
201
object.iypos = camera[0].ypos
202
break
203
204
#platform: USE_ORIGINS
205
case PLAYER_AMY_A
206
object.frame = 45
207
object.frame += 3
208
break
209
#endplatform
210
end switch
211
212
object.state++
213
end if
214
break
215
216
case ENDINGPOSE_POSE_END
217
if object.timer < 320
218
object.timer += 12
219
else
220
// Roll the credits!
221
stage.activeList = PRESENTATION_STAGE
222
stage.listPos = 2
223
224
lampPostID = 0
225
recMilliSeconds = 0
226
recSeconds = 0
227
recMinutes = 0
228
LoadStage()
229
end if
230
231
if object.timer > 0
232
temp0 = object.timer
233
else
234
temp0 = 0
235
end if
236
SetScreenFade(0, 0, 0, temp0)
237
break
238
239
// In the good ending, the character starts on this state, skipping all the ones before
240
case ENDINGPOSE_HOLDEMERALDS
241
object.timer++
242
if object.timer == 80
243
object.timer = 0
244
object.state++
245
else
246
switch stage.playerListPos
247
case PLAYER_SONIC_A
248
case PLAYER_SONIC_TAILS_A
249
object.frame = 4
250
break
251
252
case PLAYER_TAILS_A
253
object.frame = 16
254
break
255
256
case PLAYER_KNUCKLES_A
257
object.frame = 27
258
break
259
260
#platform: USE_ORIGINS
261
case PLAYER_AMY_A
262
object.frame = 45
263
object.frame += 4
264
break
265
#endplatform
266
end switch
267
268
currentPlayer = SLOT_PLAYER2
269
while currentPlayer < playerCount
270
if player[currentPlayer].speed == 0
271
player[currentPlayer].direction = FACING_LEFT
272
end if
273
274
currentPlayer++
275
loop
276
end if
277
break
278
279
case ENDINGPOSE_EMERALDSSHINE
280
object.frame = object.timer
281
object.frame >>= 2
282
object.frame &= 1
283
284
switch stage.playerListPos
285
case PLAYER_SONIC_A
286
case PLAYER_SONIC_TAILS_A
287
object.frame += 5
288
break
289
290
case PLAYER_TAILS_A
291
object.frame += 17
292
break
293
294
case PLAYER_KNUCKLES_A
295
object.frame += 27
296
break
297
298
#platform: USE_ORIGINS
299
case PLAYER_AMY_A
300
object.frame += 45
301
object.frame += 5
302
break
303
#endplatform
304
end switch
305
306
object.timer++
307
if object.timer == 80
308
object.timer = 0
309
switch stage.playerListPos
310
case PLAYER_SONIC_A
311
case PLAYER_SONIC_TAILS_A
312
object.frame = 7
313
break
314
315
case PLAYER_TAILS_A
316
object.frame = 19
317
break
318
319
case PLAYER_KNUCKLES_A
320
object.frame = 29
321
break
322
323
#platform: USE_ORIGINS
324
case PLAYER_AMY_A
325
object.frame = 45
326
object.frame += 7
327
break
328
#endplatform
329
end switch
330
331
currentPlayer = SLOT_PLAYER2
332
while currentPlayer < playerCount
333
player[currentPlayer].up = true
334
player[currentPlayer].controlMode = CONTROLMODE_NONE
335
336
currentPlayer++
337
loop
338
339
CreateTempObject(TypeName[Emeralds], 0, object.xpos, object.ypos)
340
object[tempObjectPos].drawOrder = 6
341
342
object.state++
343
else
344
currentPlayer = SLOT_PLAYER2
345
while currentPlayer < playerCount
346
if player[currentPlayer].speed == 0
347
player[currentPlayer].direction = FACING_LEFT
348
end if
349
350
currentPlayer++
351
loop
352
end if
353
break
354
355
case ENDINGPOSE_LOOKUP
356
// In this state, we wait for the Emeralds to increase our state
357
break
358
359
case ENDINGPOSE_EMERALDSFLASH_A
360
if object.timer < 384
361
object.timer += 6
362
else
363
object.timer = 256
364
365
// Set all FG chunks to use their flowered versions
366
SetTileLayerEntry(184, 0, 2, 2)
367
SetTileLayerEntry(185, 0, 3, 2)
368
SetTileLayerEntry(186, 0, 2, 3)
369
SetTileLayerEntry(187, 0, 3, 3)
370
SetTileLayerEntry(188, 0, 4, 2)
371
SetTileLayerEntry(189, 0, 5, 2)
372
SetTileLayerEntry(190, 0, 4, 3)
373
SetTileLayerEntry(191, 0, 5, 3)
374
375
object.state++
376
end if
377
378
SetScreenFade(208, 255, 224, object.timer)
379
break
380
381
case ENDINGPOSE_EMERALDSFLASH_B
382
if object.timer > 0
383
object.timer -= 16
384
SetScreenFade(208, 255, 224, object.timer)
385
else
386
switch stage.playerListPos
387
case PLAYER_SONIC_A
388
case PLAYER_SONIC_TAILS_A
389
object.frame = 8
390
break
391
392
case PLAYER_TAILS_A
393
object.frame = 20
394
break
395
396
case PLAYER_KNUCKLES_A
397
object.frame = 30
398
break
399
400
#platform: USE_ORIGINS
401
case PLAYER_AMY_A
402
object.frame = 45
403
object.frame += 8
404
break
405
#endplatform
406
end switch
407
408
object.state++
409
currentPlayer = SLOT_PLAYER2
410
while currentPlayer < playerCount
411
ResetObjectEntity(currentPlayer, TypeName[Ending Pose], 0, player[currentPlayer].xpos, player[currentPlayer].ypos)
412
player[currentPlayer].drawOrder = 6
413
player[currentPlayer].state = ENDINGPOSE_P2_LOOKAROUND
414
player[currentPlayer].frame = 43
415
player[currentPlayer].direction = FACING_LEFT
416
417
currentPlayer++
418
loop
419
end if
420
break
421
422
case ENDINGPOSE_LOOKAROUND
423
switch stage.playerListPos
424
case PLAYER_SONIC_A
425
case PLAYER_SONIC_TAILS_A
426
object.frame = object.timer
427
object.frame /= 6
428
object.frame &= 1
429
object.frame += 8
430
break
431
432
case PLAYER_TAILS_A
433
object.frame = object.timer
434
object.frame /= 10
435
object.frame &= 3
436
object.frame += 20
437
if object.timer >= 40
438
object.frame = 23
439
end if
440
break
441
442
case PLAYER_KNUCKLES_A
443
object.frame = object.timer
444
object.frame /= 10
445
object.frame &= 3
446
object.frame += 30
447
if object.timer >= 40
448
object.frame = 34
449
end if
450
break
451
452
#platform: USE_ORIGINS
453
case PLAYER_AMY_A
454
object.frame = object.timer
455
object.frame /= 6
456
object.frame &= 1
457
object.frame += 8
458
object.frame += 45
459
break
460
#endplatform
461
end switch
462
463
object.timer++
464
if object.timer == 42
465
object.timer = 0
466
object.state++
467
end if
468
break
469
470
case ENDINGPOSE_LOOKLEFT
471
object.timer++
472
if object.timer == 60
473
object.timer = 0
474
switch stage.playerListPos
475
case PLAYER_SONIC_A
476
case PLAYER_SONIC_TAILS_A
477
object.frame = 1
478
break
479
480
case PLAYER_TAILS_A
481
object.frame = 14
482
break
483
484
case PLAYER_KNUCKLES_A
485
object.frame = 25
486
break
487
488
#platform: USE_ORIGINS
489
case PLAYER_AMY_A
490
object.frame = 45
491
object.frame += 1
492
break
493
#endplatform
494
end switch
495
496
object.state = ENDINGPOSE_POSE_START
497
end if
498
break
499
500
// These remaining three states are for P2 Tails, looking busy while P1 (as a separate Ending Pose Object) gets to do the proper big poses front and center
501
502
case ENDINGPOSE_P2_LOOKAROUND
503
object.frame = object.timer
504
object.frame /= 10
505
object.frame &= 3
506
object.frame += 20
507
if object.timer >= 40
508
object.frame = 23
509
end if
510
511
object.timer++
512
if object.timer == 42
513
object.timer = 0
514
object.state++
515
end if
516
break
517
518
case ENDINGPOSE_P2_LOOKLEFT
519
object.timer++
520
if object.timer == 60
521
object.timer = 0
522
object.frame = 43
523
object.state++
524
end if
525
break
526
527
case ENDINGPOSE_P2_POSE_1
528
object.timer++
529
if object.timer == 8
530
object.frame++
531
object.timer = 0
532
object.state++
533
end if
534
break
535
536
// ENDINGPOSE_P2_POSE_2 doesn't have a case since it doesn't do anything, its frame is set when exiting ENDINGPOSE_P2_POSE_1
537
538
end switch
539
end event
540
541
542
event ObjectDraw
543
if object.tailFrame != 0
544
// Tails should have one of his tails sprites in tow
545
DrawSprite(object.tailFrame)
546
end if
547
548
// The main player sprite
549
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
550
551
// P1 should draw the logo, as well
552
if object.entityPos == 0
553
if object.state > 0
554
temp0 = screen.xcenter
555
temp0 -= 96
556
temp0 -= object.logoPos
557
if stage.player2Enabled == true
558
if options.region == true
559
// "Sonic the Hedgehog and Miles"
560
temp1 = 42
561
else
562
// "Sonic the Hedgehog and Tails"
563
temp1 = 41
564
end if
565
else
566
temp1 = 10
567
#platform: USE_STANDALONE
568
if stage.playerListPos < PLAYER_SONIC_TAILS_A
569
temp1 += stage.playerListPos
570
end if
571
#endplatform
572
573
#platform: USE_ORIGINS
574
if stage.playerListPos < PLAYER_SONIC_TAILS
575
temp1 += stage.playerListPos
576
else
577
if stage.playerListPos == PLAYER_AMY
578
temp1 = 45
579
temp1 += 10
580
end if
581
end if
582
#endplatform
583
end if
584
585
DrawSpriteScreenXY(temp1, temp0, 80)
586
end if
587
end if
588
end event
589
590
591
event ObjectStartup
592
LoadSpriteSheet("Ending/Objects.gif")
593
594
// 0 - Sonic Idle Frame
595
SpriteFrame(-14, -20, 30, 39, 28, 16)
596
597
// 1-3 - Sonic's Final Pose Animation Frames
598
SpriteFrame(-16, -16, 32, 35, 3, 220)
599
SpriteFrame(-18, -27, 44, 71, 36, 184)
600
SpriteFrame(-56, -68, 174, 134, 81, 121)
601
602
// 4-9 - Sonic's Good Ending Animation Frames
603
SpriteFrame(-10, -21, 24, 40, 3, 16)
604
SpriteFrame(-10, -21, 24, 40, 3, 16)
605
SpriteFrame(-14, -21, 28, 40, 3, 57)
606
SpriteFrame(-16, -20, 29, 39, 3, 98)
607
SpriteFrame(-16, -21, 32, 40, 3, 138)
608
SpriteFrame(-16, -21, 32, 40, 3, 179)
609
610
// 10 - "Sonic the Hedgehog"
611
SpriteFrame(-48, 0, 96, 31, 256, 141)
612
613
// 11 - "Miles 'Tails' Prower In Sonic the Hedgehog"
614
SpriteFrame(-48, -17, 96, 48, 256, 182)
615
616
// 12 - "Knuckles the Echidna in Sonic the Hedgehog"
617
SpriteFrame(-48, -17, 96, 48, 256, 124)
618
619
// 13-15 - Tails's Final Pose Animation Frames
620
SpriteFrame(-10, -13, 24, 31, 288, 16)
621
SpriteFrame(-19, -12, 33, 31, 254, 16)
622
SpriteFrame(-55, -48, 111, 96, 400, 1)
623
624
// 16-23 - Tails's Good Ending Animation Frames
625
// (The two medium-sized transition frames next to the big sprite are unused)
626
SpriteFrame(-12, -16, 27, 34, 313, 16)
627
SpriteFrame(-12, -16, 27, 34, 59, 16)
628
SpriteFrame(-15, -16, 30, 34, 87, 16)
629
SpriteFrame(-15, -14, 31, 32, 118, 16)
630
631
SpriteFrame(-12, -16, 25, 34, 150, 16)
632
SpriteFrame(-12, -16, 25, 34, 176, 16)
633
SpriteFrame(-12, -16, 25, 34, 202, 16)
634
SpriteFrame(-12, -16, 25, 34, 228, 16)
635
636
// 24-26 - Knuckles's Final Pose Animation Frames
637
SpriteFrame(-14, -23, 27, 41, 325, 57)
638
SpriteFrame(-16, -21, 28, 39, 296, 57)
639
SpriteFrame(-32, -52, 64, 104, 448, 98)
640
641
// 27-35 - Knuckles's Good Ending Animation Frames
642
// (The two medium-sized transition frames next to the big sprite are unused)
643
SpriteFrame(-12, -23, 24, 41, 32, 57)
644
SpriteFrame(-16, -23, 28, 41, 57, 57)
645
SpriteFrame(-18, -22, 45, 40, 86, 57)
646
SpriteFrame(-16, -23, 33, 41, 132, 57)
647
SpriteFrame(-16, -23, 33, 41, 166, 57)
648
SpriteFrame(-16, -23, 33, 41, 200, 57)
649
SpriteFrame(-16, -23, 33, 41, 200, 57)
650
SpriteFrame(-16, -23, 27, 41, 268, 57)
651
SpriteFrame(-16, -23, 33, 41, 234, 57)
652
653
// 36-40 - Tails's Tails' Frames
654
// Drawn using object.tailFrame, rather than the base object.frame
655
SpriteFrame(-21, -6, 16, 24, 256, 99)
656
SpriteFrame(-25, -6, 20, 24, 273, 99)
657
SpriteFrame(-25, -6, 20, 24, 294, 99)
658
SpriteFrame(-25, -6, 20, 24, 315, 99)
659
SpriteFrame(-25, -6, 20, 24, 336, 99)
660
661
// 41 - "Sonic the Hedgehog and Tails"
662
SpriteFrame(-48, 0, 96, 40, 256, 141)
663
664
// 42 - "Sonic the Hedgehog and Miles"
665
SpriteFrame(-48, 0, 96, 40, 256, 199)
666
667
// 43-44 - P2 Tails Pose Frames
668
SpriteFrame(-10, -13, 22, 31, 58, 99)
669
SpriteFrame(-20, -17, 36, 35, 44, 131)
670
671
#platform: USE_ORIGINS
672
// 45 - Amy's Normal Ending Animation Frame
673
SpriteFrame(-10, -16, 21, 35, 421, 211)
674
675
// 46-48 - Amy's Final Pose Animation Frames
676
SpriteFrame(-12, -15, 28, 34, 407, 175)
677
SpriteFrame(-30, -42, 67, 67, 353, 211)
678
SpriteFrame(-31, -73, 124, 144, 3, 256)
679
680
// 49-54 - Amy's Good Ending Animation Frames
681
SpriteFrame(-8, -16, 21, 35, 353, 139)
682
SpriteFrame(-8, -16, 21, 35, 353, 139)
683
SpriteFrame(-12, -16, 25, 35, 375, 139)
684
SpriteFrame(-13, -17, 25, 36, 401, 138)
685
SpriteFrame(-13, -16, 26, 35, 353, 175)
686
SpriteFrame(-13, -16, 26, 35, 380, 175)
687
688
// 55 - "Amy Rose in Sonic the Hedgehog"
689
SpriteFrame(-48, -17, 96, 48, 256, 240)
690
#endplatform
691
end event
692
693
694
// ========================
695
// Editor Events
696
// ========================
697
698
event RSDKDraw
699
DrawSprite(0)
700
end event
701
702
703
event RSDKLoad
704
LoadSpriteSheet("Ending/Objects.gif")
705
SpriteFrame(-56, -68, 174, 134, 81, 121)
706
707
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
708
end event
709
710