Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/R6BossDSetup.txt
1319 views
1
//---------------Sonic CD R6 Boss D Setup Script--------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.PaletteBank
7
#alias Object.Value2 : Object.AlarmTimer
8
#alias Object.Value3 : Object.AlarmTile
9
#alias Object.Value4 : Object.LightTile
10
#alias Object.Value5 : Object.ElectricTile
11
#alias Object.Value6 : Object.BounceFloorAnim
12
#alias Object.Value7 : Object.BounceFloorTile
13
#alias Object.Scale : Object.BounceFloorFlag
14
#alias Object.Direction : Object.WebDirection
15
16
// Player Aliases
17
#alias Player.Value4 : Player.InvincibleTimer
18
19
// States
20
#alias 2 : R6D_SETUP_WEB_SHOCK // Unused in boss stages
21
22
// Web Directions
23
#alias 0 : VERTICAL_WEB
24
#alias 1 : HORIZONTAL_WEB
25
#alias 2 : DIAGONAL_WEB
26
27
// Gravity
28
#alias 1 : GRAVITY_AIR
29
30
// Stage SFX
31
#alias 0 : SFX_S_BOUNCEFLOOR
32
#alias 2 : SFX_S_CATCH
33
34
// Priority
35
#alias 1 : PRIORITY_ACTIVE
36
37
// Tile Info
38
#alias 8 : TILEINFO_ANGLEB
39
40
41
sub ObjectMain
42
switch Object.AlarmTile
43
case 0
44
if Object.AlarmTimer < 15
45
Object.AlarmTimer++
46
else
47
Copy16x16Tile(646, 841)
48
Copy16x16Tile(809, 841)
49
Object.AlarmTimer = 0
50
Object.AlarmTile++
51
end if
52
break
53
case 1
54
if Object.AlarmTimer < 4
55
Object.AlarmTimer++
56
else
57
Copy16x16Tile(646, 842)
58
Copy16x16Tile(809, 842)
59
Object.AlarmTimer = 0
60
Object.AlarmTile++
61
end if
62
break
63
case 2
64
if Object.AlarmTimer < 9
65
Object.AlarmTimer++
66
else
67
Copy16x16Tile(646, 843)
68
Copy16x16Tile(809, 843)
69
Object.AlarmTimer = 0
70
Object.AlarmTile++
71
end if
72
break
73
case 3
74
if Object.AlarmTimer < 4
75
Object.AlarmTimer++
76
else
77
Copy16x16Tile(646, 840)
78
Copy16x16Tile(809, 840)
79
Object.AlarmTimer = 0
80
Object.AlarmTile = 0
81
end if
82
break
83
end switch
84
85
TempValue0 = Object.LightTile
86
TempValue0 &= 1
87
if TempValue0 == 0
88
TempValue0 = Object.LightTile
89
TempValue0 >>= 1
90
TempValue0 += 844
91
Copy16x16Tile(647, TempValue0)
92
end if
93
Object.LightTile++
94
Object.LightTile %= 24
95
96
TempValue0 = Object.ElectricTile
97
TempValue0 %= 5
98
if TempValue0 == 0
99
TempValue0 = Object.ElectricTile
100
TempValue0 /= 5
101
TempValue0 += 856
102
Copy16x16Tile(648, TempValue0)
103
TempValue0 += 3
104
Copy16x16Tile(649, TempValue0)
105
end if
106
Object.ElectricTile++
107
Object.ElectricTile %= 15
108
109
TempValue0 = Object.BounceFloorAnim
110
TempValue0 &= 1
111
if TempValue0 == 0
112
TempValue0 = Object.BounceFloorTile
113
TempValue0 += 862
114
Object.BounceFloorTile++
115
Object.BounceFloorTile %= 6
116
Copy16x16Tile(543, TempValue0)
117
end if
118
Object.BounceFloorAnim++
119
Object.BounceFloorAnim &= 511
120
121
Object.BounceFloorFlag = true
122
123
TempValue0 = Object.PaletteBank
124
TempValue0 >>= 1
125
SetActivePalette(TempValue0, 0, Screen.YSize)
126
Object.PaletteBank++
127
Object.PaletteBank %= 6
128
end sub
129
130
131
sub ObjectPlayerInteraction
132
TempValue2 = Player.XPos
133
TempValue2 >>= 16
134
TempValue2 += Player.CollisionRight
135
TempValue3 = Player.YPos
136
TempValue3 >>= 16
137
TempValue3 += Player.CollisionBottom
138
TempValue3 += 2
139
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
140
141
TempValue2 = Player.XPos
142
TempValue2 >>= 16
143
TempValue2 += Player.CollisionLeft
144
Get16x16TileInfo(TempValue1, TempValue2, TempValue3, TILEINFO_ANGLEB)
145
// Bug Details:
146
// Sonic Team updated the normal bounce floor (which is R6BounceFloor in Origins for the Past and Present)
147
// to prevent Knuckles from disabling his collisions when climbing onto the floor (they knew about this bug)
148
// However, they didn't update it here and in R6BossCSetup.
149
TempValue0 |= TempValue1
150
if TempValue0 == true
151
if Object.BounceFloorFlag == true
152
if Player.YVelocity > -1
153
Player.Animation = ANI_JUMPING
154
Player.Gravity = GRAVITY_AIR
155
Player.Timer = 0
156
Player.YVelocity = -0x160000
157
158
#platform: Use_Origins
159
Player.State = Player_State_Air_NoDropDash
160
#endplatform
161
162
#platform: Use_Standalone
163
Player.State = Player_State_Air
164
#endplatform
165
PlayStageSfx(SFX_S_BOUNCEFLOOR, false)
166
167
#platform: Use_Haptics
168
HapticEffect(60, 0, 0, 0)
169
#endplatform
170
171
end if
172
end if
173
end if
174
TempValue2 -= Player.CollisionLeft
175
TempValue3 -= Player.CollisionBottom
176
TempValue3 -= 2
177
// You will see constant checks for R6D_SETUP_WEB_SHOCK state
178
// but the code to reach that state is removed, since there are no shock webs on the boss stage
179
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
180
switch TempValue0
181
case 2
182
if Player.InvincibleTimer == 0
183
Player.State = Player_State_GotHit
184
if Player.Direction == FACING_LEFT
185
Player.Speed = 0x20000
186
else
187
Player.Speed = -0x20000
188
end if
189
end if
190
break
191
case 5
192
if Object.State == R6D_SETUP_WEB_SHOCK
193
if Player.InvincibleTimer == 0
194
Player.State = Player_State_GotHit
195
if Player.Direction == FACING_LEFT
196
Player.Speed = 0x20000
197
else
198
Player.Speed = -0x20000
199
end if
200
end if
201
end if
202
break
203
case 6
204
if Object.State == R6D_SETUP_WEB_SHOCK
205
if Object.WebDirection == VERTICAL_WEB
206
if Player.InvincibleTimer == 0
207
Player.State = Player_State_GotHit
208
if Player.Direction == FACING_LEFT
209
Player.Speed = 0x20000
210
else
211
Player.Speed = -0x20000
212
end if
213
end if
214
end if
215
end if
216
break
217
case 7
218
if Object.State == R6D_SETUP_WEB_SHOCK
219
if Object.WebDirection == HORIZONTAL_WEB
220
if Player.InvincibleTimer == 0
221
Player.State = Player_State_GotHit
222
if Player.Direction == FACING_LEFT
223
Player.Speed = 0x20000
224
else
225
Player.Speed = -0x20000
226
end if
227
end if
228
end if
229
end if
230
break
231
case 8
232
if Object.State == R6D_SETUP_WEB_SHOCK
233
if Object.WebDirection == DIAGONAL_WEB
234
if Player.InvincibleTimer == 0
235
Player.State = Player_State_GotHit
236
if Player.Direction == FACING_LEFT
237
Player.Speed = 0x20000
238
else
239
Player.Speed = -0x20000
240
end if
241
end if
242
end if
243
end if
244
break
245
end switch
246
247
TempValue3 -= 4
248
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
249
switch TempValue0
250
case 2
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
break
260
case 5
261
if Object.State == R6D_SETUP_WEB_SHOCK
262
if Player.InvincibleTimer == 0
263
Player.State = Player_State_GotHit
264
if Player.Direction == FACING_LEFT
265
Player.Speed = 0x20000
266
else
267
Player.Speed = -0x20000
268
end if
269
end if
270
end if
271
break
272
case 6
273
if Object.State == R6D_SETUP_WEB_SHOCK
274
if Object.WebDirection == VERTICAL_WEB
275
if Player.InvincibleTimer == 0
276
Player.State = Player_State_GotHit
277
if Player.Direction == FACING_LEFT
278
Player.Speed = 0x20000
279
else
280
Player.Speed = -0x20000
281
end if
282
end if
283
end if
284
end if
285
break
286
case 7
287
if Object.State == R6D_SETUP_WEB_SHOCK
288
if Object.WebDirection == HORIZONTAL_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
case 8
301
if Object.State == R6D_SETUP_WEB_SHOCK
302
if Object.WebDirection == DIAGONAL_WEB
303
if Player.InvincibleTimer == 0
304
Player.State = Player_State_GotHit
305
if Player.Direction == FACING_LEFT
306
Player.Speed = 0x20000
307
else
308
Player.Speed = -0x20000
309
end if
310
end if
311
end if
312
end if
313
break
314
end switch
315
316
TempValue3 += 4
317
TempValue3 += Player.CollisionTop
318
Get16x16TileInfo(TempValue0, TempValue2, TempValue3, TILEINFO_ANGLEB)
319
if TempValue0 == 3
320
TempValue4 = TempValue3
321
TempValue4 &= 15
322
if TempValue4 < 8
323
if Player.State != Player_State_HangBar
324
Player.State = Player_State_HangBar
325
Player.YVelocity = 0
326
Player.Animation = ANI_HANGING
327
TempValue3 &= 0x7FF0
328
TempValue3 += 4
329
TempValue3 -= Player.CollisionTop
330
Player.iYPos = TempValue3
331
PlayStageSfx(SFX_S_CATCH, false)
332
Screen.AdjustCameraY = 0
333
end if
334
end if
335
end if
336
end sub
337
338
339
sub ObjectStartup
340
Object[19].Type = TypeName[R6 Setup]
341
Object[19].Priority = PRIORITY_ACTIVE
342
Object[19].DrawOrder = 2
343
344
TempValue0 = 1
345
while TempValue0 < 3
346
RotatePalette(161, 163, 0)
347
CopyPalette(0, TempValue0)
348
TempValue0++
349
loop
350
RotatePalette(161, 163, 0)
351
end sub
352
353
354
// ========================
355
// Editor Subs
356
// ========================
357
358
sub RSDKDraw
359
DrawSprite(0)
360
end sub
361
362
363
sub RSDKLoad
364
LoadSpriteSheet("Global/Display.gif")
365
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
366
367
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
368
end sub
369
370