Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/SpecialRing.txt
1319 views
1
//---------------Sonic CD Special Ring Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Player.Value0 : Player.Rings
7
8
// Decomp usage only, to check which behaviour of the special ring animation should be used for 2011 data files
9
#alias Object.Value7 : Object.CheckVersion
10
11
// States
12
#alias 0 : SPECIALRING_IDLE
13
#alias 1 : SPECIALRING_BLANK
14
15
// Game Mode Aliases
16
#alias 1 : MODE_SAVEGAME
17
18
// Player
19
#alias 0 : PLAYER_SONIC_A
20
#alias 1 : PLAYER_TAILS_A
21
22
// Control Mode
23
#alias -1 : CONTROLMODE_NONE
24
25
// Global SFX
26
#alias 18 : SFX_G_SPECIALRING
27
#alias 24 : SFX_G_FLYING
28
#alias 25 : SFX_G_TIRED
29
30
// Decomp Usage alias
31
#alias 0 : UPDATED_VERSION
32
#alias 1 : OLD_VERSION
33
34
#alias 2 : TEXTINFO_ROWCOUNT // Menu Alias
35
36
37
sub ObjectMain
38
if Object.State == SPECIALRING_IDLE
39
if Player.Rings > 49
40
PlayerObjectCollision(C_TOUCH, -16, -16, 16, 16)
41
if CheckResult == true
42
Object[0].Type = TypeName[Blank Object]
43
Object[1].Type = TypeName[Blank Object]
44
45
Player.ControlMode = CONTROLMODE_NONE
46
47
Player.Direction = FACING_RIGHT
48
49
ResetObjectEntity(2, TypeName[Blank Object], 0, 0, 0)
50
51
Object.DrawOrder = 4
52
53
Object.State = SPECIALRING_BLANK
54
55
#platform: Use_Origins
56
Object.Frame = 32
57
#endplatform
58
59
#platform: Use_Standalone
60
// reduce the frame amount for steam datafiles
61
if Object.CheckVersion != UPDATED_VERSION
62
Object.Frame = 16
63
else
64
Object.Frame = 32
65
end if
66
#endplatform
67
68
StopSFX(SFX_G_FLYING)
69
StopSFX(SFX_G_TIRED)
70
PlaySfx(SFX_G_SPECIALRING, false)
71
Player.Left = false
72
Player.Right = false
73
74
#platform: Use_Haptics
75
HapticEffect(40, 0, 0, 0)
76
#endplatform
77
78
end if
79
end if
80
end if
81
end sub
82
83
84
sub ObjectDraw
85
switch Object.State
86
case SPECIALRING_IDLE
87
88
if Player.Rings > 49
89
TempValue0 = Object.Frame
90
91
#platform: Use_Standalone // 2011 Scripts
92
if Object.CheckVersion != UPDATED_VERSION
93
// Old Steam Animation
94
TempValue0 >>= 3
95
DrawSprite(TempValue0)
96
else
97
// Updated animation
98
TempValue0 >>= 2
99
if TempValue0 > 3
100
Object.Direction = FACING_LEFT
101
else
102
Object.Direction = FACING_RIGHT
103
end if
104
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
105
end if
106
107
#endplatform
108
109
#platform: Use_Origins // Origins animation, Same as 2011 mobile
110
TempValue0 = Object.Frame
111
TempValue0 >>= 2
112
113
if TempValue0 > 3
114
Object.Direction = FACING_LEFT
115
else
116
Object.Direction = FACING_RIGHT
117
end if
118
119
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
120
#endplatform
121
122
Object.Frame++
123
if Object.Frame > 31
124
Object.Frame = 0
125
end if
126
end if
127
break
128
129
case SPECIALRING_BLANK
130
TempValue0 = Object.Frame
131
TempValue0 >>= 2
132
133
#platform: Use_Standalone // 2011 Scripts
134
if Object.CheckVersion != UPDATED_VERSION
135
// Old Steam vanish animation
136
TempValue0 = Object.Frame
137
TempValue0 >>= 2
138
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
139
140
Object.Frame++
141
if Object.Frame > 31
142
Object.Direction = FACING_LEFT
143
end if
144
if Object.Frame > 47
145
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
146
end if
147
else
148
// Updated vanish animation
149
if TempValue0 > 11
150
Object.Direction = FACING_LEFT
151
else
152
Object.Direction = FACING_RIGHT
153
end if
154
155
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
156
157
CheckEqual(TempValue0, 11)
158
if CheckResult == true
159
Object.Direction = FACING_LEFT
160
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
161
else
162
if TempValue0 == 15
163
Object.Direction = FACING_LEFT
164
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
165
end if
166
end if
167
168
Object.Frame++
169
if Object.Frame > 63
170
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
171
end if
172
end if
173
#endplatform
174
175
#platform: Use_Origins // Origins animation, Same as 2011 mobile
176
if TempValue0 > 11
177
Object.Direction = FACING_LEFT
178
else
179
Object.Direction = FACING_RIGHT
180
end if
181
182
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
183
if TempValue0 == 11
184
Object.Direction = FACING_LEFT
185
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
186
else
187
if TempValue0 == 15
188
Object.Direction = FACING_LEFT
189
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
190
end if
191
end if
192
193
Object.Frame++
194
if Object.Frame > 63
195
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
196
end if
197
#endplatform
198
break
199
endswitch
200
end sub
201
202
203
sub ObjectStartup
204
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
205
LoadSpriteSheet("Global/Items2.gif")
206
end if
207
if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins
208
LoadSpriteSheet("Global/Items2_t.gif")
209
end if
210
#platform: Use_Origins
211
if Stage.PlayerListPos == PLAYER_KNUCKLES
212
LoadSpriteSheet("Global/Items2_k.gif")
213
end if
214
if Stage.PlayerListPos == PLAYER_AMY
215
LoadSpriteSheet("Global/Items2_a.gif")
216
end if
217
// Special Ring Frames
218
SpriteFrame(-32, -32, 64, 64, 83, 1) // #0 - Special Ring Frame 0
219
SpriteFrame(-28, -32, 56, 64, 199, 131) // #1 - Special Ring Frame 1
220
SpriteFrame(-24, -32, 48, 64, 148, 1) // #2 - Special Ring Frame 2
221
SpriteFrame(-16, -32, 32, 64, 223, 66) // #3 - Special Ring Frame 3
222
SpriteFrame(-12, -32, 24, 64, 197, 1) // #4 - Special Ring Frame 4
223
SpriteFrame(-16, -32, 32, 64, 223, 66) // #5 - Special Ring Frame 5
224
SpriteFrame(-24, -32, 48, 64, 148, 1) // #6 - Special Ring Frame 6
225
SpriteFrame(-28, -32, 56, 64, 199, 131) // #7 - Special Ring Frame 7
226
227
// Vanishing Frames
228
SpriteFrame(0, -32, 32, 64, 222, 1) // #8 - Ring Vanishing Frame 0
229
SpriteFrame(-16, -32, 48, 64, 101, 66) // #9 - Ring Vanishing Frame 1
230
SpriteFrame(-24, -32, 56, 64, 150, 66) // #10 - Ring Vanishing Frame 2
231
SpriteFrame(0, -32, 32, 64, 156, 131) // #11 - Ring Vanishing Frame 3
232
SpriteFrame(-24, -32, 56, 64, 150, 66) // #12 - Ring Vanishing Frame 4
233
SpriteFrame(-16, -32, 48, 64, 101, 66) // #13 - Ring Vanishing Frame 5
234
SpriteFrame(0, -32, 32, 64, 222, 1) // #14 - Ring Vanishing Frame 6
235
SpriteFrame(-32, -32, 32, 64, 124, 131) // #15 - Ring Vanishing Frame 7
236
#endplatform
237
238
#platform: Use_Decomp
239
// Custom decomp check of versions
240
// Checks the amount of rows Credits_Console has, a file that doesn't exist on mobile data files.
241
// if it's equal or less than 1 (depending of platform), means there's no such file in the game, therefore we're using a mobile data file, and the updated animation is needed
242
// otherwise, it means we are playing with a Steam/Blit datafile, and as such we need to use the old animation
243
SetupMenu(MENU_1, 0, 0, 0)
244
LoadTextFile(MENU_1, "Data/Game/Credits_Console.txt", false)
245
GetTextInfo(CheckResult, MENU_1, TEXTINFO_ROWCOUNT, 0, 0)
246
if CheckResult > 1
247
ArrayPos0 = 32
248
while ArrayPos0 < 1056
249
if Object[ArrayPos0].Type == TypeName[Special Ring]
250
Object[ArrayPos0].CheckVersion = OLD_VERSION
251
end if
252
ArrayPos0++
253
loop
254
end if
255
#endplatform
256
257
#platform: Use_Standalone
258
if CheckResult > 1
259
// Special Ring Frames (Blit)
260
SpriteFrame(-32, -32, 64, 64, 83, 1) // #0 - Special Ring Frame 0
261
SpriteFrame(-24, -32, 48, 64, 148, 1) // #1 - Special Ring Frame 1
262
SpriteFrame(-12, -32, 24, 64, 197, 1) // #2 - Special Ring Frame 2
263
SpriteFrame(-24, -32, 48, 64, 101, 66) // #3 - Special Ring Frame 3
264
265
// Vanishing Frames
266
SpriteFrame(0, -32, 32, 64, 222, 1) // #4 - Ring Vanishing Frame 0
267
SpriteFrame(-16, -32, 48, 64, 150, 66) // #5 - Ring Vanishing Frame 1
268
SpriteFrame(-24, -32, 56, 64, 199, 66) // #6 - Ring Vanishing Frame 2
269
SpriteFrame(-32, -32, 64, 64, 191, 131) // #7 - Ring Vanishing Frame 3
270
SpriteFrame(-24, -32, 56, 64, 199, 66) // #8 - Ring Vanishing Frame 4
271
SpriteFrame(-16, -32, 48, 64, 150, 66) // #9 - Ring Vanishing Frame 5
272
SpriteFrame(0, -32, 32, 64, 222, 1) // #10 - Ring Vanishing Frame 6
273
SpriteFrame(-32, -32, 64, 64, 126, 131) // #11 - Ring Vanishing Frame 7
274
else
275
// Special Ring Frames (Mobile)
276
SpriteFrame(-32, -32, 64, 64, 83, 1) // #0 - Special Ring Frame 0
277
SpriteFrame(-28, -32, 56, 64, 199, 131) // #1 - Special Ring Frame 1
278
SpriteFrame(-24, -32, 48, 64, 148, 1) // #2 - Special Ring Frame 2
279
SpriteFrame(-16, -32, 32, 64, 223, 66) // #3 - Special Ring Frame 3
280
SpriteFrame(-12, -32, 24, 64, 197, 1) // #4 - Special Ring Frame 4
281
SpriteFrame(-16, -32, 32, 64, 223, 66) // #5 - Special Ring Frame 5
282
SpriteFrame(-24, -32, 48, 64, 148, 1) // #6 - Special Ring Frame 6
283
SpriteFrame(-28, -32, 56, 64, 199, 131) // #7 - Special Ring Frame 7
284
285
// Vanishing Frames
286
SpriteFrame(0, -32, 32, 64, 222, 1) // #8 - Ring Vanishing Frame 0
287
SpriteFrame(-16, -32, 48, 64, 101, 66) // #9 - Ring Vanishing Frame 1
288
SpriteFrame(-24, -32, 56, 64, 150, 66) // #10 - Ring Vanishing Frame 2
289
SpriteFrame(0, -32, 32, 64, 156, 131) // #11 - Ring Vanishing Frame 3
290
SpriteFrame(-24, -32, 56, 64, 150, 66) // #12 - Ring Vanishing Frame 4
291
SpriteFrame(-16, -32, 48, 64, 101, 66) // #13 - Ring Vanishing Frame 5
292
SpriteFrame(0, -32, 32, 64, 222, 1) // #14 - Ring Vanishing Frame 6
293
SpriteFrame(-32, -32, 32, 64, 124, 131) // #15 - Ring Vanishing Frame 7
294
end if
295
#endplatform
296
297
// If all Time Stones are collected, we don't need any Special Stages anymore
298
if SpecialStage.TimeStones >= 0x7F
299
ArrayPos0 = 32
300
while ArrayPos0 < 1056
301
if Object[ArrayPos0].Type == TypeName[Special Ring]
302
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
303
end if
304
ArrayPos0++
305
loop
306
end if
307
308
// In Time Attack, we shouldn't enter any Special Stages
309
if Options.GameMode > MODE_SAVEGAME
310
ArrayPos0 = 32
311
while ArrayPos0 < 1056
312
if Object[ArrayPos0].Type == TypeName[Special Ring]
313
ResetObjectEntity(ArrayPos0, TypeName[BlankObject], 0, 0, 0)
314
end if
315
ArrayPos0++
316
loop
317
end if
318
319
// That 'Lite!' on the banner wasn't joking, better remove all Special Rings!
320
if Engine.TrialMode == true
321
ArrayPos0 = 32
322
while ArrayPos0 < 1056
323
if Object[ArrayPos0].Type == TypeName[Special Ring]
324
ResetObjectEntity(ArrayPos0, TypeName[BlankObject], 0, 0, 0)
325
end if
326
ArrayPos0++
327
loop
328
end if
329
end sub
330
331
332
// ========================
333
// Editor Subs
334
// ========================
335
336
sub RSDKDraw
337
DrawSprite(0)
338
end sub
339
340
341
sub RSDKLoad
342
LoadSpriteSheet("Global/Items2.gif")
343
SpriteFrame(-32, -32, 64, 64, 83, 1) // #0 - Special Ring Frame 0
344
345
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
346
end sub
347
348