Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/MechaBu2.txt
1319 views
1
//-----------------Sonic CD Mecha Bu 2 Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//-------Used on Mission "M110 - Extreme! Gotta Go Fast"------//
5
6
// Aliases
7
#alias Object.Value0 : Object.Timer
8
9
#alias Object.Value2 : Object.XOriginPos
10
#alias Object.Value3 : Object.YOriginPos
11
#alias Object.Value4 : Object.HornTimer
12
#alias Object.Value5 : Object.SFXTimer
13
14
#alias Object.PropertyValue : Object.Quality
15
16
// States
17
#alias 0 : MECHABU2_FINDGROUND
18
#alias 1 : MECHABU2_BACKTRACK
19
#alias 2 : MECHABU2_ADVANCE
20
21
// SFX Aliases
22
#alias 1 : SFX_S_BUZZSAW
23
24
// Collision Sides
25
#alias 0 : CSIDE_FLOOR
26
27
// Badnik Quality / Property Values
28
#alias 0 : GOOD_QUALITY
29
#alias 1 : BAD_QUALITY
30
31
32
sub ObjectMain
33
switch Object.State
34
case MECHABU2_FINDGROUND
35
// See if there's any ground to be found at the Bu's current position
36
ObjectTileCollision(CSIDE_FLOOR, 0, 15, 0)
37
38
if CheckResult == true
39
// Floor detected, go to the normal movement states now
40
41
Object.State = MECHABU2_BACKTRACK
42
else
43
// The Bu's still in the air, so move a pixel down
44
45
Object.YPos += 0x10000
46
end if
47
48
if Object.State == MECHABU2_FINDGROUND // But you're already there...
49
50
ArrayPos0 = 32
51
while ArrayPos0 < 1056
52
if Object[ArrayPos0].PropertyValue <= 1
53
TempValue3 = -16
54
else
55
TempValue3 = -32
56
TempValue3 *= Object[ArrayPos0].PropertyValue
57
TempValue3 += 16
58
end if
59
60
TempValue4 = 16
61
62
TempValue0 = Object[ArrayPos0].iXPos
63
TempValue0 -= Object.iXPos
64
65
CheckGreater(TempValue0, TempValue3)
66
TempValue1 = CheckResult
67
CheckLower(TempValue0, TempValue4)
68
TempValue1 &= CheckResult
69
if TempValue1 == true
70
TempValue2 = Object[ArrayPos0].iYPos
71
TempValue1 = Object.iYPos
72
TempValue1 += 16
73
TempValue2 -= TempValue1
74
CheckGreater(TempValue2, -16)
75
TempValue1 = CheckResult
76
CheckLower(TempValue2, 15)
77
TempValue1 &= CheckResult
78
if TempValue1 == true
79
Object.iYPos = Object[ArrayPos0].iYPos
80
Object.iYPos -= 32
81
Object.State = MECHABU2_BACKTRACK
82
ArrayPos0 = 2000
83
end if
84
end if
85
ArrayPos0++
86
loop
87
end if
88
break
89
90
case MECHABU2_BACKTRACK
91
if Object.Timer < 416
92
Object.Timer++
93
94
// Move 0.3125 pixels right (opposite of the direction the Bu's currently towards)
95
Object.XPos += 0x5000
96
else
97
// Change direction, start going ahead now
98
99
Object.Timer = 0
100
Object.State = MECHABU2_ADVANCE
101
end if
102
103
// Stay with the ground even when going backwards, quite the fancy moonwalk!
104
ObjectTileGrip(CSIDE_FLOOR, 0, 15, 0)
105
break
106
107
case MECHABU2_ADVANCE
108
if Object.Timer < 416
109
Object.Timer++
110
111
// Move 0.3125 pixels to the left (in the direction the Bu is facing)
112
Object.XPos -= 0x5000
113
else
114
// Change direction once again, start going backwards
115
116
Object.Timer = 0
117
Object.State = MECHABU2_BACKTRACK
118
end if
119
120
// Track the ground, the Bu should always be grounded
121
ObjectTileGrip(CSIDE_FLOOR, 0, 15, 0)
122
break
123
124
end switch
125
126
// See if the Bu should become a Flower instead
127
CallFunction(StageSetup_CheckGoodFuture)
128
end sub
129
130
131
sub ObjectPlayerInteraction
132
133
// Huh, it doesn't seem like the Mecha Bu ever reaches state 3, so this check
134
// is effectivly useless
135
if Object.State < 3
136
137
// Check collision with the main Mecha Bu
138
PlayerObjectCollision(C_ENEMY,-16,-14,16,14)
139
if CheckResult == true
140
CallFunction(Player_BadnikBreak)
141
end if
142
143
// Make sure the Bu hasn't become a Flower (destroyed) before checking for other parts
144
if Object.Type == TypeName[MechaBu2]
145
if Object.HornTimer > 59
146
if Object.Direction == FACING_RIGHT
147
PlayerObjectCollision(C_TOUCH, -30, -32, -8, 0)
148
else
149
PlayerObjectCollision(C_TOUCH, 8, -32, 30, 0)
150
end if
151
if CheckResult == true
152
CallFunction(Player_Hit)
153
end if
154
else
155
if Object.Direction == FACING_RIGHT
156
PlayerObjectCollision(C_TOUCH, -36, -16, -14, 16)
157
else
158
PlayerObjectCollision(C_TOUCH, 14, -16, 36, 16)
159
end if
160
if CheckResult == true
161
CallFunction(Player_Hit)
162
end if
163
end if
164
end if
165
end if
166
end sub
167
168
169
sub ObjectDraw
170
171
Object.SFXTimer++
172
if Object.SFXTimer == 48
173
Object.SFXTimer = 0
174
PlayStageSfx(SFX_S_BUZZSAW, false)
175
end if
176
177
TempValue0 = Object.AnimationTimer
178
TempValue0 /= 3
179
180
Object.AnimationTimer++
181
Object.AnimationTimer %= 6
182
183
if Object.HornTimer > 59
184
TempValue0 += 5
185
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
186
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
187
DrawSpriteFX(4, FX_FLIP, Object.XPos, Object.YPos)
188
else
189
TempValue0 += 2
190
DrawSpriteFX(TempValue0, FX_FLIP, Object.XPos, Object.YPos)
191
DrawSpriteFX(0, FX_FLIP, Object.XPos, Object.YPos)
192
DrawSpriteFX(1, FX_FLIP, Object.XPos, Object.YPos)
193
end if
194
195
Object.HornTimer++
196
Object.HornTimer %= 120
197
end sub
198
199
200
sub ObjectStartup
201
202
LoadSpriteSheet("R8/Objects.gif")
203
204
SpriteFrame(-24, -16, 48, 32, 173, 140) // #0 - Mecha Bu body
205
206
SpriteFrame(-23, -17, 16, 24, 156, 177) // #1 - Mecha Bu Horn frame 0
207
SpriteFrame(-31, -32, 24, 32, 230, 1) // #2 - Mecha Bu Saw frame 0
208
SpriteFrame(-31, -32, 24, 32, 173, 173) // #3 - Mecha Bu Saw frame 1
209
210
SpriteFrame(-33, -8, 24, 16, 131, 177) // #4 - Mecha Bu Horn frame 1
211
SpriteFrame(-37, -16, 24, 32, 230, 1) // #5 - Mecha Bu Saw frame 0
212
SpriteFrame(-37, -16, 24, 32, 173, 173) // #6 - Mecha Bu Saw frame 1
213
214
// Cycle through all Objects in the level and find all Mecha Bu's
215
ArrayPos0 = 32
216
while ArrayPos0 < 1056
217
if Object[ArrayPos0].Type == TypeName[Mecha Bu2]
218
219
// Store their its starting position
220
// (These don't ever seem to be used, though?)
221
222
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
223
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
224
225
if Object[ArrayPos0].Quality == BAD_QUALITY
226
Object[ArrayPos0].Direction = FACING_LEFT
227
end if
228
end if
229
230
ArrayPos0++
231
loop
232
end sub
233
234
235
// ========================
236
// Editor Subs
237
// ========================
238
239
sub RSDKDraw
240
DrawSprite(0)
241
end sub
242
243
244
sub RSDKLoad
245
LoadSpriteSheet("R8/Objects.gif")
246
247
SpriteFrame(-24, -16, 48, 32, 173, 140) // #0 - Mecha Bu body
248
249
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
250
end sub
251
252
253
254