Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R5/BossBomb.txt
1319 views
1
//-----------------Sonic CD Boss Bomb Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.XVelocity
8
#alias Object.Value2 : Object.YVelocity
9
#alias Object.Value3 : Object.Gravity
10
11
// Player Aliases
12
#alias Object[0].Value0 : Player.Rings
13
14
// States
15
#alias 0 : BOSSBOMB_CARRIED
16
#alias 1 : BOSSBOMB_ACTIVE
17
18
// Collision Sides
19
#alias 0 : CSIDE_FLOOR
20
21
// Global SFX
22
#alias 22 : SFX_G_EXPLOSION
23
24
// Stage SFX
25
#alias 4 : SFX_S_IMPACT1
26
27
// Property Values
28
#alias 0 : BOMB
29
#alias 1 : BOMB_FRAGMENT
30
31
32
sub ObjectMain
33
34
if Object.PropertyValue == BOMB
35
// Object is a Bomb
36
37
if Object.State == BOSSBOMB_ACTIVE
38
39
// Make the Bomb fall at a rate of 2px per frame
40
Object.YPos += 0x20000
41
42
// See if the Bomb's touched the ground yet
43
ObjectTileCollision(CSIDE_FLOOR, 0, 10, 0)
44
45
if CheckResult == true
46
if Object.Timer < 4
47
// There's a short delay between hitting the ground and actually exploding
48
Object.Timer++
49
else
50
PlayStageSfx(SFX_S_IMPACT1, false)
51
52
// Now that the Bomb's supposed to explode, create all of the Bomb Fragments
53
54
// Create the first Bomb Fragment, with starting values of:
55
// - Offset of 4px left, 4px up
56
// - XVelocity of 0.625px left per frame
57
// - YVelocity of 4px up per frame
58
// - Gravity acceleration of 0.1875px
59
CreateTempObject(TypeName[Boss Bomb], BOMB_FRAGMENT, Object.XPos, Object.YPos)
60
Object[TempObjectPos].XPos -= 0x40000
61
Object[TempObjectPos].YPos -= 0x40000
62
Object[TempObjectPos].XVelocity = -0xA000
63
Object[TempObjectPos].YVelocity = -0x40000
64
Object[TempObjectPos].Gravity = 0x3000
65
66
// And then the next Fragment, with initial values of:
67
// - Offset of 4px right, 4px up
68
// - XVelocity of 0.625px right per frame
69
// - YVelocity of 4px up per frame
70
// - Gravity acceleration of 0.1875px
71
CreateTempObject(TypeName[Boss Bomb], BOMB_FRAGMENT, Object.XPos, Object.YPos)
72
Object[TempObjectPos].XPos += 0x40000
73
Object[TempObjectPos].YPos -= 0x40000
74
Object[TempObjectPos].XVelocity = 0xA000
75
Object[TempObjectPos].YVelocity = -0x40000
76
Object[TempObjectPos].Gravity = 0x3000
77
78
// And another!
79
// This one's initial values are:
80
// - Offset of 4px left, 4px down
81
// - XVelocity of 1.25px left per frame
82
// - YVelocity of 2.25px up per frame
83
// - Gravity acceleration of 0.09375px
84
CreateTempObject(TypeName[Boss Bomb], BOMB_FRAGMENT, Object.XPos, Object.YPos)
85
Object[TempObjectPos].XPos -= 0x40000
86
Object[TempObjectPos].YPos += 0x40000
87
Object[TempObjectPos].XVelocity = -0x14000
88
Object[TempObjectPos].YVelocity = -0x24000
89
Object[TempObjectPos].Gravity = 0x1800
90
91
// Last but certainly not least, give this final Fragment
92
// some pretty good starting values of:
93
// - Offset of 4px right, 4px down
94
// - XVelocity of 1.25px left per frame
95
// - YVelocity of 2.25px up per frame
96
// - Gravity acceleration of 0.09375px
97
CreateTempObject(TypeName[Boss Bomb], BOMB_FRAGMENT, Object.XPos, Object.YPos)
98
Object[TempObjectPos].XPos += 0x40000
99
Object[TempObjectPos].YPos += 0x40000
100
Object[TempObjectPos].XVelocity = 0x14000
101
Object[TempObjectPos].YVelocity = -0x24000
102
Object[TempObjectPos].Gravity = 0x1800
103
104
// This main Boss Bomb Object doesn't actually explode and unload -
105
// instead, upon landing on the ground and exploding, it resets itself
106
// and the same Object is used for future explosions
107
108
Object.State = BOSSBOMB_CARRIED
109
Object.Timer = 0
110
111
// Return back to the Boss Top's Position
112
Object.XPos = Object[+2].XPos
113
Object.YPos = Object[+2].YPos
114
115
#platform: Use_Haptics
116
HapticEffect(77, 0, 0, 0)
117
#endplatform
118
end if
119
end if
120
end if
121
else
122
// Bomb Fragment
123
124
// Update the Fragment's horizontal movements
125
Object.XPos += Object.XVelocity
126
127
// Apply Gravity to the Fragment
128
// -> Each piece has different Gravity values, which is why
129
// this is an Object Value and not a constant value
130
Object.YVelocity += Object.Gravity
131
132
// And then, actually apply Y movement
133
Object.YPos += Object.YVelocity
134
135
if Object.OutOfBounds == true
136
// If no longer needed, unload the Object
137
Object.Type = TypeName[Blank Object]
138
end if
139
140
end if
141
142
end sub
143
144
145
sub ObjectPlayerInteraction
146
147
if Object.State == BOSSBOMB_ACTIVE
148
149
// Check Interaction with the Player
150
PlayerObjectCollision(C_TOUCH, -10, -10, 10, 10)
151
152
if CheckResult == true
153
154
// Explode if the Player has zero rings... except I think this is bugged?
155
// This check always returns true, regardless of how many rings the Player has,
156
// so the bomb always disappears...
157
if Player.Rings == 0
158
Object.State = BOSSBOMB_CARRIED
159
160
// Explode, creating the Explosion as a Temp Object rather than in this Object
161
// slot because the Bomb should remain
162
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
163
164
// Move the Bomb back to the Boss Top's Position
165
Object.XPos = Object[+2].XPos
166
Object.YPos = Object[+2].YPos
167
168
PlaySfx(SFX_G_EXPLOSION, false)
169
end if
170
171
// And now, only after checking the Player's rings, see if we should hurt the Player
172
CallFunction(Player_Hit)
173
174
// If the Player was indeed hurt...
175
if Player.State == Player_State_GotHit
176
// ...then reset the Boss Platform's Speed Value
177
Object[+5].Value3 = 0xC000
178
end if
179
180
end if
181
else
182
if Object.PropertyValue == 1
183
// Bomb Fragment
184
185
PlayerObjectCollision(C_TOUCH, -7, -7, 7, 7)
186
187
if CheckResult == true
188
189
// Similarly to above, I believe this check against the Player's Rings
190
// may actually be a bit bugged...
191
if Player.Rings == 0
192
Object.State = BOSSBOMB_CARRIED
193
CreateTempObject(TypeName[Explosion], 0, Object.XPos, Object.YPos)
194
Object.Type = TypeName[Blank Object]
195
PlaySfx(SFX_G_EXPLOSION, false)
196
end if
197
198
CallFunction(Player_Hit)
199
end if
200
end if
201
end if
202
203
end sub
204
205
206
sub ObjectDraw
207
DrawSprite(Object.PropertyValue)
208
end sub
209
210
211
sub ObjectStartup
212
LoadSpriteSheet("R5/Objects2.gif")
213
214
// Bomb Frame
215
SpriteFrame(-12, -12, 24, 24, 75, 113)
216
217
// Bomb Fragment Frame
218
SpriteFrame(-8, -8, 16, 16, 131, 138)
219
220
end sub
221
222
223
// ========================
224
// Editor Subs
225
// ========================
226
227
sub RSDKDraw
228
DrawSprite(0)
229
end sub
230
231
232
sub RSDKLoad
233
LoadSpriteSheet("R5/Objects2.gif")
234
SpriteFrame(-12, -12, 24, 24, 75, 113)
235
236
// Although used by the Object, only the normal Boss Bomb Object should ever be placed in a scene
237
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
238
end sub
239
240