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/BubblersMother.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Bubblers Mother 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.spawnTimer
14
private alias object.value2 : object.startPos.x
15
private alias object.value3 : object.startPos.y
16
17
// States
18
private alias 0 : BUBBLERSMOTHER_PATROL
19
private alias 1 : BUBBLERSMOTHER_FOUNDPLAYER
20
private alias 2 : BUBBLERSMOTHER_ATTACKING
21
22
// Player Aliases
23
private alias object.value40 : player.hitboxLeft
24
private alias object.value38 : player.hitboxTop
25
private alias object.value41 : player.hitboxRight
26
private alias object.value39 : player.hitboxBottom
27
28
// ========================
29
// Function Declarations
30
// ========================
31
32
reserve function BubblersMother_Setup
33
reserve function BubblersMother_DebugDraw
34
reserve function BubblersMother_DebugSpawn
35
36
37
// ========================
38
// Function Definitions
39
// ========================
40
41
private function BubblersMother_Setup
42
object[arrayPos0].direction = object[arrayPos0].propertyValue
43
if object[arrayPos0].direction == FLIP_NONE
44
object[arrayPos0].xvel = -0x4000
45
else
46
object[arrayPos0].xvel = 0x4000
47
end if
48
object[arrayPos0].yvel = 0
49
object[arrayPos0].timer = 512
50
object[arrayPos0].spawnTimer = 0
51
object[arrayPos0].frame = 1
52
object[arrayPos0].animationTimer = 0
53
object[arrayPos0].priority = PRIORITY_BOUNDS
54
object[arrayPos0].state = BUBBLERSMOTHER_PATROL
55
end function
56
57
58
private function BubblersMother_DebugDraw
59
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
60
end function
61
62
63
private function BubblersMother_DebugSpawn
64
CreateTempObject(TypeName[Bubblers Mother], object.direction, object.xpos, object.ypos)
65
object[tempObjectPos].startPos.x = object.xpos
66
object[tempObjectPos].startPos.y = object.ypos
67
arrayPos0 = object[tempObjectPos].entityPos
68
CallFunction(BubblersMother_Setup)
69
end function
70
71
72
// ========================
73
// Events
74
// ========================
75
76
event ObjectUpdate
77
switch object.state
78
case BUBBLERSMOTHER_PATROL
79
object.priority = PRIORITY_ACTIVE
80
object.xpos += object.xvel
81
object.animationTimer++
82
object.animationTimer &= 3
83
object.frame = object.animationTimer
84
object.frame >>= 1
85
object.frame++
86
87
object.timer--
88
if object.timer == 0
89
object.direction ^= FLIP_X
90
FlipSign(object.xvel)
91
object.timer = 512
92
end if
93
94
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
95
if object.state == BUBBLERSMOTHER_PATROL
96
if object.direction == FLIP_NONE
97
BoxCollisionTest(C_TOUCH, object.entityPos, -160, 12, 16, 96, currentPlayer, -1, -1, 1, 1)
98
else
99
BoxCollisionTest(C_TOUCH, object.entityPos, 16, 12, 160, 96, currentPlayer, -1, -1, 1, 1)
100
end if
101
102
if checkResult == true
103
object.state = BUBBLERSMOTHER_FOUNDPLAYER
104
object.frame = 2
105
object.timer = 16
106
if object.direction == FLIP_NONE
107
object.xvel = -0x28000
108
else
109
object.xvel = 0x28000
110
end if
111
end if
112
end if
113
next
114
break
115
116
case BUBBLERSMOTHER_FOUNDPLAYER
117
object.timer--
118
if object.timer < 0
119
object.state = BUBBLERSMOTHER_ATTACKING
120
end if
121
122
object.animationTimer++
123
object.animationTimer &= 3
124
object.frame = object.animationTimer
125
object.frame >>= 1
126
object.frame++
127
break
128
129
case BUBBLERSMOTHER_ATTACKING
130
object.xpos += object.xvel
131
object.ypos += object.yvel
132
133
object.spawnTimer++
134
if object.spawnTimer >= 20
135
object.spawnTimer = 0
136
temp0 = object.xpos
137
if object.direction == FLIP_NONE
138
temp0 += 0x60000
139
else
140
temp0 -= 0x60000
141
end if
142
temp1 = object.ypos
143
temp1 += 0xA0000
144
CreateTempObject(TypeName[Bubbler], 0, temp0, temp1)
145
end if
146
147
object.animationTimer++
148
if object.animationTimer >= 3
149
object.animationTimer = 0
150
end if
151
152
object.frame = object.animationTimer
153
object.frame++
154
break
155
156
end switch
157
158
if object.outOfBounds == true
159
temp0 = object.xpos
160
temp1 = object.ypos
161
object.xpos = object.startPos.x
162
object.ypos = object.startPos.y
163
if object.outOfBounds == true
164
arrayPos0 = object.entityPos
165
CallFunction(BubblersMother_Setup)
166
else
167
object.xpos = temp0
168
object.ypos = temp1
169
end if
170
end if
171
172
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
173
BoxCollisionTest(C_TOUCH, object.entityPos, -16, -12, 16, 12, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
174
if checkResult == true
175
CallFunction(Player_BadnikBreak)
176
end if
177
next
178
end event
179
180
181
event ObjectDraw
182
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
183
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
184
end event
185
186
187
event ObjectStartup
188
CheckCurrentStageFolder("Zone02")
189
if checkResult == true
190
LoadSpriteSheet("CPZ/Objects.gif")
191
SpriteFrame(-16, -12, 32, 28, 117, 102)
192
SpriteFrame(0, 0, 1, 1, 117, 102)
193
SpriteFrame(15, -3, 7, 13, 150, 111)
194
SpriteFrame(15, -3, 8, 13, 158, 111)
195
else
196
LoadSpriteSheet("MBZ/Objects.gif")
197
SpriteFrame(-16, -12, 32, 28, 117, 102)
198
199
// they uhhhh.... kinda forgot all the other frames
200
end if
201
202
foreach (TypeName[Bubblers Mother], arrayPos0, ALL_ENTITIES)
203
object[arrayPos0].startPos.x = object[arrayPos0].xpos
204
CallFunction(BubblersMother_Setup)
205
next
206
207
SetTableValue(TypeName[Bubblers Mother], DebugMode_ObjCount, DebugMode_TypesTable)
208
SetTableValue(BubblersMother_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
209
SetTableValue(BubblersMother_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
210
DebugMode_ObjCount++
211
end event
212
213
214
// ========================
215
// Editor Events
216
// ========================
217
218
event RSDKEdit
219
if editor.returnVariable == true
220
switch editor.variableID
221
case EDIT_VAR_PROPVAL // property value
222
checkResult = object.propertyValue
223
break
224
225
case 0 // direction
226
GetBit(checkResult, object.propertyValue, 0)
227
break
228
229
end switch
230
else
231
switch editor.variableID
232
case EDIT_VAR_PROPVAL // property value
233
object.propertyValue = editor.variableValue
234
break
235
236
case 0 // direction
237
CheckNotEqual(editor.variableValue, 0)
238
SetBit(object.propertyValue, 0, checkResult)
239
break
240
241
end switch
242
end if
243
end event
244
245
246
event RSDKDraw
247
GetBit(object.direction, object.propertyValue, 0)
248
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
249
end event
250
251
252
event RSDKLoad
253
CheckCurrentStageFolder("Zone02")
254
if checkResult == true
255
LoadSpriteSheet("CPZ/Objects.gif")
256
SpriteFrame(-16, -12, 32, 28, 117, 102)
257
else
258
LoadSpriteSheet("MBZ/Objects.gif")
259
SpriteFrame(-16, -12, 32, 28, 117, 102)
260
end if
261
262
AddEditorVariable("direction")
263
SetActiveVariable("direction")
264
AddEnumVariable("Left", 0)
265
AddEnumVariable("Right", 1)
266
end event
267
268