Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/R6DSetup.txt
1319 views
1
//-----------------Sonic CD R6 D Setup 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.PaletteBank
8
#alias Object.Value2 : Object.AlarmTimer
9
#alias Object.Value3 : Object.AlarmTile
10
#alias Object.Value4 : Object.LightTile
11
#alias Object.Value5 : Object.ElectricTile
12
#alias Object.Value6 : Object.BounceFloorAnim
13
#alias Object.Value7 : Object.BounceFloorTile
14
#alias Object.Scale : Object.BounceFloorFlag
15
#alias Object.Direction : Object.WebDirection
16
17
// Player Aliases
18
#alias Player.Value4 : Player.InvincibleTimer
19
20
// States
21
#alias 0 : R6D_SETUP_PREPARE_CHARGE
22
#alias 1 : R6D_SETUP_WEB_CHARGE
23
#alias 2 : R6D_SETUP_WEB_SHOCK
24
25
// Web Directions
26
#alias 0 : VERTICAL_WEB
27
#alias 1 : HORIZONTAL_WEB
28
#alias 2 : DIAGONAL_WEB
29
30
// Gravity
31
#alias 1 : GRAVITY_AIR
32
33
// Stage SFX
34
#alias 0 : SFX_S_BOUNCEFLOOR
35
#alias 1 : SFX_S_ELECTRICITY
36
#alias 2 : SFX_S_CATCH
37
38
// Priority
39
#alias 1 : PRIORITY_ACTIVE
40
41
// Tile Info
42
#alias 8 : TILEINFO_ANGLEB
43
44
45
sub ObjectMain
46
switch Object.State
47
case R6D_SETUP_PREPARE_CHARGE
48
if Object.Timer < 240
49
Object.Timer++
50
else
51
PlayStageSfx(SFX_S_ELECTRICITY, false)
52
Object.Timer = 0
53
Object.State = R6D_SETUP_WEB_CHARGE
54
end if
55
break
56
57
case R6D_SETUP_WEB_CHARGE
58
if Object.Timer < 90
59
Object.Timer++
60
Object.Frame++
61
Object.Frame &= 1
62
else
63
Object.Timer = 0
64
Object.Frame = 2
65
Object.State = R6D_SETUP_WEB_SHOCK
66
end if
67
break
68
69
case R6D_SETUP_WEB_SHOCK
70
if Object.Timer < 120
71
Object.Timer++
72
Object.Frame++
73
if Object.Frame == 9
74
Object.Frame = 2
75
end if
76
else
77
Object.Timer = 0
78
Object.Frame = 0
79
Object.State = R6D_SETUP_PREPARE_CHARGE
80
Object.WebDirection++
81
Object.WebDirection %= 3
82
end if
83
break
84
end switch
85
86
switch Object.AlarmTile
87
case 0
88
if Object.AlarmTimer < 15
89
Object.AlarmTimer++
90
else
91
Copy16x16Tile(646, 841)
92
Copy16x16Tile(809, 841)
93
Object.AlarmTimer = 0
94
Object.AlarmTile++
95
end if
96
break
97
case 1
98
if Object.AlarmTimer < 4
99
Object.AlarmTimer++
100
else
101
Copy16x16Tile(646, 842)
102
Copy16x16Tile(809, 842)
103
Object.AlarmTimer = 0
104
Object.AlarmTile++
105
end if
106
break
107
case 2
108
if Object.AlarmTimer < 9
109
Object.AlarmTimer++
110
else
111
Copy16x16Tile(646, 843)
112
Copy16x16Tile(809, 843)
113
Object.AlarmTimer = 0
114
Object.AlarmTile++
115
end if
116
break
117
case 3
118
if Object.AlarmTimer < 4
119
Object.AlarmTimer++
120
else
121
Copy16x16Tile(646, 840)
122
Copy16x16Tile(809, 840)
123
Object.AlarmTimer = 0
124
Object.AlarmTile = 0
125
end if
126
break
127
end switch
128
129
TempValue0 = Object.LightTile
130
TempValue0 &= 1
131
if TempValue0 == 0
132
TempValue0 = Object.LightTile
133
TempValue0 >>= 1
134
TempValue0 += 844
135
Copy16x16Tile(647, TempValue0)
136
end if
137
Object.LightTile++
138
Object.LightTile %= 24
139
140
TempValue0 = Object.ElectricTile
141
TempValue0 %= 5
142
if TempValue0 == 0
143
TempValue0 = Object.ElectricTile
144
TempValue0 /= 5
145
TempValue0 += 856
146
Copy16x16Tile(648, TempValue0)
147
TempValue0 += 3
148
Copy16x16Tile(649, TempValue0)
149
end if
150
Object.ElectricTile++
151
Object.ElectricTile %= 15
152
153
TempValue0 = Object.BounceFloorAnim
154
TempValue0 &= 1
155
if TempValue0 == 0
156
TempValue0 = Object.BounceFloorTile
157
TempValue0 += 862
158
Object.BounceFloorTile++
159
Object.BounceFloorTile %= 6
160
Copy16x16Tile(543, TempValue0)
161
end if
162
Object.BounceFloorAnim++
163
Object.BounceFloorAnim &= 511
164
165
Object.BounceFloorFlag = true
166
167
TempValue0 = Object.PaletteBank
168
TempValue0 >>= 1
169
SetActivePalette(TempValue0, 0, 240)
170
Object.PaletteBank++
171
Object.PaletteBank %= 6
172
end sub
173
174
175
sub ObjectPlayerInteraction
176
TempValue2 = Player.XPos
177
TempValue2 >>= 16
178
TempValue2 += Player.CollisionRight
179
TempValue3 = Player.YPos
180
TempValue3 >>= 16
181
TempValue3 += Player.CollisionBottom
182
TempValue3 += 2
183
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
184
185
TempValue2 = Player.XPos
186
TempValue2 >>= 16
187
TempValue2 += Player.CollisionLeft
188
Get16x16TileInfo(TempValue1, TempValue2, TempValue3, TILEINFO_ANGLEB)
189
// Bug Details:
190
// Sonic Team updated the normal bounce floor (which is R6BounceFloor in Origins for the Past and Present)
191
// to prevent Knuckles from disabling his collisions when climbing onto the floor (they knew about this bug)
192
// However, they didn't update it here and in R6CSetup.
193
TempValue0 |= TempValue1
194
if TempValue0 == 1
195
if Object.BounceFloorFlag == true
196
if Player.YVelocity > -1
197
Player.Animation = ANI_JUMPING
198
Player.Gravity = GRAVITY_AIR
199
Player.Timer = 0
200
Player.YVelocity = -0x160000
201
202
#platform: Use_Origins
203
Player.State = Player_State_Air_NoDropDash
204
#endplatform
205
#platform: Use_Standalone
206
Player.State = Player_State_Air
207
#endplatform
208
209
PlayStageSfx(SFX_S_BOUNCEFLOOR, false)
210
211
#platform: Use_Haptics
212
HapticEffect(60, 0, 0, 0)
213
#endplatform
214
215
end if
216
end if
217
end if
218
219
TempValue2 -= Player.CollisionLeft
220
TempValue3 -= Player.CollisionBottom
221
TempValue3 -= 2
222
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
223
switch TempValue0
224
case 2
225
if Player.InvincibleTimer == 0
226
Player.State = Player_State_GotHit
227
if Player.Direction == FACING_LEFT
228
Player.Speed = 0x20000
229
else
230
Player.Speed = -0x20000
231
end if
232
end if
233
break
234
235
case 5
236
if Object.State == R6D_SETUP_WEB_SHOCK
237
if Player.InvincibleTimer == 0
238
Player.State = Player_State_GotHit
239
if Player.Direction == FACING_LEFT
240
Player.Speed = 0x20000
241
else
242
Player.Speed = -0x20000
243
end if
244
end if
245
end if
246
break
247
248
case 6
249
if Object.State == R6D_SETUP_WEB_SHOCK
250
if Object.WebDirection == VERTICAL_WEB
251
if Player.InvincibleTimer == 0
252
Player.State = Player_State_GotHit
253
if Player.Direction == FACING_LEFT
254
Player.Speed = 0x20000
255
else
256
Player.Speed = -0x20000
257
end if
258
end if
259
end if
260
end if
261
break
262
263
case 7
264
if Object.State == R6D_SETUP_WEB_SHOCK
265
if Object.WebDirection == HORIZONTAL_WEB
266
if Player.InvincibleTimer == 0
267
Player.State = Player_State_GotHit
268
if Player.Direction == FACING_LEFT
269
Player.Speed = 0x20000
270
else
271
Player.Speed = -0x20000
272
end if
273
end if
274
end if
275
end if
276
break
277
278
case 8
279
if Object.State == R6D_SETUP_WEB_SHOCK
280
if Object.WebDirection == DIAGONAL_WEB
281
if Player.InvincibleTimer == 0
282
Player.State = Player_State_GotHit
283
if Player.Direction == FACING_LEFT
284
Player.Speed = 0x20000
285
else
286
Player.Speed = -0x20000
287
end if
288
end if
289
end if
290
end if
291
break
292
end switch
293
294
TempValue3 -= 4
295
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
296
switch TempValue0
297
case 2
298
if Player.InvincibleTimer == 0
299
Player.State = Player_State_GotHit
300
if Player.Direction == FACING_LEFT
301
Player.Speed = 0x20000
302
else
303
Player.Speed = -0x20000
304
end if
305
end if
306
break
307
308
case 5
309
if Object.State == R6D_SETUP_WEB_SHOCK
310
if Player.InvincibleTimer == 0
311
Player.State = Player_State_GotHit
312
if Player.Direction == FACING_LEFT
313
Player.Speed = 0x20000
314
else
315
Player.Speed = -0x20000
316
end if
317
end if
318
end if
319
break
320
321
case 6
322
if Object.State == R6D_SETUP_WEB_SHOCK
323
if Object.WebDirection == VERTICAL_WEB
324
if Player.InvincibleTimer == 0
325
Player.State = Player_State_GotHit
326
if Player.Direction == FACING_LEFT
327
Player.Speed = 0x20000
328
else
329
Player.Speed = -0x20000
330
end if
331
end if
332
end if
333
end if
334
break
335
336
case 7
337
if Object.State == R6D_SETUP_WEB_SHOCK
338
if Object.WebDirection == HORIZONTAL_WEB
339
if Player.InvincibleTimer == 0
340
Player.State = Player_State_GotHit
341
if Player.Direction == FACING_LEFT
342
Player.Speed = 0x20000
343
else
344
Player.Speed = -0x20000
345
end if
346
end if
347
end if
348
end if
349
break
350
351
case 8
352
if Object.State == R6D_SETUP_WEB_SHOCK
353
if Object.WebDirection == DIAGONAL_WEB
354
if Player.InvincibleTimer == 0
355
Player.State = Player_State_GotHit
356
if Player.Direction == FACING_LEFT
357
Player.Speed = 0x20000
358
else
359
Player.Speed = -0x20000
360
end if
361
end if
362
end if
363
end if
364
break
365
end switch
366
367
TempValue3 += 4
368
TempValue3 += Player.CollisionTop
369
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
370
if TempValue0 == 3
371
TempValue4 = TempValue3
372
TempValue4 &= 15
373
if TempValue4 < 8
374
if Player.State != Player_State_HangBar
375
Player.State = Player_State_HangBar
376
Player.YVelocity = 0
377
Player.Animation = ANI_HANGING
378
TempValue3 &= 0x7FF0
379
TempValue3 += 4
380
TempValue3 -= Player.CollisionTop
381
Player.iYPos = TempValue3
382
PlayStageSfx(SFX_S_CATCH, false)
383
Screen.AdjustCameraY = 0
384
end if
385
end if
386
end if
387
end sub
388
389
390
sub ObjectDraw
391
if Object.State == R6D_SETUP_WEB_SHOCK
392
switch Object.Frame
393
case 2
394
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 64)
395
break
396
case 3
397
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 32)
398
break
399
case 4
400
DrawRect(0, 0, Screen.XSize, Screen.YSize, 255, 128, 255, 32)
401
break
402
case 5
403
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 64)
404
break
405
case 6
406
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 32)
407
break
408
case 7
409
DrawRect(0, 0, Screen.XSize, Screen.YSize, 255, 128, 255, 32)
410
break
411
case 8
412
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 32)
413
break
414
end switch
415
end if
416
end sub
417
418
419
sub ObjectStartup
420
Object[19].Type = TypeName[R6 Setup]
421
Object[19].Priority = PRIORITY_ACTIVE
422
Object[19].DrawOrder = 2
423
424
TempValue0 = 1
425
while TempValue0 < 3
426
RotatePalette(161, 163, 0)
427
CopyPalette(0, TempValue0)
428
TempValue0++
429
loop
430
RotatePalette(161, 163, 0)
431
end sub
432
433
434
// ========================
435
// Editor Subs
436
// ========================
437
438
sub RSDKDraw
439
DrawSprite(0)
440
end sub
441
442
443
sub RSDKLoad
444
LoadSpriteSheet("Global/Display.gif")
445
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
446
447
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
448
end sub
449
450