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/SignPost2.txt
1479 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Sign Post2 Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// TODO: check out its scale attr in stuff like m104, ain't that strange?
9
10
// ========================
11
// Aliases
12
// ========================
13
14
// Variables
15
private alias object.value0 : object.centerInit
16
private alias object.value1 : object.spinCount
17
private alias object.value2 : object.spinTimer
18
private alias object.value3 : object.activePlayers
19
private alias object.value4 : object.allPlayersFinished
20
private alias object.value5 : object.lastPlayerID
21
private alias object.value6 : object.centerOffset // x center offset
22
private alias object.value7 : object.enableExitRight // determines if the exit stage right sequence should occur
23
24
// States
25
private alias 0 : SIGNPOST2_IDLE
26
private alias 1 : SIGNPOST2_SPUN
27
private alias 2 : SIGNPOST2_EXITPLAYER
28
private alias 3 : SIGNPOST2_IDLE_VS
29
private alias 4 : SIGNPOST2_SPUN_VS
30
private alias 5 : SIGNPOST2_UNUSED
31
private alias 6 : SIGNPOST2_FINISHED
32
33
// Player Aliases
34
private alias object.type : player.type
35
private alias object.propertyValue : player.character
36
private alias object.xpos : player.xpos
37
private alias object.ypos : player.ypos
38
private alias object.ixpos : player.ixpos
39
private alias object.speed : player.speed
40
private alias object.xvel : player.xvel
41
private alias object.controlMode : player.controlMode
42
private alias object.scrollTracking : player.scrollTracking
43
private alias object.interaction : player.interaction
44
private alias object.jumpPress : player.jumpPress
45
private alias object.jumpHold : player.jumpHold
46
private alias object.up : player.up
47
private alias object.down : player.down
48
private alias object.left : player.left
49
private alias object.right : player.right
50
private alias object.value7 : player.invincibleTimer
51
private alias object.value21 : player.acceleration
52
53
private alias 1 : SUPERSTATE_SUPER
54
private alias 2 : SUPERSTATE_FADEOUT
55
56
// VSGame aliases
57
private alias object.value0 : vsGame.timer
58
private alias object.value5 : vsGame.countdownPlayer
59
60
// VSGame States
61
private alias 0 : VSGAME_DISPLAYTAGS
62
private alias 2 : VSGAME_FADEOUT
63
private alias 3 : VSGAME_FINISH_COUNTDOWN
64
private alias 4 : VSGAME_GOTOVSRESULTS
65
66
// Game Modes
67
private alias 2 : MODE_TIMEATTACK
68
69
// Tracks
70
private alias 1 : TRACK_ACTFINISH
71
72
// Achievement Aliases
73
private alias 0 : ACHIEVEMENT_QUICKRUN
74
private alias 3 : ACHIEVEMENT_SUPERSTAR
75
private alias 10 : ACHIEVEMENT_SCRAMBLEDEGG
76
77
78
// ========================
79
// Function Declarations
80
// ========================
81
82
reserve function SignPost2_DebugDraw
83
reserve function SignPost2_DebugSpawn
84
85
86
// ========================
87
// Function Definitions
88
// ========================
89
90
private function SignPost2_DebugDraw
91
DrawSprite(0)
92
DrawSprite(1)
93
end function
94
95
96
private function SignPost2_DebugSpawn
97
CreateTempObject(TypeName[Sign Post2], 0, object.xpos, object.ypos)
98
object[tempObjectPos].frame = 1
99
object[tempObjectPos].spinCount = 16
100
if options.vsMode == true
101
object[tempObjectPos].state = SIGNPOST2_IDLE_VS
102
end if
103
end function
104
105
106
// ========================
107
// Events
108
// ========================
109
110
event ObjectUpdate
111
switch object.state
112
case SIGNPOST2_IDLE
113
temp0 = object.ypos
114
temp0 += 0x400000
115
if player[0].ypos < temp0
116
if object.centerOffset > 0
117
// These two lines used to use ixpos, but Plus changed them to xpos
118
temp0 = object.xpos
119
temp0 -= player[0].xpos
120
temp0 >>= 16
121
122
CheckGreater(temp0, 0)
123
temp1 = checkResult
124
CheckLower(temp0, object.centerOffset)
125
checkResult &= temp1
126
if checkResult == true
127
stage.newXBoundary1 = object.ixpos
128
stage.newXBoundary1 -= object.centerOffset
129
stage.newXBoundary2 = object.xpos
130
stage.newXBoundary2 >>= 16
131
stage.newXBoundary2 += screen.xcenter
132
end if
133
else
134
stage.newXBoundary1 = object.xpos
135
stage.newXBoundary1 >>= 16
136
stage.newXBoundary1 -= screen.xcenter
137
stage.newXBoundary1 -= screen.xcenter
138
stage.newXBoundary2 = object.xpos
139
stage.newXBoundary2 >>= 16
140
stage.newXBoundary2 += screen.xcenter
141
end if
142
143
if player[0].xpos > object.xpos
144
stage.newXBoundary1 = object.xpos
145
stage.newXBoundary1 >>= 16
146
stage.newXBoundary1 -= screen.xcenter
147
148
switch player[0].character
149
case PLAYER_SONIC_A
150
EditFrame(5, -24, -16, 48, 32, 34, 1)
151
break
152
153
case PLAYER_TAILS_A
154
EditFrame(5, -24, -16, 48, 32, 34, 34)
155
break
156
157
case PLAYER_KNUCKLES_A
158
EditFrame(5, -24, -16, 48, 32, 34, 67)
159
break
160
161
case PLAYER_AMY_A
162
EditFrame(5, -24, -16, 48, 32, 34, 149)
163
break
164
end switch
165
166
// No achievements in debug mode!
167
if stage.debugMode == false
168
if stage.activeList == BONUS_STAGE
169
// Boss Attack is on the Bonus Stage list, check for the Boss Attack achievement
170
// (In Origins all the Missions are on the Bonus stage list too, so this check can reward the achievement for them as well lol)
171
if stage.minutes < 7
172
CallNativeFunction2(SetAchievement, ACHIEVEMENT_SCRAMBLEDEGG, 100)
173
end if
174
else
175
if stage.listPos == 0
176
if stage.minutes == 0
177
if stage.seconds < 35
178
CallNativeFunction2(SetAchievement, ACHIEVEMENT_QUICKRUN, 100)
179
end if
180
end if
181
end if
182
end if
183
end if
184
185
CallNativeFunction2(NotifyCallback, NOTIFY_TOUCH_SIGNPOST, 0)
186
187
stage.timeEnabled = false
188
object.state = SIGNPOST2_SPUN
189
PlaySfx(SfxName[Sign Post], false)
190
191
if Player_superState == SUPERSTATE_SUPER
192
Player_superState = SUPERSTATE_FADEOUT
193
if stage.debugMode == false
194
CallNativeFunction2(SetAchievement, ACHIEVEMENT_SUPERSTAR, 100)
195
end if
196
end if
197
end if
198
end if
199
break
200
201
case SIGNPOST2_SPUN
202
music.volume--
203
204
object.spinTimer++
205
if object.spinTimer == 2
206
object.spinTimer = 0
207
object.frame++
208
if object.frame == 5
209
object.frame = 1
210
Rand(temp0, 48)
211
temp0 <<= 16
212
temp0 += object.xpos
213
temp0 -= 0x180000
214
Rand(temp1, 32)
215
temp1 <<= 16
216
temp1 += object.ypos
217
temp1 -= 0x140000
218
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
219
220
object.spinCount--
221
if object.spinCount == 0
222
if object.enableExitRight != false
223
SetBit(object.activePlayers, 0, true)
224
if stage.player2Enabled == true
225
SetBit(object.activePlayers, 1, true)
226
end if
227
else
228
player[0].interaction = false
229
player[0].controlMode = CONTROLMODE_NONE
230
player[0].up = false
231
player[0].down = false
232
player[0].left = false
233
player[0].right = false
234
player[0].jumpPress = false
235
player[0].jumpHold = false
236
end if
237
object.state = SIGNPOST2_EXITPLAYER
238
end if
239
end if
240
end if
241
break
242
243
case SIGNPOST2_EXITPLAYER
244
temp0 = screen.xcenter
245
temp0 <<= 16
246
temp0 += object.xpos
247
CheckGreater(player[0].xpos, temp0)
248
temp1 = checkResult
249
CheckEqual(object.enableExitRight, false)
250
checkResult |= temp1
251
if checkResult == true
252
PlayMusic(TRACK_ACTFINISH)
253
object.state = SIGNPOST2_FINISHED
254
object[30].type = TypeName[Act Finish]
255
object[30].drawOrder = 6
256
object[30].priority = PRIORITY_ACTIVE
257
end if
258
break
259
260
case SIGNPOST2_IDLE_VS
261
stage.newXBoundary2 = object.xpos
262
stage.newXBoundary2 >>= 16
263
stage.newXBoundary2 += screen.xcenter
264
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
265
GetBit(temp1, object.activePlayers, currentPlayer)
266
if temp1 == false
267
if player[currentPlayer].xpos > object.xpos
268
object.priority = PRIORITY_ACTIVE
269
270
SetBit(object.activePlayers, currentPlayer, true)
271
272
if currentPlayer == 0
273
if Player_superState == SUPERSTATE_SUPER
274
Player_superState = SUPERSTATE_FADEOUT
275
end if
276
277
if vs.playerID == 0
278
temp2 = 0
279
else
280
temp2 = 1
281
end if
282
else
283
if vs.playerID == 0
284
temp2 = 1
285
else
286
temp2 = 0
287
end if
288
end if
289
290
if temp2 == 0
291
vs.time1P = stage.milliSeconds
292
vs.time1P = stage.seconds
293
vs.time1P *= 100
294
temp2 = stage.minutes
295
temp2 *= 6000
296
vs.time1P += temp2
297
vs.time1P += stage.milliSeconds
298
else
299
vs.time2P = stage.milliSeconds
300
vs.time2P = stage.seconds
301
vs.time2P *= 100
302
temp2 = stage.minutes
303
temp2 *= 6000
304
vs.time2P += temp2
305
vs.time2P += stage.milliSeconds
306
end if
307
308
object.lastPlayerID = currentPlayer
309
object.spinCount = 16
310
object.state = SIGNPOST2_SPUN_VS
311
PlaySfx(SfxName[Sign Post], false)
312
313
if object.allPlayersFinished == false
314
PlaySfx(SfxName[Sign Post 2P], false)
315
object[30].state = VSGAME_FINISH_COUNTDOWN
316
vsGame[30].countdownPlayer = currentPlayer
317
vsGame[30].countdownPlayer ^= 1
318
319
switch player[currentPlayer].character
320
case PLAYER_SONIC_A
321
EditFrame(5, -24, -16, 48, 32, 34, 1)
322
break
323
324
case PLAYER_TAILS_A
325
EditFrame(5, -24, -16, 48, 32, 34, 34)
326
break
327
328
case PLAYER_KNUCKLES_A
329
EditFrame(5, -24, -16, 48, 32, 34, 67)
330
break
331
332
case PLAYER_AMY_A
333
EditFrame(5, -24, -16, 48, 32, 34, 149)
334
break
335
end switch
336
else
337
object[30].state = VSGAME_DISPLAYTAGS
338
end if
339
340
if object.activePlayers == 3
341
object.allPlayersFinished = true
342
object[30].state = VSGAME_DISPLAYTAGS
343
end if
344
end if
345
end if
346
next
347
break
348
349
case SIGNPOST2_SPUN_VS
350
if object.allPlayersFinished == true
351
music.volume--
352
else
353
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
354
GetBit(temp1, object.activePlayers, currentPlayer)
355
if temp1 == false
356
if player[currentPlayer].xpos > object.xpos
357
object.spinTimer = 1
358
object.frame = 4
359
object.spinCount = 1
360
end if
361
end if
362
next
363
end if
364
365
object.spinTimer++
366
if object.spinTimer == 2
367
object.spinTimer = 0
368
object.frame++
369
if object.frame == 5
370
object.frame = 1
371
Rand(temp0, 48)
372
temp0 <<= 16
373
temp0 += object.xpos
374
temp0 -= 0x180000
375
Rand(temp1, 32)
376
temp1 <<= 16
377
temp1 += object.ypos
378
temp1 -= 0x140000
379
CreateTempObject(TypeName[Ring Sparkle], 0, temp0, temp1)
380
381
object.spinCount--
382
if object.spinCount == 0
383
if object.allPlayersFinished == false
384
object.allPlayersFinished = true
385
object.state = SIGNPOST2_IDLE_VS
386
else
387
object.state = SIGNPOST2_FINISHED
388
object[30].state = VSGAME_GOTOVSRESULTS
389
vsGame[30].timer = -768
390
end if
391
end if
392
end if
393
end if
394
break
395
396
case SIGNPOST2_FINISHED
397
break
398
399
default
400
case SIGNPOST2_UNUSED
401
break
402
403
end switch
404
405
// Invisible off-screen barrier
406
temp0 = 40
407
temp0 += 212 // (screen.xcenter)
408
temp0 <<= 16
409
temp0 += object.xpos
410
currentPlayer = 0
411
while currentPlayer < playerCount
412
GetBit(temp1, object.activePlayers, currentPlayer)
413
if temp1 == true
414
player[currentPlayer].interaction = false
415
player[currentPlayer].controlMode = CONTROLMODE_NONE
416
player[currentPlayer].up = false
417
player[currentPlayer].down = false
418
player[currentPlayer].left = false
419
player[currentPlayer].right = true
420
player[currentPlayer].jumpPress = false
421
player[currentPlayer].jumpHold = false
422
end if
423
424
if player[currentPlayer].xpos > temp0
425
player[currentPlayer].xpos = temp0
426
player[currentPlayer].speed = 0
427
player[currentPlayer].xvel = 0
428
end if
429
430
if player[currentPlayer].type == TypeName[Debug Mode]
431
SetBit(object.activePlayers, currentPlayer, false)
432
end if
433
currentPlayer++
434
loop
435
436
if object.state > SIGNPOST2_IDLE
437
player[0].invincibleTimer = 80
438
end if
439
end event
440
441
442
event ObjectDraw
443
DrawSprite(0)
444
if object.spinCount > 8
445
DrawSprite(object.frame)
446
else
447
temp0 = object.frame
448
temp0 += 4
449
DrawSprite(temp0)
450
end if
451
end event
452
453
454
event ObjectStartup
455
LoadSpriteSheet("Global/Items2.gif")
456
457
SpriteFrame(-24, 16, 48, 16, 34, 132)
458
switch stage.playerListPos
459
// Has Sonic Team never heard of a default case?
460
case PLAYER_SONIC_A
461
case PLAYER_TAILS_A
462
case PLAYER_KNUCKLES_A
463
case PLAYER_SONIC_TAILS_A
464
case PLAYER_KNUCKLES_TAILS_A
465
SpriteFrame(-24, -16, 48, 32, 34, 100) // #1 - Eggman giving a big smile
466
SpriteFrame(-16, -16, 32, 32, 149, 99) // #2 - Spin frame 1
467
SpriteFrame(-4, -16, 8, 32, 247, 2) // #3 - Spin frame 2
468
SpriteFrame(-16, -16, 32, 32, 116, 99) // #4 - Spin frame 3
469
SpriteFrame(-24, -16, 48, 32, 34, 1) // #5 - Main character frame (Sonic here, but will change to the appropriate character in-game)
470
SpriteFrame(-16, -16, 32, 32, 149, 99) // #6 - Spin frame 4 (duplicate of frame 1)
471
SpriteFrame(-4, -16, 8, 32, 247, 2) // #7 - Spin frame 5 (duplicate of frame 2)
472
SpriteFrame(-16, -16, 32, 32, 116, 99) // #8 - Spin frame 6 (duplicate of frame 3)
473
break
474
475
case PLAYER_AMY_A
476
case PLAYER_AMY_TAILS_A
477
SpriteFrame(-24, -16, 48, 32, 34, 100) // #1 - Eggman giving a big smile
478
SpriteFrame(-16, -16, 32, 32, 149, 132) // #2 - Spin frame 1 (Amy)
479
SpriteFrame(-4, -16, 8, 32, 247, 2) // #3 - Spin frame 2
480
SpriteFrame(-16, -16, 32, 32, 116, 132) // #4 - Spin frame 3 (Amy)
481
SpriteFrame(-24, -16, 48, 32, 34, 149) // #5 - Amy frame
482
SpriteFrame(-16, -16, 32, 32, 149, 132) // #6 - Spin frame 4 (duplicate of frame 1)
483
SpriteFrame(-4, -16, 8, 32, 247, 2) // #7 - Spin frame 5 (duplicate of frame 2)
484
SpriteFrame(-16, -16, 32, 32, 116, 132) // #8 - Spin frame 6 (duplicate of frame 3)
485
break
486
end switch
487
488
foreach (TypeName[Sign Post2], arrayPos0, ALL_ENTITIES)
489
CheckGreater(object[arrayPos0].propertyValue, 0)
490
temp0 = checkResult
491
CheckEqual(options.vsMode, false)
492
temp0 &= checkResult
493
if temp0 == true
494
object[arrayPos0].type = TypeName[Blank Object]
495
else
496
// Editors can only set object values 0-3, so set value6 to value0 and then reset value0
497
// ...they could've just used value0 for the actual offset value though, it's not used for anything else in this object
498
object[arrayPos0].centerOffset = object[arrayPos0].centerInit
499
object[arrayPos0].centerOffset <<= 4
500
object[arrayPos0].centerInit = 0
501
502
// Same thing here, set value7 to value1 and reset value1
503
object[arrayPos0].enableExitRight = object[arrayPos0].spinCount
504
object[arrayPos0].spinCount = 0
505
506
object[arrayPos0].frame = 1
507
object[arrayPos0].spinCount = 16
508
if object[arrayPos0].propertyValue != 2
509
object[arrayPos0].priority = PRIORITY_XBOUNDS
510
end if
511
end if
512
513
if options.vsMode == true
514
object[arrayPos0].state = SIGNPOST2_IDLE_VS
515
end if
516
next
517
518
SetTableValue(TypeName[Sign Post2], DebugMode_ObjCount, DebugMode_TypesTable)
519
SetTableValue(SignPost2_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
520
SetTableValue(SignPost2_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
521
DebugMode_ObjCount++
522
end event
523
524
525
// ========================
526
// Editor Events
527
// ========================
528
529
event RSDKEdit
530
if editor.returnVariable == true
531
switch editor.variableID
532
case EDIT_VAR_PROPVAL // property value
533
checkResult = object.propertyValue
534
break
535
536
case 0 // type
537
checkResult = object.propertyValue
538
break
539
540
end switch
541
else
542
switch editor.variableID
543
case EDIT_VAR_PROPVAL // property value
544
object.propertyValue = editor.variableValue
545
break
546
547
case 0 // type
548
object.propertyValue = editor.variableValue
549
break
550
551
end switch
552
end if
553
end event
554
555
556
event RSDKDraw
557
DrawSprite(0)
558
DrawSprite(1)
559
end event
560
561
562
event RSDKLoad
563
LoadSpriteSheet("Global/Items2.gif")
564
SpriteFrame(-24, 16, 48, 16, 34, 132)
565
SpriteFrame(-24, -16, 48, 32, 34, 100)
566
567
AddEditorVariable("type")
568
SetActiveVariable("type")
569
AddEnumVariable("Normal", 0)
570
AddEnumVariable("VS Only (No Y Bounds)", 1)
571
AddEnumVariable("VS Only (Use Y Bounds)", 2)
572
573
SetVariableAlias(ALIAS_VAR_VAL0, "centerOffset")
574
SetVariableAlias(ALIAS_VAR_VAL1, "enableExitRight")
575
end event
576
577