Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Continue/ContinueSetup.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Continue 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
14
private alias 0 : CONTINUESETUP_SETUP
15
private alias 1 : CONTINUESETUP_FADEIN
16
private alias 2 : CONTINUESETUP_PLAYERFALL
17
private alias 3 : CONTINUESETUP_WAITING
18
private alias 4 : CONTINUESETUP_CHARGEUP
19
private alias 5 : CONTINUESETUP_RUNOFFSCREEN
20
private alias 6 : CONTINUESETUP_RETURNTOSTAGE
21
private alias 7 : CONTINUESETUP_FADETOMENU
22
23
// Continue Aliases
24
private alias 1 : CONTINUE_COUNTDOWN
25
26
// Player Aliases
27
private alias object.state : player.state
28
private alias object.type : player.type
29
private alias object.speed : player.speed
30
private alias object.xpos : player.xpos
31
private alias object.ypos : player.ypos
32
private alias object.yvel : player.yvel
33
private alias object.xvel : player.xvel
34
private alias object.animation : player.animation
35
private alias object.animationSpeed : player.animationSpeed
36
private alias object.controlMode : player.controlMode
37
private alias object.propertyValue : player.character
38
39
// ========================
40
// Events
41
// ========================
42
43
event ObjectUpdate
44
switch object.state
45
case CONTINUESETUP_SETUP
46
object.timer = 320
47
SetScreenFade(0, 0, 0, object.timer)
48
object.state++
49
break
50
51
case CONTINUESETUP_FADEIN
52
if object.timer > 0
53
object.timer -= 8
54
else
55
player[0].yvel = 0x30000
56
if player[1].type != TypeName[Blank Object]
57
player[1].yvel = 0x30000
58
end if
59
60
PlayMusic(0)
61
object.state++
62
end if
63
64
SetScreenFade(0, 0, 0, object.timer)
65
break
66
67
case CONTINUESETUP_PLAYERFALL
68
temp0 = 0
69
70
// Every character has a unique target position
71
switch stage.playerListPos
72
case PLAYER_SONIC_A
73
case PLAYER_SONIC_TAILS_A
74
// 172 pixels
75
temp1 = 0xAC0000
76
break
77
78
case PLAYER_TAILS_A
79
// 177 pixels
80
temp1 = 0xB10000
81
break
82
83
case PLAYER_KNUCKLES_A
84
// 168 pixels
85
temp1 = 0xA80000
86
break
87
#platform: USE_ORIGINS
88
case PLAYER_AMY_A
89
case PLAYER_AMY_TAILS_A
90
// 172 pixels
91
temp1 = 0xAC0000
92
break
93
#endplatform
94
95
end switch
96
97
temp2 = temp1
98
temp2 += 0x80000
99
player[0].animationSpeed = 60
100
if player[0].ypos >= temp2
101
player[0].ypos = temp1
102
player[0].yvel = 0
103
player[0].animation = ANI_CONTINUE
104
105
temp0++
106
end if
107
108
if player[1].type == TypeName[Blank Object]
109
// If there's no P2, then just skip over them
110
temp0++
111
else
112
player[1].animationSpeed = 60
113
114
// We're assuming Tails values for P2 here
115
if player[1].ypos >= 0xB90000
116
player[1].ypos = 0xB10000
117
player[1].yvel = 0
118
player[1].animation = ANI_CONTINUE
119
120
temp0++
121
end if
122
end if
123
124
// Are both players ready?
125
if temp0 == 2
126
object.state++
127
object[+2].state++ // state should become CONTINUE_COUNTDOWN
128
end if
129
break
130
131
case CONTINUESETUP_WAITING
132
#platform: USE_STANDALONE
133
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
134
if checkResult > -1
135
keyPress[0].start = true
136
end if
137
138
if keyPress[0].start == true
139
#endplatform
140
141
#platform: USE_ORIGINS
142
checkResult = false
143
checkResult |= keyPress[0].start
144
checkResult |= keyPress[0].buttonA
145
checkResult |= keyPress[0].buttonC
146
if checkResult == true
147
#endplatform
148
149
player[0].animation = ANI_CONTINUE_UP
150
player[0].speed = 0
151
#platform: USE_STANDALONE
152
if stage.playerListPos == PLAYER_KNUCKLES_A
153
player[0].ypos -= 0x20000
154
else
155
player[0].ypos -= 0x60000
156
end if
157
#endplatform
158
159
#platform: USE_ORIGINS
160
switch player[0].character
161
case PLAYER_KNUCKLES_A
162
case PLAYER_AMY_A
163
player[0].ypos -= 0x20000
164
break
165
default
166
player[0].ypos -= 0x60000
167
end switch
168
#endplatform
169
170
PlaySfx(SfxName[Charge], false)
171
172
object.state++
173
object[+2].state++ // state should become CONTINUE_COUNTDOWN
174
end if
175
break
176
177
case CONTINUESETUP_CHARGEUP
178
if music.volume > 0
179
music.volume--
180
end if
181
182
player[0].speed += 0x2000
183
if player[0].speed == 0x90000
184
player[0].xvel = 0x100000
185
if player[1].type == TypeName[Blank Object]
186
object.state++
187
end if
188
end if
189
190
if player[1].type != TypeName[Blank Object]
191
if player[0].speed == 0x20000
192
player[1].animation = ANI_CONTINUE_UP
193
player[1].speed = 0
194
player[1].ypos -= 0x60000
195
PlaySfx(SfxName[Charge], false)
196
end if
197
198
if player[0].speed > 0x20000
199
player[1].speed += 0x2000
200
if player[1].speed == 0x90000
201
player[1].xvel = 0x100000
202
object.state++
203
end if
204
end if
205
end if
206
break
207
208
case CONTINUESETUP_RUNOFFSCREEN
209
if music.volume > 0
210
music.volume--
211
end if
212
213
temp0 = screen.xsize
214
temp0 += 32
215
if player[1].type == TypeName[Blank Object]
216
temp1 = player[0].xpos
217
else
218
temp1 = player[1].xpos
219
end if
220
221
temp1 >>= 16
222
if temp1 >= temp0
223
object.state++
224
end if
225
break
226
227
case CONTINUESETUP_RETURNTOSTAGE
228
if music.volume > 0
229
music.volume--
230
end if
231
232
object.timer += 4
233
SetScreenFade(0, 0, 0, object.timer)
234
235
if object.timer == 384
236
player.continues--
237
player.lives = 3
238
fadeColor = 0
239
object.timer = 0
240
lampPostID = 0
241
object.direction = FLIP_NONE // huh?
242
stage.activeList = recStageList
243
stage.listPos = recStage
244
LoadStage()
245
end if
246
break
247
248
case CONTINUESETUP_FADETOMENU
249
object.timer += 4
250
SetScreenFade(0, 0, 0, object.timer)
251
252
if object.timer == 384
253
fadeColor = 0
254
object.timer = 0
255
lampPostID = 0
256
object.direction = FLIP_NONE // what does direction even matter here...
257
258
#platform: USE_STANDALONE
259
engine.state = 8
260
#endplatform
261
262
#platform: USE_ORIGINS
263
stage.activeList = PRESENTATION_STAGE // Origins sends you back to the title screen.
264
stage.listPos = 0
265
LoadStage()
266
#endplatform
267
268
end if
269
break
270
271
end switch
272
273
// Hide touch controls
274
options.touchControls = false
275
end event
276
277
278
event ObjectDraw
279
// Fill the screen with black
280
// -> Needed to prevent frame smear, since this level doesn't have a background
281
ClearScreen(1)
282
end event
283
284
285
event ObjectStartup
286
foreach (TypeName[Continue Setup], arrayPos0, ALL_ENTITIES)
287
object[arrayPos0].drawOrder = 0
288
next
289
290
player[0].xpos = screen.xcenter
291
player[0].xpos <<= 16
292
player[0].animation = ANI_FANROTATE
293
player[0].state = Player_State_ContinueRun
294
player[0].yvel = 0x30000
295
296
// Is P2 there?
297
if player[1].type != TypeName[Blank Object]
298
// Adjust the scene to make room for P2
299
300
player[1].xpos = screen.xcenter
301
player[1].xpos <<= 16
302
player[1].animation = ANI_FANROTATE
303
player[1].state = Player_State_ContinueRun
304
player[1].yvel = 0x30000
305
player[0].xpos += 0x200000
306
player[1].xpos -= 0x200000
307
player[1].ypos += 0x50000
308
end if
309
310
// Make minor position corrections based on the main character
311
switch stage.playerListPos
312
case PLAYER_SONIC_A
313
case PLAYER_SONIC_TAILS_A
314
// Sonic doesn't need any corrections
315
break
316
317
case PLAYER_TAILS_A
318
player[0].ypos += 0x50000
319
break
320
321
case PLAYER_KNUCKLES_A
322
#platform: USE_ORIGINS
323
case PLAYER_KNUCKLES_TAILS_A // Again...? This isn't a combo in Origins Plus...
324
#endplatform
325
player[0].ypos -= 0x40000
326
break
327
#platform: USE_ORIGINS
328
case PLAYER_AMY_A
329
case PLAYER_AMY_TAILS_A
330
// Amy (and Tails) don't need any corrections?
331
break
332
#endplatform
333
334
end switch
335
336
stage.newXBoundary2 = screen.xsize
337
stage.newYBoundary2 = screen.ysize
338
339
SetMusicTrack("Continue.ogg", 0, false)
340
341
// This is meant to disable pausing, but the Player Object doesn't check if pause is enabled,
342
// and start is the only button you can press, so it pauses when you want to continue
343
stage.pauseEnabled = false
344
345
if player.continues == 0
346
// If the player has no continues they were likely brought here from the Dev Menu, so give them 3 continues
347
348
player.continues = 3
349
end if
350
351
options.touchControls = false
352
353
#platform: USE_DECOMP
354
// Not in the original game, but this fixes an issue where
355
// pressing start to continue also pauses the entire game
356
player[0].controlMode = CONTROLMODE_NONE
357
#endplatform
358
359
end event
360
361
362
// ========================
363
// Editor Events
364
// ========================
365
366
event RSDKDraw
367
DrawSprite(0)
368
end event
369
370
371
event RSDKLoad
372
LoadSpriteSheet("Global/Display.gif")
373
SpriteFrame(-16, -16, 32, 32, 1, 143)
374
375
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
376
end event
377
378