Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/Dango.txt
1319 views
1
//-------------------Sonic CD Dango Script--------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.XOriginPos
8
#alias Object.Value2 : Object.YOriginPos
9
#alias Object.Value3 : Object.XVelocity
10
#alias Object.Value4 : Object.ChaseChain
11
12
#alias Object.PropertyValue : Object.Quality
13
14
// States
15
#alias 0 : DANGO_WALK
16
#alias 1 : DANGO_CURL1
17
#alias 2 : DANGO_CURL2
18
#alias 3 : DANGO_CHARGEROLL
19
#alias 4 : DANGO_ROLLING
20
#alias 5 : DANGO_UNCURL1
21
#alias 6 : DANGO_UNCURL2
22
#alias 7 : DANGO_UNCURLED
23
#alias 8 : DANGO_OFFSCREEN // Unused
24
25
// Gravity
26
#alias 1 : GRAVITY_AIR
27
28
// Collision Sides
29
#alias 0 : CSIDE_FLOOR
30
#alias 1 : CSIDE_LWALL
31
#alias 2 : CSIDE_RWALL
32
33
// Priority
34
#alias 0 : PRIORITY_BOUNDS
35
#alias 1 : PRIORITY_ACTIVE
36
37
// Badnik Quality / Property Values
38
#alias 0 : GOOD_QUALITY
39
#alias 1 : BAD_QUALITY
40
41
42
sub ObjectMain
43
if Object.Quality == GOOD_QUALITY
44
switch Object.State
45
case DANGO_WALK
46
Object.Priority = PRIORITY_ACTIVE
47
Object.Frame = Object.Timer
48
Object.Frame /= 10
49
Object.Timer++
50
Object.Timer %= 20
51
Object.XPos += Object.XVelocity
52
53
if Object.Direction == FACING_RIGHT
54
ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)
55
else
56
ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)
57
end if
58
59
if CheckResult == false
60
FlipSign(Object.XVelocity)
61
Object.Direction++
62
Object.Direction &= FACING_LEFT
63
Object.ChaseChain = 0
64
else
65
if Object.XVelocity > 0
66
ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)
67
if CheckResult == true
68
FlipSign(Object.XVelocity)
69
Object.Direction++
70
Object.Direction &= FACING_LEFT
71
Object.ChaseChain = 0
72
end if
73
else
74
ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)
75
if CheckResult == true
76
FlipSign(Object.XVelocity)
77
Object.Direction++
78
Object.Direction &= FACING_LEFT
79
Object.ChaseChain = 0
80
end if
81
end if
82
end if
83
break
84
case DANGO_CURL1
85
Object.Frame = 4
86
if Object.Timer < 8
87
Object.Timer++
88
else
89
Object.Timer = 0
90
Object.State++
91
end if
92
break
93
94
case DANGO_CURL2
95
Object.Frame = 5
96
if Object.Timer < 6
97
Object.Timer++
98
else
99
Object.Timer = 0
100
Object.State++
101
end if
102
break
103
104
case DANGO_CHARGEROLL
105
Object.Frame = Object.AnimationTimer
106
Object.Frame /= 5
107
Object.Frame += 6
108
Object.AnimationTimer++
109
Object.AnimationTimer %= 10
110
if Object.Timer < 34
111
Object.Timer++
112
else
113
Object.Timer = 0
114
Object.State++
115
if Object.Direction == FACING_RIGHT
116
Object.XVelocity = -0x40000
117
else
118
Object.XVelocity = 0x40000
119
end if
120
end if
121
break
122
123
case DANGO_ROLLING
124
Object.Frame = Object.AnimationTimer
125
Object.Frame /= 5
126
Object.Frame += 6
127
Object.AnimationTimer++
128
Object.AnimationTimer %= 10
129
Object.XPos += Object.XVelocity
130
131
if Object.Direction == FACING_RIGHT
132
ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)
133
else
134
ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)
135
end if
136
137
if CheckResult == false
138
Object.State++
139
Object.ChaseChain++
140
else
141
if Object.XVelocity > 0
142
ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)
143
if CheckResult == true
144
Object.State++
145
Object.ChaseChain++
146
end if
147
else
148
ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)
149
if CheckResult == true
150
Object.State++
151
Object.ChaseChain++
152
end if
153
end if
154
end if
155
break
156
157
case DANGO_UNCURL1
158
Object.Frame = 5
159
if Object.Timer < 6
160
Object.Timer++
161
else
162
Object.Timer = 0
163
Object.State++
164
end if
165
break
166
167
case DANGO_UNCURL2
168
Object.Frame = 4
169
if Object.Timer < 8
170
Object.Timer++
171
else
172
Object.Timer = 0
173
Object.State++
174
end if
175
break
176
177
178
case DANGO_UNCURLED
179
Object.Frame = 0
180
if Object.Timer < 16
181
Object.Timer++
182
else
183
Object.Timer = 0
184
Object.State = DANGO_WALK
185
if Object.ChaseChain > 7
186
// Tried going in the same direction 8 times now...
187
// Even if the player's the other way, go ahead and change directions
188
Object.Direction++
189
Object.Direction &= FACING_LEFT
190
Object.ChaseChain = 0
191
end if
192
193
if Object.Direction == FACING_RIGHT
194
Object.XVelocity = -0x6000
195
else
196
Object.XVelocity = 0x6000
197
end if
198
end if
199
break
200
201
case DANGO_OFFSCREEN
202
// This state is unused, but it serves just about the same buffer purpose as it does with other badniks
203
if Object.OutOfBounds == true
204
Object.State = DANGO_WALK
205
Object.Priority = PRIORITY_BOUNDS
206
end if
207
break
208
end switch
209
else
210
switch Object.State
211
case DANGO_WALK
212
Object.Priority = PRIORITY_ACTIVE
213
Object.Frame = Object.Timer
214
Object.Frame /= 30
215
Object.Frame += 2
216
217
Object.Timer++
218
Object.Timer %= 60
219
220
Object.XPos += Object.XVelocity
221
222
if Object.Direction == FACING_RIGHT
223
ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)
224
else
225
ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)
226
end if
227
228
if CheckResult == false
229
FlipSign(Object.XVelocity)
230
Object.Direction++
231
Object.Direction &= FACING_LEFT
232
Object.ChaseChain = 0
233
else
234
if Object.XVelocity > 0
235
ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)
236
if CheckResult == true
237
FlipSign(Object.XVelocity)
238
Object.Direction++
239
Object.Direction &= FACING_LEFT
240
Object.ChaseChain = 0
241
end if
242
else
243
ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)
244
if CheckResult == true
245
FlipSign(Object.XVelocity)
246
Object.Direction++
247
Object.Direction &= FACING_LEFT
248
Object.ChaseChain = 0
249
end if
250
end if
251
end if
252
break
253
254
case DANGO_CURL1
255
Object.Frame = 4
256
if Object.Timer < 20
257
Object.Timer++
258
else
259
Object.Timer = 0
260
Object.State++
261
end if
262
break
263
264
case DANGO_CURL2
265
Object.Frame = 5
266
if Object.Timer < 12
267
Object.Timer++
268
else
269
Object.Timer = 0
270
Object.State++
271
end if
272
break
273
274
case DANGO_CHARGEROLL
275
Object.Frame = Object.AnimationTimer
276
Object.Frame /= 10
277
Object.Frame += 8
278
Object.AnimationTimer++
279
Object.AnimationTimer %= 20
280
if Object.Timer < 96
281
Object.Timer++
282
else
283
Object.Timer = 0
284
Object.State++
285
if Object.Direction == FACING_RIGHT
286
Object.XVelocity = -0x10000
287
else
288
Object.XVelocity = 0x10000
289
end if
290
end if
291
break
292
293
294
case DANGO_ROLLING
295
Object.Frame = Object.AnimationTimer
296
Object.Frame /= 10
297
Object.Frame += 8
298
Object.AnimationTimer++
299
Object.AnimationTimer %= 20
300
Object.XPos += Object.XVelocity
301
302
if Object.Direction == FACING_RIGHT
303
ObjectTileGrip(CSIDE_FLOOR, -5, 15, 0)
304
else
305
ObjectTileGrip(CSIDE_FLOOR, 5, 15, 0)
306
end if
307
308
if CheckResult == false
309
Object.State++
310
Object.ChaseChain++
311
else
312
if Object.XVelocity > 0
313
ObjectTileCollision(CSIDE_LWALL, 16, 8, 0)
314
if CheckResult == true
315
Object.State++
316
Object.ChaseChain++
317
end if
318
else
319
ObjectTileCollision(CSIDE_RWALL, -16, 8, 0)
320
if CheckResult == true
321
Object.State++
322
Object.ChaseChain++
323
end if
324
end if
325
end if
326
break
327
328
case DANGO_UNCURL1
329
Object.Frame = 5
330
if Object.Timer < 12
331
Object.Timer++
332
else
333
Object.Timer = 0
334
Object.State++
335
end if
336
break
337
338
case DANGO_UNCURL2
339
Object.Frame = 4
340
if Object.Timer < 20
341
Object.Timer++
342
else
343
Object.Timer = 0
344
Object.State++
345
end if
346
break
347
348
case DANGO_UNCURLED
349
Object.Frame = 2
350
if Object.Timer < 64
351
Object.Timer++
352
else
353
Object.Timer = 0
354
Object.State = DANGO_WALK
355
if Object.ChaseChain > 7
356
// Been going in the same direction for 8 cycles now...
357
// Even if it may be opposite of the player, go ahead and change direction because much isn't happening now anyway
358
Object.Direction++
359
Object.Direction &= FACING_LEFT
360
Object.ChaseChain = 0
361
end if
362
363
if Object.Direction == FACING_RIGHT
364
Object.XVelocity = -0x1000
365
else
366
Object.XVelocity = 0x1000
367
end if
368
end if
369
break
370
371
case DANGO_OFFSCREEN
372
// This state is unused as Dango uses a simpler OOB process instead
373
if Object.OutOfBounds == true
374
Object.State = DANGO_WALK
375
Object.Priority = PRIORITY_BOUNDS
376
end if
377
break
378
end switch
379
end if
380
381
CallFunction(StageSetup_CheckGoodFuture)
382
383
// See if the Dango is out of bounds
384
if Object.OutOfBounds == true
385
TempValue0 = Object.XPos
386
TempValue1 = Object.YPos
387
Object.XPos = Object.XOriginPos
388
Object.YPos = Object.YOriginPos
389
if Object.OutOfBounds == true
390
// It is, so in that case it's clear to restore the Dango to its original spot
391
Object.Priority = PRIORITY_BOUNDS
392
Object.State = DANGO_WALK
393
Object.Timer = 0
394
Object.Direction = FACING_RIGHT
395
Object.ChaseChain = 0
396
397
if Object.Quality == GOOD_QUALITY
398
Object.XVelocity = -0x6000
399
else
400
Object.XVelocity = -0x1000
401
end if
402
else
403
Object.XPos = TempValue0
404
Object.YPos = TempValue1
405
end if
406
end if
407
end sub
408
409
410
sub ObjectPlayerInteraction
411
if Object.State == DANGO_WALK
412
// If the Dango's just wandering, then check to see if the player's stepped within activation range
413
414
if Object.Direction == FACING_RIGHT
415
PlayerObjectCollision(C_TOUCH, -112, -128, 0, 128)
416
else
417
PlayerObjectCollision(C_TOUCH, 0, -128, 112, 128)
418
end if
419
420
if CheckResult == true
421
// On the attack!
422
Object.State = DANGO_CURL1
423
end if
424
end if
425
426
switch Object.State
427
case DANGO_WALK
428
case DANGO_CURL1
429
case DANGO_CURL2
430
case DANGO_UNCURL1
431
case DANGO_UNCURL2
432
case DANGO_UNCURLED
433
#platform: Use_Standalone
434
PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)
435
#endplatform
436
#platform: Use_Origins
437
PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)
438
#endplatform
439
if CheckResult == true
440
CallFunction(Player_BadnikBreak)
441
end if
442
break
443
444
case DANGO_CHARGEROLL
445
#platform: Use_Standalone
446
PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)
447
#endplatform
448
#platform: Use_Origins
449
PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)
450
#endplatform
451
if CheckResult == true
452
CheckEqual(Player.Animation, ANI_JUMPING)
453
TempValue0 = CheckResult
454
CheckEqual(Player.Animation, ANI_SPINDASH)
455
TempValue0 |= CheckResult
456
if TempValue0 == true
457
// The player's rolled towards the Dango, so bounce the player back
458
Player.Speed = Player.XPos
459
Player.Speed -= Object.XPos
460
Player.Speed >>= 2
461
Player.XVelocity = Player.Speed
462
463
// Account for aerial bouncing too if needed
464
if Player.Gravity == GRAVITY_AIR
465
Player.YVelocity = Player.YPos
466
Player.YVelocity -= Object.YPos
467
Player.YVelocity >>= 2
468
end if
469
else
470
// Hurt the player
471
// (Note that there are edge cases with Tails where he may end up breaking the Dango with his tails, instead)
472
CallFunction(Player_BadnikBreak)
473
end if
474
end if
475
break
476
477
case DANGO_ROLLING
478
#platform: Use_Standalone
479
PlayerObjectCollision(C_TOUCH, -14, -10, 14, 10)
480
#endplatform
481
#platform: Use_Origins
482
PlayerObjectCollision(C_ENEMY, -14, -10, 14, 10)
483
#endplatform
484
if CheckResult == true
485
CheckEqual(Player.Animation, ANI_JUMPING)
486
TempValue0 = CheckResult
487
CheckEqual(Player.Animation, ANI_SPINDASH)
488
TempValue0 |= CheckResult
489
if TempValue0 == true
490
// The player's rolled towards the Dango, so recoil the both of them
491
Object.XVelocity = Player.XVelocity
492
Player.Speed = Player.XPos
493
Player.Speed -= Object.XPos
494
Player.Speed >>= 2
495
Player.XVelocity = Player.Speed
496
497
if Player.Gravity == GRAVITY_AIR
498
// Account for Y recoil, too
499
Player.YVelocity = Player.YPos
500
Player.YVelocity -= Object.YPos
501
Player.YVelocity >>= 2
502
else
503
// The player is on the ground, make them bounce back rolling
504
Player.State = Player_State_Roll
505
Player.Animation = ANI_JUMPING
506
end if
507
else
508
// Hurt the player
509
// (See above note about Tails's fluffy but dangerous parts)
510
CallFunction(Player_BadnikBreak)
511
end if
512
end if
513
break
514
515
end switch
516
end sub
517
518
519
sub ObjectDraw
520
if Object.State < 8
521
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
522
end if
523
end sub
524
525
526
sub ObjectStartup
527
LoadSpriteSheet("R8/Objects2.gif")
528
529
// Dango Frames
530
531
// 0-1 - Idle Animation, "Good" variant
532
SpriteFrame(-16, -7, 32, 24, 1, 84)
533
SpriteFrame(-16, -7, 32, 24, 1, 109)
534
535
// 2-3 - Idle Animation, "Bad" variant (version with the cracked shell frames)
536
SpriteFrame(-16, -7, 32, 24, 34, 84)
537
SpriteFrame(-16, -7, 32, 24, 34, 109)
538
539
// 4-5 - Curl
540
SpriteFrame(-16, -16, 32, 32, 34, 134)
541
SpriteFrame(-16, -16, 32, 32, 1, 167)
542
543
// 6-9 - Rolling Frames
544
SpriteFrame(-16, -15, 32, 32, 34, 167)
545
SpriteFrame(-16, -15, 32, 32, 124, 223)
546
SpriteFrame(-16, -16, 32, 32, 1, 134)
547
SpriteFrame(-16, -15, 32, 32, 34, 167)
548
549
// Cycle through the level and find all Dango objects
550
ArrayPos0 = 32
551
while ArrayPos0 < 1056
552
if Object[ArrayPos0].Type == TypeName[Dango]
553
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
554
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
555
if Object[ArrayPos0].Quality == GOOD_QUALITY
556
Object[ArrayPos0].XVelocity = -0x6000
557
else
558
Object[ArrayPos0].XVelocity = -0x1000
559
end if
560
end if
561
ArrayPos0++
562
loop
563
end sub
564
565
566
// ========================
567
// Editor Subs
568
// ========================
569
570
sub RSDKEdit
571
if Editor.ReturnVariable == true
572
switch Editor.VariableID
573
case EDIT_VAR_PROPVAL // Property Value
574
CheckResult = Object.PropertyValue
575
CheckResult &= 1
576
break
577
case 0 // condition
578
CheckResult = Object.PropertyValue
579
CheckResult &= 1
580
break
581
end switch
582
else
583
switch Editor.VariableID
584
case EDIT_VAR_PROPVAL // Property Value
585
Object.PropertyValue = Editor.VariableValue
586
Object.PropertyValue &= 1
587
break
588
case 0 // condition
589
Object.PropertyValue = Editor.VariableValue
590
Object.PropertyValue &= 1
591
break
592
end switch
593
end if
594
end sub
595
596
sub RSDKDraw
597
DrawSprite(Object.PropertyValue)
598
end sub
599
600
601
sub RSDKLoad
602
LoadSpriteSheet("R8/Objects2.gif")
603
// Dango Frames
604
605
// 0-1 - Idle Animation, "Good" variant
606
SpriteFrame(-16, -7, 32, 24, 1, 84)
607
608
// 2-3 - Idle Animation, "Bad" variant (version with the cracked shell frames)
609
SpriteFrame(-16, -7, 32, 24, 34, 84)
610
611
AddEditorVariable("condition")
612
SetActiveVariable("condition")
613
AddEnumVariable("Good Quality", GOOD_QUALITY)
614
AddEnumVariable("Bad Quality", BAD_QUALITY)
615
end sub
616
617