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/Monitor.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: 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
// States
16
private alias 0 : MONITOR_STATE_IDLE
17
private alias 1 : MONITOR_STATE_FALL
18
19
// Contents Types
20
private alias 0 : MONITOR_BLANK
21
private alias 1 : MONITOR_RINGS
22
private alias 2 : MONITOR_SHIELD_BLUE
23
private alias 3 : MONITOR_INVINCIBILITY
24
private alias 4 : MONITOR_SPEEDSHOES
25
private alias 5 : MONITOR_1UP_SONIC
26
private alias 6 : MONITOR_1UP_TAILS
27
private alias 7 : MONITOR_1UP_KNUX
28
private alias 8 : MONITOR_SUPER
29
private alias 9 : MONITOR_SHIELD_BUBBLE
30
private alias 10 : MONITOR_SHIELD_FIRE
31
private alias 11 : MONITOR_SHIELD_LIGHTNING
32
private alias 12 : MONITOR_EGGMAN
33
private alias 13 : MONITOR_SHIELD_GOGGLES
34
private alias 14 : MONITOR_DEBUG_SPIKES
35
private alias 15 : MONITOR_DEBUG_SHIELD
36
private alias 16 : MONITOR_DEBUG_EMERALDS
37
private alias 17 : MONITOR_COUNT
38
39
// Broken Monitor Aliases
40
private alias 0 : MONITOR_STATE_RISE
41
42
// Player Aliases
43
private alias object.yvel : player.yvel
44
private alias object.gravity : player.gravity
45
private alias object.animation : player.animation
46
private alias object.value16 : player.isSidekick
47
private alias object.value17 : debugMode.currentSelection
48
private alias object.value25 : player.gravityStrength
49
private alias object.value40 : player.hitboxLeft
50
private alias object.value38 : player.hitboxTop
51
private alias object.value41 : player.hitboxRight
52
private alias object.value39 : player.hitboxBottom
53
54
// Game Mode Aliases
55
private alias 2 : MODE_TIMEATTACK
56
57
// Path ID Aliases
58
private alias 0 : PATH_A
59
60
// Shield Type Aliases
61
private alias 2 : SHIELDTYPE_S3_S1
62
63
// Regular Stage Aliases
64
private alias 12 : STAGE_R_SLZ1
65
private alias 13 : STAGE_R_SLZ2
66
private alias 17 : STAGE_R_SBZ3
67
68
69
// ========================
70
// Function Declarations
71
// ========================
72
73
reserve function Monitor_DebugDraw
74
reserve function Monitor_DebugSpawn
75
76
77
// ========================
78
// Static Values
79
// ========================
80
81
private value Monitor_startDebugID = 0
82
83
84
// ========================
85
// Function Definitions
86
// ========================
87
88
private function Monitor_DebugDraw
89
DrawSprite(0)
90
91
temp0 = debugMode[0].currentSelection
92
temp0 -= Monitor_startDebugID
93
if temp0 == MONITOR_1UP_SONIC
94
#platform: USE_STANDALONE
95
temp0 += stage.playerListPos
96
#endplatform
97
98
#platform: USE_ORIGINS
99
if stage.playerListPos != PLAYER_AMY_A
100
temp0 += stage.playerListPos
101
end if
102
#endplatform
103
104
else
105
if temp0 > MONITOR_1UP_SONIC
106
temp0 += 2
107
end if
108
end if
109
110
111
if temp0 >= MONITOR_SHIELD_GOGGLES
112
// Only allow Goggles in Labyrinth, otherwise skip it
113
CheckCurrentStageFolder("Zone04")
114
if checkResult == false
115
temp0++
116
end if
117
end if
118
119
DrawSprite(temp0)
120
end function
121
122
123
private function Monitor_DebugSpawn
124
temp0 = debugMode[0].currentSelection
125
temp0 -= Monitor_startDebugID
126
if temp0 == MONITOR_1UP_SONIC
127
#platform: USE_STANDALONE
128
temp0 += stage.playerListPos
129
#endplatform
130
131
#platform: USE_ORIGINS
132
if stage.playerListPos != PLAYER_AMY_A
133
temp0 += stage.playerListPos
134
end if
135
#endplatform
136
else
137
if temp0 > MONITOR_1UP_SONIC
138
temp0 += 2
139
end if
140
end if
141
142
143
if temp0 >= MONITOR_SHIELD_GOGGLES
144
// only allow goggles in labyrinth, otherwise skip it
145
CheckCurrentStageFolder("Zone04")
146
if checkResult == false
147
temp0++
148
end if
149
end if
150
151
CreateTempObject(TypeName[Monitor], temp0, object.xpos, object.ypos)
152
end function
153
154
155
// ========================
156
// Events
157
// ========================
158
159
event ObjectUpdate
160
if object.state == MONITOR_STATE_FALL
161
object.yvel += 0x3800
162
object.ypos += object.yvel
163
if object.yvel >= 0
164
ObjectTileCollision(CSIDE_FLOOR, 0, 16, PATH_A)
165
if checkResult == true
166
object.yvel = 0
167
object.state = MONITOR_STATE_IDLE
168
end if
169
end if
170
end if
171
172
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
173
CheckGreater(player[currentPlayer].yvel, -1)
174
temp0 = checkResult
175
CheckEqual(player[currentPlayer].gravity, GRAVITY_GROUND)
176
temp0 |= checkResult
177
178
if temp0 == true
179
CheckEqual(player[currentPlayer].animation, ANI_JUMPING)
180
temp0 = checkResult
181
CheckEqual(player[currentPlayer].animation, ANI_GLIDING)
182
temp0 |= checkResult
183
CheckEqual(player[currentPlayer].animation, ANI_GLIDING_STOP)
184
temp0 |= checkResult
185
#platform: USE_ORIGINS
186
CheckEqual(player[currentPlayer].animation, ANI_HAMMER_JUMP)
187
temp0 |= checkResult
188
CheckEqual(player[currentPlayer].animation, ANI_HAMMER_DASH)
189
temp0 |= checkResult
190
#endplatform
191
192
193
if temp0 == true
194
if player[currentPlayer].isSidekick == false // Only P1 should be able to break monitors
195
196
// See if P1 has collided with the monitor
197
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -14, 16, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
198
if checkResult == true
199
// Start resetting this object
200
object.state = MONITOR_STATE_RISE
201
202
// Create and setup the smoke puff
203
CreateTempObject(TypeName[Smoke Puff], 0, object.xpos, object.ypos)
204
object[tempObjectPos].drawOrder = 4
205
player[currentPlayer].yvel += player[currentPlayer].gravityStrength
206
player[currentPlayer].yvel += player[currentPlayer].gravityStrength
207
208
// Player recoil
209
FlipSign(player[currentPlayer].yvel)
210
211
// Switch this item to the broken variant
212
object.type = TypeName[Broken Monitor]
213
214
if object.priority != PRIORITY_XBOUNDS_DESTROY
215
object.priority = PRIORITY_ACTIVE
216
end if
217
218
// Setup the alpha for the icon fading
219
object.alpha = 0x100
220
221
object.contentsPos.y = object.ypos
222
object.timer = -0x30000
223
224
PlaySfx(SfxName[Destroy], false)
225
end if
226
else
227
// Simply act as a box for P2 since only P1 can break monitors
228
BoxCollisionTest(C_SOLID, object.entityPos, -15, -14, 15, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
229
end if
230
else
231
// Player isn't in a state to break the monitor, just act as a solid box
232
BoxCollisionTest(C_SOLID, object.entityPos, -15, -14, 15, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
233
end if
234
else
235
// Check if the player hit the monitor
236
BoxCollisionTest(C_SOLID, object.entityPos, -15, -16, 15, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
237
238
// Did the player hit the monitor from underneath?
239
if checkResult == COL_BOTTOM
240
object.state = MONITOR_STATE_FALL
241
object.yvel = -0x20000
242
player[currentPlayer].yvel = 0x20000
243
end if
244
end if
245
next
246
end event
247
248
249
event ObjectDraw
250
DrawSprite(0)
251
252
switch StageSetup_monitorOverlayFrame
253
case 0
254
case 1
255
break
256
257
case 6
258
case 7
259
DrawSprite(18)
260
break
261
262
case 12
263
case 13
264
DrawSprite(19)
265
break
266
267
default
268
DrawSprite(object.propertyValue)
269
end switch
270
end event
271
272
273
event ObjectStartup
274
LoadSpriteSheet("Global/Items.gif")
275
276
// Monitor frames
277
278
// Base monitor sprite
279
SpriteFrame(-16, -16, 32, 32, 18, 1)
280
281
// Icons
282
SpriteFrame(-8, -9, 16, 14, 51, 16) // 1 - MONITOR_RINGS
283
SpriteFrame(-8, -9, 16, 14, 68, 16) // 2 - MONITOR_SHIELD_BLUE
284
SpriteFrame(-8, -9, 16, 14, 51, 31) // 3 - MONITOR_INVINCIBILITY
285
SpriteFrame(-8, -9, 16, 14, 68, 31) // 4 - MONITOR_SPEEDSHOES
286
#platform: USE_ORIGINS
287
if game.coinMode == false
288
if stage.playerListPos == PLAYER_AMY
289
SpriteFrame(-8, -9, 16, 14, 166, 118) // 5 - MONITOR_1UP_SONIC, except it's actually Amy
290
else
291
SpriteFrame(-8, -9, 16, 14, 51, 46) // 5 - MONITOR_1UP_SONIC, actually Sonic this time
292
end if
293
#endplatform
294
#platform: USE_STANDALONE
295
SpriteFrame(-8, -9, 16, 14, 51, 46) // 5 - MONITOR_1UP_SONIC
296
#endplatform
297
SpriteFrame(-8, -9, 16, 14, 68, 46) // 6 - MONITOR_1UP_TAILS
298
SpriteFrame(-8, -9, 16, 14, 51, 61) // 7 - MONITOR_1UP_KNUX
299
#platform: USE_ORIGINS
300
else
301
SpriteFrame(-8, -9, 16, 14, 35, 100) // 5 - MONITOR_1UP_SONIC (Coin)
302
SpriteFrame(-8, -9, 16, 14, 35, 100) // 6 - MONITOR_1UP_TAILS (Coin.. again)
303
SpriteFrame(-8, -9, 16, 14, 35, 100) // 7 - MONITOR_1UP_KNUX (Coin :D)
304
end if
305
#endplatform
306
SpriteFrame(-8, -9, 16, 14, 68, 61) // 8 - MONITOR_SUPER
307
SpriteFrame(-8, -9, 16, 14, 51, 91) // 9 - MONITOR_SHIELD_BUBBLE
308
SpriteFrame(-8, -9, 16, 14, 68, 76) // 10 - MONITOR_SHIELD_FIRE
309
SpriteFrame(-8, -9, 16, 14, 51, 76) // 11 - MONITOR_SHIELD_LIGHTNING
310
SpriteFrame(-8, -9, 16, 14, 68, 91) // 12 - MONITOR_EGGMAN
311
SpriteFrame(-8, -9, 16, 14, 18, 100) // 13 - MONITOR_SHIELD_GOGGLES
312
SpriteFrame(-8, -9, 16, 14, 117, 26) // 14 - MONITOR_DEBUG_SPIKES
313
SpriteFrame(-8, -9, 16, 14, 117, 41) // 15 - MONITOR_DEBUG_SHIELD
314
SpriteFrame(-8, -9, 16, 14, 117, 56) // 16 - MONITOR_DEBUG_EMERALDS
315
SpriteFrame(-8, -9, 16, 14, 117, 71) // 17 - unknown, it points to a Goggles sprite but it was probably an actual icon in earlier vers of the sheet
316
SpriteFrame(-8, -9, 16, 14, 51, 1) // 18 - Static 1
317
SpriteFrame(-8, -9, 16, 14, 68, 1) // 19 - Static 2
318
319
Monitor_startDebugID = DebugMode_ObjCount
320
Monitor_startDebugID--
321
322
// Loop to add all monitors to debug mode
323
temp0 = MONITOR_RINGS
324
while temp0 < MONITOR_COUNT
325
temp2 = true
326
327
if temp0 >= MONITOR_1UP_SONIC
328
if temp0 <= MONITOR_1UP_KNUX
329
temp1 = temp0
330
temp1 -= MONITOR_1UP_SONIC
331
if stage.playerListPos != temp1
332
temp2 = false
333
#platform: USE_ORIGINS
334
if temp1 == PLAYER_SONIC
335
if stage.playerListPos == PLAYER_AMY
336
temp2 = true
337
end if
338
end if
339
#endplatform
340
end if
341
end if
342
end if
343
344
if temp0 == MONITOR_SHIELD_GOGGLES
345
// Goggles are only for Labyrinth Zone
346
CheckCurrentStageFolder("Zone04")
347
if checkResult == false
348
temp2 = false
349
end if
350
end if
351
352
if temp2 == true
353
SetTableValue(TypeName[Monitor], DebugMode_ObjCount, DebugMode_TypesTable)
354
SetTableValue(Monitor_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
355
SetTableValue(Monitor_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
356
DebugMode_ObjCount++
357
end if
358
359
temp0++
360
loop
361
362
// Switch life icons to the Tails variant if Tails is the main character
363
if stage.playerListPos == PLAYER_TAILS_A
364
foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)
365
if object[arrayPos0].propertyValue == MONITOR_1UP_SONIC
366
object[arrayPos0].propertyValue = MONITOR_1UP_TAILS
367
end if
368
next
369
end if
370
371
// Switch life icons to the Knuckles variant if Knuckles is the main character
372
if stage.playerListPos == PLAYER_KNUCKLES_A
373
foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)
374
if object[arrayPos0].propertyValue == MONITOR_1UP_SONIC
375
object[arrayPos0].propertyValue = MONITOR_1UP_KNUX
376
end if
377
next
378
end if
379
380
if options.shieldType < SHIELDTYPE_S3_S1 // Are S3 shields disabled?
381
switch stage.listPos
382
case STAGE_R_SLZ1
383
case STAGE_R_SLZ2
384
case STAGE_R_SBZ3 // (aka LZ4)
385
foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)
386
if object[arrayPos0].propertyValue >= MONITOR_SHIELD_BUBBLE
387
if object[arrayPos0].propertyValue <= MONITOR_SHIELD_LIGHTNING
388
// Completely erase all elemental shield monitors
389
object[arrayPos0].type = TypeName[Blank Object]
390
end if
391
end if
392
next
393
break
394
395
default
396
foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)
397
if object[arrayPos0].propertyValue >= MONITOR_SHIELD_BUBBLE
398
if object[arrayPos0].propertyValue <= MONITOR_SHIELD_LIGHTNING
399
// Turn all elemental shield monitors into standard shields
400
object[arrayPos0].propertyValue = MONITOR_SHIELD_BLUE
401
end if
402
end if
403
next
404
break
405
406
end switch
407
end if
408
409
if options.gameMode == MODE_TIMEATTACK
410
// Delete every life monitor
411
foreach (TypeName[Monitor], arrayPos0, ALL_ENTITIES)
412
if object[arrayPos0].propertyValue == MONITOR_1UP_SONIC
413
object[arrayPos0].type = TypeName[Blank Object]
414
end if
415
next
416
end if
417
end event
418
419
420
// ========================
421
// Editor Events
422
// ========================
423
424
event RSDKEdit
425
if editor.returnVariable == true
426
switch editor.variableID
427
case EDIT_VAR_PROPVAL // property value
428
checkResult = object.propertyValue
429
break
430
431
case 0 // contents
432
checkResult = object.propertyValue
433
break
434
435
end switch
436
else
437
switch editor.variableID
438
case EDIT_VAR_PROPVAL // property value
439
object.propertyValue = editor.variableValue
440
break
441
442
case 0 // contents
443
object.propertyValue = editor.variableValue
444
break
445
446
end switch
447
end if
448
end event
449
450
451
event RSDKDraw
452
DrawSprite(0)
453
DrawSprite(object.propertyValue)
454
end event
455
456
457
event RSDKLoad
458
LoadSpriteSheet("Global/Items.gif")
459
SpriteFrame(-16, -16, 32, 32, 18, 1)
460
SpriteFrame(-8, -9, 16, 14, 51, 16)
461
SpriteFrame(-8, -9, 16, 14, 68, 16)
462
SpriteFrame(-8, -9, 16, 14, 51, 31)
463
SpriteFrame(-8, -9, 16, 14, 68, 31)
464
SpriteFrame(-8, -9, 16, 14, 51, 46)
465
SpriteFrame(-8, -9, 16, 14, 68, 46)
466
SpriteFrame(-8, -9, 16, 14, 51, 61)
467
SpriteFrame(-8, -9, 16, 14, 68, 61)
468
SpriteFrame(-8, -9, 16, 14, 51, 91)
469
SpriteFrame(-8, -9, 16, 14, 68, 76)
470
SpriteFrame(-8, -9, 16, 14, 51, 76)
471
SpriteFrame(-8, -9, 16, 14, 68, 91)
472
SpriteFrame(-8, -9, 16, 14, 18, 100)
473
SpriteFrame(-8, -9, 16, 14, 117, 26)
474
SpriteFrame(-8, -9, 16, 14, 117, 41)
475
SpriteFrame(-8, -9, 16, 14, 117, 56)
476
SpriteFrame(-8, -9, 16, 14, 117, 71)
477
SpriteFrame(-8, -9, 16, 14, 51, 1)
478
SpriteFrame(-8, -9, 16, 14, 68, 1)
479
480
AddEditorVariable("contents")
481
SetActiveVariable("contents")
482
AddEnumVariable("None", 0)
483
AddEnumVariable("10 Rings", 1)
484
AddEnumVariable("Blue Shield", 2)
485
AddEnumVariable("Invincibility", 3)
486
AddEnumVariable("Speed Shoes", 4)
487
AddEnumVariable("1UP (Sonic)", 5)
488
AddEnumVariable("1UP (Tails)", 6)
489
AddEnumVariable("1UP (Knux)", 7)
490
AddEnumVariable("Super", 8)
491
AddEnumVariable("Bubble Shield", 9)
492
AddEnumVariable("Fire Shield", 10)
493
AddEnumVariable("Lightning Shield", 11)
494
AddEnumVariable("Eggman", 12)
495
AddEnumVariable("Goggles", 13)
496
AddEnumVariable("Spike Toggle", 14)
497
AddEnumVariable("Shields Toggle", 15)
498
AddEnumVariable("Emeralds Toggle", 16)
499
end event
500
501