Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R6/PohBee.txt
1319 views
1
//------------------Sonic CD Poh Bee 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.XOriginPos
8
#alias Object.Value2 : Object.CurrentFrame
9
#alias Object.Value3 : Object.ShootingCooldown
10
#alias Object.Value4 : Object.FrameIncrease
11
12
#alias Object.PropertyValue : Object.Quality
13
14
// PohBee Bullet Aliases
15
#alias Object.Direction : PohBeeBullet.Direction
16
#alias Object.XPos : PohBeeBullet.XPos
17
#alias Object.YPos : PohBeeBullet.YPos
18
#alias Object.Value1 : PohBeeBullet.XVelocity
19
#alias Object.Value2 : PohBeeBullet.YVelocity
20
21
// States
22
#alias 0 : POHBEE_MOVING_LEFT
23
#alias 1 : POHBEE_TURN_RIGHT
24
#alias 2 : POHBEE_MOVING_RIGHT
25
#alias 3 : POHBEE_TURN_LEFT
26
#alias 4 : POHBEE_SHOOTING_LEFT
27
#alias 5 : POHBEE_SHOOTING_RIGHT
28
#alias 6 : POHBEE_RESET
29
30
// Stage SFX
31
#alias 7 : SFX_S_SHOT
32
33
// Priority
34
#alias 0 : PRIORITY_BOUNDS
35
#alias 1 : PRIORITY_ACTIVE
36
37
// Badnik Quality / Property Values
38
#alias 0 : GOOD_QUALITY
39
#alias 1 : BAD_QUALITY
40
// Origins added a new one, say hi to the stationary PohBee
41
#alias 2 : STATIONARY // This PohBee is also good quality
42
43
44
sub ObjectMain
45
if Object.OutOfBounds == true
46
Object.State = POHBEE_RESET
47
Object.Timer = 0
48
Object.Direction = FACING_RIGHT
49
50
Object.XPos = Object.XOriginPos
51
52
Object.CurrentFrame = 0
53
Object.ShootingCooldown = 0
54
Object.FrameIncrease = 0
55
end if
56
57
if Object.Quality == GOOD_QUALITY
58
switch Object.State
59
case POHBEE_MOVING_LEFT
60
Object.Priority = PRIORITY_ACTIVE
61
if Object.ShootingCooldown > 0
62
Object.ShootingCooldown--
63
end if
64
if Object.Timer < 512
65
Object.Timer++
66
Object.XPos -= 0x10000
67
else
68
Object.State = POHBEE_TURN_RIGHT
69
Object.Timer = 0
70
end if
71
break
72
73
case POHBEE_TURN_RIGHT
74
Object.Priority = PRIORITY_ACTIVE
75
if Object.ShootingCooldown > 0
76
Object.ShootingCooldown--
77
end if
78
if Object.Timer < 60
79
if Object.Timer == 30
80
Object.Direction = FACING_LEFT
81
end if
82
Object.Timer++
83
else
84
Object.State = POHBEE_MOVING_RIGHT
85
end if
86
break
87
88
case POHBEE_MOVING_RIGHT
89
Object.Priority = PRIORITY_ACTIVE
90
if Object.ShootingCooldown > 0
91
Object.ShootingCooldown--
92
end if
93
if Object.Timer < 512
94
Object.Timer++
95
Object.XPos += 0x10000
96
else
97
Object.State = POHBEE_TURN_LEFT
98
Object.Timer = 0
99
end if
100
break
101
102
case POHBEE_TURN_LEFT
103
Object.Priority = PRIORITY_ACTIVE
104
if Object.ShootingCooldown > 0
105
Object.ShootingCooldown--
106
end if
107
if Object.Timer < 60
108
if Object.Timer == 30
109
Object.Direction = FACING_RIGHT
110
end if
111
Object.Timer++
112
else
113
Object.State = POHBEE_MOVING_LEFT
114
end if
115
break
116
117
case POHBEE_SHOOTING_LEFT
118
Object.Priority = PRIORITY_ACTIVE
119
if Object.ShootingCooldown < 92
120
Object.ShootingCooldown++
121
if Object.ShootingCooldown == 30
122
Object.FrameIncrease = 4
123
end if
124
if Object.ShootingCooldown == 64
125
CreateTempObject(TypeName[Poh Bee Bullet], 0, Object.XPos, Object.YPos)
126
PohBeeBullet[TempObjectPos].XPos -= 0xF0000
127
PohBeeBullet[TempObjectPos].YPos += 0x1B0000
128
PohBeeBullet[TempObjectPos].XVelocity = -0x20000
129
PohBeeBullet[TempObjectPos].YVelocity = 0x20000
130
PlayStageSfx(SFX_S_SHOT, false)
131
end if
132
else
133
Object.State = POHBEE_MOVING_LEFT
134
Object.FrameIncrease = 0
135
Object.ShootingCooldown = 60
136
end if
137
break
138
139
case POHBEE_SHOOTING_RIGHT
140
Object.Priority = PRIORITY_ACTIVE
141
if Object.ShootingCooldown < 92
142
Object.ShootingCooldown++
143
if Object.ShootingCooldown == 30
144
Object.FrameIncrease = 4
145
end if
146
if Object.ShootingCooldown == 64
147
CreateTempObject(TypeName[Poh Bee Bullet], 0, Object.XPos, Object.YPos)
148
PohBeeBullet[TempObjectPos].Direction = FACING_LEFT
149
PohBeeBullet[TempObjectPos].XPos += 0xF0000
150
PohBeeBullet[TempObjectPos].YPos += 0x1B0000
151
PohBeeBullet[TempObjectPos].XVelocity = 0x20000
152
PohBeeBullet[TempObjectPos].YVelocity = 0x20000
153
PlayStageSfx(SFX_S_SHOT, false)
154
end if
155
else
156
Object.State = POHBEE_MOVING_RIGHT
157
Object.FrameIncrease = 0
158
Object.ShootingCooldown = 60
159
end if
160
break
161
162
case POHBEE_RESET
163
if Object.OutOfBounds == true
164
Object.State = POHBEE_MOVING_LEFT
165
Object.Priority = PRIORITY_BOUNDS
166
end if
167
break
168
169
end switch
170
else
171
switch Object.State
172
case POHBEE_MOVING_LEFT
173
Object.Priority = PRIORITY_ACTIVE
174
if Object.Timer < 1024
175
Object.Timer++
176
Object.XPos -= 0x8000
177
else
178
Object.State = POHBEE_TURN_RIGHT
179
Object.Timer = 0
180
end if
181
break
182
183
case POHBEE_TURN_RIGHT
184
Object.Priority = PRIORITY_ACTIVE
185
if Object.Timer < 60
186
if Object.Timer == 30
187
Object.Direction = FACING_LEFT
188
end if
189
Object.Timer++
190
else
191
Object.State = POHBEE_MOVING_RIGHT
192
end if
193
break
194
195
case POHBEE_MOVING_RIGHT
196
Object.Priority = PRIORITY_ACTIVE
197
if Object.Timer < 1024
198
Object.Timer++
199
Object.XPos += 0x8000
200
else
201
Object.State = POHBEE_TURN_LEFT
202
Object.Timer = 0
203
end if
204
break
205
206
case POHBEE_TURN_LEFT
207
Object.Priority = PRIORITY_ACTIVE
208
if Object.Timer < 60
209
if Object.Timer == 30
210
Object.Direction = FACING_RIGHT
211
end if
212
Object.Timer++
213
else
214
Object.State = POHBEE_MOVING_LEFT
215
end if
216
break
217
218
case POHBEE_RESET
219
if Object.OutOfBounds == true
220
Object.State = POHBEE_MOVING_LEFT
221
Object.Priority = PRIORITY_BOUNDS
222
end if
223
break
224
end switch
225
end if
226
227
#platform: Use_Origins
228
CheckEqual(game.playMode, BOOT_PLAYMODE_MISSION)
229
TempValue0 = CheckResult
230
CheckEqual(Object.Quality, STATIONARY)
231
TempValue0 &= CheckResult
232
233
if TempValue0 == true
234
switch Object.State
235
case POHBEE_MOVING_LEFT
236
Object.Priority = PRIORITY_ACTIVE
237
if Object.ShootingCooldown > 0
238
Object.ShootingCooldown--
239
end if
240
241
if Object.Timer < 512
242
Object.Timer++
243
else
244
Object.State = POHBEE_TURN_RIGHT
245
Object.Timer = 0
246
end if
247
break
248
249
case POHBEE_TURN_RIGHT
250
Object.Priority = PRIORITY_ACTIVE
251
if Object.ShootingCooldown > 0
252
Object.ShootingCooldown--
253
end if
254
255
if Object.Timer < 60
256
if Object.Timer == 30
257
Object.Direction = FACING_LEFT
258
end if
259
Object.Timer++
260
else
261
Object.State = POHBEE_MOVING_RIGHT
262
end if
263
break
264
265
case POHBEE_MOVING_RIGHT
266
Object.Priority = PRIORITY_ACTIVE
267
if Object.ShootingCooldown > 0
268
Object.ShootingCooldown--
269
end if
270
271
if Object.Timer < 512
272
Object.Timer++
273
else
274
Object.State = POHBEE_TURN_LEFT
275
Object.Timer = 0
276
end if
277
break
278
279
case POHBEE_TURN_LEFT
280
Object.Priority = PRIORITY_ACTIVE
281
if Object.ShootingCooldown > 0
282
Object.ShootingCooldown--
283
end if
284
285
if Object.Timer < 60
286
if Object.Timer == 30
287
Object.Direction = FACING_RIGHT
288
end if
289
Object.Timer++
290
else
291
Object.State = POHBEE_MOVING_LEFT
292
end if
293
break
294
295
case POHBEE_SHOOTING_LEFT
296
Object.Priority = PRIORITY_ACTIVE
297
if Object.ShootingCooldown < 92
298
Object.ShootingCooldown++
299
if Object.ShootingCooldown == 30
300
Object.FrameIncrease = 4
301
end if
302
303
if Object.ShootingCooldown == 64
304
CreateTempObject(TypeName[Poh Bee Bullet], 0, Object.XPos, Object.YPos)
305
PohBeeBullet[TempObjectPos].XPos -= 0xF0000
306
PohBeeBullet[TempObjectPos].YPos += 0x1B0000
307
PohBeeBullet[TempObjectPos].XVelocity = -0x20000
308
PohBeeBullet[TempObjectPos].YVelocity = 0x20000
309
PlayStageSfx(SFX_S_SHOT, false)
310
end if
311
else
312
Object.State = POHBEE_MOVING_LEFT
313
Object.FrameIncrease = 0
314
Object.ShootingCooldown = 60
315
end if
316
break
317
318
case POHBEE_SHOOTING_RIGHT
319
Object.Priority = PRIORITY_ACTIVE
320
321
if Object.ShootingCooldown < 92
322
Object.ShootingCooldown++
323
if Object.ShootingCooldown == 30
324
Object.FrameIncrease = 4
325
end if
326
327
if Object.ShootingCooldown == 64
328
CreateTempObject(TypeName[Poh Bee Bullet], 0, Object.XPos, Object.YPos)
329
PohBeeBullet[TempObjectPos].Direction = FACING_LEFT
330
PohBeeBullet[TempObjectPos].XPos += 0xF0000
331
PohBeeBullet[TempObjectPos].YPos += 0x1B0000
332
PohBeeBullet[TempObjectPos].XVelocity = 0x20000
333
PohBeeBullet[TempObjectPos].YVelocity = 0x20000
334
PlayStageSfx(SFX_S_SHOT, false)
335
end if
336
else
337
Object.State = POHBEE_MOVING_RIGHT
338
Object.FrameIncrease = 0
339
Object.ShootingCooldown = 60
340
end if
341
break
342
343
case POHBEE_RESET
344
if Object.OutOfBounds == true
345
Object.State = POHBEE_MOVING_LEFT
346
Object.Priority = PRIORITY_BOUNDS
347
end if
348
break
349
end switch
350
end if
351
#endplatform
352
353
// Check if this badnik should be a flower
354
CallFunction(StageSetup_CheckGoodFuture)
355
end sub
356
357
358
sub ObjectPlayerInteraction
359
if Object.Quality != BAD_QUALITY
360
if Object.State < POHBEE_SHOOTING_LEFT
361
if Object.ShootingCooldown == 0
362
PlayerObjectCollision(C_TOUCH, -96, -64, 96, 64)
363
if CheckResult == true
364
if Object.XPos > Player.XPos
365
Object.Direction = FACING_RIGHT
366
Object.State = POHBEE_SHOOTING_LEFT
367
else
368
Object.Direction = FACING_LEFT
369
Object.State = POHBEE_SHOOTING_RIGHT
370
end if
371
end if
372
end if
373
end if
374
end if
375
376
if Object.State < POHBEE_RESET
377
#platform: Use_Standalone
378
PlayerObjectCollision(C_TOUCH, -20, -16, 20, 14)
379
#endplatform
380
#platform: Use_Origins
381
PlayerObjectCollision(C_ENEMY, -20, -16, 20, 14)
382
#endplatform
383
if CheckResult == true
384
CallFunction(Player_BadnikBreak)
385
end if
386
end if
387
end sub
388
389
390
sub ObjectDraw
391
if Object.State < POHBEE_RESET
392
if Object.Quality != BAD_QUALITY
393
Object.CurrentFrame++
394
Object.CurrentFrame &= 3
395
396
Object.Frame = Object.CurrentFrame
397
Object.Frame >>= 1
398
Object.Frame += Object.FrameIncrease
399
else
400
Object.CurrentFrame++
401
Object.CurrentFrame &= 3
402
403
Object.Frame = Object.CurrentFrame
404
Object.Frame >>= 1
405
Object.Frame += 2
406
end if
407
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
408
end if
409
end sub
410
411
412
sub ObjectStartup
413
LoadSpriteSheet("R6/Objects.gif")
414
// Good
415
SpriteFrame(-24, -20, 48, 32, 148, 75) // #0 - PohBee Fly frame 0
416
SpriteFrame(-24, -16, 48, 28, 148, 108) // #1 - PohBee Fly frame 1
417
// Bad
418
SpriteFrame(-24, -20, 48, 32, 99, 133) // #2 - PohBee Fly frame 0
419
SpriteFrame(-24, -16, 48, 28, 148, 137) // #3 - PohBee Fly frame 1
420
// Shooting
421
SpriteFrame(-24, -20, 48, 40, 197, 91) // #4 - PohBee Shoot frame 0
422
SpriteFrame(-24, -16, 48, 36, 197, 132) // #5 - PohBee Shoot frame 1
423
424
ArrayPos0 = 32
425
while ArrayPos0 < 1056
426
if Object[ArrayPos0].Type == TypeName[Poh Bee]
427
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
428
end if
429
ArrayPos0++
430
loop
431
end sub
432
433
434
// ========================
435
// Editor Subs
436
// ========================
437
438
sub RSDKEdit
439
if Editor.ReturnVariable == true
440
switch Editor.VariableID
441
case EDIT_VAR_PROPVAL // Property Value
442
CheckResult = Object.PropertyValue
443
break
444
case 0 // Condition
445
CheckResult = Object.PropertyValue
446
CheckResult &= 1
447
break
448
end switch
449
else
450
switch Editor.VariableID
451
case EDIT_VAR_PROPVAL // Property Value
452
Object.PropertyValue = Editor.VariableValue
453
break
454
case 0 // Condition
455
Object.PropertyValue = Editor.VariableValue
456
Object.PropertyValue &= 1
457
break
458
end switch
459
end if
460
end sub
461
462
463
sub RSDKDraw
464
DrawSprite(Object.PropertyValue)
465
end sub
466
467
468
sub RSDKLoad
469
LoadSpriteSheet("R6/Objects.gif")
470
// Good
471
SpriteFrame(-24, -20, 48, 32, 148, 75) // #0 - PohBee Fly
472
// Bad
473
SpriteFrame(-24, -20, 48, 32, 99, 133) // #2 - PohBee Fly
474
475
AddEditorVariable("Condition")
476
SetActiveVariable("Condition")
477
AddEnumVariable("Good", GOOD_QUALITY)
478
AddEnumVariable("Bad", BAD_QUALITY)
479
end sub
480
481