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/EggmanSignPost.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: EggmanSignPost Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// This Object is used in Mission "Eggman: Blue Beam" - M049 - Mission_Zone02
9
// The script's name is kinda half misleading, this isn't just a signpost but it's also kind of a manager for the entire fight
10
// It's prolly just named this way because it's based off of S1's or CD's EggmanSignPosts which *were* actual signposts
11
12
// ========================
13
// Aliases
14
// ========================
15
16
// Variables
17
// First four are set from editor
18
private alias object.value0 : object.animTimerIncrease
19
private alias object.value1 : object.frameIncrease
20
private alias object.value2 : object.initialTrackSpeed
21
private alias object.value3 : object.initialExtraSpeed
22
private alias object.value4 : object.eggmanID
23
private alias object.value5 : object.newXBounds
24
private alias object.value6 : object.signPostID
25
26
// States
27
private alias 0 : EGGMANSIGNPOST_AWAITEGGMAN
28
private alias 1 : EGGMANSIGNPOST_AWAITBOSSFIGHT
29
private alias 2 : EGGMANSIGNPOST_SPEEDUPBOSS
30
private alias 3 : EGGMANSIGNPOST_DEFEATFALL
31
private alias 4 : EGGMANSIGNPOST_ESCAPE
32
private alias 5 : EGGMANSIGNPOST_SPAWNFALLSIGNPOST
33
private alias 6 : EGGMANSIGNPOST_FINDFALLSIGNPOST
34
private alias 7 : EGGMANSIGNPOST_MISSIONCOMPLETE
35
private alias 8 : EGGMANSIGNPOST_FINISHED
36
37
// Eggman States
38
private alias 0 : CPZEGGMAN_AWAITPLAYER
39
private alias 1 : CPZEGGMAN_BOSSFIGHT
40
private alias 3 : CPZEGGMAN_DEFEATFALL
41
private alias 6 : CPZEGGMAN_ESCAPE
42
43
// Tipping Floor States
44
private alias 1 : TIPPINGFLOOR_TIPPING
45
46
// Fall Sign Post States
47
private alias 1 : FALLSIGNPOST_FALLTOGROUND
48
private alias 2 : FALLSIGNPOST_SPINNINGONGROUND
49
private alias 4 : FALLSIGNPOST_LANDONGROUND
50
51
// Player Aliases
52
private alias object.state : player.state
53
private alias object.speed : player.speed
54
private alias object.ixpos : player.ixpos
55
private alias object.xvel : player.xvel
56
private alias object.yvel : player.yvel
57
private alias object.animation : player.animation
58
private alias object.controlMode : player.controlMode
59
private alias object.interaction : player.interaction
60
private alias object.outOfBounds : player.outOfBounds
61
private alias object.jumpPress : player.jumpPress
62
private alias object.jumpHold : player.jumpHold
63
private alias object.up : player.up
64
private alias object.down : player.down
65
private alias object.left : player.left
66
private alias object.right : player.right
67
68
// Chemical Dropper Aliases
69
private alias object.value14 : object.dropletAnimTimer
70
private alias object.value15 : object.chemicalFrame
71
private alias object.value19 : object.dropTrackSpeed
72
private alias object.value20 : object.extraSpeed
73
74
// Tipping Floor Aliases
75
private alias object.value0 : object.timer
76
private alias object.value3 : object.bossEnd
77
78
// Fall Sign Post Aliases
79
private alias object.value1 : object.spinCount
80
81
82
// ========================
83
// Events
84
// ========================
85
86
event ObjectUpdate
87
switch object.state
88
case EGGMANSIGNPOST_AWAITEGGMAN
89
if object.eggmanID == 0
90
foreach (TypeName[Eggman], arrayPos0, ACTIVE_ENTITIES)
91
object.eggmanID = arrayPos0
92
next
93
94
if object.eggmanID != 0
95
object.state++
96
97
// All of these values are to be set from editor, enforce some limits on them
98
// Their actual values in the scene are listed next to every entry
99
100
// Normally 10
101
if object.animTimerIncrease < 0
102
object.animTimerIncrease = 0
103
else
104
if object.animTimerIncrease > 18
105
object.animTimerIncrease = 18
106
end if
107
end if
108
109
// Normally 7
110
if object.frameIncrease < 0
111
object.frameIncrease = 0
112
else
113
if object.frameIncrease > 12
114
object.frameIncrease = 12
115
end if
116
end if
117
118
// Normally 2
119
if object.initialTrackSpeed < 0
120
object.initialTrackSpeed = 0
121
end if
122
123
// Normally 2
124
if object.initialExtraSpeed < 0
125
object.initialExtraSpeed = 0
126
end if
127
end if
128
end if
129
break
130
131
case EGGMANSIGNPOST_AWAITBOSSFIGHT
132
arrayPos0 = object.eggmanID
133
if object[arrayPos0].state == CPZEGGMAN_BOSSFIGHT
134
arrayPos0++
135
object[arrayPos0].dropTrackSpeed = object.initialTrackSpeed
136
object[arrayPos0].dropTrackSpeed <<= 16
137
object[arrayPos0].dropTrackSpeed += 0x10000
138
139
object[arrayPos0].extraSpeed = object.initialExtraSpeed
140
object[arrayPos0].extraSpeed <<= 16
141
object[arrayPos0].extraSpeed += 0x30000
142
object.state++
143
end if
144
break
145
146
case EGGMANSIGNPOST_SPEEDUPBOSS
147
arrayPos0 = object.eggmanID
148
if object[arrayPos0].state == CPZEGGMAN_BOSSFIGHT
149
arrayPos1 = object.eggmanID
150
arrayPos1++
151
if object[arrayPos1].dropletAnimTimer == 0
152
object[arrayPos1].dropletAnimTimer = object.animTimerIncrease
153
temp0 = object[arrayPos1].chemicalFrame
154
temp0 += object.frameIncrease
155
if temp0 >= 30
156
object[arrayPos1].chemicalFrame = 30
157
end if
158
end if
159
else
160
object.type = TypeName[Blank Object]
161
end if
162
break
163
164
case EGGMANSIGNPOST_DEFEATFALL
165
arrayPos0 = object.eggmanID
166
if object[arrayPos0].state == CPZEGGMAN_DEFEATFALL
167
stage.newXBoundary2 = object.newXBounds
168
object.state++
169
end if
170
break
171
172
case EGGMANSIGNPOST_ESCAPE
173
arrayPos0 = object.eggmanID
174
if object[arrayPos0].state == CPZEGGMAN_ESCAPE
175
stage.newXBoundary2 = object.newXBounds
176
object.state++
177
end if
178
break
179
180
case EGGMANSIGNPOST_SPAWNFALLSIGNPOST
181
arrayPos0 = object.eggmanID
182
if object[arrayPos0].type == TypeName[Blank Object]
183
game.missionCondition = MISSION_CONDITION_CLEAR
184
CreateTempObject(TypeName[FallSignPost], 0, 0, 0)
185
object[tempObjectPos].frame = 1
186
object[tempObjectPos].spinCount = 16
187
object[tempObjectPos].priority = PRIORITY_ACTIVE
188
object.state++
189
object.priority = PRIORITY_ACTIVE
190
end if
191
break
192
193
case EGGMANSIGNPOST_FINDFALLSIGNPOST
194
foreach (TypeName[FallSignPost], arrayPos0, ACTIVE_ENTITIES)
195
object.signPostID = arrayPos0
196
next
197
object.state++
198
break
199
200
case EGGMANSIGNPOST_MISSIONCOMPLETE
201
arrayPos2 = 0
202
foreach (TypeName[Tipping Floor], arrayPos0, ACTIVE_ENTITIES)
203
if object[arrayPos0].bossEnd != false
204
object[arrayPos0].state = TIPPINGFLOOR_TIPPING
205
object[arrayPos0].timer = 1
206
object[arrayPos0].animation = 1
207
object[arrayPos0].frame = 0
208
else
209
if object[arrayPos0].frame == 0
210
object[arrayPos0].state = TIPPINGFLOOR_TIPPING
211
object[arrayPos0].timer = 1
212
object[arrayPos0].animation = 1
213
object[arrayPos0].bossEnd = true
214
end if
215
end if
216
217
// Provide Platform collision between the Tipping Floor and the player, regardless of the Floor's actual frame so that the player doesn't fall and die post-boss
218
BoxCollisionTest(C_PLATFORM, object[arrayPos0].entityPos, -16, -16, 16, -8, 0, C_BOX, C_BOX, C_BOX, C_BOX)
219
arrayPos2 = arrayPos0
220
next
221
222
if object.signPostID != 0
223
arrayPos1 = object.signPostID
224
if object[arrayPos1].type == TypeName[FallSignPost]
225
if object[arrayPos1].state < FALLSIGNPOST_SPINNINGONGROUND
226
temp0 = 48
227
temp0 <<= 16
228
temp0 += object[arrayPos1].ypos
229
if object[arrayPos2].ypos <= temp0
230
if object[arrayPos1].state == FALLSIGNPOST_FALLTOGROUND
231
object[arrayPos1].state = FALLSIGNPOST_LANDONGROUND
232
end if
233
end if
234
end if
235
else
236
arrayPos0 = object.signPostID
237
CheckEqual(player[0].state, Player_State_Ground)
238
temp0 = checkResult
239
CheckEqual(player[0].state, Player_State_Static)
240
temp0 |= checkResult
241
CheckEqual(player[0].outOfBounds, true)
242
temp0 |= checkResult
243
temp1 = screen.xoffset
244
temp1 += screen.xsize
245
temp1 += 32
246
CheckGreater(player[0].ixpos, temp1)
247
temp0 |= checkResult
248
CheckGreater(object[arrayPos0].state, FALLSIGNPOST_FALLTOGROUND)
249
temp0 &= checkResult
250
251
if temp0 == true
252
SetBit(object[arrayPos0].value3, 0, false) // FallSignPosts don't use their value3 btw
253
player[0].state = Player_State_Static
254
player[0].controlMode = CONTROLMODE_NONE
255
player[0].interaction = false
256
player[0].up = false
257
player[0].down = false
258
player[0].left = false
259
player[0].right = false
260
player[0].jumpHold = false
261
player[0].jumpPress = false
262
player[0].xvel = 0
263
player[0].yvel = 0
264
player[0].speed = 0
265
player[0].animation = ANI_WAITING
266
screen.cameraEnabled = false
267
end if
268
end if
269
end if
270
break
271
272
case EGGMANSIGNPOST_FINISHED
273
// This state isn't ever even used, it seems?
274
// EGGMANSIGNPOST_MISSIONCOMPLETE is what the object should be on at the end of everything, and there's nothing to make it to go this state at all
275
break
276
277
end switch
278
end event
279
280
281
// ========================
282
// Editor Events
283
// ========================
284
285
event RSDKDraw
286
DrawSprite(0)
287
end event
288
289
290
event RSDKLoad
291
LoadSpriteSheet("Global/Display.gif")
292
SpriteFrame(-16, -16, 32, 32, 1, 143)
293
294
// TODO: val0, val1, val2, val3, they're all set from editor so they prolly do something
295
// (m049)
296
// it looks like they're used for controlling robotnik's speed and stuff? that's honestly a really cool way to do it, props to them
297
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
298
end event
299
300