Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/BossFloorControl.txt
1319 views
1
//---------------Sonic CD Floor Control 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.XVelocity
8
#alias Object.Value3 : Object.RubbleTimer
9
#alias Object.Value4 : Object.RubbleYPos
10
#alias Object.Value5 : Object.TargetFloor
11
#alias Object.Value6 : Object.CurrentFloor
12
#alias Object.Value7 : Object.PlatformTimer
13
#alias Object.Scale : Object.SpikeAmount
14
15
#alias Object[-7].YPos : BossCamera.YPos
16
#alias Object[-6].YPos : FirstElectrode.YPos
17
#alias Object[-1].XPos : Boss.XPos
18
#alias Object[-1].YPos : Boss.YPos
19
20
21
#alias Object.YPos : BossPlat.YPos
22
#alias Object.Value2 : BossPlat.YVelocity
23
#alias Object.Value3 : BossPlat.FallSpeed
24
#alias Object.Value5 : BossPlat.FCEntityNo
25
26
#alias Object.XPos : FloorRubble.XPos
27
#alias Object.Value1 : FloorRubble.XVelocity
28
#alias Object.Value2 : FloorRubble.YVelocity
29
#alias Object.Value3 : FloorRubble.FallSpeed
30
31
// HUD Alias
32
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
33
34
// States
35
#alias 0 : FLOORCONTROL_INACTIVE
36
#alias 1 : FLOORCONTROL_SETUP_CRUMBLE
37
#alias 2 : FLOORCONTROL_SPAWN_FALL_OBJS
38
#alias 3 : FLOORCONTROL_ELEC_ARC
39
#alias 4 : FLOORCONTROL_TILE_SWAP
40
#alias 5 : FLOORCONTROL_COOLDOWN
41
42
// Stage SFX
43
#alias 1 : SFX_S_ELECTRICITY
44
#alias 12 : SFX_S_CRUMBLE
45
46
// Time Periods
47
#alias 2 : TIME_GOOD_FUTURE
48
49
50
// Function declarations
51
#function FloorControl_SpawnRubble
52
#function FloorControl_SpawnPlatFarLeft
53
#function FloorControl_SpawnPlatLeft
54
#function FloorControl_SpawnPlatRight
55
#function FloorControl_SpawnPlatFarRight
56
57
58
function FloorControl_SpawnRubble
59
CreateTempObject(TypeName[Floor Rubble], 0, Boss.XPos, Object.RubbleYPos)
60
Rand(FloorRubble[TempObjectPos].XPos, 160)
61
FloorRubble[TempObjectPos].XPos -= 80
62
FloorRubble[TempObjectPos].XPos <<= 16
63
FloorRubble[TempObjectPos].XPos += Boss.XPos
64
65
Rand(FloorRubble[TempObjectPos].XVelocity, 0x500)
66
TempValue0 = FloorRubble[TempObjectPos].XVelocity
67
FloorRubble[TempObjectPos].XVelocity -= 0x280
68
FloorRubble[TempObjectPos].XVelocity <<= 8
69
70
FloorRubble[TempObjectPos].YVelocity = 0x10000
71
72
FloorRubble[TempObjectPos].FallSpeed = 2048
73
TempValue0 &= 4095
74
FloorRubble[TempObjectPos].FallSpeed += TempValue0
75
end function
76
77
78
function FloorControl_SpawnPlatFarLeft
79
switch Object.TargetFloor
80
case 0
81
ArrayPos0 = 2
82
break
83
84
case 1
85
ArrayPos0 = 5
86
break
87
88
case 2
89
ArrayPos0 = 11
90
break
91
end switch
92
93
Object[+ArrayPos0].Type = TypeName[Boss Platform]
94
BossPlat[+ArrayPos0].YPos = Object.RubbleYPos
95
BossPlat[+ArrayPos0].YVelocity = 0
96
BossPlat[+ArrayPos0].FallSpeed = 2816
97
BossPlat[+ArrayPos0].FCEntityNo = Object.EntityNo
98
end function
99
100
101
function FloorControl_SpawnPlatLeft
102
switch Object.TargetFloor
103
case 0
104
ArrayPos0 = 3
105
break
106
107
case 1
108
ArrayPos0 = 6
109
break
110
111
case 2
112
ArrayPos0 = 12
113
break
114
end switch
115
116
Object[+ArrayPos0].Type = TypeName[Boss Platform]
117
BossPlat[+ArrayPos0].YPos = Object.RubbleYPos
118
BossPlat[+ArrayPos0].YVelocity = 0
119
BossPlat[+ArrayPos0].FallSpeed = 2816
120
BossPlat[+ArrayPos0].FCEntityNo = Object.EntityNo
121
end function
122
123
124
function FloorControl_SpawnPlatRight
125
switch Object.TargetFloor
126
case 0
127
ArrayPos0 = 1
128
break
129
130
case 1
131
ArrayPos0 = 7
132
break
133
134
case 2
135
ArrayPos0 = 10
136
break
137
end switch
138
139
Object[+ArrayPos0].Type = TypeName[Boss Platform]
140
BossPlat[+ArrayPos0].YPos = Object.RubbleYPos
141
BossPlat[+ArrayPos0].YVelocity = 0
142
BossPlat[+ArrayPos0].FallSpeed = 2816
143
BossPlat[+ArrayPos0].FCEntityNo = Object.EntityNo
144
end function
145
146
147
function FloorControl_SpawnPlatFarRight
148
switch Object.TargetFloor
149
case 0
150
ArrayPos0 = 4
151
break
152
153
case 1
154
ArrayPos0 = 8
155
break
156
157
case 2
158
ArrayPos0 = 9
159
break
160
end switch
161
162
Object[+ArrayPos0].Type = TypeName[Boss Platform]
163
BossPlat[+ArrayPos0].YPos = Object.RubbleYPos
164
BossPlat[+ArrayPos0].YVelocity = 0
165
BossPlat[+ArrayPos0].FallSpeed = 2816
166
BossPlat[+ArrayPos0].FCEntityNo = Object.EntityNo
167
end function
168
169
170
sub ObjectMain
171
if Player.State == Player_State_Fly
172
if Player.Timer < 360
173
Player.Timer = 360
174
end if
175
end if
176
TempValue0 = BossCamera.YPos
177
TempValue0 += 0x800000
178
TempValue0 -= Player.YPos
179
TempValue0 >>= 25
180
181
if TempValue0 < Object.CurrentFloor
182
//Restore the chunks to their turned off versions
183
switch Object.TargetFloor
184
case 0
185
SetTileLayerEntry(500, 0, 20, 9)
186
SetTileLayerEntry(501, 0, 21, 9)
187
SetTileLayerEntry(506, 0, 22, 9)
188
case 1
189
SetTileLayerEntry(500, 0, 20, 5)
190
SetTileLayerEntry(501, 0, 21, 5)
191
SetTileLayerEntry(502, 0, 22, 5)
192
break
193
end switch
194
Object.CurrentFloor = Object.TargetFloor
195
end if
196
197
switch Object.State
198
case FLOORCONTROL_SETUP_CRUMBLE
199
if Object.Timer < 90
200
Object.Timer++
201
else
202
Object.TargetFloor = BossCamera.YPos
203
Object.TargetFloor -= Boss.YPos
204
Object.TargetFloor >>= 25
205
206
switch Object.TargetFloor
207
case 0
208
Object.RubbleYPos = 0x58C0000
209
Object.SpikeAmount = 0
210
break
211
case 1
212
Object.RubbleYPos = 0x38C0000
213
Object.SpikeAmount = 0
214
break
215
case 2
216
Object.RubbleYPos = 0x18C0000
217
Object.SpikeAmount = 6
218
if Player.XPos > Boss.XPos
219
Object.XVelocity = 0xA00000
220
else
221
Object.XVelocity = -0xA00000
222
end if
223
break
224
225
end switch
226
227
PlayStageSfx(SFX_S_CRUMBLE, false)
228
229
#platform: Use_Haptics
230
HapticEffect(77, 0, 0, 0)
231
#endplatform
232
233
Object.Timer = 0
234
Object.RubbleTimer = 24
235
Object.PlatformTimer = 0
236
237
Object.State++
238
end if
239
break
240
241
case FLOORCONTROL_SPAWN_FALL_OBJS
242
Object.PlatformTimer++
243
if Object.PlatformTimer == 128
244
CallFunction(FloorControl_SpawnPlatFarLeft)
245
end if
246
247
if Object.PlatformTimer == 148
248
CallFunction(FloorControl_SpawnPlatLeft)
249
end if
250
251
if Object.PlatformTimer == 168
252
CallFunction(FloorControl_SpawnPlatRight)
253
end if
254
255
if Object.PlatformTimer == 188
256
CallFunction(FloorControl_SpawnPlatFarRight)
257
end if
258
259
TempValue0 = Object.PlatformTimer
260
TempValue0 &= 3
261
if TempValue0 == 0
262
Screen.ShakeY = 2
263
end if
264
265
if Object.SpikeAmount > 0
266
TempValue0 = Object.PlatformTimer
267
TempValue0 %= 35
268
if TempValue0 == 0
269
Object.SpikeAmount--
270
CreateTempObject(TypeName[Boss Spike], 0, 0xAC00000, Object.RubbleYPos)
271
Object[TempObjectPos].XPos += Object.XVelocity
272
if Object.XVelocity > 0
273
Object.XVelocity -= 0x200000
274
else
275
Object.XVelocity += 0x200000
276
end if
277
end if
278
end if
279
280
Object.Timer++
281
if Object.Timer == 16
282
Object.Timer = 0
283
CallFunction(FloorControl_SpawnRubble)
284
if Object.RubbleTimer > 0
285
Object.RubbleTimer--
286
else
287
Object.State++
288
end if
289
end if
290
break
291
292
case FLOORCONTROL_ELEC_ARC
293
if Object.Timer == 30
294
PlayStageSfx(SFX_S_ELECTRICITY, false)
295
Object.TargetFloor = BossCamera.YPos
296
Object.TargetFloor -= Player.YPos
297
Object.TargetFloor >>= 25
298
if Object.CurrentFloor < Object.TargetFloor
299
Object.CurrentFloor = Object.TargetFloor
300
CreateTempObject(TypeName[Electric Arc], 0, Boss.XPos, FirstElectrode.YPos)
301
TempValue0 = Object.TargetFloor
302
TempValue0 <<= 25
303
TempValue0 += 0x20000
304
Object[TempObjectPos].YPos -= TempValue0
305
Object[TempObjectPos].Direction = FACING_LEFT
306
Object[TempObjectPos].DrawOrder = 4
307
end if
308
end if
309
310
Object.Timer++
311
if Object.Timer == 60
312
Object.Timer = 0
313
Object.State++
314
end if
315
break
316
317
case FLOORCONTROL_TILE_SWAP
318
Object.Timer++
319
if Object.Timer == 60
320
Object.Timer = 0
321
Object.State++
322
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
323
Copy16x16Tile(739, 827)
324
else
325
Copy16x16Tile(810, 863)
326
end if
327
else
328
TempValue0 = Object.Timer
329
TempValue0 >>= 1
330
TempValue0 %= 5
331
if HUD.CurrentTimePeriod == TIME_GOOD_FUTURE
332
TempValue0 += 826
333
Copy16x16Tile(739, TempValue0)
334
else
335
TempValue0 += 862
336
Copy16x16Tile(810, TempValue0)
337
end if
338
end if
339
break
340
341
case FLOORCONTROL_COOLDOWN
342
Object.Timer++
343
if Object.Timer == 420
344
Object.Timer = 0
345
Object.State = FLOORCONTROL_ELEC_ARC
346
end if
347
break
348
349
end switch
350
end sub
351
352
353
// ========================
354
// Editor Subs
355
// ========================
356
357
sub RSDKDraw
358
DrawSprite(0)
359
end sub
360
361
362
sub RSDKLoad
363
LoadSpriteSheet("Global/Display.gif")
364
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
365
366
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
367
end sub
368
369