Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/Monitor.txt
1319 views
1
//-----------------Sonic CD Monitor Script--------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.GravityStrength
7
#alias Object.Value2 : Object.CollisionPlane
8
9
// Broken Monitor Aliases
10
#alias Object.Value0 : BrokenMonitor.YVelocity
11
#alias Object.Value1 : BrokenMonitor.Timer
12
#alias Object.Priority : BrokenMonitor.Priority
13
#alias Object.Alpha : BrokenMonitor.Alpha
14
15
// Gravity
16
#alias 1 : GRAVITY_AIR
17
18
// States
19
#alias 0 : MONITOR_IDLE
20
#alias 1 : MONITOR_FALLING
21
22
// Priority
23
#alias 1 : PRIORITY_ACTIVE
24
25
// Collision Sides
26
#alias 0 : CSIDE_FLOOR
27
28
// Players
29
#alias 1 : PLAYER_TAILS_A
30
31
// Hit Values
32
#alias 4 : PLAYER_COL_ROOF
33
34
// Global SFX
35
#alias 8 : SFX_G_DESTROY
36
37
// Property Values
38
#alias 1 : SCREEN_RING
39
#alias 2 : SCREEN_SHIELD
40
#alias 3 : SCREEN_INVINCIBILITY
41
#alias 4 : SCREEN_POWER_SNEAKERS
42
#alias 5 : SCREEN_SONIC
43
#alias 6 : SCREEN_TIME
44
#alias 7 : SCREEN_TAILS
45
#alias 8 : SCREEN_S_MONITOR
46
#alias 9 : SCREEN_KNUCKLES
47
#alias 10 : SCREEN_AMY
48
49
// Standalone:
50
//#alias 9 : SCREEN_STATIC1
51
//#alias 10 : SCREEN_STATIC2
52
// Origins:
53
//#alias 11 : SCREEN_STATIC1
54
//#alias 12 : SCREEN_STATIC2
55
// Using values bigger than 9(or 11 in origins) on a level editor will swap the collision plane
56
// and restart the cycle, with 10/12 being Ring monitor
57
58
// Game Mode Aliases
59
#alias 2 : MODE_TIMEATTACK
60
61
// Collision Plane
62
#alias 1 : COLLISION_PLANE_B
63
64
65
sub ObjectMain
66
if Object.State == MONITOR_FALLING
67
Object.GravityStrength += 0x3800
68
Object.YPos += Object.GravityStrength
69
70
if Object.GravityStrength >= 0
71
ObjectTileCollision(CSIDE_FLOOR, 0, 16, 0)
72
if CheckResult == true
73
Object.GravityStrength = 0
74
Object.State = MONITOR_IDLE
75
end if
76
end if
77
end if
78
end sub
79
80
81
sub ObjectPlayerInteraction
82
if Player.CollisionPlane == Object.CollisionPlane
83
TempValue0 = false
84
if Player.Gravity == GRAVITY_AIR
85
if Player.YVelocity < 0
86
TempValue0 = true
87
end if
88
end if
89
90
if TempValue0 == false
91
// Technically also part of the origins code below
92
// but it would make a mess just for keeping essentially the same check so
93
CheckResult = false
94
if Player.Animation == ANI_JUMPING
95
CheckResult = true
96
end if
97
#platform: Use_Origins
98
if Stage.PlayerListPos == PLAYER_KNUCKLES
99
if Player.Animation == ANI_GLIDING
100
CheckResult = true
101
end if
102
if Player.Animation == ANI_GLIDING_STOP
103
CheckResult = true
104
end if
105
end if
106
107
if Stage.PlayerListPos == PLAYER_AMY
108
if Player.Animation == ANI_HAMMER_JUMP
109
CheckResult = true
110
end if
111
if Player.Animation == ANI_HAMMER_DASH
112
CheckResult = true
113
end if
114
end if
115
#endplatform
116
if CheckResult == true
117
PlayerObjectCollision(C_TOUCH, -16, -14, 16, 16)
118
if CheckResult == true
119
Object.State = MONITOR_IDLE
120
121
CreateTempObject(TypeName[Smoke Puff], 0, Object.XPos, Object.YPos)
122
123
Object[TempObjectPos].DrawOrder = 4
124
125
FlipSign(Player.YVelocity)
126
if Player.YVelocity > -0x20000
127
Player.YVelocity = -0x20000
128
end if
129
130
Object.Type = TypeName[Broken Monitor]
131
BrokenMonitor.Priority = PRIORITY_ACTIVE
132
BrokenMonitor.Alpha = 255
133
BrokenMonitor.YVelocity = Object.YPos
134
BrokenMonitor.Timer = -0x30000
135
PlaySfx(SFX_G_DESTROY, false)
136
137
#platform: Use_Haptics
138
HapticEffect(16, 0, 0, 0)
139
#endplatform
140
141
end if
142
else
143
PlayerObjectCollision(C_BOX, -15, -14, 15, 16)
144
end if
145
else
146
PlayerObjectCollision(C_BOX, -15, -16, 15, 16)
147
if CheckResult == PLAYER_COL_ROOF
148
Object.State = MONITOR_FALLING
149
Object.GravityStrength = -0x20000
150
151
Player.YVelocity = 0x20000
152
end if
153
end if
154
end if
155
end sub
156
157
158
sub ObjectDraw
159
Object.Frame++
160
if Object.Frame > 17
161
Object.Frame = 0
162
end if
163
164
switch Object.Frame
165
case 0
166
case 1
167
DrawSprite(0)
168
break
169
170
case 6
171
case 7
172
#platform: Use_Standalone
173
DrawSprite(9)
174
#endplatform
175
#platform: Use_Origins
176
DrawSprite(11)
177
#endplatform
178
break
179
180
case 12
181
case 13
182
#platform: Use_Standalone
183
DrawSprite(10)
184
#endplatform
185
#platform: Use_Origins
186
DrawSprite(12)
187
#endplatform
188
break
189
190
default
191
DrawSprite(Object.PropertyValue)
192
193
end switch
194
end sub
195
196
197
198
sub ObjectStartup
199
LoadSpriteSheet("Global/Items.gif")
200
201
SpriteFrame(-16, -16, 32, 32, 51, 67) // #0 - Monitor
202
203
SpriteFrame(-16, -16, 32, 32, 18, 1) // #1 - Ring Monitor
204
SpriteFrame(-16, -16, 32, 32, 18, 34) // #2 - Blue Shield Monitor
205
SpriteFrame(-16, -16, 32, 32, 18, 67) // #3 - Invincibility Monitor
206
SpriteFrame(-16, -16, 32, 32, 18, 100) // #4 - Power Sneakers Monitor
207
#platform: Use_Origins
208
if game.coinMode == false
209
SpriteFrame(-16, -16, 32, 32, 18, 133) // #5 - Sonic Monitor
210
SpriteFrame(-16, -16, 32, 32, 18, 166) // #6 - Time Monitor
211
SpriteFrame(-16, -16, 32, 32, 51, 100) // #7 - Tails Monitor
212
SpriteFrame(-16, -16, 32, 32, 51, 133) // #8 - S Monitor
213
SpriteFrame(-16, -16, 32, 32, 34, 256) // #9 - Knuckles Monitor
214
SpriteFrame(-16, -16, 32, 32, 1, 256) // #10 - Amy Monitor
215
else
216
SpriteFrame(-16, -16, 32, 32, 84, 200) // #5 - Coin Monitor (Sonic)
217
SpriteFrame(-16, -16, 32, 32, 18, 166) // #6 - Time Monitor
218
SpriteFrame(-16, -16, 32, 32, 84, 200) // #7 - Coin Monitor (Tails)
219
SpriteFrame(-16, -16, 32, 32, 51, 133) // #8 - S Monitor
220
SpriteFrame(-16, -16, 32, 32, 84, 200) // #9 - Coin Monitor (Knuckles)
221
SpriteFrame(-16, -16, 32, 32, 84, 200) // #10 - Coin Monitor (Amy)
222
end if
223
#endplatform
224
225
#platform: Use_Standalone
226
SpriteFrame(-16, -16, 32, 32, 18, 133) // #5 - Sonic Monitor
227
SpriteFrame(-16, -16, 32, 32, 18, 166) // #6 - Time Monitor
228
SpriteFrame(-16, -16, 32, 32, 51, 100) // #7 - Tails Monitor
229
SpriteFrame(-16, -16, 32, 32, 51, 133) // #8 - S Monitor
230
#endplatform
231
232
SpriteFrame(-16, -16, 32, 32, 51, 1) // #9 - Monitor Static 1
233
SpriteFrame(-16, -16, 32, 32, 51, 34) // #10 - Monitor Static 2
234
235
#platform: Use_Standalone
236
ArrayPos0 = 32
237
while ArrayPos0 < 1056
238
if Object[ArrayPos0].Type == TypeName[Monitor]
239
if Object[ArrayPos0].PropertyValue > 9
240
Object[ArrayPos0].PropertyValue -= 10
241
Object[ArrayPos0].DrawOrder = 1
242
Object[ArrayPos0].CollisionPlane = COLLISION_PLANE_B
243
end if
244
end if
245
ArrayPos0++
246
loop
247
248
if Stage.PlayerListPos == PLAYER_TAILS_A
249
ArrayPos0 = 32
250
while ArrayPos0 < 1056
251
if Object[ArrayPos0].Type == TypeName[Monitor]
252
if Object[ArrayPos0].PropertyValue == SCREEN_SONIC
253
Object[ArrayPos0].PropertyValue = SCREEN_TAILS
254
end if
255
end if
256
ArrayPos0++
257
loop
258
end if
259
#endplatform
260
261
#platform: Use_Origins
262
// Note - (used to be a Bug Detail but then they fixed it :( ):
263
// Sonic Team adjusted how Monitors' plane value work in Plus.. but they didn't actually update the scenes for it
264
// In 99% of cases it doesn't matter, since almost all monitors are Plane A,
265
// but monitors that are intended to be Plane B monitors never had their property values updated.. leading to the weird invalid monitor in Metallic Madness 2
266
// (this got fixed in 2.0.1, but leaving these comments here anyways)
267
ArrayPos0 = 32
268
while ArrayPos0 < 1056
269
if Object[ArrayPos0].Type == TypeName[Monitor]
270
if Object[ArrayPos0].PropertyValue > 11
271
Object[ArrayPos0].PropertyValue -= 12
272
Object[ArrayPos0].DrawOrder = 1
273
Object[ArrayPos0].CollisionPlane = COLLISION_PLANE_B
274
end if
275
end if
276
ArrayPos0++
277
loop
278
279
ArrayPos0 = 32
280
while ArrayPos0 < 1056
281
if Object[ArrayPos0].Type == TypeName[Monitor]
282
if Object[ArrayPos0].PropertyValue == SCREEN_SONIC
283
if Stage.PlayerListPos == PLAYER_TAILS
284
Object[ArrayPos0].PropertyValue = SCREEN_TAILS
285
end if
286
287
if Stage.PlayerListPos == PLAYER_KNUCKLES
288
Object[ArrayPos0].PropertyValue = SCREEN_KNUCKLES
289
end if
290
291
if Stage.PlayerListPos == PLAYER_AMY
292
Object[ArrayPos0].PropertyValue = SCREEN_AMY
293
end if
294
end if
295
end if
296
ArrayPos0++
297
loop
298
#endplatform
299
300
if Options.GameMode == MODE_TIMEATTACK
301
ArrayPos0 = 32
302
while ArrayPos0 < 1056
303
if Object[ArrayPos0].Type == TypeName[Monitor]
304
if Object[ArrayPos0].PropertyValue == SCREEN_SONIC
305
Object[ArrayPos0].Type = TypeName[Blank Object]
306
end if
307
end if
308
ArrayPos0++
309
loop
310
end if
311
end sub
312
313
314
// ========================
315
// Editor Subs
316
// ========================
317
318
sub RSDKEdit
319
if Editor.ReturnVariable == true
320
switch Editor.VariableID
321
case EDIT_VAR_PROPVAL // Property Value
322
CheckResult = Object.PropertyValue
323
break
324
case 0 // Contents (Standalone)
325
CheckResult = Object.PropertyValue
326
break
327
case 1 // Contents (Origins)
328
CheckResult = Object.PropertyValue
329
break
330
end switch
331
else
332
switch Editor.VariableID
333
case EDIT_VAR_PROPVAL // Property Value
334
Object.PropertyValue = Editor.VariableValue
335
break
336
case 0 // Contents (Standalone)
337
Object.PropertyValue = Editor.VariableValue
338
break
339
case 1 // Contents (Origins)
340
Object.PropertyValue = Editor.VariableValue
341
break
342
end switch
343
end if
344
end sub
345
346
347
sub RSDKDraw
348
TempValue0 = Object.PropertyValue
349
TempValue0 %= 11
350
DrawSprite(TempValue0)
351
end sub
352
353
354
sub RSDKLoad
355
LoadSpriteSheet("Global/Items.gif")
356
SpriteFrame(-16, -16, 32, 32, 51, 67) // #0 - Monitor
357
SpriteFrame(-16, -16, 32, 32, 18, 1) // #1 - Ring Monitor
358
SpriteFrame(-16, -16, 32, 32, 18, 34) // #2 - Blue Shield Monitor
359
SpriteFrame(-16, -16, 32, 32, 18, 67) // #3 - Invincibility Monitor
360
SpriteFrame(-16, -16, 32, 32, 18, 100) // #4 - Power Sneakers Monitor
361
SpriteFrame(-16, -16, 32, 32, 18, 133) // #5 - Sonic Monitor
362
SpriteFrame(-16, -16, 32, 32, 18, 166) // #6 - Time Monitor
363
SpriteFrame(-16, -16, 32, 32, 51, 100) // #7 - Tails Monitor
364
SpriteFrame(-16, -16, 32, 32, 51, 133) // #8 - S Monitor
365
SpriteFrame(-16, -16, 32, 32, 34, 256) // #9 - Knuckles Monitor
366
SpriteFrame(-16, -16, 32, 32, 1, 256) // #10 - Amy Monitor
367
SpriteFrame(-16, -16, 32, 32, 51, 1) // #11 - Monitor Static 1
368
SpriteFrame(-16, -16, 32, 32, 51, 34) // #12 - Monitor Static 2
369
370
AddEditorVariable("Contents (Standalone)")
371
SetActiveVariable("Contents (Standalone)")
372
AddEnumVariable("None", 0)
373
AddEnumVariable("10 Rings", 1)
374
AddEnumVariable("Blue Shield", 2)
375
AddEnumVariable("Invincibility", 3)
376
AddEnumVariable("Speed Shoes", 4)
377
AddEnumVariable("1UP (Sonic)", 5)
378
AddEnumVariable("Clock (Unused)", 6)
379
AddEnumVariable("1UP (Tails)", 7)
380
AddEnumVariable("S Monitor", 8)
381
AddEnumVariable("Invalid (Static)", 9)
382
AddEnumVariable("10 Rings (Plane B)", 10)
383
AddEnumVariable("Blue Shield (Plane B)", 11)
384
AddEnumVariable("Invincibility (Plane B)", 12)
385
AddEnumVariable("Speed Shoes (Plane B)", 13)
386
AddEnumVariable("1UP (Sonic (Plane B))", 14)
387
AddEnumVariable("Clock (Unused) (Plane B)", 15)
388
AddEnumVariable("1UP (Tails) (Plane B)", 16)
389
AddEnumVariable("S Monitor (Plane B)", 17)
390
AddEnumVariable("Invalid (Static) (Plane B)", 18)
391
392
AddEditorVariable("Contents (Origins)")
393
SetActiveVariable("Contents (Origins)")
394
AddEnumVariable("None", 0)
395
AddEnumVariable("10 Rings", 1)
396
AddEnumVariable("Blue Shield", 2)
397
AddEnumVariable("Invincibility", 3)
398
AddEnumVariable("Speed Shoes", 4)
399
AddEnumVariable("1UP (Sonic)", 5)
400
AddEnumVariable("Clock (Unused)", 6)
401
AddEnumVariable("1UP (Tails)", 7)
402
AddEnumVariable("S Monitor", 8)
403
AddEnumVariable("1UP (Knuckles)", 9)
404
AddEnumVariable("1UP (Amy)", 10)
405
AddEnumVariable("Invalid (Static)", 11)
406
AddEnumVariable("10 Rings (Plane B)", 12)
407
AddEnumVariable("Blue Shield (Plane B)", 13)
408
AddEnumVariable("Invincibility (Plane B)", 14)
409
AddEnumVariable("Speed Shoes (Plane B)", 15)
410
AddEnumVariable("1UP (Sonic (Plane B))", 16)
411
AddEnumVariable("Clock (Unused) (Plane B)", 17)
412
AddEnumVariable("1UP (Tails) (Plane B)", 18)
413
AddEnumVariable("S Monitor (Plane B)", 19)
414
AddEnumVariable("1UP (Knuckles)", 20)
415
AddEnumVariable("1UP (Amy)", 21)
416
AddEnumVariable("Invalid (Static) (Plane B)", 22)
417
end sub
418
419