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/2PVS/2PVSMenu4.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: 2P VS Menu 4 Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This script is exclusive to Sonic Origins
9
// It's a local multiplayer version of 2P VS Menu 2 (Character Select)
10
11
// Slot 0 = 2PVSSetup
12
// Slot 1 = Player 1's 2PVSMenu4 (prop val 1)
13
// Slot 2 = Player 2's 2PVSMenu4 (prop val 2)
14
15
// ========================
16
// Aliases
17
// ========================
18
19
private alias object.propertyValue : object.player
20
21
private alias object.value0 : object.timer
22
private alias object.value1 : object.selection
23
private alias object.value2 : object.selectionTimer
24
25
// States
26
private alias 0 : 2PVSMENU4_SETUP
27
private alias 1 : 2PVSMENU4_WAITFORINPUT
28
private alias 2 : 2PVSMENU4_SELECTING
29
private alias 3 : 2PVSMENU4_SELECTEDPLAYER
30
private alias 4 : 2PVSMENU4_WAITFORP1
31
private alias 5 : 2PVSMENU4_WAITFORP2
32
private alias 6 : 2PVSMENU4_TOVSMENU3
33
private alias 7 : 2PVSMENU4_TOVSMENU1
34
35
// Selections
36
private alias 0 : 2PVSMENU4_SEL_NONE
37
private alias 1 : 2PVSMENU4_SEL_SONIC
38
private alias 2 : 2PVSMENU4_SEL_TAILS
39
private alias 3 : 2PVSMENU4_SEL_KNUX
40
private alias 4 : 2PVSMENU4_SEL_AMY
41
private alias 5 : 2PVSMENU4_SEL_BACK
42
43
// 2PVSMenu1 Aliases
44
private alias object.value0 : 2PVSMenu1.timer
45
46
private alias 1 : 2PVSMENU1_SELECTING
47
48
// 2PVSMenu3 Aliases
49
private alias object.value0 : 2PVSMenu3.timer
50
51
private alias 1 : 2PVSMENU3_SELECTING
52
53
54
// ========================
55
// Events
56
// ========================
57
58
event ObjectUpdate
59
switch object.state
60
case 2PVSMENU4_SETUP
61
AssignInputSlotToDevice(object.player, -1)
62
object.selection = 2PVSMENU4_SEL_NONE
63
object.state = 2PVSMENU4_WAITFORINPUT
64
break
65
66
case 2PVSMENU4_WAITFORINPUT
67
arrayPos0 = object.player
68
69
checkResult = keyPress[arrayPos0].up
70
checkResult |= keyPress[arrayPos0].down
71
checkResult |= keyPress[arrayPos0].left
72
checkResult |= keyPress[arrayPos0].right
73
checkResult |= keyPress[arrayPos0].buttonA
74
checkResult |= keyPress[arrayPos0].buttonC
75
checkResult |= keyPress[arrayPos0].start
76
77
if checkResult == true
78
object.selection = 2PVSMENU4_SEL_SONIC
79
object.state = 2PVSMENU4_SELECTING
80
PlaySfx(SfxName[Menu Move], false)
81
end if
82
83
if keyPress[0].buttonB == true
84
if object.entityPos == 1 // If this is the P1 box
85
if object.state == 2PVSMENU4_WAITFORINPUT
86
object.timer = 0
87
object.state = 2PVSMENU4_TOVSMENU1
88
end if
89
end if
90
end if
91
break
92
93
case 2PVSMENU4_SELECTING
94
arrayPos0 = object.player
95
96
temp0 = 0
97
98
if keyPress[arrayPos0].buttonB == true
99
object.selection = 2PVSMENU4_SEL_NONE
100
object.state = 2PVSMENU4_WAITFORINPUT
101
else
102
if keyPress[arrayPos0].left == true
103
temp0 = 1
104
object.selection--
105
if object.selection < 2PVSMENU4_SEL_SONIC
106
if game.hasPlusDLC == true
107
object.selection = 2PVSMENU4_SEL_AMY
108
else
109
object.selection = 2PVSMENU4_SEL_KNUX
110
end if
111
end if
112
PlaySfx(SfxName[Menu Move], false)
113
end if
114
115
if keyPress[arrayPos0].right == true
116
temp0 = 2
117
object.selection++
118
if game.hasPlusDLC == true
119
if object.selection > 2PVSMENU4_SEL_AMY
120
object.selection = 2PVSMENU4_SEL_SONIC
121
end if
122
else
123
if object.selection > 2PVSMENU4_SEL_KNUX
124
object.selection = 2PVSMENU4_SEL_SONIC
125
end if
126
end if
127
PlaySfx(SfxName[Menu Move], false)
128
end if
129
130
checkResult = keyPress[arrayPos0].start
131
checkResult |= keyPress[arrayPos0].buttonA
132
if checkResult == true
133
object.selectionTimer = 0
134
PlaySfx(SfxName[Star Post], false)
135
object.state = 2PVSMENU4_SELECTEDPLAYER
136
end if
137
end if
138
139
foreach (TypeName[2P VS Menu 4], arrayPos0, ACTIVE_ENTITIES)
140
if arrayPos0 != object.entityPos
141
if object[arrayPos0].state > 2PVSMENU4_SELECTING
142
// If both players are highlighting the same character, change it so they aren't
143
if object[arrayPos0].selection == object.selection
144
if temp0 == 1
145
object.selection--
146
if object.value1 < 2PVSMENU4_SEL_SONIC
147
if game.hasPlusDLC == true
148
object.selection = 2PVSMENU4_SEL_AMY
149
else
150
object.selection = 2PVSMENU4_SEL_KNUX
151
end if
152
end if
153
else
154
object.selection++
155
if game.hasPlusDLC == true
156
if object.selection > 2PVSMENU4_SEL_AMY
157
object.selection = 2PVSMENU4_SEL_SONIC
158
end if
159
else
160
if object.selection > 2PVSMENU4_SEL_KNUX
161
object.selection = 2PVSMENU4_SEL_SONIC
162
end if
163
end if
164
end if
165
end if
166
end if
167
end if
168
next
169
break
170
171
case 2PVSMENU4_SELECTEDPLAYER
172
if object.selectionTimer < 32
173
object.selectionTimer++
174
else
175
object.timer = -256
176
177
if object.player == 1
178
object.state = 2PVSMENU4_WAITFORP2
179
if object.selection == 2PVSMENU4_SEL_AMY
180
stage.playerListPos = PLAYER_AMY
181
else
182
stage.playerListPos = object.selection
183
stage.playerListPos--
184
end if
185
else
186
object.state = 2PVSMENU4_WAITFORP1
187
if object.selection == 2PVSMENU4_SEL_AMY
188
vs.player2Type = PLAYER_AMY
189
else
190
vs.player2Type = object.selection
191
vs.player2Type--
192
end if
193
end if
194
end if
195
break
196
197
case 2PVSMENU4_WAITFORP1
198
break
199
200
case 2PVSMENU4_WAITFORP2
201
checkResult = true
202
foreach (TypeName[2P VS Menu 4], arrayPos0, ACTIVE_ENTITIES)
203
if object[arrayPos0].state < 2PVSMENU4_WAITFORP1
204
checkResult = false
205
end if
206
next
207
208
if checkResult == true
209
object.state = 2PVSMENU4_TOVSMENU3
210
else
211
arrayPos0 = object.player
212
if keyPress[arrayPos0].buttonB == true
213
object.state = 2PVSMENU4_SELECTING
214
PlaySfx(SfxName[Menu Back], false)
215
end if
216
end if
217
break
218
219
case 2PVSMENU4_TOVSMENU3
220
if object.timer < 256
221
object.timer += 16
222
if object.timer > 0
223
SetScreenFade(0, 0, 0, object.timer)
224
end if
225
else
226
ResetObjectEntity(1, TypeName[2P VS Menu 3], 0, 0, 0)
227
object[1].priority = PRIORITY_ACTIVE
228
ResetObjectEntity(2, TypeName[Blank Object], 0, 0, 0)
229
object[0].state = 2PVSMENU3_SELECTING
230
2PVSMenu3[0].timer = 384
231
SetScreenFade(0, 0, 0, 255)
232
end if
233
break
234
235
case 2PVSMENU4_TOVSMENU1
236
if object.timer < 256
237
object.timer += 16
238
SetScreenFade(0, 0, 0, object.timer)
239
else
240
ResetObjectEntity(1, TypeName[2P VS Menu 1], 0, 0, 0)
241
object[1].priority = PRIORITY_ACTIVE
242
ResetObjectEntity(2, TypeName[Blank Object], 0, 0, 0)
243
object[0].state = 2PVSMENU1_SELECTING
244
2PVSMenu1[0].timer = 384
245
SetScreenFade(0, 0, 0, 255)
246
end if
247
break
248
249
end switch
250
end event
251
252
253
event ObjectDraw
254
if object.player == 1
255
// For the main object, draw the "Player Select" text at the top of the screen
256
DrawSpriteScreenXY(0, screen.xcenter, 17)
257
DrawSpriteScreenXY(1, screen.xcenter, 17)
258
end if
259
260
// Draw the Selection Box
261
// (This little bit of math is to make the selection box flash a little, after the character's been selected)
262
temp0 = object.selectionTimer
263
temp0 >>= 2
264
temp0 &= 1
265
temp0 += 2
266
DrawSpriteScreenXY(temp0, screen.xcenter, object.ypos)
267
268
switch object.selection
269
case 2PVSMENU4_SEL_NONE
270
DrawSpriteScreenXY(11, screen.xcenter, object.ypos) // "Wating for"
271
temp0 = 11
272
temp0 += object.player
273
DrawSpriteScreenXY(temp0, screen.xcenter, object.ypos) // Either "P1" or "P2"
274
break
275
276
case 2PVSMENU4_SEL_SONIC
277
DrawSpriteScreenXY(4, screen.xcenter, object.ypos)
278
break
279
280
case 2PVSMENU4_SEL_TAILS
281
DrawSpriteScreenXY(5, screen.xcenter, object.ypos)
282
break
283
284
case 2PVSMENU4_SEL_KNUX
285
DrawSpriteScreenXY(6, screen.xcenter, object.ypos)
286
break
287
288
case 2PVSMENU4_SEL_AMY
289
DrawSpriteScreenXY(14, screen.xcenter, object.ypos)
290
break
291
end switch
292
293
if object.state == 2PVSMENU4_SELECTING
294
arrayPos0 = object.player
295
296
if keyDown[arrayPos0].left == true
297
DrawSpriteScreenXY(8, screen.xcenter, object.ypos)
298
else
299
DrawSpriteScreenXY(7, screen.xcenter, object.ypos)
300
end if
301
302
if keyDown[arrayPos0].right == true
303
DrawSpriteScreenXY(10, screen.xcenter, object.ypos)
304
else
305
DrawSpriteScreenXY(9, screen.xcenter, object.ypos)
306
end if
307
end if
308
end event
309
310
311
event ObjectStartup
312
LoadSpriteSheet("LevelSelect/Icons.gif")
313
SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0
314
SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1
315
SpriteFrame(-32, -32, 64, 64, 98, 249) // Details Border - #2
316
SpriteFrame(-32, -32, 64, 64, 163, 249) // Details Border (Selected) - #3
317
SpriteFrame(-12, -20, 24, 40, 1, 279) // Sonic - #4
318
SpriteFrame(-16, -20, 32, 40, 54, 279) // Tails - #5
319
SpriteFrame(-14, -20, 27, 40, 26, 279) // Knuckles - #6
320
SpriteFrame(-56, -10, 20, 20, 138, 22) // Left Arrow - #7
321
SpriteFrame(-56, -10, 20, 20, 138, 64) // Right Arrow - #8
322
SpriteFrame(36, -10, 20, 20, 159, 22) // Left Arrow (Pressed) - #9
323
SpriteFrame(36, -10, 20, 20, 159, 64) // Right Arrow (Pressed) - #10
324
SpriteFrame(-28, -16, 56, 15, 44, 362) // WAITING FOR - #11
325
SpriteFrame(-8, 8, 16, 7, 218, 124) // 1P - #12
326
SpriteFrame(-8, 8, 16, 7, 218, 132) // 2P - #13
327
SpriteFrame(-10, -15, 21, 35, 1, 453) // Amy - #14
328
329
// It still checks for 2P VS Menu 2 LOL
330
// (This object is never placed in a scene anyway, so this bit of code doesn't really matter)
331
foreach (TypeName[2P VS Menu 2], arrayPos0, ALL_ENTITIES)
332
object[arrayPos0].priority = PRIORITY_ACTIVE
333
next
334
end event
335
336
337
// ========================
338
// Editor Events
339
// ========================
340
341
event RSDKDraw
342
DrawSprite(0)
343
DrawSprite(1)
344
end event
345
346
347
event RSDKLoad
348
LoadSpriteSheet("LevelSelect/Icons.gif")
349
SpriteFrame(-104, 0, 96, 14, 1, 249) // PLAYER text - #0
350
SpriteFrame(8, 0, 96, 14, 1, 264) // SELECT text - #1
351
352
// Although used by the object, it's not to be set from the editor
353
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
354
end event
355
356