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/SCZ/SCZSetup.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: SCZ Setup Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value1 : object.palRotateTimer
14
private alias object.value2 : object.palRotateIndex
15
16
private alias -1 : SCZSETUP_STATIC
17
private alias 0 : SCZSETUP_FORWARD
18
private alias 1 : SCZSETUP_WINGFORTRESS
19
private alias 2 : SCZSETUP_GIVECHASE
20
private alias 3 : SCZSETUP_TOWINGFORTRESS
21
private alias 4 : SCZSETUP_FADEOUT
22
23
// Player Aliases
24
private alias object.xpos : player.xpos
25
private alias object.xvel : player.xvel
26
private alias object.yvel : player.yvel
27
private alias object.speed : player.speed
28
private alias object.gravity : player.gravity
29
private alias object.controlMode : player.controlMode
30
private alias object.tileCollisions : player.tileCollisions
31
private alias object.collisionRight : player.collisionRight
32
private alias object.jumpPress : player.jumpPress
33
private alias object.jumpHold : player.jumpHold
34
private alias object.up : player.up
35
private alias object.down : player.down
36
private alias object.left : player.left
37
private alias object.right : player.right
38
39
private alias object.value0 : player.rings
40
41
// Game Modes
42
private alias 0 : MODE_NOSAVE
43
private alias 1 : MODE_SAVEGAME
44
private alias 2 : MODE_TIMEATTACK
45
46
// Tracks
47
private alias 0 : TRACK_STAGE
48
49
// Reserved object slots
50
private alias 10 : SLOT_ZONESETUP
51
52
// Music Loops
53
private alias 198253 : MUSIC_LOOP_SCZ
54
55
56
// ========================
57
// Static Values
58
// ========================
59
60
public value SCZSetup_scrollPos.x = 0
61
public value SCZSetup_scrollPos.y = 0
62
public value SCZSetup_scrollVelocity.x = 0
63
public value SCZSetup_scrollVelocity.y = 0
64
public value SCZSetup_hPropellerFrame = 0
65
public value SCZSetup_hPropellerTimer = 0
66
public value SCZSetup_vPropellerFrame = 0
67
public value SCZSetup_vPropellerTimer = 0
68
69
70
// ========================
71
// Tables
72
// ========================
73
74
private table SCZSetup_palRotationTable
75
0xE0E040, 0xE0A020, 0xE06000, 0xC02000
76
0xE0E0E0, 0xE0E040, 0xE0A020, 0xE06000
77
0xE0E040, 0xE0A020, 0xE06000, 0xC02000
78
0xE0A020, 0xE06000, 0xC02000, 0x802000
79
end table
80
81
82
// ========================
83
// Events
84
// ========================
85
86
event ObjectUpdate
87
object.palRotateTimer++
88
if object.palRotateTimer == 2
89
object.palRotateTimer = 0
90
91
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
92
SetPaletteEntry(0, 167, temp0)
93
94
object.palRotateIndex++
95
object.palRotateIndex &= 15
96
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
97
SetPaletteEntry(0, 168, temp0)
98
99
object.palRotateIndex++
100
object.palRotateIndex &= 15
101
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
102
SetPaletteEntry(0, 169, temp0)
103
104
object.palRotateIndex++
105
object.palRotateIndex &= 15
106
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
107
SetPaletteEntry(0, 170, temp0)
108
109
object.palRotateIndex++
110
object.palRotateIndex &= 15
111
end if
112
113
// Always keep the camera moving
114
camera[0].style = CAMERASTYLE_FOLLOW
115
116
player[0].gravity = GRAVITY_AIR
117
player[0].tileCollisions = false
118
119
switch object.state
120
case SCZSETUP_FORWARD // initial flight
121
SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x
122
123
temp0 = SCZSetup_scrollPos.x
124
temp0 >>= 16
125
stage.curXBoundary1 = temp0
126
127
temp0 += screen.xsize
128
stage.curXBoundary2 = temp0
129
130
if stage.curXBoundary1 >= 4480
131
object.state++
132
end if
133
break
134
135
case SCZSETUP_WINGFORTRESS // see wing fortress "fly past" (we actually just move down+left LOL)
136
SCZSetup_scrollVelocity.x = -0x10000
137
SCZSetup_scrollVelocity.y = 0x10000
138
SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x
139
SCZSetup_scrollPos.y += SCZSetup_scrollVelocity.y
140
141
temp0 = SCZSetup_scrollPos.x
142
temp0 >>= 16
143
stage.curXBoundary1 = temp0
144
145
temp0 += screen.xsize
146
stage.curXBoundary2 = temp0
147
temp0 = SCZSetup_scrollPos.y
148
149
temp0 >>= 16
150
stage.curYBoundary1 = temp0
151
152
temp0 += screen.ysize
153
stage.curYBoundary2 = temp0
154
155
temp0 <<= 16
156
stage.deathBoundary = temp0
157
158
if stage.curYBoundary1 >= 1280
159
object.state++
160
end if
161
break
162
163
case SCZSETUP_GIVECHASE // we saw wing fortress, continue to chase that egghead down!
164
SCZSetup_scrollVelocity.x = 0x10000
165
SCZSetup_scrollVelocity.y = 0
166
SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x
167
temp0 = SCZSetup_scrollPos.x
168
temp0 >>= 16
169
stage.curXBoundary1 = temp0
170
temp0 += screen.xsize
171
stage.curXBoundary2 = temp0
172
if stage.curXBoundary1 >= 5256
173
player[0].controlMode = CONTROLMODE_NONE
174
player[0].jumpPress = false
175
player[0].jumpHold = false
176
player[0].left = false
177
player[0].right = true
178
player[0].up = false
179
player[0].down = false
180
hParallax[0].scrollSpeed = 0
181
object.state++
182
end if
183
break
184
185
case SCZSETUP_TOWINGFORTRESS // player holds right and goes off screen
186
SCZSetup_scrollVelocity.x = 0
187
temp0 = stage.curXBoundary2
188
temp0 -= 32
189
temp0 <<= 16
190
if player[0].xpos > temp0
191
object.state++
192
193
#platform: USE_ORIGINS
194
stage.timeEnabled = false
195
CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)
196
if game.oneStageFlag != false
197
game.callbackResult = -1
198
CallNativeFunction4(NotifyCallback, NOTIFY_STAGE_RETRY, 1, stage.listPos, 0)
199
object.state = SCZSETUP_STATIC
200
end if
201
#endplatform
202
end if
203
break
204
205
case SCZSETUP_FADEOUT // fade to WFZ
206
player[0].yvel = 0
207
object.timer += 4
208
music.volume -= 2
209
SetScreenFade(0, 0, 0, object.timer)
210
if object.timer == 320
211
fadeColor = 0x000000
212
object.timer = 0
213
starPostID = 0
214
215
// This object's direction is never used, is it?
216
// I don't think this does anything...
217
object.direction = FACING_RIGHT
218
219
stage.listPos++
220
221
if options.gameMode == MODE_SAVEGAME
222
arrayPos1 = options.saveSlot
223
arrayPos1 <<= 3
224
if stage.player2Enabled == true
225
#platform: USE_STANDALONE
226
saveRAM[arrayPos1] = PLAYER_SONIC_TAILS_A
227
#endplatform
228
#platform: USE_ORIGINS
229
switch stage.playerListPos
230
case PLAYER_SONIC_A
231
saveRAM[arrayPos1] = PLAYER_SONIC_TAILS
232
break
233
234
case PLAYER_KNUCKLES_A
235
saveRAM[arrayPos1] = PLAYER_KNUCKLES_TAILS
236
break
237
238
case PLAYER_AMY_A
239
saveRAM[arrayPos1] = PLAYER_AMY_TAILS
240
break
241
end switch
242
#endplatform
243
else
244
saveRAM[arrayPos1] = stage.playerListPos
245
end if
246
arrayPos1++
247
saveRAM[arrayPos1] = player.lives
248
arrayPos1++
249
saveRAM[arrayPos1] = player.score
250
arrayPos1++
251
saveRAM[arrayPos1] = player.scoreBonus
252
arrayPos1++
253
254
// Bug Details:
255
// This is missing the check for if your save file is already past the next act
256
// This means the save file's act will be overwritten to Wing Fortress Zone, even if you're on a Complete save file...
257
saveRAM[arrayPos1] = stage.listPos
258
saveRAM[arrayPos1]++
259
260
arrayPos1++
261
saveRAM[arrayPos1] = specialStage.emeralds
262
arrayPos1++
263
saveRAM[arrayPos1] = specialStage.listPos
264
WriteSaveRAM()
265
end if
266
267
// ???
268
// you cannot speedrun sky chase.
269
if options.gameMode == MODE_TIMEATTACK
270
timeAttack.result = stage.seconds
271
timeAttack.result *= 100
272
temp0 = stage.minutes
273
temp0 *= 6000
274
timeAttack.result += temp0
275
timeAttack.result += stage.milliSeconds
276
stage.listPos--
277
CallNativeFunction2(SetLeaderboard, stage.listPos, timeAttack.result)
278
engine.state = 8
279
else
280
temp0 = engine.trialMode
281
if stage.listPos >= stage.listSize
282
temp0 = true
283
end if
284
285
if temp0 == false
286
#platform: USE_ORIGINS
287
CallNativeFunction4(NotifyCallback, NOTIFY_STATS_ENEMY, StageStatsUsabilityParam1, StageStatsUsabilityParam2, StageStatsUsabilityParam3)
288
CallNativeFunction2(NotifyCallback, NOTIFY_STATS_RING, player[0].rings)
289
temp0 = StageStatsUsabilityParam5
290
temp0 &= 1
291
temp1 = StageStatsUsabilityParam5
292
temp1 &= 2
293
temp2 = StageStatsUsabilityParam5
294
temp2 &= 4
295
CallNativeFunction4(NotifyCallback, NOTIFY_STATS_CHARA_ACTION, temp0, temp1, temp2)
296
CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)
297
StageStatsUsabilityParam1 = 0
298
StageStatsUsabilityParam2 = 0
299
StageStatsUsabilityParam3 = 0
300
StageStatsUsabilityParam4 = 0
301
StageStatsUsabilityParam5 = 0
302
StatsUsabilityParam1 = 0
303
StatsUsabilityParam2 = 0
304
StatsUsabilityParam3 = 0
305
StatsUsabilityParam4 = 0
306
StatsUsabilityParam5 = 0
307
#endplatform
308
309
LoadStage()
310
else
311
stage.activeList = PRESENTATION_STAGE
312
stage.listPos = 0
313
LoadStage()
314
end if
315
end if
316
end if
317
break
318
319
end switch
320
321
// R Boundary
322
if object.state < SCZSETUP_TOWINGFORTRESS
323
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
324
temp0 = player[currentPlayer].collisionRight
325
temp0 <<= 16
326
temp0 += player[currentPlayer].xpos
327
temp1 = stage.curXBoundary2
328
temp1 <<= 16
329
if temp0 > temp1
330
player[currentPlayer].xvel = 0
331
player[currentPlayer].speed = 0
332
player[currentPlayer].xpos = temp1
333
temp0 = player[currentPlayer].collisionRight
334
temp0 <<= 16
335
player[currentPlayer].xpos -= temp0
336
end if
337
next
338
end if
339
340
SCZSetup_hPropellerFrame = SCZSetup_hPropellerTimer
341
SCZSetup_hPropellerFrame >>= 1
342
SCZSetup_hPropellerTimer++
343
SCZSetup_hPropellerTimer %= 12
344
345
SCZSetup_vPropellerFrame = SCZSetup_vPropellerTimer
346
SCZSetup_vPropellerFrame >>= 1
347
SCZSetup_vPropellerTimer++
348
SCZSetup_vPropellerTimer %= 6
349
end event
350
351
352
event ObjectStartup
353
SetMusicTrack("SkyChase.ogg", TRACK_STAGE, MUSIC_LOOP_SCZ)
354
355
// Set the "inhabitants" of this zone
356
// I sure hope they can fly...
357
animalType1 = TypeName[Cucky]
358
animalType2 = TypeName[Tocky]
359
360
object[SLOT_ZONESETUP].type = TypeName[SCZ Setup]
361
object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE
362
363
SCZSetup_scrollPos.x = screen.xcenter
364
SCZSetup_scrollPos.x *= -0x10000
365
SCZSetup_scrollPos.x += player[0].xpos
366
367
SCZSetup_scrollPos.y = 0
368
369
SCZSetup_scrollVelocity.x = 0x10000
370
SCZSetup_scrollVelocity.y = 0
371
372
SCZSetup_hPropellerFrame = 0
373
SCZSetup_hPropellerTimer = 0
374
SCZSetup_vPropellerFrame = 0
375
SCZSetup_vPropellerTimer = 0
376
377
stage.curYBoundary2 = 240
378
stage.deathBoundary = 0xF00000
379
hParallax[0].scrollSpeed = 0x8000
380
end event
381
382
383
// ========================
384
// Editor Events
385
// ========================
386
387
event RSDKDraw
388
DrawSprite(0)
389
end event
390
391
392
event RSDKLoad
393
LoadSpriteSheet("Global/Display.gif")
394
SpriteFrame(-16, -16, 32, 32, 1, 143)
395
396
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
397
end event
398
399