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