Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/R6Setup.txt
1319 views
1
//------------------Sonic CD R6 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 : R6_SETUP_PREPARE_CHARGE
22
#alias 1 : R6_SETUP_WEB_CHARGE
23
#alias 2 : R6_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 R6_SETUP_PREPARE_CHARGE
48
if Object.Timer < 480
49
Object.Timer++
50
else
51
PlayStageSfx(SFX_S_ELECTRICITY, false)
52
Object.Timer = 0
53
Object.State = R6_SETUP_WEB_CHARGE
54
end if
55
break
56
57
case R6_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 = R6_SETUP_WEB_SHOCK
66
end if
67
break
68
69
case R6_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 = R6_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(578, 801)
92
Copy16x16Tile(677, 801)
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(578, 802)
102
Copy16x16Tile(677, 802)
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(578, 803)
112
Copy16x16Tile(677, 803)
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(578, 800)
122
Copy16x16Tile(677, 800)
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 += 804
135
Copy16x16Tile(579, 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 += 816
146
Copy16x16Tile(580, TempValue0)
147
TempValue0 += 3
148
Copy16x16Tile(581, TempValue0)
149
end if
150
Object.ElectricTile++
151
Object.ElectricTile %= 15
152
153
if Object.BounceFloorAnim < 32
154
Object.BounceFloorAnim++
155
Object.BounceFloorFlag = false
156
else
157
if Object.BounceFloorAnim < 212
158
TempValue0 = Object.BounceFloorAnim
159
TempValue0 &= 1
160
if TempValue0 == 0
161
TempValue0 = Object.BounceFloorTile
162
TempValue0 += 822
163
Object.BounceFloorTile++
164
Object.BounceFloorTile %= 6
165
Copy16x16Tile(543, TempValue0)
166
end if
167
Object.BounceFloorAnim++
168
Object.BounceFloorFlag = true
169
else
170
Object.BounceFloorAnim = 0
171
Object.BounceFloorFlag = false
172
Copy16x16Tile(543, 822)
173
end if
174
end if
175
176
TempValue0 = Object.PaletteBank
177
TempValue0 >>= 1
178
SetActivePalette(TempValue0, 0, 240)
179
Object.PaletteBank++
180
Object.PaletteBank %= 6
181
end sub
182
183
184
sub ObjectPlayerInteraction
185
// They changed up how the Bounce Floor works in Origins Plus, see the new R6BounceFloor object
186
// This is just (most of) the code from Standalone here.
187
188
TempValue2 = Player.XPos
189
TempValue2 >>= 16
190
#platform: Use_Standalone
191
TempValue2 += Player.CollisionRight
192
#endplatform
193
TempValue3 = Player.YPos
194
TempValue3 >>= 16
195
#platform: Use_Standalone
196
TempValue3 += Player.CollisionBottom
197
TempValue3 += 2
198
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
199
200
TempValue2 = Player.XPos
201
TempValue2 >>= 16
202
TempValue2 += Player.CollisionLeft
203
Get16x16TileInfo(TempValue1, TempValue2, TempValue3, TILEINFO_ANGLEB)
204
205
TempValue0 |= TempValue1
206
if TempValue0 == 1
207
if Object.BounceFloorFlag == true
208
if Player.YVelocity > -1
209
Player.Animation = ANI_JUMPING
210
Player.Gravity = GRAVITY_AIR
211
Player.Timer = 0
212
Player.YVelocity = -0x160000
213
214
Player.State = Player_State_Air
215
216
PlayStageSfx(SFX_S_BOUNCEFLOOR, false)
217
#endplatform
218
#platform: Use_Haptics
219
HapticEffect(60, 0, 0, 0)
220
#endplatform
221
#platform: Use_Standalone
222
end if
223
end if
224
end if
225
TempValue2 -= Player.CollisionLeft
226
TempValue3 -= Player.CollisionBottom
227
TempValue3 -= 2
228
#endplatform
229
230
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
231
switch TempValue0
232
case 2
233
if Player.InvincibleTimer == 0
234
Player.State = Player_State_GotHit
235
if Player.Direction == FACING_LEFT
236
Player.Speed = 0x20000
237
else
238
Player.Speed = -0x20000
239
end if
240
end if
241
break
242
243
case 5
244
if Object.State == R6_SETUP_WEB_SHOCK
245
if Player.InvincibleTimer == 0
246
Player.State = Player_State_GotHit
247
if Player.Direction == FACING_LEFT
248
Player.Speed = 0x20000
249
else
250
Player.Speed = -0x20000
251
end if
252
end if
253
end if
254
break
255
256
case 6
257
if Object.State == R6_SETUP_WEB_SHOCK
258
if Object.WebDirection == VERTICAL_WEB
259
if Player.InvincibleTimer == 0
260
Player.State = Player_State_GotHit
261
if Player.Direction == FACING_LEFT
262
Player.Speed = 0x20000
263
else
264
Player.Speed = -0x20000
265
end if
266
end if
267
end if
268
end if
269
break
270
271
case 7
272
if Object.State == R6_SETUP_WEB_SHOCK
273
if Object.WebDirection == HORIZONTAL_WEB
274
if Player.InvincibleTimer == 0
275
Player.State = Player_State_GotHit
276
if Player.Direction == FACING_LEFT
277
Player.Speed = 0x20000
278
else
279
Player.Speed = -0x20000
280
end if
281
end if
282
end if
283
end if
284
break
285
286
case 8
287
if Object.State == R6_SETUP_WEB_SHOCK
288
if Object.WebDirection == DIAGONAL_WEB
289
if Player.InvincibleTimer == 0
290
Player.State = Player_State_GotHit
291
if Player.Direction == FACING_LEFT
292
Player.Speed = 0x20000
293
else
294
Player.Speed = -0x20000
295
end if
296
end if
297
end if
298
end if
299
break
300
end switch
301
302
TempValue3 -= 4
303
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
304
switch TempValue0
305
case 2
306
if Player.InvincibleTimer == 0
307
Player.State = Player_State_GotHit
308
if Player.Direction == FACING_LEFT
309
Player.Speed = 0x20000
310
else
311
Player.Speed = -0x20000
312
end if
313
end if
314
break
315
316
case 5
317
if Object.State == R6_SETUP_WEB_SHOCK
318
if Player.InvincibleTimer == 0
319
Player.State = Player_State_GotHit
320
if Player.Direction == FACING_LEFT
321
Player.Speed = 0x20000
322
else
323
Player.Speed = -0x20000
324
end if
325
end if
326
end if
327
break
328
329
case 6
330
if Object.State == R6_SETUP_WEB_SHOCK
331
if Object.WebDirection == VERTICAL_WEB
332
if Player.InvincibleTimer == 0
333
Player.State = Player_State_GotHit
334
if Player.Direction == FACING_LEFT
335
Player.Speed = 0x20000
336
else
337
Player.Speed = -0x20000
338
end if
339
end if
340
end if
341
end if
342
break
343
344
case 7
345
if Object.State == R6_SETUP_WEB_SHOCK
346
if Object.WebDirection == HORIZONTAL_WEB
347
if Player.InvincibleTimer == 0
348
Player.State = Player_State_GotHit
349
if Player.Direction == FACING_LEFT
350
Player.Speed = 0x20000
351
else
352
Player.Speed = -0x20000
353
end if
354
end if
355
end if
356
end if
357
break
358
359
case 8
360
if Object.State == R6_SETUP_WEB_SHOCK
361
if Object.WebDirection == DIAGONAL_WEB
362
if Player.InvincibleTimer == 0
363
Player.State = Player_State_GotHit
364
if Player.Direction == FACING_LEFT
365
Player.Speed = 0x20000
366
else
367
Player.Speed = -0x20000
368
end if
369
end if
370
end if
371
end if
372
break
373
end switch
374
375
TempValue3 += 4
376
TempValue3 += Player.CollisionTop
377
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
378
if TempValue0 == 3
379
TempValue4 = TempValue3
380
TempValue4 &= 15
381
if TempValue4 < 8
382
if Player.State != Player_State_HangBar
383
Player.State = Player_State_HangBar
384
Player.YVelocity = 0
385
Player.Animation = ANI_HANGING
386
TempValue3 &= 0x7FF0
387
TempValue3 += 4
388
TempValue3 -= Player.CollisionTop
389
Player.iYPos = TempValue3
390
PlayStageSfx(SFX_S_CATCH, false)
391
Screen.AdjustCameraY = 0
392
end if
393
end if
394
end if
395
end sub
396
397
398
sub ObjectDraw
399
if Object.State == R6_SETUP_WEB_SHOCK
400
switch Object.Frame
401
case 2
402
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 64)
403
break
404
405
case 3
406
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 32)
407
break
408
409
case 4
410
DrawRect(0, 0, Screen.XSize, Screen.YSize, 255, 128, 255, 32)
411
break
412
413
case 5
414
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 64)
415
break
416
417
case 6
418
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 32)
419
break
420
421
case 7
422
DrawRect(0, 0, Screen.XSize, Screen.YSize, 255, 128, 255, 32)
423
break
424
425
case 8
426
DrawRect(0, 0, Screen.XSize, Screen.YSize, 128, 0, 64, 32)
427
break
428
end switch
429
end if
430
end sub
431
432
433
sub ObjectStartup
434
Object[19].Type = TypeName[R6 Setup]
435
Object[19].Priority = PRIORITY_ACTIVE
436
Object[19].DrawOrder = 2
437
438
TempValue0 = 1
439
while TempValue0 < 3
440
RotatePalette(161, 163, 0)
441
CopyPalette(0, TempValue0)
442
TempValue0++
443
loop
444
RotatePalette(161, 163, 0)
445
end sub
446
447
448
// ========================
449
// Editor Subs
450
// ========================
451
452
sub RSDKDraw
453
DrawSprite(0)
454
end sub
455
456
457
sub RSDKLoad
458
LoadSpriteSheet("Global/Display.gif")
459
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
460
461
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
462
end sub
463
464