Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R8/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.YOriginPos
9
#alias Object.Value3 : Object.PohBeeOscillation
10
#alias Object.Value4 : SpikeBallN1.Oscillation
11
#alias Object.Value5 : SpikeBallN2.Oscillation
12
#alias Object.Value6 : SpikeBallN2.Rotation
13
#alias Object.Value7 : Object.SBallDistance
14
15
#alias Object.PropertyValue : Object.Quality
16
17
// States
18
#alias 0 : POHBEE_MOVING_RIGHT
19
#alias 1 : POHBEE_MOVING_LEFT
20
21
// Badnik Quality / Property Values
22
#alias 0 : GOOD_QUALITY
23
#alias 1 : BAD_QUALITY
24
25
26
sub ObjectMain
27
if Object.OutOfBounds == true
28
Object.XPos = Object.XOriginPos
29
Object.Timer = 0
30
Object.State = POHBEE_MOVING_RIGHT
31
end if
32
33
Object.Rotation += 9
34
Object.Rotation &= 2047
35
36
if Object.Quality == GOOD_QUALITY
37
SpikeBallN2.Rotation += 10
38
SpikeBallN2.Rotation &= 2047
39
switch Object.State
40
case POHBEE_MOVING_RIGHT
41
Object.Direction = FACING_LEFT
42
if Object.Timer < 128
43
Object.Timer++
44
Object.XPos += 0x10000
45
else
46
Object.State = POHBEE_MOVING_LEFT
47
Object.Timer = 0
48
end if
49
break
50
51
case POHBEE_MOVING_LEFT
52
Object.Direction = FACING_RIGHT
53
if Object.Timer < 128
54
Object.Timer++
55
Object.XPos -= 0x10000
56
else
57
Object.State = POHBEE_MOVING_RIGHT
58
Object.Timer = 0
59
end if
60
break
61
end switch
62
63
Object.PohBeeOscillation += 8
64
Object.PohBeeOscillation &= 511
65
Sin(Object.YPos, Object.PohBeeOscillation)
66
Object.YPos <<= 12
67
Object.YPos += Object.YOriginPos
68
69
TempValue0 = Object.Rotation
70
TempValue0 >>= 2
71
Sin(SpikeBallN1.Oscillation, TempValue0)
72
SpikeBallN1.Oscillation >>= 2
73
SpikeBallN1.Oscillation += 136
74
SpikeBallN1.Oscillation *= 120
75
SpikeBallN1.Oscillation >>= 7
76
77
TempValue0 = SpikeBallN2.Rotation
78
TempValue0 >>= 2
79
Sin(SpikeBallN2.Oscillation, TempValue0)
80
SpikeBallN2.Oscillation >>= 2
81
SpikeBallN2.Oscillation += 144
82
SpikeBallN2.Oscillation *= 112
83
SpikeBallN2.Oscillation >>= 7
84
else
85
switch Object.State
86
case POHBEE_MOVING_RIGHT
87
Object.Direction = FACING_LEFT
88
if Object.Timer < 256
89
Object.Timer++
90
Object.XPos += 0x8000
91
else
92
Object.State = POHBEE_MOVING_LEFT
93
Object.Timer = 0
94
end if
95
break
96
97
case POHBEE_MOVING_LEFT
98
Object.Direction = FACING_RIGHT
99
if Object.Timer < 256
100
Object.Timer++
101
Object.XPos -= 0x8000
102
else
103
Object.State = POHBEE_MOVING_RIGHT
104
Object.Timer = 0
105
end if
106
break
107
end switch
108
109
Object.PohBeeOscillation += 6
110
Object.PohBeeOscillation &= 511
111
Sin(Object.YPos, Object.PohBeeOscillation)
112
Object.YPos <<= 11
113
Object.YPos += Object.YOriginPos
114
115
TempValue0 = Object.Rotation
116
TempValue0 >>= 2
117
Sin(SpikeBallN1.Oscillation, TempValue0)
118
SpikeBallN1.Oscillation >>= 2
119
SpikeBallN1.Oscillation += 136
120
SpikeBallN1.Oscillation *= 120
121
SpikeBallN1.Oscillation >>= 7
122
end if
123
124
Object.SBallDistance = Object.YPos
125
Object.SBallDistance += 0xD0000
126
127
CallFunction(StageSetup_CheckGoodFuture)
128
end sub
129
130
131
sub ObjectPlayerInteraction
132
#platform: Use_Standalone
133
PlayerObjectCollision(C_TOUCH, -20, -16, 20, 14)
134
#endplatform
135
#platform: Use_Origins
136
PlayerObjectCollision(C_ENEMY, -20, -16, 20, 14)
137
#endplatform
138
if CheckResult == true
139
CallFunction(Player_BadnikBreak)
140
end if
141
142
TempValue0 = Object.XPos
143
TempValue1 = Object.YPos
144
145
Cos(Object.XPos, SpikeBallN1.Oscillation)
146
Object.XPos *= 0x2A00
147
Object.XPos += TempValue0
148
149
Sin(Object.YPos, SpikeBallN1.Oscillation)
150
Object.YPos *= 0x2A00
151
Object.YPos += Object.SBallDistance
152
153
PlayerObjectCollision(C_TOUCH, -9, -9, 9, 9)
154
if CheckResult == true
155
CallFunction(Player_Hit)
156
end if
157
158
if Object.Quality == GOOD_QUALITY
159
Cos(Object.XPos, SpikeBallN2.Oscillation)
160
Object.XPos *= 0x1200
161
Object.XPos += TempValue0
162
163
Sin(Object.YPos, SpikeBallN2.Oscillation)
164
Object.YPos *= 0x1200
165
Object.YPos += Object.SBallDistance
166
167
PlayerObjectCollision(C_TOUCH, -9, -9, 9, 9)
168
if CheckResult == true
169
CallFunction(Player_Hit)
170
end if
171
end if
172
173
Object.XPos = TempValue0
174
Object.YPos = TempValue1
175
end sub
176
177
178
sub ObjectDraw
179
if Object.Quality == GOOD_QUALITY
180
// First Spike Ball chain
181
TempValue0 = 0
182
TempValue1 = 4
183
while TempValue0 < 10
184
Cos(TempValue2, SpikeBallN1.Oscillation)
185
TempValue2 *= TempValue1
186
TempValue2 <<= 7
187
TempValue2 += Object.XPos
188
Sin(TempValue3, SpikeBallN1.Oscillation)
189
TempValue3 *= TempValue1
190
TempValue3 <<= 7
191
TempValue3 += Object.SBallDistance
192
DrawSpriteXY(2, TempValue2, TempValue3)
193
TempValue0++
194
TempValue1 += 8
195
loop
196
197
// First Spike Ball
198
Cos(TempValue2, SpikeBallN1.Oscillation)
199
TempValue2 *= TempValue1
200
TempValue2 <<= 7
201
TempValue2 += Object.XPos
202
Sin(TempValue3, SpikeBallN1.Oscillation)
203
TempValue3 *= TempValue1
204
TempValue3 <<= 7
205
TempValue3 += Object.SBallDistance
206
DrawSpriteXY(3, TempValue2, TempValue3)
207
208
// Second Spike Ball chain
209
TempValue0 = 0
210
TempValue1 = 4
211
while TempValue0 < 4
212
Cos(TempValue2, SpikeBallN2.Oscillation)
213
TempValue2 *= TempValue1
214
TempValue2 <<= 7
215
TempValue2 += Object.XPos
216
Sin(TempValue3, SpikeBallN2.Oscillation)
217
TempValue3 *= TempValue1
218
TempValue3 <<= 7
219
TempValue3 += Object.SBallDistance
220
DrawSpriteXY(2, TempValue2, TempValue3)
221
TempValue0++
222
TempValue1 += 8
223
loop
224
225
// Second Spike Ball
226
Cos(TempValue2, SpikeBallN2.Oscillation)
227
TempValue2 *= TempValue1
228
TempValue2 <<= 7
229
TempValue2 += Object.XPos
230
Sin(TempValue3, SpikeBallN2.Oscillation)
231
TempValue3 *= TempValue1
232
TempValue3 <<= 7
233
TempValue3 += Object.SBallDistance
234
DrawSpriteXY(3, TempValue2, TempValue3)
235
else
236
TempValue0 = 0
237
TempValue1 = 4
238
while TempValue0 < 10
239
Cos(TempValue2, SpikeBallN1.Oscillation)
240
TempValue2 *= TempValue1
241
TempValue2 <<= 7
242
TempValue2 += Object.XPos
243
Sin(TempValue3, SpikeBallN1.Oscillation)
244
TempValue3 *= TempValue1
245
TempValue3 <<= 7
246
TempValue3 += Object.SBallDistance
247
DrawSpriteXY(2, TempValue2, TempValue3)
248
TempValue0++
249
TempValue1 += 8
250
loop
251
Cos(TempValue2, SpikeBallN1.Oscillation)
252
TempValue2 *= TempValue1
253
TempValue2 <<= 7
254
TempValue2 += Object.XPos
255
Sin(TempValue3, SpikeBallN1.Oscillation)
256
TempValue3 *= TempValue1
257
TempValue3 <<= 7
258
TempValue3 += Object.SBallDistance
259
DrawSpriteXY(4, TempValue2, TempValue3)
260
end if
261
262
Object.AnimationTimer++
263
Object.AnimationTimer &= 3
264
265
Object.Frame = Object.AnimationTimer
266
Object.Frame >>= 1
267
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
268
end sub
269
270
271
sub ObjectStartup
272
LoadSpriteSheet("R8/Objects.gif")
273
// PohBee
274
SpriteFrame(-19, -20, 48, 36, 75, 140) // #0 - PohBee frame 0
275
SpriteFrame(-19, -20, 48, 36, 124, 140) // #1 - PohBee frame 1
276
277
// Spike Ball
278
SpriteFrame(-8, -8, 16, 16, 58, 114) // #2 - Spike ball joint
279
// Good
280
SpriteFrame(-12, -12, 24, 24, 230, 67) // #3 - Spike Ball
281
// Bad
282
SpriteFrame(-12, -12, 24, 24, 75, 114) // #4 - Broken Spike Ball
283
284
ArrayPos0 = 32
285
while ArrayPos0 < 1056
286
if Object[ArrayPos0].Type == TypeName[Poh Bee]
287
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
288
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
289
end if
290
ArrayPos0++
291
loop
292
end sub
293
294
295
// ========================
296
// Editor Subs
297
// ========================
298
299
sub RSDKEdit
300
if Editor.ReturnVariable == true
301
switch Editor.VariableID
302
case EDIT_VAR_PROPVAL // Property Value
303
CheckResult = Object.PropertyValue
304
CheckResult &= 1
305
break
306
case 0 // condition
307
CheckResult = Object.PropertyValue
308
CheckResult &= 1
309
break
310
end switch
311
else
312
switch Editor.VariableID
313
case EDIT_VAR_PROPVAL // Property Value
314
Object.PropertyValue = Editor.VariableValue
315
Object.PropertyValue &= 1
316
break
317
case 0 // condition
318
Object.PropertyValue = Editor.VariableValue
319
Object.PropertyValue &= 1
320
break
321
end switch
322
end if
323
end sub
324
325
sub RSDKDraw
326
DrawSprite(0)
327
// Spikeball good/bad future frame
328
TempValue7 = 3
329
TempValue7 += Object.PropertyValue
330
331
Sin(TempValue4, 0)
332
TempValue4 >>= 2
333
TempValue4 += 136
334
TempValue4 *= 120
335
TempValue4 >>= 7
336
337
Sin(TempValue5, 0)
338
TempValue5 >>= 2
339
TempValue5 += 144
340
TempValue5 *= 112
341
TempValue5 >>= 7
342
343
TempValue6 = Object.YPos
344
TempValue6 += 0xD0000
345
346
// First Spike Ball chain
347
TempValue0 = 0
348
TempValue1 = 4
349
while TempValue0 < 10
350
Cos(TempValue2, TempValue4)
351
TempValue2 *= TempValue1
352
TempValue2 <<= 7
353
TempValue2 += Object.XPos
354
Sin(TempValue3, TempValue4)
355
TempValue3 *= TempValue1
356
TempValue3 <<= 7
357
TempValue3 += TempValue6
358
DrawSpriteXY(2, TempValue2, TempValue3)
359
TempValue0++
360
TempValue1 += 8
361
loop
362
363
// First Spike Ball
364
Cos(TempValue2, TempValue4)
365
TempValue2 *= TempValue1
366
TempValue2 <<= 7
367
TempValue2 += Object.XPos
368
Sin(TempValue3, TempValue4)
369
TempValue3 *= TempValue1
370
TempValue3 <<= 7
371
TempValue3 += TempValue6
372
DrawSpriteXY(TempValue7, TempValue2, TempValue3)
373
374
if Object.PropertyValue == GOOD_QUALITY
375
// Second Spike Ball chain
376
TempValue0 = 0
377
TempValue1 = 4
378
while TempValue0 < 4
379
Cos(TempValue2, TempValue5)
380
TempValue2 *= TempValue1
381
TempValue2 <<= 7
382
TempValue2 += Object.XPos
383
Sin(TempValue3, TempValue5)
384
TempValue3 *= TempValue1
385
TempValue3 <<= 7
386
TempValue3 += TempValue6
387
DrawSpriteXY(2, TempValue2, TempValue3)
388
TempValue0++
389
TempValue1 += 8
390
loop
391
392
// Second Spike Ball
393
Cos(TempValue2, TempValue5)
394
TempValue2 *= TempValue1
395
TempValue2 <<= 7
396
TempValue2 += Object.XPos
397
Sin(TempValue3, TempValue5)
398
TempValue3 *= TempValue1
399
TempValue3 <<= 7
400
TempValue3 += TempValue6
401
DrawSpriteXY(3, TempValue2, TempValue3)
402
end if
403
end sub
404
405
sub RSDKLoad
406
LoadSpriteSheet("R8/Objects.gif")
407
// PohBee
408
SpriteFrame(-19, -20, 48, 36, 75, 140) // #0 - PohBee frame 0
409
SpriteFrame(-19, -20, 48, 36, 124, 140) // #1 - PohBee frame 1
410
411
// Spike Ball
412
SpriteFrame(-8, -8, 16, 16, 58, 114) // #2 - Spike ball joint
413
// Good
414
SpriteFrame(-12, -12, 24, 24, 230, 67) // #3 - Spike Ball
415
// Bad
416
SpriteFrame(-12, -12, 24, 24, 75, 114) // #4 - Broken Spike Ball
417
418
AddEditorVariable("condition")
419
SetActiveVariable("condition")
420
AddEnumVariable("Good Quality", GOOD_QUALITY)
421
AddEnumVariable("Bad Quality", BAD_QUALITY)
422
end sub
423
424