Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Enemies/Bee.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Bee Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value1 : object.startPos.x
14
private alias object.value2 : object.hasShot
15
private alias object.value3 : object.shootTimer
16
17
// States
18
private alias 0 : BEE_FLYING
19
private alias 1 : BEE_STOPPED
20
private alias 2 : BEE_SHOOTING
21
private alias 3 : BEE_INVISIBLE
22
23
// Animations
24
private alias 0 : BEE_ANI_FLYING
25
private alias 1 : BEE_ANI_STOPPED
26
private alias 2 : BEE_ANI_SHOOTING
27
private alias 3 : BEE_ANI_INVISIBLE
28
29
// Player Aliases
30
private alias object.value40 : player.hitboxLeft
31
private alias object.value38 : player.hitboxTop
32
private alias object.value41 : player.hitboxRight
33
private alias object.value39 : player.hitboxBottom
34
35
36
// ========================
37
// Function Declarations
38
// ========================
39
40
reserve function Bee_DebugDraw
41
reserve function Bee_DebugSpawn
42
43
44
// ========================
45
// Function Definitions
46
// ========================
47
48
private function Bee_DebugDraw
49
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
50
end function
51
52
53
private function Bee_DebugSpawn
54
CreateTempObject(TypeName[Bee], 0, object.xpos, object.ypos)
55
GetBit(temp0, object.direction, 0)
56
if temp0 == FACING_RIGHT
57
object[tempObjectPos].direction = FLIP_NONE
58
object[tempObjectPos].xvel = -0x10000
59
else
60
object[tempObjectPos].direction = FLIP_X
61
object[tempObjectPos].xvel = 0x10000
62
end if
63
end function
64
65
66
// ========================
67
// Events
68
// ========================
69
70
event ObjectUpdate
71
switch object.state
72
case BEE_FLYING
73
object.priority = PRIORITY_ACTIVE
74
if object.timer < 256
75
object.timer++
76
object.xpos += object.xvel
77
else
78
object.timer = 0
79
object.state = BEE_STOPPED
80
object.animation = BEE_ANI_STOPPED
81
object.direction ^= FLIP_X
82
FlipSign(object.xvel)
83
end if
84
break
85
86
case BEE_STOPPED
87
if object.shootTimer < 30
88
object.shootTimer++
89
else
90
object.shootTimer = 0
91
object.state = BEE_FLYING
92
object.animation = BEE_ANI_FLYING
93
object.hasShot = false
94
end if
95
break
96
97
case BEE_SHOOTING
98
if object.shootTimer < 50
99
object.shootTimer++
100
if object.shootTimer == 30
101
CreateTempObject(TypeName[Bee Shot], 0, object.xpos, object.ypos)
102
object[tempObjectPos].direction = object.direction
103
if object.direction == FLIP_NONE
104
object[tempObjectPos].xpos += 0xD0000
105
object[tempObjectPos].xvel = -0x18000
106
else
107
object[tempObjectPos].xpos -= 0xD0000
108
object[tempObjectPos].xvel = 0x18000
109
end if
110
object[tempObjectPos].ypos += 0x180000
111
object[tempObjectPos].yvel = 0x18000
112
end if
113
else
114
object.shootTimer = 0
115
object.state = BEE_FLYING
116
object.animation = BEE_ANI_FLYING
117
object.hasShot = true
118
end if
119
break
120
121
case BEE_INVISIBLE
122
object.animation = BEE_ANI_INVISIBLE
123
break
124
125
end switch
126
127
if object.outOfBounds == true
128
temp0 = object.xpos
129
object.xpos = object.startPos.x
130
if object.shootTimer == 1
131
object.state = BEE_INVISIBLE
132
end if
133
134
if object.outOfBounds == true
135
object.xpos = object.startPos.x
136
137
GetBit(temp0, object.propertyValue, 0)
138
if temp0 == 0
139
object.direction = FLIP_NONE
140
object.xvel = -0x10000
141
else
142
object.direction = FLIP_X
143
object.xvel = 0x10000
144
end if
145
146
object.timer = 0
147
object.animation = BEE_ANI_FLYING
148
object.priority = PRIORITY_BOUNDS
149
object.state = BEE_FLYING
150
else
151
object.xpos = temp0
152
end if
153
end if
154
155
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
156
if object.state == BEE_FLYING
157
if object.hasShot == false
158
if object.direction == FLIP_NONE
159
BoxCollisionTest(C_TOUCH, object.entityPos, -28, -256, -30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
160
else
161
BoxCollisionTest(C_TOUCH, object.entityPos, 28, -256, 30, 256, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
162
end if
163
164
if checkResult == true
165
object.state = BEE_SHOOTING
166
object.animation = BEE_ANI_SHOOTING
167
end if
168
end if
169
end if
170
171
if object.state < BEE_INVISIBLE
172
BoxCollisionTest(C_TOUCH, object.entityPos, -24, -12, 24, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
173
if checkResult == true
174
CallFunction(Player_BadnikBreak)
175
end if
176
end if
177
next
178
179
object.frame = object.animationTimer
180
object.frame /= 3
181
object.frame += 3
182
object.animationTimer++
183
if object.animationTimer >= 6
184
object.animationTimer = 0
185
end if
186
end event
187
188
189
event ObjectDraw
190
switch object.animation
191
case BEE_ANI_FLYING
192
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
193
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
194
break
195
196
case BEE_ANI_STOPPED
197
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
198
break
199
200
case BEE_ANI_SHOOTING
201
DrawSpriteFX(1, FX_FLIP, object.xpos, object.ypos)
202
203
if object.shootTimer > 20
204
if object.shootTimer < 30
205
DrawSpriteFX(2, FX_FLIP, object.xpos, object.ypos)
206
end if
207
end if
208
break
209
210
case BEE_ANI_INVISIBLE
211
break
212
213
end switch
214
end event
215
216
217
event ObjectStartup
218
CheckCurrentStageFolder("Zone01")
219
if checkResult == true
220
LoadSpriteSheet("EHZ/Objects.gif")
221
SpriteFrame(-24, -8, 48, 18, 78, 1)
222
SpriteFrame(-24, -8, 42, 31, 146, 224)
223
SpriteFrame(1, 6, 17, 17, 50, 1)
224
SpriteFrame(5, -8, 6, 5, 19, 50)
225
SpriteFrame(5, -8, 7, 5, 19, 56)
226
else
227
LoadSpriteSheet("MBZ/Objects.gif")
228
229
// This is strange - they *partially* adjusted some of the frames for MBZ?
230
// The ones shared with the Buzzer (which is used in MBZ) got updated, while the ones unique to the Bee were neglected
231
// How strange...
232
233
SpriteFrame(-24, -8, 48, 18, 78, 1)
234
SpriteFrame(-24, -8, 42, 31, 146, 224)
235
SpriteFrame(1, 6, 17, 17, 50, 1)
236
SpriteFrame(5, -8, 6, 5, 137, 331)
237
SpriteFrame(5, -8, 7, 5, 137, 337)
238
end if
239
240
foreach (TypeName[Bee], arrayPos0, ALL_ENTITIES)
241
object[arrayPos0].startPos.x = object[arrayPos0].xpos
242
243
GetBit(temp0, object[arrayPos0].propertyValue, 0)
244
if temp0 == 0
245
object[arrayPos0].direction = FLIP_NONE
246
object[arrayPos0].xvel = -0x10000
247
else
248
object[arrayPos0].direction = FLIP_X
249
object[arrayPos0].xvel = 0x10000
250
end if
251
next
252
253
SetTableValue(TypeName[Bee], DebugMode_ObjCount, DebugMode_TypesTable)
254
SetTableValue(Bee_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
255
SetTableValue(Bee_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
256
DebugMode_ObjCount++
257
end event
258
259
260
// ========================
261
// Editor Events
262
// ========================
263
264
event RSDKEdit
265
if editor.returnVariable == true
266
switch editor.variableID
267
case EDIT_VAR_PROPVAL // property value
268
checkResult = object.propertyValue
269
break
270
271
case 0 // direction
272
checkResult = object.propertyValue
273
break
274
275
end switch
276
else
277
switch editor.variableID
278
case EDIT_VAR_PROPVAL // property value
279
object.propertyValue = editor.variableValue
280
break
281
282
case 0 // direction
283
object.propertyValue = editor.variableValue
284
break
285
286
end switch
287
end if
288
end event
289
290
291
event RSDKDraw
292
GetBit(object.direction, object.propertyValue, 0)
293
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
294
DrawSpriteFX(3, FX_FLIP, object.xpos, object.ypos)
295
end event
296
297
298
event RSDKLoad
299
CheckCurrentStageFolder("Zone01")
300
if checkResult == true
301
LoadSpriteSheet("EHZ/Objects.gif")
302
SpriteFrame(-24, -8, 48, 18, 78, 1)
303
SpriteFrame(-24, -8, 42, 31, 146, 224)
304
SpriteFrame(1, 6, 17, 17, 50, 1)
305
SpriteFrame(5, -8, 6, 5, 19, 50)
306
SpriteFrame(5, -8, 7, 5, 19, 56)
307
else
308
LoadSpriteSheet("MBZ/Objects.gif")
309
SpriteFrame(-24, -8, 48, 18, 78, 1)
310
SpriteFrame(-24, -8, 42, 31, 146, 224)
311
SpriteFrame(1, 6, 17, 17, 50, 1)
312
SpriteFrame(5, -8, 6, 5, 137, 331)
313
SpriteFrame(5, -8, 7, 5, 137, 337)
314
end if
315
316
AddEditorVariable("direction")
317
SetActiveVariable("direction")
318
AddEnumVariable("Left", 0)
319
AddEnumVariable("Right", 1)
320
end event
321
322