Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/SpecialSetup.txt
1319 views
1
//---------------Sonic CD Special Setup Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
7
// Universal
8
#alias Object.Value5 : Object.ScreenDepth
9
10
// HUD Alias
11
#alias Object.Value0 : HUD.UFOsCount
12
#alias Object.Value1 : HUD.TimeSeconds
13
#alias Object.Value2 : HUD.TimeFrames
14
#alias Object.Value6 : HUD.BonusUFONo // "No" akin to Entity No, not as in "is there no UFO?"
15
#alias Object.Value7 : HUD.WaterTimer
16
17
// UFO Alias
18
#alias Object.YPos : Object.ZPos
19
20
// SSSonic Aliases
21
#alias Player.ControlMode : SSSonic.ControlMode
22
23
// ControlMode Aliases
24
#alias -1 : CONTROLMODE_NONE
25
26
// Stage Finish State Aliases
27
#alias 9 : STAGEFINISH_LOADLEVELSELECT
28
29
// Game Mode Aliases
30
#alias 2 : MODE_TIMEATTACK
31
32
// Stage SFX
33
#alias 5 : SFX_S_TIMEUFO
34
#alias 7 : SFX_S_DROWNALERT
35
36
// Soundtrack
37
#alias 0 : OST_JP
38
39
// Priority
40
#alias 1 : PRIORITY_ACTIVE
41
42
// Tile Layer Types
43
#alias 4 : LAYER_3DSKY
44
45
46
sub ObjectMain
47
3DScene.NoVertices = 0
48
3DScene.NoFaces = 0
49
50
// Update the oscillation value
51
// Although it's normally used for synced movements throughout a stage, the Oscillation value is never actually used within the Special Stage
52
Oscillation++
53
if Oscillation == 512
54
Oscillation = 0
55
end if
56
57
// Time is managed here
58
59
if HUD[4].UFOsCount > 0
60
61
// This used to be checking if it was false, but Origins changed it up a bit
62
if Stage.TimeEnabled == true
63
// However, this is a bit faulty and results on a time ufo sometimes appearing in time attack, so let's exclude any of this from time attack for decomp
64
#platform: Use_Decomp
65
if Options.GameMode != MODE_TIMEATTACK
66
#endplatform
67
// Progress the timer
68
HUD[4].TimeFrames++
69
if HUD[4].TimeFrames == 60
70
HUD[4].TimeFrames = 0
71
72
if HUD[4].TimeSeconds > 0
73
if HUD[4].TimeSeconds < 6
74
// Time's almost up, play a jingle to alert the player
75
PlayStageSfx(SFX_S_DROWNALERT, false)
76
end if
77
78
HUD[4].TimeSeconds--
79
if HUD[4].TimeSeconds < 20
80
// Less than 20 seconds left, quickly, spawn a time UFO to help the player!
81
ArrayPos0 = HUD[4].BonusUFONo
82
83
// Make sure the bonus UFO doesn't exist already
84
if Object[ArrayPos0].Type != TypeName[UFO]
85
PlayStageSfx(SFX_S_TIMEUFO, false)
86
87
ArrayPos1 = ArrayPos0
88
ArrayPos1++
89
90
Object[ArrayPos0].Type = TypeName[UFO]
91
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
92
Object[ArrayPos0].PropertyValue = 2
93
Object[ArrayPos0].XPos = Object[ArrayPos1].XPos
94
Object[ArrayPos0].ZPos = Object[ArrayPos1].ZPos
95
end if
96
end if
97
else
98
// This will never happen on Time Attack
99
if Options.GameMode != MODE_TIMEATTACK
100
// Time's over, so start the stage results
101
Object[30].Type = TypeName[Stage Finish]
102
if Stage.ActNo == 8
103
// If in the Robotnik Special Stage, then go to the Level Select
104
Object[30].State = STAGEFINISH_LOADLEVELSELECT
105
Object[30].DrawOrder = 7
106
else
107
// Nope, we can just do normal results
108
Object[30].DrawOrder = 6
109
end if
110
SSSonic.ControlMode = CONTROLMODE_NONE
111
end if
112
end if
113
end if
114
115
if HUD[4].WaterTimer > 0
116
if HUD[4].WaterTimer > 1
117
if HUD[4].WaterTimer > 20
118
TempValue0 = HUD[4].TimeFrames
119
TempValue0 &= 1
120
121
if HUD[4].TimeSeconds > 0
122
HUD[4].TimeSeconds -= TempValue0
123
else
124
// In Time Attack, you can't run out of time
125
if Options.GameMode != MODE_TIMEATTACK
126
// No more time left, end the stage by spawning the results
127
Object[30].Type = TypeName[Stage Finish]
128
129
if Stage.ActNo == 8
130
// If in the Robotnik Special Stage, then go back to the Level Select rather than the normal SS results
131
132
Object[30].State = STAGEFINISH_LOADLEVELSELECT
133
Object[30].DrawOrder = 7
134
else
135
// We're in a normal stage, so show the results as normal
136
137
Object[30].DrawOrder = 6
138
end if
139
140
SSSonic.ControlMode = CONTROLMODE_NONE
141
end if
142
end if
143
else
144
if Object[3].Type != TypeName[WaterSplash]
145
HUD[4].WaterTimer = 0
146
end if
147
end if
148
149
HUD[4].WaterTimer--
150
else
151
if Object[3].Type != TypeName[WaterSplash]
152
HUD[4].WaterTimer = 0
153
else
154
TempValue0 = HUD[4].TimeFrames
155
TempValue0 &= 1
156
157
if HUD[4].TimeSeconds > 0
158
HUD[4].TimeSeconds -= TempValue0
159
else
160
161
// In Time Attack, you can't muddle your time up and time out
162
if Options.GameMode != MODE_TIMEATTACK
163
164
// Player wasted too much time puddling around and now time's up, end the stage
165
Object[30].Type=TypeName[Stage Finish]
166
167
if Stage.ActNo == 8
168
169
// If we're in Robotnik's secret Special Stage, then return to the level select
170
171
Object[30].State = STAGEFINISH_LOADLEVELSELECT
172
Object[30].DrawOrder = 7
173
174
else
175
176
// We're in a normal stage, so show the normal results
177
178
Object[30].DrawOrder = 6
179
180
end if
181
182
SSSonic.ControlMode = CONTROLMODE_NONE
183
end if
184
185
end if
186
end if
187
end if
188
end if
189
#platform: Use_Decomp
190
end if
191
#endplatform
192
end if
193
end if
194
195
end sub
196
197
198
sub ObjectDraw
199
// Sort the drawing orders of all entities
200
// (Things further away from the camera should be drawn first and things closest should be last, etc.)
201
202
TempValue0 = 0
203
TempValue1 = Screen.DrawListSize[3]
204
while TempValue0 < TempValue1
205
TempValue2 = TempValue1
206
TempValue2--
207
208
while TempValue2 > TempValue0
209
TempValue3 = TempValue2
210
TempValue2--
211
212
// Get the object slots of the two objects
213
GetDrawListEntityRef(ArrayPos0, 3, TempValue3)
214
GetDrawListEntityRef(ArrayPos1, 3, TempValue2)
215
216
// Compare their sorted draw orders
217
if Object[ArrayPos0].ScreenDepth > Object[ArrayPos1].ScreenDepth
218
// Swap them around if needed
219
SetDrawListEntityRef(ArrayPos0, 3, TempValue2)
220
SetDrawListEntityRef(ArrayPos1, 3, TempValue3)
221
end if
222
loop
223
224
TempValue0++
225
loop
226
227
end sub
228
229
230
sub ObjectStartup
231
232
// Despite not having any SpriteFrames to draw with, go ahead and load the Special Stage objects sheet anyway
233
// (It doesn't make much of a difference but hey, may as well anyway!)
234
LoadSpriteSheet("Special/Objects.gif")
235
236
// Set the ground to the "3d Sky" layer type
237
// -> This way, it'll render in high-quality mode if possible, as opposed to the "3d Floor" type
238
TileLayer[0].Type = LAYER_3DSKY
239
240
if Options.Soundtrack == OST_JP
241
SetMusicTrack("JP/SpecialStage.ogg", 0, true)
242
SetMusicTrack("JP/ZoneComplete.ogg", 1, false)
243
else
244
SetMusicTrack("US/SpecialStage.ogg", 0, 270972)
245
SetMusicTrack("US/ZoneComplete.ogg", 1, false)
246
end if
247
248
Stage.PauseEnabled = false
249
250
// Origins changed this up a bit - before, Time would always be disabled, but Origins makes it enabled for standard play
251
if Options.GameMode == MODE_TIMEATTACK
252
Stage.TimeEnabled = false
253
else
254
Stage.TimeEnabled = true
255
end if
256
257
Object[23].Type = TypeName[Special Setup]
258
Object[23].Priority = PRIORITY_ACTIVE
259
260
// Give it a draw order lower right before the primary one, to make sure it can sort all the upcoming 3d entities correctly
261
Object[23].DrawOrder = 2
262
263
// Cycle through all Blank Objects?
264
// There was likely a proper name here in the original source,
265
// but it was an invalid name so upon compiling, it got resolved as 0
266
// What this original name was though, we have no idea...
267
ArrayPos0 = 32
268
while ArrayPos0 < 1056
269
if Object[ArrayPos0].Type == TypeName[Blank Object]
270
// If the object is blank... then blank it again...
271
ResetObjectEntity(ArrayPos0, TypeName[Blank Object], 0, 0, 0)
272
end if
273
274
ArrayPos0++
275
loop
276
277
end sub
278
279
280
// ========================
281
// Editor Subs
282
// ========================
283
284
sub RSDKDraw
285
DrawSprite(0)
286
end sub
287
288
289
sub RSDKLoad
290
LoadSpriteSheet("Global/Display.gif")
291
SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Box
292
293
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
294
end sub
295
296