Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/RedSpring.txt
1319 views
1
//----------------Sonic CD Red Spring Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.ActiveSpringFrame
7
#alias Object.Value2 : Object.Unused // "introduced" in Origins Plus but it isn't really used for anything
8
#alias Object.Value7 : Object.EnabledInAir // Only has effect on horizontal springs
9
10
// Player Aliases
11
#alias Player.Value7 : Player.AnimationReserve
12
13
// Directions
14
#alias 0 : FLIP_NONE
15
#alias 2 : FLIP_Y
16
17
// Gravity
18
#alias 0 : GRAVITY_GROUND
19
#alias 1 : GRAVITY_AIR
20
21
// Collision Modes
22
#alias 0 : CMODE_FLOOR
23
#alias 2 : CMODE_ROOF
24
25
// Global SFX
26
#alias 11 : SFX_G_SPRING
27
28
// Property Values
29
#alias 0 : FACE_FACING_UP
30
#alias 1 : FACE_FACING_RIGHT
31
#alias 2 : FACE_FACING_LEFT
32
#alias 3 : FACE_FACING_DOWN
33
#alias 4 : FACE_FACING_DIAGONAL_UR
34
#alias 5 : FACE_FACING_DIAGONAL_UL
35
#alias 6 : FACE_FACING_DIAGONAL_DR // Actually not facing down when spawned from debug mode
36
#alias 7 : FACE_FACING_DIAGONAL_DL // Actually not facing down when spawned from debug mode
37
38
39
sub ObjectPlayerInteraction
40
switch Object.PropertyValue
41
case FACE_FACING_UP
42
TempValue0 = false
43
if Player.Gravity == GRAVITY_AIR
44
TempValue0 = true
45
end if
46
47
if Player.CollisionMode > CMODE_FLOOR
48
if Player.YVelocity < 0
49
TempValue0 = true
50
end if
51
end if
52
53
if TempValue0 == false
54
PlayerObjectCollision(C_BOX, -16, -8, 16, 8)
55
56
PlayerObjectCollision(C_TOUCH, -16, -10, 16, -6)
57
#platform: Use_Origins
58
if CheckResult == true
59
if Stage.PlayerListPos == PLAYER_KNUCKLES
60
if Player.State == Player_State_LedgePullUp
61
CheckResult = false
62
Object.Unused = 1
63
end if
64
end if
65
end if
66
#endplatform
67
if CheckResult == true
68
Player.AnimationReserve = ANI_WALKING
69
70
if Player.Animation == ANI_RUNNING
71
Player.AnimationReserve = ANI_RUNNING
72
end if
73
74
if Player.Animation == ANI_PEELOUT
75
Player.AnimationReserve = ANI_PEELOUT
76
end if
77
78
Object.ActiveSpringFrame = 1
79
80
#platform: Use_Origins
81
Player.State = Player_State_Air_NoDropDash
82
#endplatform
83
84
#platform: Use_Standalone
85
Player.State = Player_State_Air
86
#endplatform
87
88
Player.Gravity = GRAVITY_AIR
89
Player.YVelocity = -0x100000
90
Player.Animation = ANI_BOUNCING
91
Player.Timer = 0
92
93
PlaySfx(SFX_G_SPRING, false)
94
95
#platform: Use_Haptics
96
HapticEffect(9, 0, 0, 0)
97
#endplatform
98
99
end if
100
else
101
if Player.YVelocity >= 0
102
PlayerObjectCollision(C_PLATFORM, -16, -8, 16, 8)
103
104
PlayerObjectCollision(C_TOUCH, -16, -10, 16, -6)
105
#platform: Use_Origins
106
if CheckResult == true
107
if Stage.PlayerListPos == PLAYER_KNUCKLES
108
if Player.State == Player_State_LedgePullUp
109
CheckResult = false
110
Object.Unused = 1
111
end if
112
end if
113
end if
114
#endplatform
115
if CheckResult == true
116
117
Player.AnimationReserve = ANI_WALKING
118
119
if Player.Animation == ANI_RUNNING
120
Player.AnimationReserve = ANI_RUNNING
121
end if
122
123
if Player.Animation == ANI_PEELOUT
124
Player.AnimationReserve = ANI_PEELOUT
125
end if
126
127
Object.ActiveSpringFrame = 1
128
129
#platform: Use_Origins
130
Player.State = Player_State_Air_NoDropDash
131
#endplatform
132
133
#platform: Use_Standalone
134
Player.State = Player_State_Air
135
#endplatform
136
137
Player.Gravity = GRAVITY_AIR
138
Player.YVelocity = -0x100000
139
Player.Animation = ANI_BOUNCING
140
Player.Timer = 0
141
142
PlaySfx(SFX_G_SPRING, false)
143
144
#platform: Use_Haptics
145
HapticEffect(9, 0, 0, 0)
146
#endplatform
147
148
end if
149
end if
150
end if
151
break
152
153
case FACE_FACING_RIGHT
154
PlayerObjectCollision(C_BOX, -8, -16, 8, 16)
155
#platform: Use_Origins
156
if Player.Animation != ANI_GLIDING
157
#endplatform
158
if Player.Gravity == GRAVITY_GROUND
159
160
PlayerObjectCollision(C_TOUCH, 6, -15, 11, 15)
161
if CheckResult == true
162
#platform: Use_Origins
163
CheckResult = false
164
if Player.State == Player_State_GlideSlide
165
CheckResult = true
166
end if
167
if Player.State == Player_State_HammerDash
168
CheckResult = true
169
end if
170
if CheckResult == true
171
Player.State = Player_State_Ground
172
end if
173
#endplatform
174
Object.ActiveSpringFrame = 1
175
176
Player.Angle = 0
177
Player.Speed = 0x100000
178
Player.CollisionMode = CMODE_FLOOR
179
Player.Pushing = false
180
Player.Direction = FACING_RIGHT
181
Player.ControlLock = 16
182
183
PlaySfx(SFX_G_SPRING, false)
184
#platform: Use_Haptics
185
HapticEffect(9, 0, 0, 0)
186
#endplatform
187
end if
188
else
189
if Object.EnabledInAir == true
190
PlayerObjectCollision(C_TOUCH, 6, -15, 11, 15)
191
if CheckResult == true
192
#platform: Use_Origins
193
CheckResult = false
194
if Player.State == Player_State_GlideSlide
195
CheckResult = true
196
end if
197
if Player.State == Player_State_HammerDash
198
CheckResult = true
199
end if
200
if CheckResult == true
201
Player.State = Player_State_Ground
202
end if
203
#endplatform
204
Object.ActiveSpringFrame = 1
205
206
Player.Angle = 0
207
Player.Speed = 0x100000
208
Player.CollisionMode = CMODE_FLOOR
209
Player.Pushing = false
210
Player.Direction = FACING_RIGHT
211
Player.ControlLock = 16
212
213
PlaySfx(SFX_G_SPRING, false)
214
215
#platform: Use_Haptics
216
HapticEffect(9, 0, 0, 0)
217
#endplatform
218
219
end if
220
end if
221
end if
222
#platform: Use_Origins
223
end if
224
#endplatform
225
break
226
227
case FACE_FACING_LEFT
228
PlayerObjectCollision(C_BOX, -8, -16, 8, 16)
229
#platform: Use_Origins
230
if Player.Animation != ANI_GLIDING
231
#endplatform
232
if Player.Gravity == GRAVITY_GROUND
233
234
PlayerObjectCollision(C_TOUCH, -10, -15, -6, 15)
235
if CheckResult == true
236
#platform: Use_Origins
237
CheckResult = false
238
if Player.State == Player_State_GlideSlide
239
CheckResult = true
240
end if
241
if Player.State == Player_State_HammerDash
242
CheckResult = true
243
end if
244
if CheckResult == true
245
Player.State = Player_State_Ground
246
end if
247
#endplatform
248
Object.ActiveSpringFrame = 1
249
250
Player.Speed = -0x100000
251
Player.CollisionMode = CMODE_FLOOR
252
Player.Pushing = false
253
Player.Direction = FACING_LEFT
254
Player.ControlLock = 16
255
256
PlaySfx(SFX_G_SPRING, false)
257
#platform: Use_Haptics
258
HapticEffect(9, 0, 0, 0)
259
#endplatform
260
end if
261
else
262
if Object.EnabledInAir == true
263
PlayerObjectCollision(C_TOUCH, -10, -15, -6, 15)
264
if CheckResult == true
265
#platform: Use_Origins
266
CheckResult = false
267
if Player.State == Player_State_GlideSlide
268
CheckResult = true
269
end if
270
if Player.State == Player_State_HammerDash
271
CheckResult = true
272
end if
273
if CheckResult == true
274
Player.State = Player_State_Ground
275
end if
276
#endplatform
277
Object.ActiveSpringFrame = 1
278
279
Player.Speed = -0x100000
280
Player.YVelocity = 0x20000
281
Player.CollisionMode = CMODE_FLOOR
282
Player.Pushing = false
283
Player.Direction = FACING_LEFT
284
Player.ControlLock = 16
285
286
PlaySfx(SFX_G_SPRING, false)
287
288
#platform: Use_Haptics
289
HapticEffect(9, 0, 0, 0)
290
#endplatform
291
292
end if
293
end if
294
end if
295
#platform: Use_Origins
296
end if
297
#endplatform
298
break
299
300
case FACE_FACING_DOWN
301
PlayerObjectCollision(C_BOX, -16, -8, 16, 8)
302
PlayerObjectCollision(C_TOUCH, -15, 6, 15, 10)
303
if CheckResult == true
304
if Player.CollisionMode == CMODE_ROOF
305
FlipSign(Player.Speed)
306
FlipSign(Player.XVelocity)
307
end if
308
Object.ActiveSpringFrame = 1
309
310
#platform: Use_Origins
311
Player.State = Player_State_Air_NoDropDash
312
#endplatform
313
314
#platform: Use_Standalone
315
Player.State = Player_State_Air
316
#endplatform
317
318
Player.Gravity = GRAVITY_AIR
319
Player.YVelocity = 0x100000
320
Player.Timer = 0
321
322
PlaySfx(SFX_G_SPRING, false)
323
324
#platform: Use_Haptics
325
HapticEffect(9, 0, 0, 0)
326
#endplatform
327
328
end if
329
break
330
331
case FACE_FACING_DIAGONAL_UR
332
PlayerObjectCollision(C_TOUCH, -12, -16, 12, 12)
333
#platform: Use_Origins
334
if CheckResult == true
335
if Stage.PlayerListPos == PLAYER_KNUCKLES
336
if Player.State == Player_State_LedgePullUp
337
CheckResult = false
338
Object.Unused = 1
339
end if
340
end if
341
end if
342
#endplatform
343
if Player.Gravity == GRAVITY_GROUND
344
if CheckResult == true
345
Object.ActiveSpringFrame = 1
346
347
#platform: Use_Origins
348
Player.State = Player_State_Air_NoDropDash
349
#endplatform
350
351
#platform: Use_Standalone
352
Player.State = Player_State_Air
353
#endplatform
354
355
Player.Gravity = GRAVITY_AIR
356
Player.Speed = 0xB4000
357
Player.YVelocity = -0xB4000
358
Player.Animation = ANI_WALKING
359
Player.Direction = FACING_RIGHT
360
Player.Timer = 0
361
362
PlaySfx(SFX_G_SPRING, false)
363
364
#platform: Use_Haptics
365
HapticEffect(9, 0, 0, 0)
366
#endplatform
367
368
end if
369
end if
370
if Player.YVelocity >= 0
371
if CheckResult == true
372
Object.ActiveSpringFrame = 1
373
374
#platform: Use_Origins
375
Player.State = Player_State_Air_NoDropDash
376
#endplatform
377
378
#platform: Use_Standalone
379
Player.State = Player_State_Air
380
#endplatform
381
382
Player.Gravity = GRAVITY_AIR
383
Player.Speed = 0xB4000
384
Player.YVelocity = -0xB4000
385
Player.Animation = ANI_WALKING
386
Player.Direction = FACING_RIGHT
387
Player.Timer = 0
388
389
PlaySfx(SFX_G_SPRING, false)
390
391
#platform: Use_Haptics
392
HapticEffect(9, 0, 0, 0)
393
#endplatform
394
395
end if
396
end if
397
break
398
399
case FACE_FACING_DIAGONAL_UL
400
PlayerObjectCollision(C_TOUCH, -12, -16, 12, 12)
401
#platform: Use_Origins
402
if CheckResult == true
403
if Stage.PlayerListPos == PLAYER_KNUCKLES
404
if Player.State == Player_State_LedgePullUp
405
CheckResult = false
406
Object.Unused = 1
407
end if
408
end if
409
end if
410
#endplatform
411
if Player.YVelocity >= 0
412
if CheckResult == true
413
Object.ActiveSpringFrame = 1
414
415
#platform: Use_Origins
416
Player.State = Player_State_Air_NoDropDash
417
#endplatform
418
419
#platform: Use_Standalone
420
Player.State = Player_State_Air
421
#endplatform
422
423
Player.Gravity = GRAVITY_AIR
424
Player.Speed = -0xB4000
425
Player.YVelocity = -0xB4000
426
Player.Animation = ANI_WALKING
427
Player.Direction = FACING_LEFT
428
Player.Timer = 0
429
430
PlaySfx(SFX_G_SPRING, false)
431
432
#platform: Use_Haptics
433
HapticEffect(9, 0, 0, 0)
434
#endplatform
435
436
end if
437
end if
438
if Player.Gravity == GRAVITY_GROUND
439
if CheckResult == true
440
Object.ActiveSpringFrame = 1
441
442
#platform: Use_Origins
443
Player.State = Player_State_Air_NoDropDash
444
#endplatform
445
446
#platform: Use_Standalone
447
Player.State = Player_State_Air
448
#endplatform
449
450
Player.Gravity = GRAVITY_AIR
451
Player.Speed = -0xB4000
452
Player.YVelocity = -0xB4000
453
Player.Animation = ANI_WALKING
454
Player.Direction = FACING_LEFT
455
Player.Timer = 0
456
457
PlaySfx(SFX_G_SPRING, false)
458
459
#platform: Use_Haptics
460
HapticEffect(9, 0, 0, 0)
461
#endplatform
462
463
end if
464
end if
465
break
466
467
case FACE_FACING_DIAGONAL_DR
468
PlayerObjectCollision(C_TOUCH, -12, -12, 12, 12)
469
if CheckResult == true
470
Object.ActiveSpringFrame = 1
471
472
#platform: Use_Origins
473
Player.State = Player_State_Air_NoDropDash
474
#endplatform
475
476
#platform: Use_Standalone
477
Player.State = Player_State_Air
478
#endplatform
479
480
Player.Gravity = GRAVITY_AIR
481
Player.Speed = 0xB4000
482
Player.YVelocity = 0xB4000
483
Player.Timer = 0
484
PlaySfx(SFX_G_SPRING, false)
485
486
#platform: Use_Haptics
487
HapticEffect(9, 0, 0, 0)
488
#endplatform
489
490
end if
491
break
492
493
case FACE_FACING_DIAGONAL_DL
494
PlayerObjectCollision(C_TOUCH, -12, -12, 12, 12)
495
if CheckResult == true
496
Object.ActiveSpringFrame = 1
497
498
#platform: Use_Origins
499
Player.State = Player_State_Air_NoDropDash
500
#endplatform
501
502
#platform: Use_Standalone
503
Player.State = Player_State_Air
504
#endplatform
505
506
Player.Gravity = GRAVITY_AIR
507
Player.Speed = -0xB4000
508
Player.YVelocity = 0xB4000
509
Player.Timer = 0
510
511
PlaySfx(SFX_G_SPRING, false)
512
513
#platform: Use_Haptics
514
HapticEffect(9, 0, 0, 0)
515
#endplatform
516
517
end if
518
break
519
end switch
520
end sub
521
522
523
sub ObjectDraw
524
if Object.ActiveSpringFrame == 0
525
DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)
526
else
527
Object.ActiveSpringFrame++
528
529
TempValue0 = Object.ActiveSpringFrame
530
TempValue0 >>= 1
531
switch TempValue0
532
case 0
533
case 1
534
DrawSpriteFX(Object.PropertyValue, FX_FLIP, Object.XPos, Object.YPos)
535
break
536
537
case 2
538
case 6
539
TempValue1 = Object.PropertyValue
540
TempValue1 += 8
541
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
542
break
543
544
case 3
545
case 4
546
case 5
547
TempValue1 = Object.PropertyValue
548
TempValue1 += 16
549
DrawSpriteFX(TempValue1, FX_FLIP, Object.XPos, Object.YPos)
550
break
551
552
end switch
553
554
if Object.ActiveSpringFrame > 12
555
Object.ActiveSpringFrame = 0
556
end if
557
end if
558
end sub
559
560
561
sub ObjectStartup
562
LoadSpriteSheet("Global/Items.gif")
563
564
// Springs
565
SpriteFrame(-16, -8, 32, 16, 84, 1) // #0 - Red Spring facing up
566
SpriteFrame(-8, -16, 16, 32, 117, 1) // #1 - Red Spring facing right
567
SpriteFrame(-8, -16, 16, 32, 175, 1) // #2 - Red Spring facing left
568
SpriteFrame(-16, -8, 32, 16, 84, 59) // #3 - Red Spring facing down
569
SpriteFrame(-16, -16, 32, 32, 84, 117) // #4 - Red Spring facing diagonal right
570
SpriteFrame(-16, -16, 32, 32, 117, 165) // #5 - Red Spring facing diagonal left
571
SpriteFrame(-16, -16, 32, 32, 84, 117) // #6 - Red Spring facing diagonal right 2
572
SpriteFrame(-16, -16, 32, 32, 117, 165) // #7 - Red Spring facing diagonal left 2
573
574
// Spring Recoil
575
SpriteFrame(-16, 0, 32, 8, 84, 1) // #8 - Red Spring Head facing up
576
SpriteFrame(-8, -16, 8, 32, 125, 1) // #9 - Red Spring Head facing right
577
SpriteFrame(0, -16, 8, 32, 175, 1) // #10 - Red Spring Head facing left
578
SpriteFrame(-16, -8, 32, 8, 84, 67) // #11 - Red Spring Head facing down
579
SpriteFrame(-16, -16, 32, 32, 84, 150) // #12 - Red Spring Recoiled diagonal right
580
SpriteFrame(-16, -16, 32, 32, 150, 165) // #13 - Red Spring Recoiled diagonal left
581
SpriteFrame(-16, -16, 32, 32, 84, 150) // #14 - Red Spring Recoiled diagonal right 2
582
SpriteFrame(-16, -16, 32, 32, 150, 165) // #15 - Red Spring Recoiled diagonal left 2
583
// Spring Launch
584
SpriteFrame(-16, -32, 32, 40, 84, 18) // #16 - Red Spring Launch facing up
585
SpriteFrame(-8, -16, 40, 32, 134, 1) // #17 - Red Spring Launch facing right
586
SpriteFrame(-16, -16, 40, 32, 192, 1) // #18 - Red Spring Launch facing left
587
SpriteFrame(-16, -8, 32, 40, 84, 76) // #19 - Red Spring Launch facing down
588
SpriteFrame(-16, -32, 48, 48, 117, 34) // #20 - Red Spring Launch diagonal right
589
SpriteFrame(-32, -32, 48, 48, 166, 34) // #21 - Red Spring Launch diagonal left
590
SpriteFrame(-16, -32, 48, 48, 117, 34) // #22 - Red Spring Launch diagonal right 2
591
SpriteFrame(-32, -32, 48, 48, 166, 34) // #23 - Red Spring Launch diagonal left 2
592
593
// Used to be below LoadSpriteSheet, moved here for consistency
594
ArrayPos0 = 32
595
while ArrayPos0 < 1056
596
if Object[ArrayPos0].Type == TypeName[Red Spring]
597
if Object[ArrayPos0].PropertyValue > 7
598
Object[ArrayPos0].PropertyValue -= 8
599
Object[ArrayPos0].EnabledInAir = true
600
end if
601
602
if Object[ArrayPos0].PropertyValue > 5
603
Object[ArrayPos0].Direction = FLIP_Y
604
end if
605
end if
606
ArrayPos0++
607
loop
608
end sub
609
610
611
// ========================
612
// Editor Subs
613
// ========================
614
615
sub RSDKEdit
616
if Editor.ReturnVariable == true
617
switch Editor.VariableID
618
case EDIT_VAR_PROPVAL // property value
619
CheckResult = Object.PropertyValue
620
break
621
622
case 0 // flipFlags
623
CheckResult = Object.PropertyValue
624
CheckResult &= 7
625
break
626
627
case 1 // enabledInAir
628
GetBit(CheckResult, Object.PropertyValue, 3)
629
break
630
631
end switch
632
else
633
switch Editor.VariableID
634
case EDIT_VAR_PROPVAL // property value
635
Object.PropertyValue = Editor.VariableValue
636
break
637
638
case 0 // flipFlags
639
TempValue0 = 7
640
Not(TempValue0)
641
Object.PropertyValue &= TempValue0
642
Editor.VariableValue &= 7
643
644
Object.PropertyValue |= Editor.VariableValue
645
break
646
647
case 1 // enabledInAir
648
CheckNotEqual(Editor.VariableValue, false)
649
SetBit(Object.PropertyValue, 3, CheckResult)
650
break
651
652
end switch
653
end if
654
end sub
655
656
657
sub RSDKDraw
658
if Object.PropertyValue > 5
659
// Fun little fact - the official RSDKv3 editor displayed down diagonal springs wrong
660
// Here though, we may as well right that
661
Object.Direction = FLIP_Y
662
else
663
Object.Direction = FLIP_NONE
664
end if
665
666
TempValue0 = Object.PropertyValue
667
TempValue0 &= 7
668
669
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
670
end sub
671
672
673
sub RSDKLoad
674
LoadSpriteSheet("Global/Items.gif")
675
SpriteFrame(-16, -8, 32, 16, 84, 1) // #0 - Red Spring facing up
676
SpriteFrame(-8, -16, 16, 32, 117, 1) // #1 - Red Spring facing right
677
SpriteFrame(-8, -16, 16, 32, 175, 1) // #2 - Red Spring facing left
678
SpriteFrame(-16, -8, 32, 16, 84, 59) // #3 - Red Spring facing down
679
SpriteFrame(-16, -16, 32, 32, 84, 117) // #4 - Red Spring facing diagonal right
680
SpriteFrame(-16, -16, 32, 32, 117, 165) // #5 - Red Spring facing diagonal left
681
SpriteFrame(-16, -16, 32, 32, 84, 117) // #6 - Red Spring facing diagonal right 2
682
SpriteFrame(-16, -16, 32, 32, 117, 165) // #7 - Red Spring facing diagonal left 2
683
684
AddEditorVariable("Type")
685
SetActiveVariable("Type")
686
AddEnumVariable("Up", 0)
687
AddEnumVariable("Right", 1)
688
AddEnumVariable("Left", 2)
689
AddEnumVariable("Down", 3)
690
AddEnumVariable("Diagonal (Up Right)", 4)
691
AddEnumVariable("Diagonal (Up Left)", 5)
692
AddEnumVariable("Diagonal (Down Right)", 6)
693
AddEnumVariable("Diagonal (Down Right)", 7)
694
695
AddEditorVariable("EnabledInAir")
696
SetActiveVariable("EnabledInAir")
697
AddEnumVariable("False", false)
698
AddEnumVariable("True", true)
699
end sub
700
701