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/SuperSonic.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: SuperSonic Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This Object is used in Mission "Super Sonic Finish" - M045 - Mission_Zone09
9
// This Object is also used in its follow-up DLC Mission, "Extreme! Super Sonic Finish" - M104 - DLC_Zone06
10
// It's to be paired with the SetRingCount object, or else Sonic will detransform immediately since he has no rings and all
11
12
// ========================
13
// Aliases
14
// ========================
15
16
// States
17
private alias 0 : SUPERSONIC_TRANSFORM
18
private alias 1 : SUPERSONIC_NOSUPERCHECK
19
private alias 2 : SUPERSONIC_STATIC
20
private alias 3 : SUPERSONIC_PLAYMUSIC
21
private alias 4 : SUPERSONIC_FACERIGHT
22
23
// Player Aliases
24
private alias object.type : player.type
25
private alias object.state : player.state
26
private alias object.visible : player.visible
27
private alias object.xpos : player.xpos
28
private alias object.ypos : player.ypos
29
private alias object.direction : player.direction
30
private alias object.value1 : player.timer
31
private alias object.value7 : player.invincibleTimer
32
private alias object.value8 : player.blinkTimer
33
private alias object.value34 : player.collisionDisabled
34
35
// Super State Aliases
36
private alias 0 : SUPERSTATE_NONE
37
private alias 1 : SUPERSTATE_SUPER
38
private alias 2 : SUPERSTATE_FADEOUT
39
private alias 3 : SUPERSTATE_END
40
41
// Track Aliases
42
private alias 7 : TRACK_SUPER
43
44
45
// ========================
46
// Events
47
// ========================
48
49
event ObjectUpdate
50
switch object.state
51
case SUPERSONIC_TRANSFORM
52
currentPlayer = 0
53
object.type = player[0].type // Set ourselves to Player Object for the function we're about to call
54
CallFunction(Player_TryTransform)
55
object.type = TypeName[SuperSonic] // We're done pretending to be Sonic, set ourselves back
56
object.state = SUPERSONIC_NOSUPERCHECK
57
break
58
59
case SUPERSONIC_NOSUPERCHECK
60
if Player_superState == SUPERSTATE_NONE
61
if stage.timeEnabled == true
62
// You turned back into regular Sonic. Test failed.
63
game.forceKillPlayer = true
64
object.state = SUPERSONIC_STATIC
65
end if
66
end if
67
break
68
69
case SUPERSONIC_STATIC
70
break
71
72
// These following two states are pretty much unused
73
case SUPERSONIC_PLAYMUSIC
74
PlayMusic(TRACK_SUPER)
75
object.state = SUPERSONIC_FACERIGHT
76
break
77
78
case SUPERSONIC_FACERIGHT // Why is this a separate state???
79
player[0].direction = FACING_RIGHT
80
object.state = SUPERSONIC_NOSUPERCHECK
81
break
82
83
end switch
84
end event
85
86
87
event ObjectStartup
88
temp0 = false
89
foreach (TypeName[SuperSonic], arrayPos0, ALL_ENTITIES)
90
object[arrayPos0].priority = PRIORITY_ACTIVE
91
92
if object[arrayPos0].propertyValue != 0
93
// Do note - every instance of a SuperSonic object in the game has a property value of 0
94
95
player[arrayPos0].state = SUPERSONIC_PLAYMUSIC
96
temp0 = true
97
end if
98
next
99
100
if temp0 != false
101
// This is another stubbed out/unused method of making the Player start as Super Sonic
102
// It doesn't work quite as it should, the version used in ObjectUpdate is used instead
103
104
currentPlayer = 0
105
arrayPos0 = currentPlayer
106
arrayPos0 += playerCount
107
ResetObjectEntity(arrayPos0, TypeName[Super Spark], 0, player[0].xpos, player[0].ypos)
108
object[arrayPos0].priority = PRIORITY_ACTIVE
109
110
Player_superState = SUPERSTATE_SUPER
111
player[currentPlayer].invincibleTimer = 60
112
player[currentPlayer].blinkTimer = 0
113
player[currentPlayer].visible = true
114
CallFunction(Player_UpdatePhysicsState)
115
116
if stage.playerListPos == PLAYER_SONIC_A
117
// This animation file is being loaded to the [SuperSonic] object type, it's supposed to be
118
// for the [Player Object] type though
119
LoadAnimation("SuperSonic.ani")
120
end if
121
122
player[currentPlayer].state = Player_State_Air_NoDropDash
123
player[currentPlayer].collisionDisabled = true
124
player[currentPlayer].timer = 0
125
end if
126
end event
127
128
129
// ========================
130
// Editor Events
131
// ========================
132
133
event RSDKDraw
134
DrawSprite(0)
135
end event
136
137
138
event RSDKLoad
139
LoadSpriteSheet("Global/Items.gif")
140
SpriteFrame(-24, -24, 48, 48, 207, 149)
141
142
// Well technically it does something, but even if it is set, the ObjectUpdate version of the routine will run the right after anyway, so...
143
// May as well keep its label as "unused"
144
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
145
end event
146
147