Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Mission/PohBee3.txt
1319 views
1
//------------------Sonic CD PohBee 3 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
#alias Object.Value1 : Object.XOriginPos
9
#alias Object.Value2 : Object.YOriginPos
10
#alias Object.Value3 : Object.PohBeeOscillation
11
#alias Object.Value4 : SpikeBallN1.Oscillation
12
#alias Object.Value5 : SpikeBallN2.Oscillation
13
#alias Object.Value6 : SpikeBallN2.Rotation
14
#alias Object.Value7 : Object.SBallDistance
15
16
#alias Object.PropertyValue : Object.Quality
17
18
// States
19
#alias 0 : POHBEE3_MOVING_RIGHT
20
#alias 1 : POHBEE3_MOVING_LEFT
21
22
// Badnik Quality / Property Values
23
#alias 0 : GOOD_QUALITY
24
#alias 1 : BAD_QUALITY
25
26
27
sub ObjectMain
28
if Object.OutOfBounds == true
29
Object.XPos = Object.XOriginPos
30
Object.Timer = 0
31
Object.State = POHBEE3_MOVING_RIGHT
32
end if
33
34
Object.Rotation += 16
35
Object.Rotation &= 2047
36
37
if Object.Quality == GOOD_QUALITY
38
SpikeBallN2.Rotation += 20
39
SpikeBallN2.Rotation &= 2047
40
switch Object.State
41
case POHBEE3_MOVING_RIGHT
42
Object.Direction = FACING_LEFT
43
if Object.Timer < 64
44
Object.Timer++
45
Object.XPos += 0x20000
46
else
47
Object.State = POHBEE3_MOVING_LEFT
48
Object.Timer = 0
49
end if
50
break
51
case POHBEE3_MOVING_LEFT
52
Object.Direction = FACING_RIGHT
53
if Object.Timer < 64
54
Object.Timer++
55
Object.XPos -= 0x20000
56
else
57
Object.State = POHBEE3_MOVING_RIGHT
58
Object.Timer = 0
59
end if
60
break
61
end switch
62
63
Object.PohBeeOscillation += 16
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 += 272
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 += 288
82
SpikeBallN2.Oscillation *= 112
83
SpikeBallN2.Oscillation >>= 7
84
else
85
switch Object.State
86
case POHBEE3_MOVING_RIGHT
87
Object.Direction = FACING_LEFT
88
if Object.Timer < 128
89
Object.Timer++
90
Object.XPos += 0x10000
91
else
92
Object.State = POHBEE3_MOVING_LEFT
93
Object.Timer = 0
94
end if
95
break
96
97
case POHBEE3_MOVING_LEFT
98
Object.Direction = FACING_RIGHT
99
if Object.Timer < 128
100
Object.Timer++
101
Object.XPos -= 0x10000
102
else
103
Object.State = POHBEE3_MOVING_RIGHT
104
Object.Timer = 0
105
end if
106
break
107
end switch
108
109
Object.PohBeeOscillation += 12
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
119
SpikeBallN1.Oscillation >>= 2
120
SpikeBallN1.Oscillation += 272
121
SpikeBallN1.Oscillation *= 120
122
SpikeBallN1.Oscillation >>= 7
123
end if
124
125
Object.SBallDistance = Object.YPos
126
Object.SBallDistance += 0xD0000
127
128
CallFunction(StageSetup_CheckGoodFuture)
129
end sub
130
131
132
sub ObjectPlayerInteraction
133
PlayerObjectCollision(C_ENEMY, -20, -16, 20, 14)
134
if CheckResult == true
135
CallFunction(Player_BadnikBreak)
136
end if
137
138
TempValue0 = Object.XPos
139
TempValue1 = Object.YPos
140
141
Cos(Object.XPos, SpikeBallN1.Oscillation)
142
Object.XPos *= 0x2A00
143
Object.XPos += TempValue0
144
145
Sin(Object.YPos, SpikeBallN1.Oscillation)
146
Object.YPos *= 0x2A00
147
Object.YPos += Object.SBallDistance
148
149
PlayerObjectCollision(C_TOUCH, -9, -9, 9, 9)
150
if CheckResult == true
151
CallFunction(Player_Hit)
152
end if
153
154
if Object.Quality == GOOD_QUALITY
155
Cos(Object.XPos, SpikeBallN2.Oscillation)
156
Object.XPos *= 0x1200
157
Object.XPos += TempValue0
158
159
Sin(Object.YPos, SpikeBallN2.Oscillation)
160
Object.YPos *= 0x1200
161
Object.YPos += Object.SBallDistance
162
163
PlayerObjectCollision(C_TOUCH, -9, -9, 9, 9)
164
if CheckResult == true
165
CallFunction(Player_Hit)
166
end if
167
end if
168
169
Object.XPos = TempValue0
170
Object.YPos = TempValue1
171
end sub
172
173
174
sub ObjectDraw
175
if Object.Quality == GOOD_QUALITY
176
// First Spike Ball chain
177
TempValue0 = 0
178
TempValue1 = 4
179
while TempValue0 < 10
180
Cos(TempValue2, SpikeBallN1.Oscillation)
181
TempValue2 *= TempValue1
182
TempValue2 <<= 7
183
TempValue2 += Object.XPos
184
Sin(TempValue3, SpikeBallN1.Oscillation)
185
TempValue3 *= TempValue1
186
TempValue3 <<= 7
187
TempValue3 += Object.SBallDistance
188
DrawSpriteXY(2, TempValue2, TempValue3)
189
TempValue0++
190
TempValue1 += 8
191
loop
192
193
// First Spike Ball
194
Cos(TempValue2, SpikeBallN1.Oscillation)
195
TempValue2 *= TempValue1
196
TempValue2 <<= 7
197
TempValue2 += Object.XPos
198
Sin(TempValue3, SpikeBallN1.Oscillation)
199
TempValue3 *= TempValue1
200
TempValue3 <<= 7
201
TempValue3 += Object.SBallDistance
202
DrawSpriteXY(3, TempValue2, TempValue3)
203
204
// Second Spike Ball chain
205
TempValue0 = 0
206
TempValue1 = 4
207
while TempValue0 < 4
208
Cos(TempValue2, SpikeBallN2.Oscillation)
209
TempValue2 *= TempValue1
210
TempValue2 <<= 7
211
TempValue2 += Object.XPos
212
Sin(TempValue3, SpikeBallN2.Oscillation)
213
TempValue3 *= TempValue1
214
TempValue3 <<= 7
215
TempValue3 += Object.SBallDistance
216
DrawSpriteXY(2, TempValue2, TempValue3)
217
TempValue0++
218
TempValue1 += 8
219
loop
220
221
// Second Spike Ball
222
Cos(TempValue2, SpikeBallN2.Oscillation)
223
TempValue2 *= TempValue1
224
TempValue2 <<= 7
225
TempValue2 += Object.XPos
226
Sin(TempValue3, SpikeBallN2.Oscillation)
227
TempValue3 *= TempValue1
228
TempValue3 <<= 7
229
TempValue3 += Object.SBallDistance
230
DrawSpriteXY(3, TempValue2, TempValue3)
231
else
232
TempValue0 = 0
233
TempValue1 = 4
234
while TempValue0 < 10
235
Cos(TempValue2, SpikeBallN1.Oscillation)
236
TempValue2 *= TempValue1
237
TempValue2 <<= 7
238
TempValue2 += Object.XPos
239
Sin(TempValue3, SpikeBallN1.Oscillation)
240
TempValue3 *= TempValue1
241
TempValue3 <<= 7
242
TempValue3 += Object.SBallDistance
243
DrawSpriteXY(2, TempValue2, TempValue3)
244
TempValue0++
245
TempValue1 += 8
246
loop
247
Cos(TempValue2, SpikeBallN1.Oscillation)
248
TempValue2 *= TempValue1
249
TempValue2 <<= 7
250
TempValue2 += Object.XPos
251
Sin(TempValue3, SpikeBallN1.Oscillation)
252
TempValue3 *= TempValue1
253
TempValue3 <<= 7
254
TempValue3 += Object.SBallDistance
255
DrawSpriteXY(4, TempValue2, TempValue3)
256
end if
257
258
Object.AnimationTimer++
259
Object.AnimationTimer &= 3
260
261
Object.Frame = Object.AnimationTimer
262
Object.Frame >>= 1
263
DrawSpriteFX(Object.Frame, FX_FLIP, Object.XPos, Object.YPos)
264
end sub
265
266
267
sub ObjectStartup
268
LoadSpriteSheet("R8/Objects.gif")
269
// PohBee
270
SpriteFrame(-19, -20, 48, 36, 75, 140) // #0 - PohBee frame 0
271
SpriteFrame(-19, -20, 48, 36, 124, 140) // #1 - PohBee frame 1
272
273
// Spike Ball
274
SpriteFrame(-8, -8, 16, 16, 58, 114) // #2 - Spike ball joint
275
// Good
276
SpriteFrame(-12, -12, 24, 24, 230, 67) // #3 - Spike Ball
277
// Bad
278
SpriteFrame(-12, -12, 24, 24, 75, 114) // #4 - Broken Spike Ball
279
280
ArrayPos0 = 32
281
while ArrayPos0 < 1056
282
if Object[ArrayPos0].Type == TypeName[PohBee3]
283
Object[ArrayPos0].XOriginPos = Object[ArrayPos0].XPos
284
Object[ArrayPos0].YOriginPos = Object[ArrayPos0].YPos
285
end if
286
ArrayPos0++
287
loop
288
end sub
289
290
291
// ========================
292
// Editor Subs
293
// ========================
294
295
sub RSDKEdit
296
if Editor.ReturnVariable == true
297
switch Editor.VariableID
298
case EDIT_VAR_PROPVAL // Property Value
299
CheckResult = Object.PropertyValue
300
break
301
case 0 // Condition
302
CheckResult = Object.PropertyValue
303
break
304
end switch
305
else
306
switch Editor.VariableID
307
case EDIT_VAR_PROPVAL // Property Value
308
Object.PropertyValue = Editor.VariableValue
309
break
310
case 0 // Condition
311
Object.PropertyValue = Editor.VariableValue
312
break
313
end switch
314
end if
315
end sub
316
317
318
sub RSDKDraw
319
DrawSprite(0)
320
end sub
321
322
323
sub RSDKLoad
324
LoadSpriteSheet("R8/Objects.gif")
325
// PohBee
326
SpriteFrame(-19, -20, 48, 36, 75, 140) // #0 - PohBee frame 0
327
328
// Spike Ball
329
SpriteFrame(-8, -8, 16, 16, 58, 114) // #2 - Spike ball joint
330
// Good
331
SpriteFrame(-12, -12, 24, 24, 230, 67) // #3 - Spike Ball
332
// Bad
333
SpriteFrame(-12, -12, 24, 24, 75, 114) // #4 - Broken Spike Ball
334
335
AddEditorVariable("Condition")
336
SetActiveVariable("Condition")
337
AddEnumVariable("Good", GOOD_QUALITY)
338
AddEnumVariable("Bad", BAD_QUALITY)
339
end sub
340
341
342
343