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/BrokenMonitor.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Broken Monitor 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.value0 : object.contentsPos.y
13
private alias object.value1 : object.timer
14
15
// Monitor type aliases
16
private alias 0 : MONITOR_BLANK
17
private alias 1 : MONITOR_RINGS
18
private alias 2 : MONITOR_SHIELD_BLUE
19
private alias 3 : MONITOR_INVINCIBILITY
20
private alias 4 : MONITOR_SPEEDSHOES
21
private alias 5 : MONITOR_1UP_SONIC
22
private alias 6 : MONITOR_1UP_TAILS
23
private alias 7 : MONITOR_1UP_KNUX
24
private alias 8 : MONITOR_SUPER
25
private alias 9 : MONITOR_SHIELD_BUBBLE
26
private alias 10 : MONITOR_SHIELD_FIRE
27
private alias 11 : MONITOR_SHIELD_LIGHTNING
28
private alias 12 : MONITOR_EGGMAN
29
private alias 13 : MONITOR_SHIELD_GOGGLES
30
private alias 14 : MONITOR_DEBUG_SPIKES
31
private alias 15 : MONITOR_DEBUG_SHIELD
32
private alias 16 : MONITOR_DEBUG_EMERALDS
33
34
// Monitor states
35
private alias 0 : MONITOR_STATE_RISE
36
private alias 1 : MONITOR_STATE_FADE
37
private alias 2 : MONITOR_STATE_IDLE
38
39
// Player Aliases
40
private alias object.type : player.type
41
private alias object.xpos : player.xpos
42
private alias object.ypos : player.ypos
43
private alias object.value0 : player.rings
44
private alias object.value3 : player.drownTimer
45
private alias object.value4 : player.drownLevel
46
private alias object.value6 : player.speedShoesTimer
47
private alias object.value7 : player.invincibleTimer
48
private alias object.value37 : player.shield
49
50
// Shields
51
private alias 0 : SHIELD_NONE
52
private alias 1 : SHIELD_NORMAL
53
private alias 2 : SHIELD_BUBBLE
54
private alias 3 : SHIELD_FIRE
55
private alias 4 : SHIELD_LIGHTNING
56
private alias 5 : SHIELD_GOGGLES
57
58
// Game Mode Aliases
59
private alias 2 : MODE_TIMEATTACK
60
61
// Shield Type Aliases
62
private alias 0 : SHIELDTYPE_S1
63
private alias 1 : SHIELDTYPE_S2
64
private alias 2 : SHIELDTYPE_S3_S1
65
private alias 3 : SHIELDTYPE_S3_S2
66
67
// Tracks
68
private alias 2 : TRACK_INVINCIBLE
69
70
// Music Events
71
private alias 25 : SLOT_MUSICEVENT_CHANGE
72
73
private alias 2 : MUSICEVENT_TRANSITION
74
75
// Super States
76
private alias 1 : SUPERSTATE_SUPER
77
78
// Achievement Aliases
79
private alias 4 : ACHIEVEMENT_RINGKING
80
81
82
// ========================
83
// Function Declarations
84
// ========================
85
86
reserve function BrokenMonitor_Blank
87
88
89
// ========================
90
// Static Values
91
// ========================
92
93
public value BrokenMonitor_ResetDrownMusic = 0
94
95
96
// ========================
97
// Function Definitions
98
// ========================
99
100
// Dummy function
101
private function BrokenMonitor_Blank
102
// Not much to do, no drowning music to reset
103
end function
104
105
106
// ========================
107
// Events
108
// ========================
109
110
event ObjectUpdate
111
switch object.state
112
case MONITOR_STATE_RISE
113
if object.timer < 0
114
object.contentsPos.y += object.timer
115
object.timer += 0x1800
116
else
117
object.timer = 0
118
end if
119
120
if object.timer == 0
121
object.state = MONITOR_STATE_FADE
122
object.inkEffect = INK_ALPHA
123
switch object.propertyValue
124
case MONITOR_BLANK
125
default
126
break
127
128
case MONITOR_RINGS
129
player[0].rings += 10
130
if ringPan == 0
131
PlaySfx(SfxName[Ring L], false)
132
SetSfxAttributes(SfxName[Ring L], -1, -100)
133
ringPan = 1
134
else
135
PlaySfx(SfxName[Ring R], false)
136
SetSfxAttributes(SfxName[Ring R], -1, 100)
137
ringPan = 0
138
end if
139
140
if player[0].rings > 999
141
player[0].rings = 999
142
end if
143
144
if player[0].rings >= ringExtraLife
145
if options.gameMode != MODE_TIMEATTACK
146
#platform: USE_ORIGINS
147
if game.coinMode == false
148
player.lives++
149
else
150
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
151
end if
152
#endplatform
153
#platform: USE_STANDALONE
154
player.lives++
155
#endplatform
156
PlaySfx(SfxName[Life], false)
157
PauseMusic()
158
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
159
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
160
end if
161
162
ringExtraLife += 100
163
if ringExtraLife > 300
164
ringExtraLife = 1000
165
end if
166
167
if stage.debugMode == false
168
if player[0].rings >= 200
169
// Grant the "Ring King" Achievement
170
CallNativeFunction2(SetAchievement, ACHIEVEMENT_RINGKING, 100)
171
end if
172
end if
173
end if
174
break
175
176
case MONITOR_SHIELD_BLUE
177
PlaySfx(SfxName[Blue Shield], false)
178
arrayPos0 = playerCount
179
currentPlayer = 0
180
player[currentPlayer].shield = SHIELD_NORMAL
181
182
if Player_superState != SUPERSTATE_SUPER
183
if object[arrayPos0].type != invincibilityType
184
CallFunction(Player_ApplyShield)
185
end if
186
end if
187
break
188
189
case MONITOR_INVINCIBILITY
190
if Player_superState != SUPERSTATE_SUPER
191
arrayPos0 = playerCount
192
currentPlayer = 0
193
ResetObjectEntity(arrayPos0, invincibilityType, 0, player[currentPlayer].xpos, player[currentPlayer].ypos)
194
object[arrayPos0].priority = PRIORITY_ACTIVE
195
player[currentPlayer].invincibleTimer = 1260
196
PlayMusic(TRACK_INVINCIBLE)
197
end if
198
break
199
200
case MONITOR_SPEEDSHOES
201
currentPlayer = 0
202
if SpeedUpMusic != 0
203
if player[currentPlayer].speedShoesTimer == 0
204
CallFunction(SpeedUpMusic)
205
end if
206
end if
207
208
player[currentPlayer].speedShoesTimer = 1320
209
CallFunction(Player_UpdatePhysicsState)
210
break
211
212
case MONITOR_1UP_SONIC
213
case MONITOR_1UP_TAILS
214
case MONITOR_1UP_KNUX
215
#platform: USE_ORIGINS
216
if game.coinMode == false
217
player.lives++
218
else
219
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
220
end if
221
#endplatform
222
#platform: USE_STANDALONE
223
player.lives++
224
#endplatform
225
PlaySfx(SfxName[Life], false)
226
PauseMusic()
227
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
228
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
229
break
230
231
case MONITOR_SUPER
232
currentPlayer = 0
233
player[0].rings += 50
234
235
if Player_superState != SUPERSTATE_SUPER
236
object.type = player[0].type
237
CallFunction(Player_TryTransform)
238
object.type = TypeName[Broken Monitor]
239
else
240
if ringPan == 0
241
PlaySfx(SfxName[Ring L], false)
242
SetSfxAttributes(SfxName[Ring L], -1, -100)
243
ringPan = 1
244
else
245
PlaySfx(SfxName[Ring R], false)
246
SetSfxAttributes(SfxName[Ring R], -1, 100)
247
ringPan = 0
248
end if
249
end if
250
251
if player[0].rings > 999
252
player[0].rings = 999
253
end if
254
255
if player[0].rings >= ringExtraLife
256
if options.gameMode != MODE_TIMEATTACK
257
#platform: USE_ORIGINS
258
if game.coinMode == false
259
player.lives++
260
else
261
CallNativeFunction2(NotifyCallback, NOTIFY_ADD_COIN, 1)
262
end if
263
#endplatform
264
#platform: USE_STANDALONE
265
player.lives++
266
#endplatform
267
PlaySfx(SfxName[Life], false)
268
PauseMusic()
269
ResetObjectEntity(SLOT_MUSICEVENT_CHANGE, TypeName[Music Event], MUSICEVENT_TRANSITION, 0, 0)
270
object[SLOT_MUSICEVENT_CHANGE].priority = PRIORITY_ACTIVE
271
end if
272
273
ringExtraLife += 100
274
if ringExtraLife > 300
275
ringExtraLife = 1000
276
end if
277
end if
278
break
279
280
case MONITOR_SHIELD_BUBBLE
281
PlaySfx(SfxName[Bubble Shield], false)
282
arrayPos0 = playerCount
283
currentPlayer = 0
284
player[currentPlayer].shield = SHIELD_BUBBLE
285
286
if Player_superState != SUPERSTATE_SUPER
287
if object[arrayPos0].type != invincibilityType
288
CallFunction(Player_ApplyShield)
289
end if
290
end if
291
292
if player[currentPlayer].drownLevel >= 3
293
player[currentPlayer].drownTimer = 0
294
player[currentPlayer].drownLevel = 0
295
CallFunction(BrokenMonitor_ResetDrownMusic)
296
end if
297
break
298
299
case MONITOR_SHIELD_FIRE
300
PlaySfx(SfxName[Fire Shield], false)
301
arrayPos0 = playerCount
302
currentPlayer = 0
303
player[currentPlayer].shield = SHIELD_FIRE
304
305
if Player_superState != SUPERSTATE_SUPER
306
if object[arrayPos0].type != invincibilityType
307
CallFunction(Player_ApplyShield)
308
end if
309
end if
310
break
311
312
case MONITOR_SHIELD_LIGHTNING
313
PlaySfx(SfxName[Lightning Shield], false)
314
arrayPos0 = playerCount
315
currentPlayer = 0
316
player[currentPlayer].shield = SHIELD_LIGHTNING
317
318
if Player_superState != SUPERSTATE_SUPER
319
if object[arrayPos0].type != invincibilityType
320
CallFunction(Player_ApplyShield)
321
end if
322
end if
323
break
324
325
case MONITOR_EGGMAN
326
currentPlayer = 0
327
CallFunction(Player_Hit)
328
break
329
330
case MONITOR_SHIELD_GOGGLES
331
PlaySfx(SfxName[Catch], false)
332
arrayPos0 = playerCount
333
currentPlayer = 0
334
player[currentPlayer].shield = SHIELD_GOGGLES
335
336
if Player_superState != SUPERSTATE_SUPER
337
if object[arrayPos0].type != invincibilityType
338
CallFunction(Player_ApplyShield)
339
end if
340
end if
341
break
342
343
case MONITOR_DEBUG_SPIKES
344
PlaySfx(SfxName[Spike], false)
345
options.spikeBehavior ^= true
346
break
347
348
case MONITOR_DEBUG_SHIELD
349
PlaySfx(SfxName[Blue Shield], false)
350
options.shieldType++
351
options.shieldType &= SHIELDTYPE_S3_S2
352
switch options.shieldType
353
case SHIELDTYPE_S1
354
case SHIELDTYPE_S3_S1
355
blueShieldType = TypeName[Blue Shield]
356
invincibilityType = TypeName[Invincibility 2]
357
break
358
359
case SHIELDTYPE_S2
360
case SHIELDTYPE_S3_S2
361
blueShieldType = TypeName[Blue Shield 2]
362
invincibilityType = TypeName[Invincibility 2]
363
break
364
365
end switch
366
arrayPos0 = playerCount
367
currentPlayer = 0
368
CallFunction(Player_ApplyShield)
369
break
370
371
case MONITOR_DEBUG_EMERALDS
372
if specialStage.emeralds >= 0x40 // Does the player have the 7th emerald?
373
if specialStage.emeralds == 0x7F
374
options.superStates = false
375
specialStage.emeralds = 0
376
else
377
PlaySfx(SfxName[Transform], false)
378
specialStage.emeralds = 0x7F
379
end if
380
else
381
PlaySfx(SfxName[Transform], false)
382
options.superStates = true
383
specialStage.emeralds |= 0x40 // Give the Player the 7th emerald
384
end if
385
break
386
387
end switch
388
end if
389
break
390
391
case MONITOR_STATE_FADE
392
object.timer++
393
if object.timer == 30
394
object.timer = 0
395
object.state = MONITOR_STATE_IDLE
396
object.propertyValue = MONITOR_BLANK
397
if object.priority != PRIORITY_XBOUNDS_DESTROY
398
object.priority = PRIORITY_BOUNDS
399
end if
400
else
401
if object.timer > 14
402
object.alpha -= 16
403
end if
404
end if
405
break
406
407
case MONITOR_STATE_IDLE
408
break
409
410
end switch
411
end event
412
413
414
event ObjectDraw
415
DrawSprite(0)
416
417
if object.propertyValue > MONITOR_BLANK
418
DrawSpriteFX(object.propertyValue, FX_INK, object.xpos, object.contentsPos.y)
419
end if
420
end event
421
422
423
event ObjectStartup
424
LoadSpriteSheet("Global/Items.gif")
425
426
// Broken monitor frame
427
SpriteFrame(-16, 0, 32, 16, 51, 166)
428
429
// Icons
430
SpriteFrame(-8, -9, 16, 14, 51, 16) // 1 - MONITOR_RINGS
431
SpriteFrame(-8, -9, 16, 14, 68, 16) // 2 - MONITOR_SHIELD_BLUE
432
SpriteFrame(-8, -9, 16, 14, 51, 31) // 3 - MONITOR_INVINCIBILITY
433
SpriteFrame(-8, -9, 16, 14, 68, 31) // 4 - MONITOR_SPEEDSHOES
434
#platform: USE_ORIGINS
435
if game.coinMode == false
436
if stage.playerListPos == PLAYER_AMY
437
SpriteFrame(-8, -9, 16, 14, 166, 118) // 5 - MONITOR_1UP_SONIC, except it's actually Amy
438
else
439
SpriteFrame(-8, -9, 16, 14, 51, 46) // 5 - MONITOR_1UP_SONIC, actually Sonic this time
440
end if
441
#endplatform
442
#platform: USE_STANDALONE
443
SpriteFrame(-8, -9, 16, 14, 51, 46) // 5 - MONITOR_1UP_SONIC
444
#endplatform
445
SpriteFrame(-8, -9, 16, 14, 68, 46) // 6 - MONITOR_1UP_TAILS
446
SpriteFrame(-8, -9, 16, 14, 51, 61) // 7 - MONITOR_1UP_KNUX
447
#platform: USE_ORIGINS
448
else
449
SpriteFrame(-8, -9, 16, 14, 35, 100) // 5 - MONITOR_1UP_SONIC (Coin)
450
SpriteFrame(-8, -9, 16, 14, 35, 100) // 6 - MONITOR_1UP_TAILS (Coin.. again)
451
SpriteFrame(-8, -9, 16, 14, 35, 100) // 7 - MONITOR_1UP_KNUX (Coin :D)
452
end if
453
#endplatform
454
SpriteFrame(-8, -9, 16, 14, 68, 61) // 8 - MONITOR_SUPER
455
SpriteFrame(-8, -9, 16, 14, 51, 91) // 9 - MONITOR_SHIELD_BUBBLE
456
SpriteFrame(-8, -9, 16, 14, 68, 76) // 10 - MONITOR_SHIELD_FIRE
457
SpriteFrame(-8, -9, 16, 14, 51, 76) // 11 - MONITOR_SHIELD_LIGHTNING
458
SpriteFrame(-8, -9, 16, 14, 68, 91) // 12 - MONITOR_EGGMAN
459
SpriteFrame(-8, -9, 16, 14, 18, 100) // 13 - MONITOR_SHIELD_GOGGLES
460
SpriteFrame(-8, -9, 16, 14, 117, 26) // 14 - MONITOR_DEBUG_SPIKES
461
SpriteFrame(-8, -9, 16, 14, 117, 41) // 15 - MONITOR_DEBUG_SHIELD
462
SpriteFrame(-8, -9, 16, 14, 117, 56) // 16 - MONITOR_DEBUG_EMERALDS
463
464
BrokenMonitor_ResetDrownMusic = BrokenMonitor_Blank
465
end event
466
467
468
// ========================
469
// Editor Events
470
// ========================
471
472
event RSDKDraw
473
DrawSprite(0)
474
end event
475
476
477
event RSDKLoad
478
LoadSpriteSheet("Global/Items.gif")
479
SpriteFrame(-16, 0, 32, 16, 51, 166)
480
481
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
482
end event
483
484