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/Continue/ContinueSetup.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
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
// States
15
private alias 0 : CONTINUE_INIT
16
private alias 1 : CONTINUE_FADEIN
17
private alias 2 : CONTINUE_DISPLAY
18
private alias 3 : CONTINUE_REVUP
19
private alias 4 : CONTINUE_RUN
20
private alias 5 : CONTINUE_ACCEPTED
21
private alias 6 : CONTINUE_TIMEDOUT
22
23
// Player aliases
24
private alias object.type : player.type
25
private alias object.state : player.state
26
private alias object.animation : player.animation
27
private alias object.xpos : player.xpos
28
private alias object.ypos : player.ypos
29
private alias object.xvel : player.xvel
30
private alias object.speed : player.speed
31
private alias object.controlMode : player.controlMode
32
33
34
// ========================
35
// Events
36
// ========================
37
38
event ObjectUpdate
39
switch object.state
40
case CONTINUE_INIT
41
object.timer = 320
42
SetScreenFade(0x00, 0x00, 0x00, object.timer)
43
object.state++
44
break
45
46
case CONTINUE_FADEIN
47
if object.timer > 0
48
object.timer -= 8
49
else
50
PlayMusic(0)
51
object.state++
52
53
// Tell the Continue Screen object to start counting
54
object[-1].state++
55
end if
56
SetScreenFade(0x00, 0x00, 0x00, object.timer)
57
break
58
59
case CONTINUE_DISPLAY
60
#platform: USE_STANDALONE
61
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
62
if checkResult > -1
63
keyPress[0].start = true
64
end if
65
66
if keyPress[0].start == true
67
#endplatform
68
69
#platform: USE_ORIGINS
70
checkResult = false
71
checkResult |= keyPress[0].start
72
checkResult |= keyPress[0].buttonA
73
checkResult |= keyPress[0].buttonC
74
if checkResult == true
75
#endplatform
76
player[0].animation = ANI_CONTINUE_UP
77
player[0].speed = 0
78
PlaySfx(SfxName[Charge], false)
79
object.state++
80
81
// Tell the Continue Screen object to stop counting
82
object[-1].state++
83
end if
84
break
85
86
case CONTINUE_REVUP
87
if music.volume > 0
88
// Fade out music
89
music.volume--
90
end if
91
92
player[0].speed += 0x2000
93
if player[0].speed == 0x90000
94
player[0].xvel = 0x100000
95
if player[1].type == TypeName[Blank Object]
96
object.state++
97
end if
98
end if
99
100
if player[1].type != TypeName[Blank Object]
101
if player[0].speed == 0x20000
102
player[1].animation = ANI_CONTINUE_UP
103
player[1].speed = 0
104
PlaySfx(SfxName[Charge], false)
105
end if
106
107
if player[0].speed > 0x20000
108
player[1].speed += 0x2000
109
if player[1].speed == 0x90000
110
player[1].xvel = 0x100000
111
object.state++
112
end if
113
end if
114
end if
115
break
116
117
case CONTINUE_RUN
118
if music.volume > 0
119
music.volume--
120
end if
121
122
temp0 = screen.xsize
123
temp0 += 32
124
if player[1].type == TypeName[Blank Object]
125
temp1 = player[0].xpos
126
else
127
temp1 = player[1].xpos
128
end if
129
130
temp1 >>= 16
131
if temp1 >= temp0
132
object.state++
133
end if
134
break
135
136
case CONTINUE_ACCEPTED
137
if music.volume > 0
138
music.volume--
139
end if
140
141
object.timer += 4
142
143
SetScreenFade(0x00, 0x00, 0x00, object.timer)
144
145
if object.timer == 384
146
player.continues--
147
player.lives = 3
148
fadeColor = 0x000000
149
object.timer = 0
150
starPostID = 0
151
object.direction = FLIP_NONE // this object's direction doesn't even matter...
152
stage.activeList = recStageList
153
stage.listPos = recStage
154
LoadStage()
155
end if
156
break
157
158
case CONTINUE_TIMEDOUT
159
object.timer += 4
160
SetScreenFade(0x00, 0x00, 0x00, object.timer)
161
if object.timer == 384
162
fadeColor = 0x000000
163
object.timer = 0
164
starPostID = 0
165
object.direction = FLIP_NONE // if you really wanna, ig
166
#platform: USE_STANDALONE
167
engine.state = 8
168
#endplatform
169
#platform: USE_ORIGINS
170
stage.activeList = PRESENTATION_STAGE
171
stage.listPos = 0
172
LoadStage()
173
#endplatform
174
end if
175
break
176
177
end switch
178
179
// Hide touch controls
180
options.touchControls = false
181
end event
182
183
184
event ObjectDraw
185
// Clear all old frames
186
// (This level doesn't have a background so this is needed to prevent old frame smear)
187
ClearScreen(1)
188
end event
189
190
191
event ObjectStartup
192
foreach (TypeName[Continue Setup], arrayPos0, ALL_ENTITIES)
193
object[arrayPos0].drawOrder = 0 // Draw Order 0 so we draw before everything else
194
next
195
196
// Put the player in the middle of the screen
197
player[0].xpos = screen.xcenter
198
player[0].xpos <<= 16
199
200
// Set the player's animation, although it gets set to ANI_CONTINUE a few lines below again anyway
201
player[0].animation = ANI_FANROTATE
202
203
player[0].state = Player_State_ContinueRun
204
205
// Different starting offsets based on P1
206
switch stage.playerListPos
207
case PLAYER_SONIC_A
208
case PLAYER_SONIC_TAILS_A
209
// 172 pixels
210
player[0].ypos = 0xAC0000
211
break
212
213
case PLAYER_TAILS_A
214
// Also 172 pixels, still separate from the above for whatever reason
215
player[0].ypos = 0xAC0000
216
break
217
218
case PLAYER_KNUCKLES_A // There's no check for Knuckles & Tails here in Origins, not that it's really needed anyway
219
// 176 pixels
220
player[0].ypos = 0xB00000
221
break
222
223
#platform: USE_ORIGINS
224
case PLAYER_AMY_A
225
case PLAYER_AMY_TAILS_A
226
// 175 pixels
227
player[0].ypos = 0xAF0000
228
break
229
#endplatform
230
end switch
231
232
// Set the proper P1 animation here
233
player[0].animation = ANI_CONTINUE
234
235
if player[1].type != TypeName[Blank Object]
236
// Move P2 to the center of the screen too
237
player[1].xpos = screen.xcenter
238
player[1].xpos <<= 16
239
240
// Set P2's animation, and then...
241
player[1].animation = ANI_FANROTATE
242
243
player[1].state = Player_State_ContinueRun
244
245
// Move the players a bit to make room for two
246
player[0].xpos -= 0x100000
247
player[1].xpos += 0x100000
248
player[1].ypos = player[0].ypos
249
#platform: USE_STANDALONE
250
player[1].ypos += 0x40000
251
252
// ...now set P2's animation *again*...?
253
player[1].animation = ANI_BORED
254
#endplatform
255
256
#platform: USE_ORIGINS
257
switch stage.playerListPos
258
case PLAYER_SONIC_A
259
case PLAYER_TAILS_A
260
case PLAYER_SONIC_TAILS_A
261
player[1].ypos += 0x40000
262
player[1].animation = ANI_BORED
263
break
264
265
case PLAYER_KNUCKLES_A
266
case PLAYER_KNUCKLES_TAILS_A
267
player[1].xpos -= 0x40000
268
player[1].ypos += 0x30000
269
player[1].animation = ANI_BORED
270
break
271
272
case PLAYER_AMY_A
273
case PLAYER_AMY_TAILS_A
274
player[1].ypos += 0x10000
275
player[1].animation = ANI_CONTINUE
276
break
277
end switch
278
#endplatform
279
end if
280
281
stage.newXBoundary2 = screen.xsize
282
stage.newYBoundary2 = screen.ysize
283
284
SetMusicTrack("Continue.ogg", 0, false)
285
286
// Do note - this doesn't quite work when physical input is being used since the player doesn't check against this variable before pausing the game
287
stage.pauseEnabled = false
288
289
#platform: USE_DECOMP
290
// Not in the original game, but this is for the above to fix an issue where
291
// pressing start to continue also pauses the entire game
292
player[0].controlMode = CONTROLMODE_NONE
293
#endplatform
294
295
if player.continues == 0
296
// Player was most likely brought here from the dev menu, give them three free continues
297
player.continues = 3
298
end if
299
300
options.touchControls = false
301
end event
302
303
304
// ========================
305
// Editor Events
306
// ========================
307
308
event RSDKDraw
309
DrawSprite(0)
310
end event
311
312
313
event RSDKLoad
314
LoadSpriteSheet("Global/Display.gif")
315
SpriteFrame(-16, -16, 32, 32, 1, 143)
316
317
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
318
end event
319
320