Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Global/DeathEvent.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Death Event Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value1 : object.leftTextPos
13
private alias object.value2 : object.rightTextPos
14
private alias object.value3 : object.timer
15
private alias object.value4 : object.timeOver
16
17
// States
18
private alias 0 : DEATHEVENT_GAMEOVER
19
private alias 1 : DEATHEVENT_TIMEOVER
20
private alias 2 : DEATHEVENT_DEATH
21
private alias 3 : DEATHEVENT_DEATH_TA
22
private alias 4 : DEATHEVENT_WAITFORCALLBACK
23
private alias 5 : DEATHEVENT_RETRY
24
private alias 6 : DEATHEVENT_SETSCREENFADE
25
26
// Player aliases
27
private alias object.value0 : player.rings
28
29
// Game Modes
30
private alias 1 : MODE_SAVEGAME
31
32
33
// ========================
34
// Events
35
// ========================
36
37
event ObjectUpdate
38
switch object.state
39
case DEATHEVENT_GAMEOVER
40
#platform: USE_ORIGINS
41
if game.playMode == BOOT_PLAYMODE_CLASSIC
42
CheckEqual(object.timeOver, false)
43
temp0 = checkResult
44
CheckEqual(stage.minutes, 9)
45
temp0 &= checkResult
46
CheckEqual(stage.seconds, 59)
47
temp0 &= checkResult
48
CheckEqual(stage.milliSeconds, 99)
49
temp0 &= checkResult
50
temp0 |= game.timeOver
51
52
if temp0 != false
53
if player.continues == 0
54
object.timeOver = true
55
else
56
recMilliSeconds = 0
57
recSeconds = 0
58
recMinutes = 0
59
game.timeOver = false
60
end if
61
end if
62
end if
63
// Fall-through
64
#endplatform
65
case DEATHEVENT_TIMEOVER
66
#platform: USE_ORIGINS
67
object.timeOver |= object.state
68
69
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
70
// In Boss Rush we don't need to be the ones to tell the Player they've Game Over'd, there's already all the fancy stuff over on the Hedgehog Engine 2 wrapper side of things
71
object.type = TypeName[Blank Object]
72
end if
73
#endplatform
74
75
temp0 = screen.xcenter
76
#platform: USE_STANDALONE
77
temp0 -= 72
78
#endplatform
79
#platform: USE_ORIGINS
80
temp0 -= 40
81
#endplatform
82
if object.leftTextPos < temp0
83
object.leftTextPos += 16
84
if object.leftTextPos > temp0
85
object.leftTextPos = temp0
86
end if
87
end if
88
89
temp0 += 80
90
if object.rightTextPos > temp0
91
object.rightTextPos -= 16
92
if object.rightTextPos < temp0
93
object.rightTextPos = temp0
94
end if
95
end if
96
97
if object.timer < 288
98
object.timer += 4
99
else
100
#platform: USE_ORIGINS
101
if object.timeOver == true
102
if starPostID > 0
103
recMilliSeconds = 99
104
recSeconds = 59
105
recMinutes = 9
106
game.timeOver = true
107
else
108
recMilliSeconds = 0
109
recSeconds = 0
110
recMinutes = 0
111
end if
112
end if
113
#endplatform
114
115
if object.state == 0
116
recStageList = stage.activeList
117
recStage = stage.listPos
118
stage.activeList = PRESENTATION_STAGE
119
if options.vsMode == false
120
if player.continues == 0
121
stage.listPos = 0
122
#platform: USE_STANDALONE
123
engine.state = 8
124
#endplatform
125
CallNativeFunction2(ShowPromoPopup, 0, "GameOverPromo")
126
else
127
stage.listPos = 4
128
end if
129
else
130
stage.listPos = 3
131
if vs.playerID == 0
132
if object.entityPos == 0
133
player.score = 0
134
player.lives = 3
135
vs.time1P = 60000
136
vs.rings1P = 0
137
vs.totalRings1P = 0
138
vs.items1P = 0
139
else
140
player.score2 = 0
141
player.lives2 = 3
142
vs.time2P = 60000
143
vs.rings2P = 0
144
vs.totalRings2P = 0
145
vs.items2P = 0
146
end if
147
else
148
if object.entityPos == 1
149
player.score2 = 0
150
player.lives2 = 3
151
vs.time1P = 60000
152
vs.rings1P = 0
153
vs.totalRings1P = 0
154
vs.items1P = 0
155
else
156
player.score = 0
157
player.lives = 3
158
vs.time2P = 60000
159
vs.rings2P = 0
160
vs.totalRings2P = 0
161
vs.items2P = 0
162
end if
163
end if
164
end if
165
166
starPostID = 0
167
if options.gameMode == MODE_SAVEGAME
168
arrayPos1 = options.saveSlot
169
arrayPos1 <<= 3
170
arrayPos1++
171
if saveRAM[arrayPos1] < 3
172
saveRAM[arrayPos1] = 3
173
end if
174
arrayPos1++
175
saveRAM[arrayPos1] = 0
176
arrayPos1++
177
saveRAM[arrayPos1] = 50000
178
player.score = 0
179
WriteSaveRAM()
180
end if
181
else
182
if options.vsMode == true
183
if vs.playerID == 0
184
vs.rings1P = player[0].rings
185
vs.rings2P = player[1].rings
186
else
187
vs.rings1P = player[1].rings
188
vs.rings2P = player[0].rings
189
end if
190
191
starPostID = 0
192
stage.activeList = PRESENTATION_STAGE
193
stage.listPos = 3
194
end if
195
196
if options.gameMode == MODE_SAVEGAME
197
arrayPos1 = options.saveSlot
198
arrayPos1 <<= 3
199
arrayPos1++
200
saveRAM[arrayPos1] = player.lives
201
WriteSaveRAM()
202
end if
203
end if
204
205
#platform: USE_STANDALONE
206
if object.state == DEATHEVENT_TIMEOVER
207
recMilliSeconds = 0
208
recSeconds = 0
209
recMinutes = 0
210
end if
211
#endplatform
212
213
#platform: USE_ORIGINS
214
if object.state == DEATHEVENT_GAMEOVER
215
CallNativeFunction2(NotifyCallback, NOTIFY_TIME_OVER, game.timeOver)
216
end if
217
218
if object.state == DEATHEVENT_TIMEOVER
219
player.deadResetRings = true
220
end if
221
#endplatform
222
223
LoadStage()
224
end if
225
226
if object.timer > 0
227
music.volume -= 2
228
SetScreenFade(0, 0, 0, object.timer)
229
else
230
if keyPress[0].buttonA == true
231
object.timer = 0
232
end if
233
234
if keyPress[0].buttonB == true
235
object.timer = 0
236
end if
237
238
if keyPress[0].buttonC == true
239
object.timer = 0
240
end if
241
242
#platform: MOBILE
243
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
244
if checkResult > -1
245
object.timer = 0
246
end if
247
#endplatform
248
end if
249
break
250
251
case DEATHEVENT_DEATH
252
#platform: USE_ORIGINS
253
CheckNotEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
254
temp0 = checkResult
255
CheckNotEqual(game.oneStageFlag, false)
256
checkResult &= temp0
257
258
if checkResult != false
259
game.callbackResult = -1
260
CallNativeFunction4(NotifyCallback, NOTIFY_STAGE_RETRY, 0, stage.listPos, 0)
261
object.state = DEATHEVENT_WAITFORCALLBACK
262
if options.gameMode == MODE_SAVEGAME
263
arrayPos1 = options.saveSlot
264
arrayPos1 <<= 3
265
arrayPos1++
266
saveRAM[arrayPos1] = player.lives
267
WriteSaveRAM()
268
end if
269
else
270
#endplatform
271
if object.timer < 288
272
music.volume -= 2
273
object.timer += 4
274
else
275
if options.gameMode == MODE_SAVEGAME
276
arrayPos1 = options.saveSlot
277
arrayPos1 <<= 3
278
arrayPos1++
279
saveRAM[arrayPos1] = player.lives
280
WriteSaveRAM()
281
end if
282
283
#platform: USE_STANDALONE
284
LoadStage()
285
#endplatform
286
287
#platform: USE_ORIGINS
288
if game.playMode != BOOT_PLAYMODE_MISSION
289
LoadStage()
290
else
291
player.score = 0
292
end if
293
#endplatform
294
end if
295
296
SetScreenFade(0, 0, 0, object.timer)
297
#platform: USE_ORIGINS
298
end if
299
300
player.deadResetRings = true
301
#endplatform
302
break
303
304
case DEATHEVENT_DEATH_TA
305
if object.timer < 288
306
music.volume -= 2
307
object.timer += 4
308
else
309
timeAttack.result = 0
310
vs.bossAttack = false
311
player.score = 0
312
starPostID = 0
313
recMilliSeconds = 0
314
recSeconds = 0
315
recMinutes = 0
316
stage.milliSeconds = 0
317
stage.seconds = 0
318
stage.minutes = 0
319
engine.state = 8
320
321
#platform: USE_ORIGINS
322
CallNativeFunction4(NotifyCallback, NOTIFY_STATS_ENEMY, StageStatsUsabilityParam1, StageStatsUsabilityParam2, StageStatsUsabilityParam3)
323
324
StageStatsUsabilityParam1 = 0
325
StageStatsUsabilityParam2 = 0
326
StageStatsUsabilityParam3 = 0
327
StageStatsUsabilityParam4 = 0
328
StageStatsUsabilityParam5 = 0
329
330
StatsUsabilityParam1 = 0
331
StatsUsabilityParam2 = 0
332
StatsUsabilityParam3 = 0
333
StatsUsabilityParam4 = 0
334
StatsUsabilityParam5 = 0
335
#endplatform
336
end if
337
SetScreenFade(0, 0, 0, object.timer)
338
break
339
340
#platform: USE_ORIGINS
341
case DEATHEVENT_WAITFORCALLBACK
342
if game.callbackResult >= 0
343
object.timer = 0
344
object.state = DEATHEVENT_RETRY
345
end if
346
break
347
348
case DEATHEVENT_RETRY
349
if object.timer < 288
350
music.volume -= 2
351
object.timer += 4
352
else
353
if game.callbackResult == 0
354
engine.state = 8
355
else
356
LoadStage()
357
end if
358
end if
359
360
SetScreenFade(0, 0, 0, object.timer)
361
break
362
363
case DEATHEVENT_SETSCREENFADE
364
SetScreenFade(0, 0, 0, 255)
365
break
366
#endplatform
367
end switch
368
end event
369
370
371
event ObjectDraw
372
switch object.state
373
case DEATHEVENT_GAMEOVER
374
#platform: USE_ORIGINS
375
if game.playMode == BOOT_PLAYMODE_MIRRORING
376
object.direction = FLIP_X
377
DrawSpriteScreenFX(2, FX_FLIP, object.leftTextPos, 96)
378
DrawSpriteScreenFX(0, FX_FLIP, object.rightTextPos, 96)
379
else
380
DrawSpriteScreenXY(0, object.leftTextPos, 96)
381
DrawSpriteScreenXY(2, object.rightTextPos, 96)
382
end if
383
#endplatform
384
#platform: USE_STANDALONE
385
DrawSpriteScreenXY(0, object.leftTextPos, 96)
386
DrawSpriteScreenXY(2, object.rightTextPos, 96)
387
#endplatform
388
break
389
390
case DEATHEVENT_TIMEOVER
391
#platform: USE_ORIGINS
392
if game.playMode == BOOT_PLAYMODE_MIRRORING
393
object.direction = FLIP_X
394
DrawSpriteScreenFX(2, FX_FLIP, object.leftTextPos, 96)
395
DrawSpriteScreenFX(1, FX_FLIP, object.rightTextPos, 96)
396
else
397
DrawSpriteScreenXY(1, object.leftTextPos, 96)
398
DrawSpriteScreenXY(2, object.rightTextPos, 96)
399
end if
400
#endplatform
401
#platform: USE_STANDALONE
402
DrawSpriteScreenXY(1, object.leftTextPos, 96)
403
DrawSpriteScreenXY(2, object.rightTextPos, 96)
404
#endplatform
405
break
406
end switch
407
end event
408
409
410
event ObjectStartup
411
LoadSpriteSheet("Global/Display.gif")
412
#platform: USE_STANDALONE
413
SpriteFrame(0, 0, 64, 16, 1, 239) // 0 - "GAME"
414
SpriteFrame(0, 0, 56, 16, 66, 239) // 1 - "TIME"
415
SpriteFrame(0, 0, 64, 16, 123, 239) // 2 - "OVER"
416
#endplatform
417
#platform: USE_ORIGINS
418
// I really don't know why they did this.
419
SpriteFrame(-32, 0, 64, 16, 1, 239) // 0 - "GAME"
420
SpriteFrame(-28, 0, 56, 16, 66, 239) // 1 - "TIME"
421
SpriteFrame(-32, 0, 64, 16, 123, 239) // 2 - "OVER"
422
#endplatform
423
end event
424
425
426
// ========================
427
// Editor Events
428
// ========================
429
430
event RSDKDraw
431
DrawSprite(0)
432
end event
433
434
435
event RSDKLoad
436
LoadSpriteSheet("Global/Display.gif")
437
SpriteFrame(-16, -16, 32, 32, 1, 143)
438
439
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
440
end event
441
442