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