Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Global/DeathEvent.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
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
// Game Modes Aliases
27
private alias 1 : MODE_SAVEGAME
28
29
// Presentation Stage Aliases
30
private alias 0 : STAGE_P_TITLE
31
private alias 4 : STAGE_P_CONTINUE
32
33
34
// ========================
35
// Events
36
// ========================
37
38
event ObjectUpdate
39
switch object.state
40
case DEATHEVENT_GAMEOVER
41
#platform: USE_ORIGINS
42
if game.playMode == BOOT_PLAYMODE_CLASSIC
43
CheckEqual(object.timeOver, false)
44
temp0 = checkResult
45
CheckEqual(stage.minutes, 9)
46
temp0 &= checkResult
47
CheckEqual(stage.seconds, 59)
48
temp0 &= checkResult
49
CheckEqual(stage.milliSeconds, 99)
50
temp0 &= checkResult
51
temp0 |= game.timeOver
52
53
if temp0 != false
54
if player.continues == 0
55
object.timeOver = true
56
else
57
recMilliSeconds = 0
58
recSeconds = 0
59
recMinutes = 0
60
game.timeOver = false
61
end if
62
end if
63
end if
64
#endplatform
65
// [Fall-through]
66
case DEATHEVENT_TIMEOVER
67
#platform: USE_ORIGINS
68
object.timeOver |= object.state
69
70
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
71
object.type = TypeName[Blank Object]
72
end if
73
#endplatform
74
75
temp0 = screen.xcenter
76
temp0 -= 72
77
if object.leftTextPos < temp0
78
object.leftTextPos += 16
79
if object.leftTextPos > temp0
80
object.leftTextPos = temp0
81
end if
82
end if
83
84
temp0 += 80
85
if object.rightTextPos > temp0
86
object.rightTextPos -= 16
87
if object.rightTextPos < temp0
88
object.rightTextPos = temp0
89
end if
90
end if
91
92
if object.timer < 288
93
object.timer += 4
94
else
95
#platform: USE_ORIGINS
96
if object.timeOver == true
97
if lampPostID > 0
98
recMilliSeconds = 99
99
recSeconds = 59
100
recMinutes = 9
101
game.timeOver = true
102
else
103
recMilliSeconds = 0
104
recSeconds = 0
105
recMinutes = 0
106
end if
107
end if
108
#endplatform
109
110
if object.state == DEATHEVENT_GAMEOVER
111
recStageList = stage.activeList
112
recStage = stage.listPos
113
stage.activeList = PRESENTATION_STAGE
114
115
if player.continues == 0
116
stage.listPos = STAGE_P_TITLE
117
#platform: USE_STANDALONE
118
engine.state = 8
119
#endplatform
120
CallNativeFunction2(ShowPromoPopup, 0, "GameOverPromo") // still in Origins btw
121
else
122
stage.listPos = STAGE_P_CONTINUE
123
end if
124
125
lampPostID = 0
126
127
if options.gameMode == MODE_SAVEGAME
128
arrayPos1 = options.saveSlot
129
arrayPos1 <<= 3
130
arrayPos1++
131
if saveRAM[arrayPos1] < 3 // lives
132
saveRAM[arrayPos1] = 3
133
end if
134
arrayPos1++
135
saveRAM[arrayPos1] = 0 // score
136
arrayPos1++
137
saveRAM[arrayPos1] = 50000 // score bonus
138
player.score = 0
139
WriteSaveRAM()
140
end if
141
else
142
if options.gameMode == MODE_SAVEGAME
143
arrayPos1 = options.saveSlot
144
arrayPos1 <<= 3
145
arrayPos1++
146
saveRAM[arrayPos1] = player.lives
147
WriteSaveRAM()
148
end if
149
end if
150
151
#platform: USE_STANDALONE
152
if object.state == DEATHEVENT_TIMEOVER
153
recMilliSeconds = 0
154
recSeconds = 0
155
recMinutes = 0
156
end if
157
#endplatform
158
159
#platform: USE_ORIGINS
160
if object.state == DEATHEVENT_GAMEOVER
161
CallNativeFunction2(NotifyCallback, NOTIFY_TIME_OVER, game.timeOver)
162
end if
163
164
if object.state == DEATHEVENT_TIMEOVER
165
player.deadResetRings = true
166
end if
167
#endplatform
168
169
LoadStage()
170
end if
171
172
if object.timer > 0
173
music.volume -= 2
174
SetScreenFade(0, 0, 0, object.timer)
175
else
176
if keyPress[0].buttonA == true
177
object.timer = 0
178
end if
179
180
if keyPress[0].buttonB == true
181
object.timer = 0
182
end if
183
184
if keyPress[0].buttonC == true
185
object.timer = 0
186
end if
187
188
#platform: MOBILE
189
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
190
if checkResult > -1
191
object.timer = 0
192
end if
193
#endplatform
194
end if
195
break
196
197
case DEATHEVENT_DEATH
198
#platform: USE_ORIGINS
199
CheckNotEqual(game.playMode, BOOT_PLAYMODE_BOSSRUSH)
200
temp0 = checkResult
201
CheckNotEqual(game.oneStageFlag, false)
202
checkResult &= temp0
203
204
if checkResult != false
205
game.callbackResult = -1
206
CallNativeFunction4(NotifyCallback, NOTIFY_STAGE_RETRY, false, stage.listPos, 0)
207
object.state = DEATHEVENT_WAITFORCALLBACK
208
if options.gameMode == MODE_SAVEGAME
209
arrayPos1 = options.saveSlot
210
arrayPos1 <<= 3
211
arrayPos1++
212
saveRAM[arrayPos1] = player.lives
213
WriteSaveRAM()
214
end if
215
else
216
#endplatform
217
if object.timer < 288
218
music.volume -= 2
219
object.timer += 4
220
else
221
if options.gameMode == MODE_SAVEGAME
222
arrayPos1 = options.saveSlot
223
arrayPos1 <<= 3
224
arrayPos1++
225
saveRAM[arrayPos1] = player.lives
226
WriteSaveRAM()
227
end if
228
229
#platform: USE_STANDALONE
230
LoadStage()
231
#endplatform
232
233
#platform: USE_ORIGINS
234
if game.playMode != BOOT_PLAYMODE_MISSION
235
LoadStage()
236
end if
237
#endplatform
238
end if
239
240
SetScreenFade(0, 0, 0, object.timer)
241
#platform: USE_ORIGINS
242
end if
243
244
player.deadResetRings = true
245
#endplatform
246
break
247
248
case DEATHEVENT_DEATH_TA
249
if object.timer < 288
250
music.volume -= 2
251
object.timer += 4
252
else
253
timeAttack.result = 100000
254
player.score = 0
255
lampPostID = 0
256
recMilliSeconds = 0
257
recSeconds = 0
258
recMinutes = 0
259
stage.milliSeconds = 0
260
stage.seconds = 0
261
stage.minutes = 0
262
engine.state = 8
263
264
#platform: USE_ORIGINS
265
CallNativeFunction4(NotifyCallback, NOTIFY_STATS_ENEMY, StageStatsUsabilityParam1, StageStatsUsabilityParam2, StageStatsUsabilityParam3)
266
StageStatsUsabilityParam1 = 0
267
StageStatsUsabilityParam2 = 0
268
StageStatsUsabilityParam3 = 0
269
StageStatsUsabilityParam4 = 0
270
StageStatsUsabilityParam5 = 0
271
StatsUsabilityParam1 = 0
272
StatsUsabilityParam2 = 0
273
StatsUsabilityParam3 = 0
274
StatsUsabilityParam4 = 0
275
StatsUsabilityParam5 = 0
276
#endplatform
277
end if
278
SetScreenFade(0, 0, 0, object.timer)
279
break
280
281
#platform: USE_ORIGINS
282
case DEATHEVENT_WAITFORCALLBACK
283
if game.callbackResult >= 0
284
object.timer = 0
285
object.state = DEATHEVENT_RETRY
286
end if
287
break
288
289
case DEATHEVENT_RETRY
290
if object.timer < 288
291
music.volume -= 2
292
object.timer += 4
293
else
294
if game.callbackResult == 0
295
engine.state = 8
296
else
297
LoadStage()
298
end if
299
end if
300
301
SetScreenFade(0, 0, 0, object.timer)
302
break
303
304
case DEATHEVENT_SETSCREENFADE
305
SetScreenFade(0, 0, 0, 255)
306
break
307
#endplatform
308
end switch
309
end event
310
311
312
event ObjectDraw
313
switch object.state
314
case DEATHEVENT_GAMEOVER
315
DrawSpriteScreenXY(0, object.leftTextPos, 96)
316
DrawSpriteScreenXY(2, object.rightTextPos, 96)
317
break
318
319
case DEATHEVENT_TIMEOVER
320
DrawSpriteScreenXY(1, object.leftTextPos, 96)
321
DrawSpriteScreenXY(2, object.rightTextPos, 96)
322
break
323
324
end switch
325
end event
326
327
328
event ObjectStartup
329
LoadSpriteSheet("Global/Display.gif")
330
331
// Death Event frames
332
SpriteFrame(0, 0, 64, 16, 1, 239) // 0 - "Game"
333
SpriteFrame(0, 0, 56, 16, 66, 239) // 1 - "Time"
334
SpriteFrame(0, 0, 64, 16, 123, 239) // 2 - "Over"
335
end event
336
337
338
// ========================
339
// Editor Events
340
// ========================
341
342
event RSDKDraw
343
DrawSprite(0)
344
end event
345
346
347
event RSDKLoad
348
LoadSpriteSheet("Global/Display.gif")
349
SpriteFrame(-16, -16, 32, 32, 1, 143)
350
351
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
352
end event
353
354