Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/BombCarrier.txt
1319 views
1
//----------------Sonic CD Bomb Carrier Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// ========================
6
// Aliases
7
// ========================
8
9
#alias Object.Value0 : Object.Timer
10
#alias Object.Value1 : Object.Angle
11
12
// States
13
#alias 0 : BOMBCARRIER_IDLE
14
#alias 1 : BOMBCARRIER_WAITFORBOSSFIGHT
15
#alias 2 : BOMBCARRIER_GRABBOMB
16
#alias 3 : BOMBCARRIER_SLIDERIGHT
17
#alias 4 : BOMBCARRIER_SLIDELEFT
18
#alias 5 : BOMBCARRIER_RELEASEBOMB
19
#alias 6 : BOMBCARRIER_HOVER
20
21
// Boss Platform Aliases
22
#alias Object.Value5 : Object.Grind
23
24
#alias 8 : BOSSPLATFORM_FALL_4
25
#alias 9 : BOSSPLATFORM_FIGHT_4
26
27
// Eggman Aliases
28
#alias 0 : EGGMAN_IDLE
29
#alias 1 : EGGMAN_CONTROL
30
#alias 5 : EGGMAN_PANICK_CONTROL
31
#alias 6 : EGGMAN_FLEE
32
33
// Boss Bomb Aliases
34
#alias 1 : BOSSBOMB_ACTIVE
35
36
// Stage SFX Aliases
37
#alias 5 : SFX_S_BOMBCARRIER
38
39
// Fade Music Aliases
40
#alias 0 : FADEMUSIC_TO_BOSS
41
42
43
// ========================
44
// Events
45
// ========================
46
47
sub ObjectMain
48
switch Object.State
49
case BOMBCARRIER_IDLE
50
TempValue0 = Object.XPos
51
TempValue0 += 0x200000
52
53
// See if the Player's past 32 pixels away from this Bomb Carrier Object
54
if Player.XPos > TempValue0
55
CreateTempObject(TypeName[Fade Music], FADEMUSIC_TO_BOSS, 0, 0)
56
Object.State = BOMBCARRIER_WAITFORBOSSFIGHT
57
end if
58
break
59
60
case BOMBCARRIER_GRABBOMB
61
if Object[+3].State < EGGMAN_FLEE
62
if Object.Timer < 180
63
Object.Timer++
64
else
65
Object.State = BOMBCARRIER_SLIDELEFT
66
PlayStageSfx(SFX_S_BOMBCARRIER, false)
67
68
if Object[+4].State < BOSSPLATFORM_FALL_4
69
// If the Boss Platform is still in its main phase, then make Robotnik resume his control animation
70
71
Object[+3].State = EGGMAN_CONTROL
72
else
73
// If the Boss Platform is just about to die, then make Robotnik worried for himself too
74
75
Object[+3].State = EGGMAN_PANICK_CONTROL
76
Object[+3].Timer = 0
77
Object[+3].Frame = 0
78
end if
79
end if
80
else
81
// Robotnik's Fleeing, so Unload this Object as well
82
83
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
84
end if
85
break
86
87
case BOMBCARRIER_SLIDERIGHT
88
if Object.XPos < Object[+1].XPos
89
// If we haven't reached the Boss Top yet, then keep on moving
90
91
Object.XPos += 0x1E000
92
else
93
Object.State = BOMBCARRIER_GRABBOMB
94
Object.XPos = Object[+1].XPos
95
Object.Timer = 0
96
97
if Object[+4].State > BOSSPLATFORM_FALL_4
98
99
// If the Boss Platform is XXX
100
if Object[+4].State > BOSSPLATFORM_FIGHT_4
101
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
102
end if
103
104
// If the Boss Platform is past a specific Grind point, then also unload
105
if Object[+4].Grind > 640
106
ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, 0, 0)
107
end if
108
109
end if
110
end if
111
break
112
113
case BOMBCARRIER_SLIDELEFT
114
// If this Object is further to the right than the Player, then...
115
if Object.XPos > Player.XPos
116
117
// Move the Carrier left by 0.75 pixels
118
Object.XPos -= 0xC000
119
120
// Has this Object past the Player now?
121
if Object.XPos <= Player.XPos
122
// If it did, then start releasig the Bomb
123
124
Object.State = BOMBCARRIER_RELEASEBOMB
125
126
// Match the Player's Position
127
Object.XPos = Player.XPos
128
129
// if the Boss Platform XXX, then make Robotnik go back to his Idle State
130
if Object[+4].State < BOSSPLATFORM_FALL_4
131
Object[+3].State = EGGMAN_IDLE
132
end if
133
134
Object.Timer = 0
135
end if
136
else
137
// No need to move left anymore, start relasing the Bomb
138
Object.State = BOMBCARRIER_RELEASEBOMB
139
Object.XPos = Player.XPos
140
141
// Put Robotnik in his normal pose, he doesn't need to be pushing the lever anymore either
142
Object[+3].State = EGGMAN_IDLE
143
144
Object.Timer = 0
145
end if
146
147
TempValue0 = Object[+1].XPos
148
TempValue0 -= 0x300000
149
150
if Object.XPos > TempValue0
151
152
// If the Bomb Carrier is still within 48 pixels left of the Boss Top's Position,
153
// then keep the Bomb steady
154
Object.Angle = 384
155
156
else
157
// Increase the Bomb's Angle
158
159
Object.Angle += 8
160
Object.Angle &= 511
161
end if
162
163
// Make the Bomb move with the Bomb Carrier
164
Object[-1].XPos = Object.XPos
165
166
// Make the Bomb bounce a bit
167
Sin(Object[-1].YPos, Object.Angle)
168
Object[-1].YPos <<= 9
169
170
// Bump it to 28 pixels beyond this Object's Y Position
171
Object[-1].YPos += Object.YPos
172
Object[-1].YPos += 0x1C0000
173
break
174
175
case BOMBCARRIER_RELEASEBOMB
176
if Object.Timer < 30
177
// Hold for half a second
178
Object.Timer++
179
else
180
// Go to the post-bomb-release pause state
181
Object.State = BOMBCARRIER_HOVER
182
Object.Timer = 0
183
184
// And actually release the Bomb
185
Object[-1].State = BOSSBOMB_ACTIVE
186
end if
187
188
// Increase the Bomb's hover angle
189
Object.Angle += 8
190
Object.Angle &= 511
191
192
// And then actually make the Bomb hover
193
Sin(Object[-1].YPos, Object.Angle)
194
Object[-1].YPos <<= 9
195
196
// Make it 28 pixels below this Bomb Carrier Object
197
Object[-1].YPos += Object.YPos
198
Object[-1].YPos += 0x1C0000
199
break
200
201
case BOMBCARRIER_HOVER
202
if Object.Timer < 90
203
// Pause for a second and a half
204
Object.Timer++
205
else
206
// Job complete, returning to HQ!
207
Object.State = BOMBCARRIER_SLIDERIGHT
208
end if
209
break
210
211
end switch
212
end sub
213
214
215
sub ObjectDraw
216
switch Object.State
217
case BOMBCARRIER_IDLE
218
case BOMBCARRIER_WAITFORBOSSFIGHT
219
case BOMBCARRIER_GRABBOMB
220
case BOMBCARRIER_SLIDERIGHT
221
case BOMBCARRIER_HOVER
222
// The Carrier isn't holding a Bomb, so draw the inactive Frame
223
DrawSprite(0)
224
break
225
226
case BOMBCARRIER_SLIDELEFT
227
case BOMBCARRIER_RELEASEBOMB
228
// The Carrier is holding a Bomb, so draw the active version of the Frame
229
DrawSprite(1)
230
231
// And then draw the Gravitional Force Pull thing
232
TempValue0 = Object.Frame
233
TempValue0 >>= 2
234
TempValue0 += 2
235
236
DrawSprite(TempValue0)
237
238
Object.Frame++
239
Object.Frame &= 7
240
break
241
242
end switch
243
end sub
244
245
246
sub ObjectStartup
247
LoadSpriteSheet("R5/Objects2.gif")
248
249
// Main Carrier Frame
250
SpriteFrame(-16, -12, 32, 24, 33, 215)
251
252
// Active Carrier Frame
253
SpriteFrame(-16, -12, 32, 24, 100, 113)
254
255
// Levitation Effect Frames
256
SpriteFrame(-16, 12, 32, 16, 33, 239)
257
SpriteFrame(-16, 12, 32, 16, 1, 239)
258
end sub
259
260
261
// ========================
262
// Editor Subs
263
// ========================
264
265
sub RSDKDraw
266
DrawSprite(0)
267
end sub
268
269
270
sub RSDKLoad
271
LoadSpriteSheet("R5/Objects2.gif")
272
SpriteFrame(-16, -12, 32, 24, 33, 215)
273
274
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
275
end sub
276
277