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/Mission/SCZMSetup.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: SCZSetup Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This script is mostly just a copy of the standard [SCZ Setup] object, just with a few changes for Mission Mode
9
// Changes are marked throughout the script
10
11
// Everything here is still labelled under `SCZSetup` since only the script path is different - the object name is still the same (beyond removing the space for some reason)
12
13
// ========================
14
// Aliases
15
// ========================
16
17
private alias object.value0 : object.timer
18
private alias object.value1 : object.palRotateTimer
19
private alias object.value2 : object.palRotateIndex
20
21
private alias -1 : SCZSETUP_STATIC
22
private alias 0 : SCZSETUP_FORWARD
23
private alias 1 : SCZSETUP_WINGFORTRESS
24
private alias 2 : SCZSETUP_GIVECHASE
25
private alias 3 : SCZSETUP_TOWINGFORTRESS
26
private alias 4 : SCZSETUP_FADEOUT
27
private alias 5 : SCZSETUP_RESULTS
28
29
// Player Aliases
30
private alias object.xpos : player.xpos
31
private alias object.xvel : player.xvel
32
private alias object.yvel : player.yvel
33
private alias object.speed : player.speed
34
private alias object.gravity : player.gravity
35
private alias object.controlMode : player.controlMode
36
private alias object.tileCollisions : player.tileCollisions
37
private alias object.collisionRight : player.collisionRight
38
private alias object.jumpPress : player.jumpPress
39
private alias object.jumpHold : player.jumpHold
40
private alias object.up : player.up
41
private alias object.down : player.down
42
private alias object.left : player.left
43
private alias object.right : player.right
44
45
// Game Modes
46
private alias 0 : MODE_NOSAVE
47
private alias 1 : MODE_SAVEGAME
48
private alias 2 : MODE_TIMEATTACK
49
50
// Tracks
51
private alias 0 : TRACK_STAGE
52
53
// Reserved object slots
54
private alias 10 : SLOT_ZONESETUP
55
56
// Music Loops
57
private alias 198253 : MUSIC_LOOP_SCZ
58
59
60
// ========================
61
// Static Values
62
// ========================
63
64
public value SCZSetup_scrollPos.x = 0
65
public value SCZSetup_scrollPos.y = 0
66
public value SCZSetup_scrollVelocity.x = 0
67
public value SCZSetup_scrollVelocity.y = 0
68
public value SCZSetup_hPropellerFrame = 0
69
public value SCZSetup_hPropellerTimer = 0
70
public value SCZSetup_vPropellerFrame = 0
71
public value SCZSetup_vPropellerTimer = 0
72
73
74
// ========================
75
// Tables
76
// ========================
77
78
private table SCZSetup_palRotationTable
79
0xE0E040, 0xE0A020, 0xE06000, 0xC02000
80
0xE0E0E0, 0xE0E040, 0xE0A020, 0xE06000
81
0xE0E040, 0xE0A020, 0xE06000, 0xC02000
82
0xE0A020, 0xE06000, 0xC02000, 0x802000
83
end table
84
85
86
// ========================
87
// Events
88
// ========================
89
90
event ObjectUpdate
91
object.palRotateTimer++
92
if object.palRotateTimer == 2
93
object.palRotateTimer = 0
94
95
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
96
SetPaletteEntry(0, 167, temp0)
97
98
object.palRotateIndex++
99
object.palRotateIndex &= 15
100
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
101
SetPaletteEntry(0, 168, temp0)
102
103
object.palRotateIndex++
104
object.palRotateIndex &= 15
105
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
106
SetPaletteEntry(0, 169, temp0)
107
108
object.palRotateIndex++
109
object.palRotateIndex &= 15
110
GetTableValue(temp0, object.palRotateIndex, SCZSetup_palRotationTable)
111
SetPaletteEntry(0, 170, temp0)
112
113
object.palRotateIndex++
114
object.palRotateIndex &= 15
115
end if
116
117
// Always keep the camera moving
118
camera[0].style = CAMERASTYLE_FOLLOW
119
120
player[0].gravity = GRAVITY_AIR
121
player[0].tileCollisions = false
122
123
switch object.state
124
case SCZSETUP_FORWARD // initial flight
125
SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x
126
127
temp0 = SCZSetup_scrollPos.x
128
temp0 >>= 16
129
stage.curXBoundary1 = temp0
130
131
temp0 += screen.xsize
132
stage.curXBoundary2 = temp0
133
134
if stage.curXBoundary1 >= 4480
135
// The first of the SCZMSetup changes, additions were made here to lock player control
136
// Normally, it's just `object.state++` inside here, but we skip WFZ in Missions
137
138
player[0].controlMode = CONTROLMODE_NONE
139
player[0].jumpPress = false
140
player[0].jumpHold = false
141
player[0].left = false
142
player[0].right = true
143
player[0].up = false
144
player[0].down = false
145
hParallax[0].scrollSpeed = 0
146
147
// Let's skip the Wing Fortress passby states, just end the level here
148
object.state = SCZSETUP_TOWINGFORTRESS
149
end if
150
break
151
152
case SCZSETUP_WINGFORTRESS
153
// This whole state is unused in this Mission script, it's skipped by the above
154
155
SCZSetup_scrollVelocity.x = -0x10000
156
SCZSetup_scrollVelocity.y = 0x10000
157
SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x
158
SCZSetup_scrollPos.y += SCZSetup_scrollVelocity.y
159
160
temp0 = SCZSetup_scrollPos.x
161
temp0 >>= 16
162
stage.curXBoundary1 = temp0
163
164
temp0 += screen.xsize
165
stage.curXBoundary2 = temp0
166
temp0 = SCZSetup_scrollPos.y
167
168
temp0 >>= 16
169
stage.curYBoundary1 = temp0
170
171
temp0 += screen.ysize
172
stage.curYBoundary2 = temp0
173
174
temp0 <<= 16
175
stage.deathBoundary = temp0
176
177
if stage.curYBoundary1 >= 1280
178
object.state++
179
end if
180
break
181
182
case SCZSETUP_GIVECHASE
183
// This whole state is unused here as well
184
185
SCZSetup_scrollVelocity.x = 0x10000
186
SCZSetup_scrollVelocity.y = 0
187
SCZSetup_scrollPos.x += SCZSetup_scrollVelocity.x
188
temp0 = SCZSetup_scrollPos.x
189
temp0 >>= 16
190
stage.curXBoundary1 = temp0
191
temp0 += screen.xsize
192
stage.curXBoundary2 = temp0
193
if stage.curXBoundary1 >= 5256
194
player[0].controlMode = CONTROLMODE_NONE
195
player[0].jumpPress = false
196
player[0].jumpHold = false
197
player[0].left = false
198
player[0].right = true
199
player[0].up = false
200
player[0].down = false
201
hParallax[0].scrollSpeed = 0
202
object.state++
203
end if
204
break
205
206
case SCZSETUP_TOWINGFORTRESS // player holds right and goes off screen
207
208
// Another SCZMSetup change, the following two lines are just here to make the player go off screen a bit faster
209
player[0].right = true
210
player[0].xpos += player[0].xvel
211
212
SCZSetup_scrollVelocity.x = 0
213
temp0 = stage.curXBoundary2
214
temp0 -= 32
215
temp0 <<= 16
216
if player[0].xpos > temp0
217
object.state++
218
end if
219
break
220
221
case SCZSETUP_FADEOUT // fade to WFZ
222
223
// One more SCZMSetup change, they added a line here to reset player xvel
224
// yvel reset is already part of the normal script, it's just this xvel part that's new
225
player[0].xvel = 0
226
227
player[0].yvel = 0
228
object.timer += 4
229
music.volume -= 2
230
231
// (Right here there would be a SetScreenFade to fade the screen to black, but SCZMSetup removed it)
232
233
if object.timer == 320
234
fadeColor = 0x000000
235
object.timer = 0
236
starPostID = 0
237
object.direction = FACING_RIGHT // this object's direction doesn't even matter, i think?
238
239
// Almost at the end of the SCZMSetup changes, the whole standard level end routine here was replaced
240
// with the following three lines, making the Origins mission complete HUD pop up instead
241
CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_SIGNPOST, 0)
242
object.state++
243
PlayMusic(1)
244
end if
245
break
246
247
case SCZSETUP_RESULTS
248
// The final SCZMSetup change, this state is new in this script
249
// There's not much to it, just making sure the player doesn't go flying off or anything
250
player[0].gravity = GRAVITY_GROUND
251
player[0].xpos = 0
252
player[0].xvel = 0
253
break
254
255
end switch
256
257
// R Boundary
258
if object.state < SCZSETUP_TOWINGFORTRESS
259
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
260
temp0 = player[currentPlayer].collisionRight
261
temp0 <<= 16
262
temp0 += player[currentPlayer].xpos
263
temp1 = stage.curXBoundary2
264
temp1 <<= 16
265
if temp0 > temp1
266
player[currentPlayer].xvel = 0
267
player[currentPlayer].speed = 0
268
player[currentPlayer].xpos = temp1
269
temp0 = player[currentPlayer].collisionRight
270
temp0 <<= 16
271
player[currentPlayer].xpos -= temp0
272
end if
273
next
274
end if
275
276
// The Missions never fly by WFZ, but this animation code is still here anyway cuz why not
277
SCZSetup_hPropellerFrame = SCZSetup_hPropellerTimer
278
SCZSetup_hPropellerFrame >>= 1
279
SCZSetup_hPropellerTimer++
280
SCZSetup_hPropellerTimer %= 12
281
282
SCZSetup_vPropellerFrame = SCZSetup_vPropellerTimer
283
SCZSetup_vPropellerFrame >>= 1
284
SCZSetup_vPropellerTimer++
285
SCZSetup_vPropellerTimer %= 6
286
end event
287
288
289
event ObjectStartup
290
SetMusicTrack("SkyChase.ogg", TRACK_STAGE, MUSIC_LOOP_SCZ)
291
292
// Set the "inhabitants" of this zone
293
// I sure hope they can fly...
294
animalType1 = TypeName[Cucky]
295
animalType2 = TypeName[Tocky]
296
297
object[SLOT_ZONESETUP].type = TypeName[SCZSetup]
298
object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE
299
300
SCZSetup_scrollPos.x = screen.xcenter
301
SCZSetup_scrollPos.x *= -0x10000
302
SCZSetup_scrollPos.x += player[0].xpos
303
304
SCZSetup_scrollPos.y = 0
305
306
SCZSetup_scrollVelocity.x = 0x10000
307
SCZSetup_scrollVelocity.y = 0
308
309
// These values are essentially unused, the WFZ flyby never happens in Missions
310
SCZSetup_hPropellerFrame = 0
311
SCZSetup_hPropellerTimer = 0
312
SCZSetup_vPropellerFrame = 0
313
SCZSetup_vPropellerTimer = 0
314
315
stage.curYBoundary2 = 240
316
stage.deathBoundary = 0xF00000
317
hParallax[0].scrollSpeed = 0x8000
318
end event
319
320
321
// ========================
322
// Editor Events
323
// ========================
324
325
event RSDKDraw
326
DrawSprite(0)
327
end event
328
329
330
event RSDKLoad
331
LoadSpriteSheet("Global/Display.gif")
332
SpriteFrame(-16, -16, 32, 32, 1, 143)
333
334
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
335
end event
336
337