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/Ending/EndingControl.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Ending Control 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 : ENDINGCONTROL_INIT
15
private alias 1 : ENDINGCONTROL_FADEIN
16
private alias 2 : ENDINGCONTROL_MAIN
17
private alias 3 : ENDINGCONTROL_NONE
18
19
private alias 5 : ENDINGPOSE_HOLDEMERALDS
20
21
// Player Aliases
22
private alias object.xpos : player.xpos
23
private alias object.ypos : player.ypos
24
private alias object.speed : player.speed
25
private alias object.controlMode : player.controlMode
26
private alias object.up : player.up
27
private alias object.down: player.down
28
private alias object.left : player.left
29
private alias object.right : player.right
30
private alias object.jumpPress : player.jumpPress
31
private alias object.jumpHold : player.jumpHold
32
private alias object.value1 : player.timer
33
34
// Ending Pose Aliases
35
private alias object.value1 : object.logoPos
36
37
38
// ========================
39
// Events
40
// ========================
41
42
event ObjectUpdate
43
switch object.state
44
case ENDINGCONTROL_INIT
45
PlayMusic(0)
46
47
object.state++
48
// [Fallthrough]
49
case ENDINGCONTROL_FADEIN
50
player[0].controlMode = CONTROLMODE_NONE
51
player[0].up = false
52
player[0].down = false
53
player[0].left = true
54
player[0].right = false
55
player[0].jumpHold = false
56
player[0].jumpPress = false
57
58
if options.superStates == false
59
// Six emeralds
60
temp0 = 0x3F
61
else
62
// Seven emeralds
63
temp0 = 0x7F
64
end if
65
66
if specialStage.emeralds >= temp0
67
// If this is the good ending, then make the player start closer to the final ending position
68
// (object[+1] is a node on the closer hill in the scene, normally a Blank Object can it can be whatever if you really wanna)
69
player[0].xpos = object[+1].xpos
70
player[0].ypos = object[+1].ypos
71
end if
72
73
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
74
if currentPlayer == 0
75
player[currentPlayer].speed = -0x60000
76
else
77
// For all non-P1 players, start them to the right side of P1, hehind them
78
player[currentPlayer].speed = -0x60000
79
player[currentPlayer].xpos = player[0].xpos
80
player[currentPlayer].xpos += 0x400000
81
player[currentPlayer].ypos = player[0].ypos
82
83
StopSfx(SfxName[Skidding])
84
end if
85
next
86
87
if object.timer > 0
88
object.timer -= 16
89
else
90
temp0 = 424
91
temp0 += screen.xcenter
92
stage.newXBoundary2 = temp0
93
object.state++
94
end if
95
96
SetScreenFade(0, 0, 0, object.timer)
97
break
98
99
case ENDINGCONTROL_MAIN
100
temp0 = object.xpos
101
temp0 -= 0x180000
102
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
103
if player[currentPlayer].speed < -0x60000
104
// Enforce a minimum speed of 6 pixels per second, even if Sonic's on an uphill slope or all that stuff
105
player[currentPlayer].speed = -0x60000
106
end if
107
108
if player[currentPlayer].xpos < temp0
109
// Sonic accidentally ran past the ending position, make him skid and turn around for a little bit now
110
player[currentPlayer].left = false
111
player[currentPlayer].right = true
112
end if
113
114
if player[currentPlayer].xpos > object.xpos
115
if player[currentPlayer].right == true
116
// Sonic's turned around at reached the ending point, so now let's stop him and do all the fancy stuff
117
118
player[currentPlayer].right = false
119
player[currentPlayer].speed = 0x00000
120
121
if currentPlayer == playerCount
122
// Huh? currentPlayer should never match playerCount, but if it is, then increase state to ENDINGCONTROL_NONE?
123
// Not quite sure why this exists, this is really strange...
124
object.state++
125
else
126
if currentPlayer == 0
127
ResetObjectEntity(currentPlayer, TypeName[Ending Pose], 0, object.xpos, object.ypos)
128
object[currentPlayer].controlMode = CONTROLMODE_NONE
129
object[currentPlayer].drawOrder = 6
130
131
if options.superStates == false
132
// Six emeralds
133
temp0 = 0x3F
134
else
135
// Seven emeralds
136
temp0 = 0x7F
137
end if
138
139
if specialStage.emeralds < temp0
140
// Normal Ending Frames
141
142
switch stage.playerListPos
143
case PLAYER_SONIC_A
144
case PLAYER_SONIC_TAILS_A
145
object[currentPlayer].frame = 0
146
break
147
148
case PLAYER_TAILS_A
149
object[currentPlayer].frame = 13
150
break
151
152
case PLAYER_KNUCKLES_A
153
object[currentPlayer].frame = 24
154
break
155
#platform: USE_ORIGINS
156
case PLAYER_AMY_A
157
object[currentPlayer].frame = 45
158
break
159
#endplatform
160
161
end switch
162
else
163
// Good Ending Frames
164
165
switch stage.playerListPos
166
case PLAYER_SONIC_A
167
case PLAYER_SONIC_TAILS_A
168
object[currentPlayer].frame = 4
169
break
170
171
case PLAYER_TAILS_A
172
object[currentPlayer].frame = 16
173
break
174
175
case PLAYER_KNUCKLES_A
176
object[currentPlayer].frame = 27
177
break
178
#platform: USE_ORIGINS
179
case PLAYER_AMY_A
180
object[currentPlayer].frame += 45
181
object[currentPlayer].frame += 4
182
break
183
#endplatform
184
end switch
185
186
// Put them in the Good Ending state too, looks like the Emeralds are starting to do something
187
object[currentPlayer].state = ENDINGPOSE_HOLDEMERALDS
188
end if
189
190
object[currentPlayer].logoPos = 224
191
end if
192
end if
193
end if
194
end if
195
next
196
break
197
198
// State 3 (dubbed ENDINGCONTROL_NONE here) doesn't do anything
199
// The object shouldn't even get to that state, unless something's *really* wrong
200
201
end switch
202
end event
203
204
205
event ObjectStartup
206
foreach (TypeName[Ending Control], arrayPos0, ALL_ENTITIES)
207
object[arrayPos0].priority = PRIORITY_ACTIVE
208
object[arrayPos0].timer = 272
209
next
210
end event
211
212
213
// ========================
214
// Editor Events
215
// ========================
216
217
event RSDKDraw
218
DrawSprite(0)
219
220
if editor.showGizmos == true
221
editor.drawingOverlay = true
222
223
if TypeName[Player Object] > 0
224
object.type = TypeName[Player Object]
225
object.inkEffect = INK_BLEND
226
// object.direction = FACING_LEFT // You can't use ink effects and flip at the same time :(
227
DrawSpriteFX(0, FX_INK, object[+1].xpos, object[+1].ypos)
228
end if
229
230
// Draw a line from this object to the start position teleport node
231
DrawArrow(object.xpos, object.ypos, object[+1].xpos, object[+1].ypos, 0xFF, 0xFF, 0x00)
232
233
editor.drawingOverlay = false
234
end if
235
end event
236
237
238
event RSDKLoad
239
LoadSpriteSheet("Global/Display.gif")
240
SpriteFrame(-16, -16, 32, 32, 1, 143)
241
242
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
243
end event
244
245