Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/BrokenMonitor.txt
1319 views
1
//---------------Sonic CD Broken Monitor Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.PowerUpPos
7
#alias Object.Value1 : Object.Timer
8
9
// Player Aliases
10
#alias Player.Value0 : Player.Rings
11
#alias Player.Value3 : Player.SpeedShoesTimer
12
#alias Player.Value4 : Player.InvincibleTimer
13
#alias Player.Value5 : Player.BlinkTimer
14
15
// States
16
#alias 0 : BROKENMONITOR_SPAWN_POWERUP
17
#alias 1 : BROKENMONITOR_FADE_POWERUP
18
#alias 2 : BROKENMONITOR_BLANK
19
20
// Player
21
#alias 0 : PLAYER_SONIC_A
22
23
// Soundtrack
24
#alias 0 : OST_JP
25
26
// Priority
27
#alias 0 : PRIORITY_BOUNDS
28
#alias 1 : PRIORITY_ACTIVE
29
30
// Ink Effects
31
#alias 2 : INK_ALPHA
32
33
// Panning
34
#alias 0 : PAN_RIGHT
35
#alias 1 : PAN_LEFT
36
37
// Global SFX
38
#alias 10 : SFX_G_BLUESHIELD
39
#alias 20 : SFX_G_1UP
40
#alias 21 : SFX_G_ACHIEVEMENT
41
42
// Property Values
43
#alias 0 : MONITOR_BLANK
44
#alias 1 : MONITOR_RINGS
45
#alias 2 : MONITOR_SHIELD
46
#alias 3 : MONITOR_INVINCIBILITY
47
#alias 4 : MONITOR_POWER_SNEAKERS
48
#alias 5 : MONITOR_SONIC1UP
49
#alias 6 : MONITOR_TIME
50
#alias 7 : MONITOR_TAILS1UP
51
#alias 8 : MONITOR_SUPER
52
53
// Origins Exclusive
54
#alias 9 : MONITOR_KNUCKLES1UP
55
#alias 10 : MONITOR_AMY1UP
56
57
// Game Mode Aliases
58
#alias 2 : MODE_TIMEATTACK
59
60
// Blue Shield possesion Property Value
61
#alias 1 : ACTIVE_SHIELD
62
63
sub ObjectMain
64
switch Object.State
65
case BROKENMONITOR_SPAWN_POWERUP
66
if Object.Timer < 0
67
Object.PowerUpPos += Object.Timer
68
Object.Timer += 0x1800
69
else
70
Object.Timer = 0
71
end if
72
73
if Object.Timer == 0
74
Object.State = BROKENMONITOR_FADE_POWERUP
75
Object.InkEffect = INK_ALPHA
76
switch Object.PropertyValue
77
case MONITOR_RINGS
78
Player.Rings += 10
79
if Ring.Pan == PAN_RIGHT
80
SetSfxAttributes(1, -1, -100)
81
Ring.Pan = PAN_LEFT
82
else
83
SetSfxAttributes(2, -1, 100)
84
Ring.Pan = PAN_RIGHT
85
end if
86
87
if Player.Rings > 999
88
Player.Rings = 999
89
end if
90
91
if Player.Rings >= Ring.ExtraLife
92
if Options.GameMode != MODE_TIMEATTACK
93
94
#platform: Use_Origins
95
if game.coinMode == false
96
Player.Lives++
97
else
98
game.callbackParam0 = 1 // Set the amount of coins to add
99
EngineCallback(NOTIFY_ADD_COIN)
100
end if
101
#endplatform
102
103
#platform: Use_Standalone
104
Player.Lives++
105
#endplatform
106
107
if Stage.PlayerListPos == PLAYER_SONIC_A
108
PlaySfx(SFX_G_1UP, false)
109
else
110
PlaySfx(SFX_G_ACHIEVEMENT, false)
111
end if
112
113
end if
114
115
Ring.ExtraLife += 100
116
if Ring.ExtraLife > 300
117
Ring.ExtraLife = 1000
118
end if
119
120
// King of the Rings Unlock Criteria
121
if Player.Rings >= 200
122
if Stage.PlayerListPos == PLAYER_SONIC_A
123
if Stage.DebugMode == false
124
SetAchievement(4, 100)
125
end if
126
end if
127
end if
128
end if
129
break
130
131
case MONITOR_SHIELD
132
PlaySfx(SFX_G_BLUESHIELD, false)
133
Object[2].PropertyValue = ACTIVE_SHIELD
134
if Object[2].Type != TypeName[Invincibility]
135
Object[2].Type = TypeName[Blue Shield]
136
Object[2].Priority = PRIORITY_ACTIVE
137
Object[2].DrawOrder = 4
138
Object[2].InkEffect = INK_ALPHA
139
Object[2].Alpha = 160
140
Object[2].XPos = Player.XPos
141
Object[2].YPos = Player.YPos
142
end if
143
break
144
145
case MONITOR_INVINCIBILITY
146
Object[2].Type = TypeName[Invincibility]
147
Object[2].Priority = PRIORITY_ACTIVE
148
Object[2].DrawOrder = 4
149
Object[2].XPos = Player.XPos
150
Object[2].YPos = Player.YPos
151
152
if Options.Soundtrack == OST_JP
153
Player.InvincibleTimer = 0x4EC
154
else
155
Player.InvincibleTimer = 0x528
156
end if
157
158
Player.BlinkTimer = 0
159
Player.Visible = true
160
PlayMusic(2)
161
break
162
163
case MONITOR_POWER_SNEAKERS
164
PlayMusic(3)
165
Player.Acceleration = 0x1800
166
Player.AirAcceleration = 0x3000
167
Player.TopSpeed = 0xC0000
168
Player.SpeedShoesTimer = 0x528
169
break
170
171
case MONITOR_SONIC1UP
172
#platform: Use_Origins
173
// Bug Details (kinda):
174
// For some reason, Knuckles and Amy use the Sonic monitor's switch case code, meaning 1Up.wav will play instead of Achievement.wav
175
// This doesn't matter in the context of Origins since both files point to the same sound effect in HE2's RFL parameters, but
176
// in a standalone program such as the decomps, hearing Sonic's voice while playing as another character is pretty freaky
177
case MONITOR_KNUCKLES1UP
178
case MONITOR_AMY1UP
179
if game.coinMode == false
180
Player.Lives++
181
else
182
game.callbackParam0 = 1 // Set the amount of coins to add
183
EngineCallback(NOTIFY_ADD_COIN)
184
end if
185
#endplatform
186
187
#platform: Use_Standalone
188
Player.Lives++
189
#endplatform
190
191
PlaySfx(SFX_G_1UP, false)
192
break
193
194
case MONITOR_TIME
195
// Earlier in development, this monitor behaved like an Eggman monitor, hurting the player when broken
196
// This was likely a leftover from Sonic Nexus, where Eggman monitors had the same property value (6)
197
break
198
199
case MONITOR_TAILS1UP
200
#platform: Use_Origins
201
if game.coinMode == false
202
Player.Lives++
203
else
204
game.callbackParam0 = 1 // Set the amount of coins to add
205
EngineCallback(NOTIFY_ADD_COIN)
206
end if
207
#endplatform
208
209
#platform: Use_Standalone
210
Player.Lives++
211
#endplatform
212
213
PlaySfx(SFX_G_ACHIEVEMENT, false)
214
break
215
216
case MONITOR_SUPER
217
Object[2].Type = TypeName[Invincibility]
218
Object[2].Priority = PRIORITY_ACTIVE
219
Object[2].DrawOrder = 4
220
Object[2].XPos = Player.XPos
221
Object[2].YPos = Player.YPos
222
223
Player.InvincibleTimer = 0x528
224
Player.BlinkTimer = 0
225
Player.Visible = true
226
Player.Acceleration = 0x1800
227
Player.AirAcceleration = 0x3000
228
Player.TopSpeed = 0xC0000
229
Player.SpeedShoesTimer = 0x528
230
break
231
232
end switch
233
end if
234
break
235
236
case BROKENMONITOR_FADE_POWERUP
237
Object.Timer++
238
if Object.Timer == 30
239
Object.Timer = 0
240
Object.State = BROKENMONITOR_BLANK
241
242
Object.PropertyValue = MONITOR_BLANK
243
Object.Priority = PRIORITY_BOUNDS
244
else
245
if Object.Timer > 14
246
Object.Alpha -= 16
247
end if
248
end if
249
break
250
251
case BROKENMONITOR_BLANK
252
break
253
end switch
254
end sub
255
256
257
sub ObjectDraw
258
DrawSprite(0)
259
260
if Object.PropertyValue > 0
261
DrawSpriteFX(Object.PropertyValue, FX_INK, Object.XPos, Object.PowerUpPos)
262
end if
263
end sub
264
265
266
sub ObjectStartup
267
268
LoadSpriteSheet("Global/Items.gif")
269
270
// 0 - Broken Monitor Frame
271
SpriteFrame(-16, 0, 32, 16, 51, 166)
272
273
// 1-8 - Icons
274
SpriteFrame(-8, -8, 16, 16, 26, 7) // #1 - Ring
275
SpriteFrame(-8, -8, 16, 16, 26, 40) // #2 - Blue Shield
276
SpriteFrame(-8, -8, 16, 16, 26, 73) // #3 - Invincibility
277
SpriteFrame(-8, -8, 16, 16, 26, 106) // #4 - Power Sneakers
278
279
#platform: Use_Origins
280
if game.coinMode == false
281
SpriteFrame(-8, -8, 16, 16, 26, 139) // #5 - Sonic
282
else
283
SpriteFrame(-8, -8, 16, 16, 92, 206) // #5 - Coins
284
end if
285
#endplatform
286
287
#platform: Use_Standalone
288
SpriteFrame(-8, -8, 16, 16, 26, 139) // #5 - Sonic
289
#endplatform
290
291
SpriteFrame(-8, -8, 16, 16, 26, 172) // #6 - Time
292
293
#platform: Use_Origins
294
if game.coinMode == false
295
SpriteFrame(-8, -8, 16, 16, 59, 106) // #7 - Tails
296
else
297
SpriteFrame(-8, -8, 16, 16, 92, 206) // #7 - Coins
298
end if
299
#endplatform
300
301
#platform: Use_Standalone
302
SpriteFrame(-8, -8, 16, 16, 59, 106) // #7 - Tails
303
#endplatform
304
305
SpriteFrame(-8, -8, 16, 16, 59, 139) // #8 - S
306
307
#platform: Use_Origins
308
if game.coinMode == false
309
SpriteFrame(-8, -8, 16, 16, 42, 262) // #9 - Knuckles
310
else
311
SpriteFrame(-8, -8, 16, 16, 92, 206) // #9 - Coins
312
end if
313
if game.coinMode == false
314
SpriteFrame(-8, -8, 16, 16, 9, 262) // #10 - Amy
315
else
316
SpriteFrame(-8, -8, 16, 16, 92, 206) // #10 - Coins
317
end if
318
#endplatform
319
end sub
320
321
322
// ========================
323
// Editor Subs
324
// ========================
325
326
sub RSDKDraw
327
DrawSprite(0)
328
end sub
329
330
331
sub RSDKLoad
332
LoadSpriteSheet("Global/Items.gif")
333
SpriteFrame(-16, 0, 32, 16, 51, 166) // Broken Monitor
334
335
// Not to be used in-editor
336
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
337
end sub
338
339