Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/PohBee2.txt
1319 views
1
//------------------Sonic CD PohBee 2 Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
//-----------Used on Mission "M086 - Gotta Go Fast"-----------//
5
6
// Aliases
7
#alias Object.Value0 : Object.Timer
8
#alias Object.Value1 : Object.XOriginPos
9
#alias Object.Value2 : Object.CurrentFrame
10
#alias Object.Value3 : Object.ShootingCooldown
11
#alias Object.Value4 : Object.FrameIncrease
12
13
#alias Object.PropertyValue : Object.Quality
14
15
// PohBee Bullet Aliases
16
#alias Object.Direction : PohBeeBullet.Direction
17
#alias Object.XPos : PohBeeBullet.XPos
18
#alias Object.YPos : PohBeeBullet.YPos
19
#alias Object.Value1 : PohBeeBullet.XVelocity
20
#alias Object.Value2 : PohBeeBullet.YVelocity
21
22
// States
23
#alias 0 : POHBEE2_MOVING_LEFT
24
#alias 1 : POHBEE2_TURN_RIGHT
25
#alias 2 : POHBEE2_MOVING_RIGHT
26
#alias 3 : POHBEE2_TURN_LEFT
27
#alias 4 : POHBEE2_SHOOTING_LEFT
28
#alias 5 : POHBEE2_SHOOTING_RIGHT
29
#alias 6 : POHBEE2_RESET
30
31
// Priority
32
#alias 0 : PRIORITY_BOUNDS
33
#alias 1 : PRIORITY_ACTIVE
34
35
// Stage SFX
36
#alias 7 : SFX_S_SHOT
37
38
// Badnik Quality / Property Values
39
#alias 0 : GOOD_QUALITY
40
#alias 1 : BAD_QUALITY
41
#alias 2 : STATIONARY // This PohBee is also good quality
42
43
44
sub ObjectMain
45
if Object.OutOfBounds == true
46
Object.State = POHBEE2_RESET
47
Object.Timer = 0
48
Object.Direction = FACING_RIGHT
49
Object.XPos = Object.XOriginPos
50
Object.CurrentFrame = 0
51
Object.ShootingCooldown = 0
52
Object.FrameIncrease = 0
53
end if
54
55
if Object.Quality == GOOD_QUALITY
56
switch Object.State
57
case POHBEE2_MOVING_LEFT
58
Object.Priority = PRIORITY_ACTIVE
59
if Object.ShootingCooldown > 0
60
Object.ShootingCooldown--
61
end if
62
if Object.Timer < 256
63
Object.Timer++
64
Object.XPos -= 0x20000
65
else
66
Object.State = POHBEE2_TURN_RIGHT
67
Object.Timer = 0
68
end if
69
break
70
71
case POHBEE2_TURN_RIGHT
72
Object.Priority = PRIORITY_ACTIVE
73
if Object.ShootingCooldown > 0
74
Object.ShootingCooldown--
75
end if
76
if Object.Timer < 60
77
if Object.Timer == 30
78
Object.Direction=FACING_LEFT
79
end if
80
Object.Timer++
81
else
82
Object.State = POHBEE2_MOVING_RIGHT
83
end if
84
break
85
86
case POHBEE2_MOVING_RIGHT
87
Object.Priority = PRIORITY_ACTIVE
88
if Object.ShootingCooldown > 0
89
Object.ShootingCooldown--
90
end if
91
if Object.Timer < 256
92
Object.Timer++
93
Object.XPos += 0x20000
94
else
95
Object.State = POHBEE2_TURN_LEFT
96
Object.Timer = 0
97
end if
98
break
99
100
case POHBEE2_TURN_LEFT
101
Object.Priority = PRIORITY_ACTIVE
102
if Object.ShootingCooldown > 0
103
Object.ShootingCooldown--
104
end if
105
if Object.Timer < 60
106
if Object.Timer == 30
107
Object.Direction = FACING_RIGHT
108
end if
109
Object.Timer++
110
else
111
Object.State = POHBEE2_MOVING_LEFT
112
end if
113
break
114
115
case POHBEE2_SHOOTING_LEFT
116
Object.Priority = PRIORITY_ACTIVE
117
if Object.ShootingCooldown < 46
118
Object.ShootingCooldown++
119
if Object.ShootingCooldown == 15
120
Object.FrameIncrease = 4
121
end if
122
if Object.ShootingCooldown == 32
123
CreateTempObject(TypeName[Poh Bee Bullet],0,Object.XPos,Object.YPos)
124
PohBeeBullet[TempObjectPos].XPos -= 0xF0000
125
PohBeeBullet[TempObjectPos].YPos += 0x1B0000
126
PohBeeBullet[TempObjectPos].XVelocity = -0x40000
127
PohBeeBullet[TempObjectPos].YVelocity = 0x40000
128
PlayStageSfx(SFX_S_SHOT,0)
129
end if
130
else
131
Object.State = POHBEE2_MOVING_LEFT
132
Object.FrameIncrease = 0
133
Object.ShootingCooldown = 30
134
end if
135
break
136
137
case POHBEE2_SHOOTING_RIGHT
138
Object.Priority = PRIORITY_ACTIVE
139
if Object.ShootingCooldown < 46
140
Object.ShootingCooldown++
141
if Object.ShootingCooldown == 15
142
Object.FrameIncrease = 4
143
end if
144
if Object.ShootingCooldown == 32
145
CreateTempObject(TypeName[Poh Bee Bullet],0,Object.XPos,Object.YPos)
146
PohBeeBullet[TempObjectPos].Direction = FACING_LEFT
147
PohBeeBullet[TempObjectPos].XPos += 0xF0000
148
PohBeeBullet[TempObjectPos].YPos += 0x1B0000
149
PohBeeBullet[TempObjectPos].XVelocity = 0x40000
150
PohBeeBullet[TempObjectPos].YVelocity = 0x40000
151
PlayStageSfx(SFX_S_SHOT,0)
152
end if
153
else
154
Object.State = POHBEE2_MOVING_RIGHT
155
Object.FrameIncrease = 0
156
Object.ShootingCooldown = 30
157
end if
158
break
159
160
case POHBEE2_RESET
161
if Object.OutOfBounds == true
162
Object.State = POHBEE2_MOVING_LEFT
163
Object.Priority = PRIORITY_BOUNDS
164
end if
165
break
166
167
end switch
168
else
169
switch Object.State
170
case POHBEE2_MOVING_LEFT
171
Object.Priority = PRIORITY_ACTIVE
172
if Object.Timer < 256
173
Object.Timer++
174
Object.XPos -= 0x10000
175
else
176
Object.State = POHBEE2_TURN_RIGHT
177
Object.Timer = 0
178
end if
179
break
180
181
case POHBEE2_TURN_RIGHT
182
Object.Priority = PRIORITY_ACTIVE
183
if Object.Timer < 30
184
if Object.Timer == 15
185
Object.Direction = FACING_LEFT
186
end if
187
Object.Timer++
188
else
189
Object.State = POHBEE2_MOVING_RIGHT
190
end if
191
break
192
193
194
case POHBEE2_MOVING_RIGHT
195
Object.Priority = PRIORITY_ACTIVE
196
if Object.Timer < 512
197
Object.Timer++
198
Object.XPos += 0x10000
199
else
200
Object.State = POHBEE2_TURN_LEFT
201
Object.Timer = 0
202
end if
203
break
204
205
case POHBEE2_TURN_LEFT
206
Object.Priority = PRIORITY_ACTIVE
207
if Object.Timer < 30
208
if Object.Timer == 15
209
Object.Direction = FACING_RIGHT
210
end if
211
Object.Timer++
212
else
213
Object.State = POHBEE2_MOVING_LEFT
214
end if
215
break
216
217
case POHBEE2_RESET
218
if Object.OutOfBounds == true
219
Object.State = POHBEE2_MOVING_LEFT
220
Object.Priority = PRIORITY_BOUNDS
221
end if
222
break
223
end switch
224
end if
225
226
CallFunction(StageSetup_CheckGoodFuture)
227
end sub
228
229
230
sub ObjectPlayerInteraction
231
if Object.Quality == GOOD_QUALITY
232
if Object.State < POHBEE2_SHOOTING_LEFT
233
if Object.ShootingCooldown == 0
234
PlayerObjectCollision(C_TOUCH, -96, -64, 96, 64)
235
if CheckResult == true
236
if Object.XPos > Player.XPos
237
Object.Direction = FACING_RIGHT
238
Object.State = POHBEE2_SHOOTING_LEFT
239
else
240
Object.Direction = FACING_LEFT
241
Object.State = POHBEE2_SHOOTING_RIGHT
242
end if
243
end if
244
end if
245
end if
246
end if
247
248
if Object.State < POHBEE2_RESET
249
PlayerObjectCollision(C_ENEMY, -20, -16, 20, 14)
250
if CheckResult == true
251
CallFunction(Player_BadnikBreak)
252
end if
253
end if
254
end sub
255
256
257
sub ObjectDraw
258
if Object.State < POHBEE2_RESET
259
if Object.Quality == GOOD_QUALITY
260
Object.CurrentFrame++
261
Object.CurrentFrame &= 3
262
263
Object.Frame = Object.CurrentFrame
264
Object.Frame >>= 1
265
Object.Frame += Object.FrameIncrease
266
else
267
Object.CurrentFrame++
268
Object.CurrentFrame &= 3
269
270
Object.Frame = Object.CurrentFrame
271
Object.Frame >>= 1
272
Object.Frame += 2
273
end if
274
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
275
end if
276
end sub
277
278
279
sub ObjectStartup
280
LoadSpriteSheet("R6/Objects.gif")
281
// Good
282
SpriteFrame(-24, -20, 48, 32, 148, 75) // #0 - PohBee Fly frame 0
283
SpriteFrame(-24, -16, 48, 28, 148, 108) // #1 - PohBee Fly frame 1
284
// Bad
285
SpriteFrame(-24, -20, 48, 32, 99, 133) // #2 - PohBee Fly frame 0
286
SpriteFrame(-24, -16, 48, 28, 148, 137) // #3 - PohBee Fly frame 1
287
// Shooting
288
SpriteFrame(-24, -20, 48, 40, 197, 91) // #4 - PohBee Shoot frame 0
289
SpriteFrame(-24, -16, 48, 36, 197, 132) // #5 - PohBee Shoot frame 1
290
291
ArrayPos0 = 32
292
while ArrayPos0 < 1056
293
if Object[ArrayPos0].Type == TypeName[Poh Bee]
294
Object[ArrayPos0].Type = TypeName[PohBee2]
295
end if
296
if Object[ArrayPos0].Type == TypeName[PohBee2]
297
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
298
end if
299
ArrayPos0++
300
loop
301
end sub
302
303
304
// ========================
305
// Editor Subs
306
// ========================
307
308
sub RSDKEdit
309
if Editor.ReturnVariable == true
310
switch Editor.VariableID
311
case EDIT_VAR_PROPVAL // Property Value
312
CheckResult = Object.PropertyValue
313
break
314
case 0 // Condition
315
CheckResult = Object.PropertyValue
316
break
317
end switch
318
else
319
switch Editor.VariableID
320
case EDIT_VAR_PROPVAL // Property Value
321
Object.PropertyValue = Editor.VariableValue
322
break
323
case 0 // Condition
324
Object.PropertyValue = Editor.VariableValue
325
break
326
end switch
327
end if
328
end sub
329
330
331
sub RSDKDraw
332
DrawSprite(Object.PropertyValue)
333
end sub
334
335
336
sub RSDKLoad
337
LoadSpriteSheet("R6/Objects.gif")
338
// Good
339
SpriteFrame(-24, -20, 48, 32, 148, 75) // #0 - PohBee Fly
340
// Bad
341
SpriteFrame(-24, -20, 48, 32, 99, 133) // #2 - PohBee Fly
342
343
AddEditorVariable("Condition")
344
SetActiveVariable("Condition")
345
AddEnumVariable("Good", GOOD_QUALITY)
346
AddEnumVariable("Bad", BAD_QUALITY)
347
AddEnumVariable("Good, Stationary", STATIONARY)
348
end sub
349
350
351
352