Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R1/Ramp3D.txt
1319 views
1
//------------------Sonic CD 3D Ramp Script-------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Player.XOriginPos
7
#alias Object[+3].Value0 : StarBush1.XOriginPos
8
#alias Object[+3].XPos : StarBush1.XPos
9
#alias Object[+4].Value0 : StarBush2.XOriginPos
10
#alias Object[+4].XPos : StarBush2.XPos
11
#alias Object[+5].Value0 : BoostSpinner.XOriginPos
12
#alias Object[+5].XPos : BoostSpinner.XPos
13
14
// States
15
#alias 0 : RAMP3D_RUN
16
#alias 1 : RAMP3D_EXIT_UNUSED // a copy of Exit Boost
17
#alias 2 : RAMP3D_EXIT
18
#alias 3 : RAMP3D_SET_YBOUND // this doesn't really have anything to do with this object
19
#alias 4 : RAMP3D_ENTER
20
#alias 5 : RAMP3D_DROP
21
#alias 6 : RAMP3D_SET_YBOUND2 // this doesn't really have anything to do with this object
22
#alias 7 : RAMP3D_RUN_FROM_TOP
23
#alias 8 : RAMP3D_EXIT_BOOST
24
25
// Gravity
26
#alias 0 : GRAVITY_GROUND
27
#alias 1 : GRAVITY_AIR
28
29
// Priority
30
#alias 0 : PRIORITY_BOUNDS
31
#alias 1 : PRIORITY_ACTIVE
32
33
// Control Mode
34
#alias -1 : CONTROLMODE_NONE
35
#alias 0 : CONTROLMODE_NORMAL
36
37
// Function declarations
38
#function Ramp3D_SetPlayerLaunch
39
40
function Ramp3D_SetPlayerLaunch
41
#platform: Use_Origins
42
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
43
if CheckResult == 1
44
Player.Timer = 0
45
Player.State = Player_State_Air_NoDropDash
46
47
Player.TileCollisions = true
48
49
Player.Speed = 0x80000
50
Player.XVelocity = 0x80000
51
Player.YVelocity = -0xE0000
52
53
Player.Gravity = GRAVITY_AIR
54
Player.Rotation = 384
55
56
Stage.NewYBoundary2 = 1280
57
Stage.NewXBoundary1 = 2080
58
59
if Player.Animation == ANI_ROLL3D
60
Player.Animation = ANI_JUMPING
61
else
62
if Player.Animation != ANI_JUMPING
63
Player.Animation = ANI_WALKING
64
end if
65
end if
66
67
Object[15].Type = TypeName[BackgroundFX]
68
Object[15].Priority = PRIORITY_ACTIVE
69
Object[15].DrawOrder = 0
70
71
ArrayPos0 = 0
72
while ArrayPos0 < 2
73
HParallax[ArrayPos0].ScrollPos = 0
74
ArrayPos0++
75
loop
76
end if
77
if Player.YVelocity < 0
78
Player.ControlMode = CONTROLMODE_NONE
79
Player.Left = false
80
Player.Right = false
81
Object.Priority = PRIORITY_ACTIVE
82
end if
83
#endplatform
84
end function
85
86
87
sub ObjectPlayerInteraction
88
switch Object.PropertyValue
89
case RAMP3D_RUN
90
if Player.Gravity == GRAVITY_GROUND
91
92
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
93
if CheckResult == true
94
95
if Player.State != Player_State_Static
96
Player.State = Player_State_Static
97
98
Player.TrackScroll = true
99
Player.TileCollisions = false
100
101
Player.Speed = 0
102
Player.XVelocity = 0
103
Player.YVelocity = -0xC0000
104
105
Player.AnimationSpeed = 0
106
end if
107
end if
108
end if
109
break
110
111
case RAMP3D_EXIT_UNUSED
112
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
113
if CheckResult == true
114
115
#platform: Use_Origins
116
Player.State = Player_State_Air_NoDropDash
117
#endplatform
118
119
#platform: Use_Standalone
120
Player.State = Player_State_Air
121
#endplatform
122
123
Player.TileCollisions = true
124
125
Player.Speed = 0x80000
126
Player.XVelocity = 0x80000
127
Player.YVelocity = -0xE0000
128
129
Player.Gravity = GRAVITY_AIR
130
Player.Rotation = 384
131
132
Stage.NewYBoundary2 = 1280
133
Stage.NewXBoundary1 = 2080
134
135
if Player.Animation == ANI_ROLL3D
136
Player.Animation = ANI_JUMPING
137
else
138
if Player.Animation != ANI_JUMPING
139
Player.Animation = ANI_WALKING
140
end if
141
end if
142
143
Object[15].Type = TypeName[Background FX]
144
Object[15].Priority = PRIORITY_ACTIVE
145
Object[15].DrawOrder = 0
146
147
ArrayPos0 = 0
148
while ArrayPos0 < 2
149
HParallax[ArrayPos0].ScrollPos = 0
150
ArrayPos0++
151
loop
152
end if
153
break
154
155
case RAMP3D_EXIT
156
if Player.State == Player_State_Static
157
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
158
if CheckResult == true
159
160
#platform: Use_Origins
161
Player.State = Player_State_Air_NoDropDash
162
#endplatform
163
164
#platform: Use_Standalone
165
Player.State = Player_State_Air
166
#endplatform
167
168
Player.TileCollisions = true
169
170
Player.Speed = 0x40000
171
Player.XVelocity = 0x40000
172
Player.YVelocity = -0xC0000
173
174
Player.Gravity = GRAVITY_AIR
175
Player.Rotation = 384
176
177
Stage.NewYBoundary2 = 1280
178
179
if Player.Animation == ANI_ROLL3D
180
Player.Animation = ANI_JUMPING
181
else
182
if Player.Animation != ANI_JUMPING
183
Player.Animation = ANI_WALKING
184
end if
185
end if
186
end if
187
end if
188
break
189
190
case RAMP3D_SET_YBOUND
191
if Player.XPos > Object.XPos
192
Stage.YBoundary2 = 1024
193
else
194
Stage.YBoundary2 = 1280
195
end if
196
break
197
198
case RAMP3D_ENTER
199
if Player.XPos > Object.XPos
200
if Player.Gravity == GRAVITY_GROUND
201
if Player.State != Player_State_Static
202
if Player.State == Player_State_Roll
203
204
if Player.Angle > 216
205
Player.Animation = ANI_JUMPING
206
else
207
if Player.Angle == 0
208
Player.Animation = ANI_JUMPING
209
else
210
Player.Animation = ANI_ROLL3D
211
end if
212
end if
213
else
214
215
if Player.Speed != 0
216
Player.State = Player_State_Ramp3D
217
end if
218
end if
219
end if
220
end if
221
222
StarBush1.XOriginPos = Player.XPos
223
StarBush1.XOriginPos -= Object.XPos
224
225
BoostSpinner.XOriginPos = StarBush1.XOriginPos
226
BoostSpinner.XOriginPos /= 3
227
228
StarBush1.XOriginPos >>= 1
229
StarBush2.XOriginPos = StarBush1.XOriginPos
230
StarBush1.XOriginPos += StarBush1.XPos
231
StarBush2.XOriginPos += StarBush2.XPos
232
233
BoostSpinner.XOriginPos += BoostSpinner.XPos
234
235
TempValue0 = Object.YPos
236
TempValue0 -= Player.YPos
237
if TempValue0 < 0xE00000
238
239
TempValue0 = Player.XPos
240
TempValue0 -= Player.XOriginPos
241
HParallax[0].ScrollPos += TempValue0
242
243
ArrayPos0 = 13
244
TempValue2 = 128
245
while ArrayPos0 < 141
246
TempValue1 = TempValue0
247
TempValue1 *= TempValue2
248
TempValue1 >>= 7
249
HParallax[ArrayPos0].ScrollPos += TempValue1
250
251
ArrayPos0++
252
253
TempValue2--
254
loop
255
256
TempValue0 <<= 1
257
HParallax[1].ScrollPos += TempValue0
258
end if
259
else
260
StarBush1.XOriginPos = StarBush1.XPos
261
262
StarBush2.XOriginPos = StarBush2.XPos
263
264
BoostSpinner.XOriginPos = BoostSpinner.XPos
265
266
if Player.Gravity == GRAVITY_GROUND
267
if Player.State == Player_State_Ramp3D
268
Player.State = Player_State_Ground
269
end if
270
end if
271
272
end if
273
Player.XOriginPos = Player.XPos
274
break
275
276
case RAMP3D_DROP
277
#platform: Use_Origins
278
CheckEqual(Player.State, Player_State_Air_NoDropDash)
279
TempValue0 = CheckResult
280
CheckEqual(Player.State, Player_State_Air)
281
TempValue0 |= CheckResult
282
#endplatform
283
284
#platform: Use_Standalone
285
CheckEqual(Player.State, Player_State_Air) // used to be a straight check, changed to be have a cleaner check with origins
286
TempValue0 = CheckResult
287
#endplatform
288
289
if TempValue0 != false
290
PlayerObjectCollision(C_TOUCH, -16, -128, 16, 16)
291
if CheckResult == true
292
Player.Animation = ANI_DROPPING
293
Player.XOriginPos = Player.XPos
294
end if
295
296
if Player.Animation == ANI_DROPPING
297
Player.Speed = 0
298
Player.XVelocity = 0
299
Player.XPos = Player.XOriginPos
300
end if
301
end if
302
break
303
304
case RAMP3D_SET_YBOUND2
305
if Player.YPos < Object.YPos
306
if Player.XPos > Object.XPos
307
Stage.YBoundary2 = 792
308
else
309
Stage.YBoundary2 = 1024
310
end if
311
end if
312
break
313
314
case RAMP3D_RUN_FROM_TOP // Technically speaking another YBound-like object
315
if Player.XPos > Object.XPos
316
Stage.YBoundary2 = 1024
317
if Player.Gravity == GRAVITY_GROUND
318
if Player.State == Player_State_Ramp3D
319
Player.State = Player_State_Ground
320
end if
321
end if
322
else
323
Stage.YBoundary2 = 792
324
end if
325
break
326
327
case RAMP3D_EXIT_BOOST
328
#platform: Use_Standalone
329
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
330
if CheckResult == true
331
Player.Timer = 0
332
Player.State = Player_State_Air
333
334
Player.TileCollisions = true
335
336
Player.Speed = 0x80000
337
Player.XVelocity = 0x80000
338
Player.YVelocity = -0xE0000
339
340
Player.Gravity = GRAVITY_AIR
341
Player.Rotation = 384
342
343
Stage.NewYBoundary2 = 1280
344
Stage.NewXBoundary1 = 2080
345
346
if Player.Animation == ANI_ROLL3D
347
Player.Animation = ANI_JUMPING
348
else
349
if Player.Animation != ANI_JUMPING
350
Player.Animation = ANI_WALKING
351
end if
352
end if
353
354
Object[15].Type = TypeName[Background FX]
355
Object[15].Priority = PRIORITY_ACTIVE
356
Object[15].DrawOrder = 0
357
358
ArrayPos0 = 0
359
while ArrayPos0 < 2
360
HParallax[ArrayPos0].ScrollPos = 0
361
ArrayPos0++
362
loop
363
end if
364
365
if Player.YVelocity < 0
366
Player.ControlMode = CONTROLMODE_NONE
367
Player.Left = false
368
Player.Right = false
369
Object.Priority = PRIORITY_ACTIVE
370
else
371
Player.ControlMode = CONTROLMODE_NORMAL
372
Object.Priority = PRIORITY_BOUNDS
373
end if
374
#endplatform
375
376
#platform: Use_Origins
377
if Stage.PlayerListPos == PLAYER_KNUCKLES
378
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
379
if CheckResult == true
380
TempValue0 = true
381
if Player.Angle == 0
382
TempValue0 = false
383
end if
384
if TempValue0 == true
385
CallFunction(Ramp3D_SetPlayerLaunch)
386
end if
387
end if
388
else
389
CallFunction(Ramp3D_SetPlayerLaunch)
390
end if
391
if Player.YVelocity >= 0
392
Player.ControlMode = CONTROLMODE_NORMAL
393
Object.Priority = PRIORITY_BOUNDS
394
end if
395
#endplatform
396
397
break
398
end switch
399
end sub
400
401
402
sub ObjectStartup
403
if Player.XPos > 0x7D00000
404
Stage.YBoundary2 = 1280
405
Object[15].Type = TypeName[Background FX]
406
Object[15].Priority = PRIORITY_ACTIVE
407
Object[15].DrawOrder = 0
408
end if
409
410
if Player.XPos > 0xFA00000
411
Stage.YBoundary2 = 1024
412
end if
413
end sub
414
415
416
// ========================
417
// Editor Subs
418
// ========================
419
420
sub RSDKEdit
421
if Editor.ReturnVariable == true
422
switch Editor.VariableID
423
case EDIT_VAR_PROPVAL // Property Value
424
case 0 // type
425
CheckResult = Object.PropertyValue
426
CheckResult %= 9
427
break
428
end switch
429
else
430
switch Editor.VariableID
431
case EDIT_VAR_PROPVAL // Property Value
432
case 0 // type
433
Object.PropertyValue = Editor.VariableValue
434
CheckResult %= 9
435
break
436
end switch
437
end if
438
end sub
439
440
441
sub RSDKDraw
442
LoadSpriteSheet("Global/Display.gif")
443
TempValue5 = Object.SpriteSheet
444
LoadSpriteSheet("Players/Sonic2.gif")
445
TempValue6 = Object.SpriteSheet
446
LoadSpriteSheet("Players/Sonic3.gif")
447
TempValue7 = Object.SpriteSheet
448
449
switch object.PropertyValue
450
case 0
451
Object.SpriteSheet = TempValue6
452
Object.InkEffect = 1
453
DrawSpriteFX(3,FX_INK, Object.XPos, Object.YPos)
454
Object.InkEffect = 0
455
if Editor.ShowGizmos == true
456
Editor.DrawingOverlay = true
457
TempValue1 = Object.YPos
458
TempValue1 -= 0xC00000
459
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue1, 255, 255, 0)
460
Editor.DrawingOverlay = false
461
end if
462
break
463
case 1
464
case 8
465
Object.SpriteSheet = TempValue6
466
Object.InkEffect = 1
467
DrawSpriteFX(3,FX_INK, Object.XPos, Object.YPos)
468
Object.InkEffect = 0
469
if Editor.ShowGizmos == true
470
Editor.DrawingOverlay = true
471
TempValue0 = Object.XPos
472
TempValue0 += 0x800000
473
TempValue1 = Object.YPos
474
TempValue1 -= 0xE00000
475
DrawArrow(Object.XPos, Object.YPos, TempValue0, TempValue1, 255, 255, 0)
476
Editor.DrawingOverlay = false
477
end if
478
break
479
case 2
480
Object.SpriteSheet = TempValue6
481
Object.InkEffect = 1
482
DrawSpriteFX(3,FX_INK, Object.XPos, Object.YPos)
483
Object.InkEffect = 0
484
if Editor.ShowGizmos == true
485
Editor.DrawingOverlay = true
486
TempValue0 = Object.XPos
487
TempValue0 += 0x400000
488
TempValue1 = Object.YPos
489
TempValue1 -= 0xC00000
490
DrawArrow(Object.XPos, Object.YPos, TempValue0, TempValue1, 255, 255, 0)
491
Editor.DrawingOverlay = false
492
end if
493
break
494
case 3
495
case 6
496
Object.SpriteSheet = TempValue5
497
TempValue0 = Object.XPos
498
TempValue0 -= 0x100000
499
TempValue1 = Object.YPos
500
TempValue1 -= 0x100000
501
DrawRectWorld(TempValue0,TempValue1,32,32,96,96,192,255)
502
503
TempValue0 = Object.XPos
504
TempValue0 -= 0x80000
505
TempValue1 = Object.YPos
506
TempValue1 -= 0x80000
507
DrawSpriteXY(1, TempValue0, TempValue1)
508
509
TempValue0 += 0x100000
510
DrawSpriteXY(1, TempValue0, TempValue1)
511
512
TempValue1 += 0x100000
513
DrawSpriteXY(1, TempValue0, TempValue1)
514
515
TempValue0 -= 0x100000
516
DrawSpriteXY(1, TempValue0, TempValue1)
517
break
518
case 7
519
Object.SpriteSheet = TempValue5
520
TempValue0 = Object.XPos
521
TempValue0 -= 0x100000
522
TempValue1 = Object.YPos
523
TempValue1 -= 0xC0000
524
DrawSpriteXY(1, TempValue0, TempValue1)
525
526
Object.SpriteSheet = TempValue6
527
Object.InkEffect = 1
528
DrawSpriteFX(2, FX_INK, Object.XPos, Object.YPos)
529
Object.InkEffect = 0
530
531
if Editor.ShowGizmos == true
532
Editor.DrawingOverlay = true
533
TempValue0 = Object.XPos
534
TempValue0 -= 0x200000
535
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, 255, 0)
536
Editor.DrawingOverlay = false
537
end if
538
break
539
case 4
540
Object.SpriteSheet = TempValue6
541
Object.InkEffect = 1
542
DrawSpriteFX(2, FX_INK, Object.XPos, Object.YPos)
543
Object.InkEffect = 0
544
545
if Editor.ShowGizmos == true
546
Editor.DrawingOverlay = true
547
TempValue0 = Object.XPos
548
TempValue0 += 0x200000
549
DrawArrow(Object.XPos, Object.YPos, TempValue0, Object.YPos, 255, 255, 0)
550
551
552
Editor.DrawingOverlay = false
553
end if
554
break
555
case 5
556
Object.SpriteSheet = TempValue7
557
Object.InkEffect = 1
558
DrawSpriteFX(4, FX_INK, Object.XPos, Object.YPos)
559
Object.InkEffect = 0
560
if Editor.ShowGizmos == true
561
Editor.DrawingOverlay = true
562
TempValue0 = Object.YPos
563
TempValue0 += 0x200000
564
DrawArrow(Object.XPos, Object.YPos, Object.XPos, TempValue0, 255, 255, 0)
565
Editor.DrawingOverlay = false
566
end if
567
break
568
default
569
Object.SpriteSheet = TempValue5
570
DrawSprite(0)
571
end switch
572
end sub
573
574
575
sub RSDKLoad
576
LoadSpriteSheet("Global/Display.gif")
577
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
578
SpriteFrame(-4, -4, 8, 8, 10, 98) // #1 - "Y"
579
580
LoadSpriteSheet("Players/Sonic2.gif")
581
SpriteFrame(-20, -20, 40, 40, 133, 171) // #2 - Sonic 3D Ramp Enter
582
SpriteFrame(-16, -20, 32, 40, 1, 169) // #3 - Sonic 3D Ramp Exit
583
584
LoadSpriteSheet("Players/Sonic3.gif")
585
SpriteFrame(-20, -24, 40, 48, 1, 83) // #4 - Sonic 3D Ramp Drop
586
587
588
AddEditorVariable("type")
589
SetActiveVariable("type")
590
AddEnumVariable("3D Ramp Run", RAMP3D_RUN)
591
AddEnumVariable("3D Ramp Exit Boost (Unused)", RAMP3D_EXIT_UNUSED)
592
AddEnumVariable("3D Ramp Exit ", RAMP3D_EXIT)
593
AddEnumVariable("3D Ramp (Set YBound)", RAMP3D_SET_YBOUND)
594
AddEnumVariable("3D Ramp Start", RAMP3D_ENTER)
595
AddEnumVariable("3D Ramp Drop", RAMP3D_DROP)
596
AddEnumVariable("3D Ramp (Set YBound 2)", RAMP3D_SET_YBOUND2)
597
AddEnumVariable("3D Ramp Top Run", RAMP3D_RUN_FROM_TOP)
598
AddEnumVariable("3D Ramp Exit Boost", RAMP3D_EXIT_BOOST)
599
end sub
600
601