Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/DeathEvent.txt
1319 views
1
//----------------Sonic CD Death Event Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.Text1Pos
7
#alias Object.Value2 : Object.Text2Pos
8
9
#alias Object.Value3 : Object.Timer
10
#alias Object.Value5 : Object.StagePosP
11
#alias Object.Value6 : Object.TimeOver
12
13
// HUD alias
14
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
15
16
// States
17
#alias 0 : DEATHEVENT_GAMEOVER
18
#alias 1 : DEATHEVENT_TIMEOVER
19
#alias 2 : DEATHEVENT_FADEOUT
20
#alias 3 : DEATHEVENT_TIMEATTACK
21
#alias 4 : DEATHEVENT_HOLDOVERRESTART
22
#alias 5 : DEATHEVENT_FADEOUTRESTART
23
24
// Player Aliases
25
#alias 0 : PLAYER_SONIC_A
26
#alias 1 : PLAYER_TAILS_A
27
28
// Game Mode Aliases
29
#alias 1 : MODE_SAVEGAME
30
31
// Callback & Engine States
32
#alias 8 : ENGINE_WAIT
33
34
// Time Periods
35
#alias 0 : TIME_PRESENT
36
#alias 1 : TIME_PAST
37
#alias 2 : TIME_GOOD_FUTURE
38
#alias 3 : TIME_BAD_FUTURE
39
40
// Presentation Stages
41
#alias 0 : STAGE_P_TITLE
42
#alias 2 : STAGE_P_TATTACK
43
44
45
sub ObjectMain
46
switch Object.State
47
case DEATHEVENT_GAMEOVER
48
#platform: Use_Origins
49
// Origins handles the time over of Classic Mode through here
50
if game.playMode == BOOT_PLAYMODE_CLASSIC
51
CheckEqual(Object.TimeOver, false)
52
TempValue0 = CheckResult
53
CheckEqual(Stage.Minutes, 9)
54
TempValue0 &= CheckResult
55
CheckEqual(Stage.Seconds, 59)
56
TempValue0 &= CheckResult
57
CheckEqual(Stage.MilliSeconds, 99)
58
TempValue0 &= CheckResult
59
60
TempValue0 |= game.timeOver
61
62
if TempValue0 != false
63
Object.TimeOver = true
64
end if
65
end if
66
#endplatform
67
// [Fallthrough]
68
case DEATHEVENT_TIMEOVER
69
70
#platform: Use_Origins
71
Object.TimeOver |= Object.State
72
73
// In Boss Rush, you can't Game Over (thankfully..?)
74
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
75
Object.Type = TypeName[Blank Object]
76
end if
77
#endplatform
78
79
TempValue0 = Screen.CenterX
80
TempValue0 -= 40
81
if Object.Text1Pos < TempValue0
82
Object.Text1Pos += 16
83
if Object.Text1Pos > TempValue0
84
Object.Text1Pos = TempValue0
85
end if
86
end if
87
88
TempValue0 += 80
89
if Object.Text2Pos > TempValue0
90
Object.Text2Pos -= 16
91
if Object.Text2Pos < TempValue0
92
Object.Text2Pos = TempValue0
93
end if
94
end if
95
96
if Object.Timer < 288
97
Object.Timer += 4
98
else
99
100
#platform: Use_Origins
101
if Object.TimeOver == true
102
if LampPost.Check > 0
103
Rec_Milliseconds = 99
104
Rec_Seconds = 59
105
Rec_Minutes = 9
106
game.timeOver = true
107
else
108
Rec_Milliseconds = 0
109
Rec_Seconds = 0
110
Rec_Minutes = 0
111
end if
112
end if
113
#endplatform
114
115
if Object.State == DEATHEVENT_GAMEOVER
116
Stage.ActiveList = PRESENTATION_STAGE
117
Stage.ListPos = STAGE_P_TITLE
118
LampPost.Check = 0
119
120
Transporter_Destroyed = false
121
MetalSonic_Destroyed = false
122
123
if Options.GameMode == MODE_SAVEGAME
124
ArrayPos1 = Options.SaveSlot
125
ArrayPos1 <<= 3
126
ArrayPos1++
127
if SaveRAM[ArrayPos1] < 3
128
SaveRAM[ArrayPos1] = 3
129
end if
130
131
WriteSaveRAM()
132
end if
133
end if
134
135
#platform: Use_Origins
136
if Object.State == DEATHEVENT_GAMEOVER
137
game.callbackParam0 = game.timeOver // Tell HE2 that the time over state
138
EngineCallback(NOTIFY_TIME_OVER)
139
end if
140
141
if Object.State == DEATHEVENT_TIMEOVER
142
Player.deadResetRings = true
143
end if
144
#endplatform
145
146
#platform: Use_Standalone
147
if Object.State == DEATHEVENT_TIMEOVER
148
Rec_Milliseconds = 0
149
Rec_Seconds = 0
150
Rec_Minutes = 0
151
end if
152
#endplatform
153
LoadStage()
154
end if
155
156
if Object.Timer > 0
157
Music.Volume -= 2
158
SetScreenFade(0, 0, 0, Object.Timer)
159
else
160
// Looking at index 1? What's that for?
161
162
if KeyPress[1].ButtonA == true
163
Object.Timer = 0
164
end if
165
166
if KeyPress[1].ButtonB == true
167
Object.Timer = 0
168
end if
169
170
if KeyPress[1].ButtonC == true
171
Object.Timer = 0
172
end if
173
end if
174
break
175
176
case DEATHEVENT_FADEOUT
177
#platform: Use_Origins
178
CheckNotEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
179
TempValue0 = CheckResult
180
// Check if the player is replaying the stage from My Data & Rankings
181
CheckNotEqual(game.oneStageFlag, false)
182
CheckResult &= TempValue0
183
184
if CheckResult != false
185
LampPost.Check = 0
186
Object.StagePosP = Stage.ListPos
187
188
game.callbackResult = -1 // Reset any callback result
189
game.callbackParam0 = 0 // 0 - Normal Retry, anything else - Show current and best time
190
game.callbackParam1 = Object.StagePosP // Get current stage
191
game.callbackParam2 = 0 // Unknown
192
EngineCallback(NOTIFY_STAGE_RETRY) // This will change callbackResult's value
193
194
Object.State = DEATHEVENT_HOLDOVERRESTART
195
else
196
if Object.Timer < 288
197
Music.Volume -= 2
198
Object.Timer += 4
199
else
200
Object.StagePosP = Stage.ListPos
201
202
switch HUD.CurrentTimePeriod
203
case TIME_PRESENT
204
break
205
206
case TIME_PAST
207
Object.StagePosP--
208
break
209
210
case TIME_GOOD_FUTURE
211
Object.StagePosP -= 2
212
break
213
214
case TIME_BAD_FUTURE
215
Object.StagePosP -= 3
216
break
217
218
end switch
219
220
if game.playMode != BOOT_PLAYMODE_MISSION
221
LoadStage()
222
else
223
Stage.ListPos = Object.StagePosP
224
end if
225
end if
226
227
SetScreenFade(0, 0, 0, Object.Timer)
228
end if
229
230
Player.deadResetRings = true
231
#endplatform
232
233
#platform: Use_Standalone
234
if Object.Timer < 288
235
Music.Volume -= 2
236
Object.Timer += 4
237
else
238
LoadStage()
239
end if
240
SetScreenFade(0, 0, 0, Object.Timer)
241
#endplatform
242
break
243
244
case DEATHEVENT_TIMEATTACK
245
if Object.Timer < 288
246
Music.Volume -= 2
247
Object.Timer += 4
248
else
249
TimeAttack.Result = 0
250
LampPost.Check = 0
251
Stage.ActiveList = PRESENTATION_STAGE
252
Stage.ListPos = STAGE_P_TATTACK
253
LoadStage()
254
end if
255
256
SetScreenFade(0, 0, 0, Object.Timer)
257
258
#platform: Use_Origins
259
game.callbackParam0 = StageStatsUsabilityParam1 // Enemies destroyed by any means
260
game.callbackParam1 = StageStatsUsabilityParam2 // Enemies destroyed by rolling
261
game.callbackParam2 = 0
262
EngineCallback(NOTIFY_STATS_ENEMY)
263
264
game.callbackParam0 = StageStatsUsabilityParam3 // Get Lamp post check
265
EngineCallback(NOTIFY_STATS_PARAM_1)
266
267
game.callbackParam0 = StageStatsUsabilityParam4 // Get player state?, Lamp Post related
268
EngineCallback(NOTIFY_STATS_CHARA_ACTION)
269
270
StageStatsUsabilityParam1 = 0
271
StageStatsUsabilityParam2 = 0
272
StageStatsUsabilityParam3 = 0
273
StageStatsUsabilityParam4 = 0
274
StatsUsabilityParam1 = 0
275
StatsUsabilityParam2 = 0
276
StatsUsabilityParam3 = 0
277
StatsUsabilityParam4 = 0
278
#endplatform
279
break
280
281
#platform: Use_Origins
282
case DEATHEVENT_HOLDOVERRESTART
283
if game.callbackResult >= 0
284
Object.Timer = 0
285
Object.State++
286
end if
287
break
288
289
case DEATHEVENT_FADEOUTRESTART
290
if Object.Timer < 288
291
Music.Volume -= 2
292
Object.Timer += 4
293
else
294
if game.callbackResult == false
295
Engine.State = ENGINE_WAIT
296
else
297
LoadStage()
298
end if
299
end if
300
301
SetScreenFade(0, 0, 0, Object.Timer)
302
break
303
304
#endplatform
305
end switch
306
end sub
307
308
309
sub ObjectDraw
310
switch Object.State
311
case DEATHEVENT_GAMEOVER
312
#platform: Use_Origins
313
// In Mirror Mode, draw the sprites in reverse so that it'll look correct when mirrored
314
if game.playMode == BOOT_PLAYMODE_MIRRORING
315
Object.Direction = FACING_LEFT
316
DrawSpriteScreenFX(2, FX_FLIP, Object.Text1Pos, 96)
317
DrawSpriteScreenFX(0, FX_FLIP, Object.Text2Pos, 96)
318
else
319
DrawSpriteScreenXY(0, Object.Text1Pos, 96)
320
DrawSpriteScreenXY(2, Object.Text2Pos, 96)
321
end if
322
#endplatform
323
324
#platform: Use_Standalone
325
DrawSpriteScreenXY(0, Object.Text1Pos, 96)
326
DrawSpriteScreenXY(2, Object.Text2Pos, 96)
327
#endplatform
328
break
329
330
case DEATHEVENT_TIMEOVER
331
#platform: Use_Origins
332
// Mirror Mode's gonna flip everything, so let's flip ourselves first!
333
if game.playMode == BOOT_PLAYMODE_MIRRORING
334
Object.Direction = FACING_LEFT
335
DrawSpriteScreenFX(2, FX_FLIP, Object.Text1Pos, 96)
336
DrawSpriteScreenFX(1, FX_FLIP, Object.Text2Pos, 96)
337
else
338
DrawSpriteScreenXY(1, Object.Text1Pos, 96)
339
DrawSpriteScreenXY(2, Object.Text2Pos, 96)
340
end if
341
#endplatform
342
343
#platform: Use_Standalone
344
DrawSpriteScreenXY(1, Object.Text1Pos, 96)
345
DrawSpriteScreenXY(2, Object.Text2Pos, 96)
346
#endplatform
347
break
348
349
end switch
350
end sub
351
352
353
sub ObjectStartup
354
if Stage.PlayerListPos == PLAYER_SONIC_A
355
LoadSpriteSheet("Global/Display.gif")
356
end if
357
if Stage.PlayerListPos == PLAYER_TAILS_A
358
LoadSpriteSheet("Global/Display_t.gif")
359
end if
360
#platform: Use_Origins
361
if Stage.PlayerListPos == PLAYER_KNUCKLES
362
LoadSpriteSheet("Global/Display_k.gif")
363
end if
364
if Stage.PlayerListPos == PLAYER_AMY
365
LoadSpriteSheet("Global/Display_a.gif")
366
end if
367
#endplatform
368
369
// 0 - "Game"
370
SpriteFrame(-32, 0, 64, 16, 0, 189)
371
372
// 1 - "Time"
373
SpriteFrame(-28, 0, 56, 16, 65, 189)
374
375
// 2 - "Over"
376
SpriteFrame(-32, 0, 64, 16, 122, 189)
377
end sub
378
379
380
// ========================
381
// Editor Subs
382
// ========================
383
384
sub RSDKDraw
385
DrawSprite(0)
386
end sub
387
388
389
sub RSDKLoad
390
LoadSpriteSheet("Global/Display.gif")
391
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
392
393
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
394
end sub
395
396