Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Special/SpecialSetup.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Special Setup Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
public alias 256 : GROUP_PLAYERS
13
public alias arrayPos6 : currentPlayer
14
public alias arrayPos7 : playerCount
15
16
// Gravity
17
public alias 0 : GRAVITY_GROUND
18
public alias 1 : GRAVITY_AIR
19
20
// Priority
21
public alias 0 : PRIORITY_BOUNDS
22
public alias 1 : PRIORITY_ACTIVE
23
public alias 2 : PRIORITY_ALWAYS
24
public alias 3 : PRIORITY_XBOUNDS
25
public alias 4 : PRIORITY_XBOUNDS_DESTROY
26
public alias 5 : PRIORITY_INACTIVE
27
public alias 6 : PRIORITY_BOUNDS_SMALL
28
public alias 7 : PRIORITY_ACTIVE_SMALL
29
30
// Control Modes
31
public alias -1 : CONTROLMODE_NONE
32
public alias 0 : CONTROLMODE_P1
33
public alias 1 : CONTROLMODE_P2
34
public alias 2 : CONTROLMODE_P3
35
public alias 3 : CONTROLMODE_P4
36
37
// Camera Styles
38
public alias 0 : CAMERASTYLE_FOLLOW
39
public alias 1 : CAMERASTYLE_EXTENDED
40
public alias 2 : CAMERASTYLE_EXTENDED_OFFSET_L
41
public alias 3 : CAMERASTYLE_EXTENDED_OFFSET_R
42
public alias 4 : CAMERASTYLE_HLOCKED
43
44
// Ink Effects
45
public alias 0 : INK_NONE
46
public alias 1 : INK_BLEND
47
public alias 2 : INK_ALPHA
48
public alias 3 : INK_ADD
49
public alias 4 : INK_SUB
50
51
// Flip Directions
52
public alias 0 : FLIP_NONE
53
public alias 1 : FLIP_X
54
public alias 2 : FLIP_Y
55
public alias 3 : FLIP_XY
56
57
// Collision Sides
58
public alias 0 : CSIDE_FLOOR
59
public alias 1 : CSIDE_LWALL
60
public alias 2 : CSIDE_RWALL
61
public alias 3 : CSIDE_ROOF
62
63
// Collision Modes
64
public alias 0 : CMODE_FLOOR
65
public alias 1 : CMODE_LWALL
66
public alias 2 : CMODE_ROOF
67
public alias 3 : CMODE_RWALL
68
69
// Collision Directions
70
public alias 0 : COL_NONE
71
public alias 1 : COL_TOP
72
public alias 2 : COL_LEFT
73
public alias 3 : COL_RIGHT
74
public alias 4 : COL_BOTTOM
75
76
// Players List Pos Aliases
77
public alias 0 : PLAYER_SONIC_A
78
public alias 1 : PLAYER_TAILS_A
79
public alias 2 : PLAYER_KNUCKLES_A
80
public alias 3 : PLAYER_SONIC_TAILS_A
81
public alias 4 : PLAYER_KNUCKLES_TAILS_A
82
public alias 5 : PLAYER_AMY_A
83
public alias 6 : PLAYER_AMY_TAILS_A
84
85
private alias object.value1 : object.palTimer
86
private alias object.value2 : object.palID1
87
private alias object.value3 : object.palID2
88
89
// Start Message Aliases
90
private alias object.value0 : startMessage.ringCount2P
91
private alias object.value1 : startMessage.ringCountSonic
92
private alias object.value2 : startMessage.ringCountKnux
93
94
// Checkpoint Aliases
95
private alias object.value0 : checkpoint.ringCount2P
96
private alias object.value1 : checkpoint.ringCountSonic
97
private alias object.value2 : checkpoint.ringCountKnux
98
99
// Reserved object slots
100
private alias 9 : SLOT_SPECIALSETUP
101
private alias 10 : SLOT_SPECIALHUD
102
103
// Tracks
104
private alias 0 : TRACK_STAGE
105
private alias 1 : TRACK_ACTFINISH
106
107
// Music Loops
108
private alias 496644 : MUSIC_LOOP_SPECIAL
109
110
111
// ========================
112
// Static Values
113
// ========================
114
115
public value SpecialSetup_gotEmerald = 0
116
public value SpecialSetup_StageColor1 = 0
117
public value SpecialSetup_StageColor2 = 0
118
public value SpecialSetup_checkpointID = 0
119
public value SpecialSetup_ringCountTable = 0
120
121
122
// ========================
123
// Tables
124
// ========================
125
126
public table SpecialSetup_ringCount2P[3]
127
128
public table SpecialSetup_ringCountSonic[3]
129
130
public table SpecialSetup_ringCountKnux[3]
131
132
private table SpecialSetup_starPalCycle
133
0xE0E0E0, 0xD0D0D0, 0xC0C0C0, 0xB0B0B0, 0xA0A0A0, 0x909090, 0x808080, 0x707070, 0x606060, 0x707070, 0x808080, 0x909090, 0xA0A0A0, 0xB0B0B0, 0xC0C0C0, 0xD0D0D0
134
end table
135
136
137
// ========================
138
// Events
139
// ========================
140
141
event ObjectUpdate
142
ringTimer++
143
if ringTimer == 4
144
ringTimer = 0
145
ringFrame++
146
ringFrame &= 7
147
end if
148
149
object.palTimer++
150
if object.palTimer == 4
151
object.palTimer = 0
152
153
object.palID1++
154
object.palID1 &= 15
155
GetTableValue(temp0, object.palID1, SpecialSetup_starPalCycle)
156
SetPaletteEntry(0, 142, temp0)
157
158
object.palID2++
159
object.palID2 &= 15
160
GetTableValue(temp0, object.palID2, SpecialSetup_starPalCycle)
161
SetPaletteEntry(0, 143, temp0)
162
end if
163
164
#platform: USE_STANDALONE
165
// There aren't any demos in Special Stages I believe... so why is this here..?
166
// Best guess is that it's just a leftover from the standard Stage Setup script, but I can't say for sure
167
if options.attractMode == false
168
if object[2].controlMode > CONTROLMODE_NONE
169
options.touchControls = true
170
else
171
options.touchControls = false
172
end if
173
else
174
options.touchControls = false
175
end if
176
#endplatform
177
end event
178
179
180
event ObjectStartup
181
#platform: USE_ORIGINS
182
switch stage.playerListPos
183
case PLAYER_SONIC_TAILS_A
184
stage.playerListPos = PLAYER_SONIC
185
stage.player2Enabled = true
186
break
187
188
case PLAYER_KNUCKLES_TAILS_A
189
stage.playerListPos = PLAYER_KNUCKLES
190
stage.player2Enabled = true
191
break
192
193
case PLAYER_AMY_TAILS_A
194
stage.playerListPos = PLAYER_AMY
195
stage.player2Enabled = true
196
break
197
end switch
198
#endplatform
199
200
SetMusicTrack("SpecialStage.ogg", TRACK_STAGE, MUSIC_LOOP_SPECIAL)
201
SetMusicTrack("ActComplete.ogg", TRACK_ACTFINISH, false)
202
SpecialSetup_gotEmerald = false
203
204
#platform: USE_ORIGINS
205
// Sure, record the time for an autoscroller, you do you, Sonic Team
206
stage.timeEnabled = true
207
#endplatform
208
209
object[SLOT_SPECIALSETUP].type = TypeName[Special Setup]
210
object[SLOT_SPECIALSETUP].priority = PRIORITY_ACTIVE
211
object[SLOT_SPECIALSETUP].drawOrder = 1
212
object[SLOT_SPECIALSETUP].palID2 = 8
213
214
object[SLOT_SPECIALHUD].type = TypeName[HUD]
215
object[SLOT_SPECIALHUD].priority = PRIORITY_ACTIVE
216
object[SLOT_SPECIALHUD].drawOrder = 6
217
218
#platform: USE_STANDALONE
219
if stage.playerListPos >= PLAYER_SONIC_TAILS_A
220
stage.playerListPos = PLAYER_SONIC_A
221
stage.player2Enabled = true
222
end if
223
#endplatform
224
225
if options.vsMode == false
226
// In normal Special Stages, use a palette corresponding to the current act number
227
temp1 = stage.actNum
228
else
229
if vs.activeList == SPECIAL_STAGE
230
// Use a palette corresponding to the current act number, but offset a little
231
temp1 = stage.actNum
232
temp1 += 3
233
else
234
// Go all in, use a completely randomised number
235
vs.randomValue *= 1103515245
236
vs.randomValue += 12345
237
vs.randomValue &= 0x7FFFFFFF
238
temp1 = vs.randomValue
239
temp1 >>= 16
240
temp1 %= 12
241
temp1++
242
end if
243
end if
244
245
temp1 <<= 3
246
temp0 = temp1
247
temp0 -= 8
248
LoadPalette("SpecialStage.act", 0, 192, temp0, temp1)
249
250
// Grab the primary colors, for the Halfpipe vertex colors
251
GetPaletteEntry(0, 197, SpecialSetup_StageColor1)
252
SpecialSetup_StageColor1 |= 0xFF000000
253
254
GetPaletteEntry(0, 192, SpecialSetup_StageColor2)
255
SpecialSetup_StageColor2 |= 0xFF000000
256
257
if options.attractMode == false
258
// Huh. Normally there'd be STANDARD platform specific code here, but even Origins has this condition empty...
259
end if
260
261
temp0 = 1
262
foreach (TypeName[Start Message], arrayPos0, ALL_ENTITIES)
263
object[11].type = TypeName[Start Message]
264
object[11].priority = PRIORITY_ALWAYS
265
object[11].drawOrder = 5
266
SetTableValue(startMessage[arrayPos0].ringCount2P, 0, SpecialSetup_ringCount2P)
267
SetTableValue(startMessage[arrayPos0].ringCountSonic, 0, SpecialSetup_ringCountSonic)
268
SetTableValue(startMessage[arrayPos0].ringCountKnux, 0, SpecialSetup_ringCountKnux)
269
ResetObjectEntity(arrayPos0, TypeName[Blank Object], 0, 0, 0)
270
next
271
272
temp0 = 1
273
foreach (TypeName[Checkpoint], arrayPos0, ALL_ENTITIES)
274
if temp0 < 3
275
SetTableValue(checkpoint[arrayPos0].ringCount2P, temp0, SpecialSetup_ringCount2P)
276
SetTableValue(checkpoint[arrayPos0].ringCountSonic, temp0, SpecialSetup_ringCountSonic)
277
SetTableValue(checkpoint[arrayPos0].ringCountKnux, temp0, SpecialSetup_ringCountKnux)
278
temp0++
279
end if
280
281
checkpoint[arrayPos0].ringCount2P = 0
282
checkpoint[arrayPos0].ringCountSonic = 0
283
checkpoint[arrayPos0].ringCountKnux = 0
284
next
285
286
SpecialSetup_checkpointID = 0
287
if stage.player2Enabled == true
288
SpecialSetup_ringCountTable = SpecialSetup_ringCount2P
289
else
290
if stage.playerListPos == PLAYER_KNUCKLES_A
291
SpecialSetup_ringCountTable = SpecialSetup_ringCountKnux
292
else
293
SpecialSetup_ringCountTable = SpecialSetup_ringCountSonic
294
end if
295
end if
296
297
arrayPos0 = 0x20
298
while arrayPos0 < 0x420
299
if object[arrayPos0].type == TypeName[Blank Object]
300
object[arrayPos0].ypos = 0x7FFF0000
301
else
302
object[arrayPos0].priority = PRIORITY_INACTIVE
303
end if
304
305
arrayPos0++
306
loop
307
308
// Sort all objects based on ypos
309
arrayPos0 = 0x20
310
while arrayPos0 < 0x300
311
arrayPos1 = 0x2FF
312
arrayPos2 = 0x2FE
313
while arrayPos1 > arrayPos0
314
if object[arrayPos1].ypos < object[arrayPos2].ypos
315
temp0 = object[arrayPos1].type
316
temp1 = object[arrayPos1].propertyValue
317
temp2 = object[arrayPos1].xpos
318
temp3 = object[arrayPos1].ypos
319
320
object[arrayPos1].type = object[arrayPos2].type
321
object[arrayPos1].propertyValue = object[arrayPos2].propertyValue
322
object[arrayPos1].xpos = object[arrayPos2].xpos
323
object[arrayPos1].ypos = object[arrayPos2].ypos
324
325
object[arrayPos2].type = temp0
326
object[arrayPos2].propertyValue = temp1
327
object[arrayPos2].xpos = temp2
328
object[arrayPos2].ypos = temp3
329
end if
330
arrayPos1--
331
arrayPos2--
332
loop
333
334
arrayPos0++
335
loop
336
end event
337
338
339
// ========================
340
// Editor Events
341
// ========================
342
343
event RSDKDraw
344
DrawSprite(0)
345
end event
346
347
348
event RSDKLoad
349
LoadSpriteSheet("Global/Display.gif")
350
SpriteFrame(-16, -16, 32, 32, 1, 143)
351
352
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
353
end event
354
355