Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Enemies/Burrobot.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Burrobot 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.startPos.x
13
private alias object.value1 : object.startPos.y
14
private alias object.value2 : object.backupPlayer
15
private alias object.value3 : object.targetPlayer
16
private alias object.value4 : object.targetDistance
17
private alias object.value5 : object.timer
18
private alias object.value6 : object.unused // it's set, but never actually *used*
19
20
private alias 0 : BURROBOT_AWAITPLAYER
21
private alias 1 : BURROBOT_JUMPED
22
private alias 2 : BURROBOT_MOVING
23
private alias 3 : BURROBOT_STOPPED
24
25
private alias 0 : BURROBOT_ANI_HIDDEN
26
private alias 1 : BURROBOT_ANI_JUMPED
27
private alias 2 : BURROBOT_ANI_MOVING
28
private alias 3 : BURROBOT_ANI_STOPPED
29
30
// Player Aliases
31
private alias object.xpos : player.xpos
32
private alias object.ypos : player.ypos
33
34
private alias object.value40 : player.hitboxLeft
35
private alias object.value38 : player.hitboxTop
36
private alias object.value41 : player.hitboxRight
37
private alias object.value39 : player.hitboxBottom
38
39
// Path ID Aliases
40
private alias 0 : PATH_A
41
42
43
// ========================
44
// Function Declarations
45
// ========================
46
47
reserve function Burrobot_DebugDraw
48
reserve function Burrobot_DebugSpawn
49
50
51
// ========================
52
// Function Definitions
53
// ========================
54
55
private function Burrobot_DebugDraw
56
DrawSpriteFX(3, FX_FLIP, object.xpos, object.ypos)
57
end function
58
59
60
private function Burrobot_DebugSpawn
61
CreateTempObject(TypeName[Burrobot], 0, object.xpos, object.ypos)
62
object[tempObjectPos].direction = object.direction
63
if object[tempObjectPos].direction == FLIP_NONE
64
object[tempObjectPos].xvel = -0x8000
65
else
66
object[tempObjectPos].xvel = 0x8000
67
end if
68
object[tempObjectPos].startPos.x = object.xpos
69
object[tempObjectPos].startPos.y = object.ypos
70
object[tempObjectPos].yvel = -0x40000
71
object[tempObjectPos].animation = BURROBOT_ANI_JUMPED
72
object[tempObjectPos].state = BURROBOT_JUMPED
73
end function
74
75
76
// ========================
77
// Events
78
// ========================
79
80
event ObjectUpdate
81
switch object.state
82
case BURROBOT_AWAITPLAYER
83
object.targetDistance = 0x7FFFFFFF
84
object.backupPlayer = 0
85
object.targetPlayer = 0xFFFF
86
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
87
temp0 = player[currentPlayer].xpos
88
temp0 -= object.xpos
89
Abs(temp0)
90
if temp0 < object.targetDistance
91
object.targetDistance = temp0
92
object.backupPlayer = currentPlayer
93
end if
94
if temp0 < 0x600000
95
if player[currentPlayer].ypos <= object.ypos
96
if object.targetPlayer != 0xFFFF
97
arrayPos0 = object.targetPlayer
98
if player[currentPlayer].ypos < player[arrayPos0].ypos
99
object.targetPlayer = currentPlayer
100
end if
101
else
102
object.targetPlayer = currentPlayer
103
end if
104
end if
105
end if
106
next
107
108
if object.targetPlayer != 0xFFFF
109
arrayPos0 = object.targetPlayer
110
temp0 = object.ypos
111
temp0 -= player[arrayPos0].ypos
112
if temp0 >= 0
113
if temp0 <= 0x800000
114
Rand(temp0, 8)
115
if temp0 == 0
116
object.state = BURROBOT_JUMPED
117
object.priority = PRIORITY_ACTIVE
118
if player[arrayPos0].xpos < object.xpos
119
object.direction = FLIP_NONE
120
object.xvel = -0x8000
121
else
122
object.direction = FLIP_X
123
object.xvel = 0x8000
124
end if
125
object.yvel = -0x40000
126
object.animation = BURROBOT_ANI_JUMPED
127
end if
128
end if
129
end if
130
else
131
arrayPos0 = object.backupPlayer
132
if player[arrayPos0].xpos < object.xpos
133
object.direction = FLIP_NONE
134
else
135
object.direction = FLIP_X
136
end if
137
end if
138
break
139
140
case BURROBOT_JUMPED
141
object.xpos += object.xvel
142
object.ypos += object.yvel
143
object.yvel += 0x1800
144
145
if object.yvel > 0
146
ObjectTileCollision(CSIDE_FLOOR, 0, 20, PATH_A)
147
if checkResult == true
148
arrayPos0 = object.backupPlayer
149
if player[arrayPos0].xpos < object.xpos
150
object.direction = FLIP_NONE
151
else
152
object.direction = FLIP_X
153
end if
154
155
object.timer = 256
156
object.animation = BURROBOT_ANI_MOVING
157
object.unused = false
158
object.state = BURROBOT_MOVING
159
end if
160
end if
161
break
162
163
case BURROBOT_MOVING
164
object.xpos += object.xvel
165
166
temp0 = false
167
object.timer--
168
if object.timer == 0
169
temp0 = true
170
end if
171
172
if object.direction == FLIP_NONE
173
ObjectTileCollision(CSIDE_FLOOR, -12, 21, PATH_A)
174
if checkResult == false
175
ObjectTileCollision(CSIDE_FLOOR, -12, 19, PATH_A)
176
if checkResult == false
177
ObjectTileCollision(CSIDE_FLOOR, -12, 20, PATH_A)
178
end if
179
end if
180
else
181
ObjectTileCollision(CSIDE_FLOOR, 12, 21, PATH_A)
182
if checkResult == false
183
ObjectTileCollision(CSIDE_FLOOR, 12, 19, PATH_A)
184
if checkResult == false
185
ObjectTileCollision(CSIDE_FLOOR, 12, 20, PATH_A)
186
end if
187
end if
188
end if
189
190
if checkResult == false
191
temp0 = true
192
end if
193
194
ObjectTileGrip(CSIDE_FLOOR, 0, 20, PATH_A)
195
if temp0 == true
196
GetBit(temp0, oscillation, 2)
197
if temp0 == false
198
object.yvel = -0x40000
199
object.animation = BURROBOT_ANI_JUMPED
200
object.state = BURROBOT_JUMPED
201
else
202
object.timer = 60
203
object.animation = BURROBOT_ANI_STOPPED
204
object.state = BURROBOT_STOPPED
205
end if
206
end if
207
break
208
209
case BURROBOT_STOPPED
210
object.timer--
211
if object.timer == 0
212
FlipSign(object.xvel)
213
if object.xvel < 0
214
object.direction = FLIP_NONE
215
else
216
object.direction = FLIP_X
217
end if
218
object.timer = 256
219
object.animation = BURROBOT_ANI_MOVING
220
object.state = BURROBOT_MOVING
221
end if
222
break
223
224
end switch
225
226
if object.outOfBounds == true
227
temp0 = object.xpos
228
temp1 = object.ypos
229
object.xpos = object.startPos.x
230
object.ypos = object.startPos.y
231
if object.outOfBounds == true
232
object.xpos = object.startPos.x
233
object.ypos = object.startPos.y
234
object.xvel = 0
235
object.yvel = 0
236
object.animation = BURROBOT_ANI_HIDDEN
237
object.animationTimer = 0
238
object.priority = PRIORITY_BOUNDS
239
object.unused = true
240
object.state = BURROBOT_AWAITPLAYER
241
else
242
object.xpos = temp0
243
object.ypos = temp1
244
end if
245
end if
246
247
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
248
BoxCollisionTest(C_TOUCH, object.entityPos, -12, -18, 12, 18, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
249
if checkResult == true
250
CallFunction(Player_BadnikBreak)
251
end if
252
next
253
254
object.frame = object.animationTimer
255
object.frame >>= 2
256
switch object.animation
257
case BURROBOT_ANI_HIDDEN
258
case BURROBOT_ANI_JUMPED
259
if object.yvel > 0
260
object.frame = 5
261
else
262
object.frame += 3
263
end if
264
break
265
266
case BURROBOT_ANI_MOVING
267
break
268
269
case BURROBOT_ANI_STOPPED
270
object.frame++
271
break
272
273
end switch
274
275
object.animationTimer++
276
object.animationTimer &= 7
277
end event
278
279
280
event ObjectDraw
281
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
282
end event
283
284
285
event ObjectStartup
286
CheckCurrentStageFolder("Zone04")
287
if checkResult == true
288
LoadSpriteSheet("LZ/Objects.gif")
289
SpriteFrame(-16, -16, 28, 36, 34, 68)
290
SpriteFrame(-16, -16, 28, 36, 63, 68)
291
SpriteFrame(-16, -16, 28, 36, 194, 90)
292
SpriteFrame(-12, -24, 24, 46, 92, 68)
293
SpriteFrame(-12, -24, 24, 46, 143, 90)
294
SpriteFrame(-16, -20, 25, 42, 168, 90)
295
SpriteFrame(-24, -12, 38, 24, 118, 65)
296
end if
297
298
CheckCurrentStageFolder("Zone07")
299
if checkResult == true
300
LoadSpriteSheet("MBZ/Objects.gif")
301
SpriteFrame(-16, -16, 28, 36, 1, 227)
302
SpriteFrame(-16, -16, 28, 36, 30, 227)
303
SpriteFrame(-16, -16, 28, 36, 59, 227)
304
SpriteFrame(-12, -24, 24, 46, 88, 217)
305
SpriteFrame(-12, -24, 24, 46, 113, 217)
306
SpriteFrame(-16, -20, 25, 42, 138, 221)
307
SpriteFrame(-24, -12, 38, 24, 215, 229)
308
end if
309
310
#platform: USE_ORIGINS
311
CheckCurrentStageFolder("DLC_Zone06")
312
if checkResult == true
313
LoadSpriteSheet("LZ/Objects.gif")
314
SpriteFrame(-16, -16, 28, 36, 34, 68)
315
SpriteFrame(-16, -16, 28, 36, 63, 68)
316
SpriteFrame(-16, -16, 28, 36, 194, 90)
317
SpriteFrame(-12, -24, 24, 46, 92, 68)
318
SpriteFrame(-12, -24, 24, 46, 143, 90)
319
SpriteFrame(-16, -20, 25, 42, 168, 90)
320
SpriteFrame(-24, -12, 38, 24, 118, 65)
321
end if
322
#endplatform
323
324
foreach (TypeName[Burrobot], arrayPos0, ALL_ENTITIES)
325
object[arrayPos0].startPos.x = object[arrayPos0].xpos
326
object[arrayPos0].startPos.y = object[arrayPos0].ypos
327
object[arrayPos0].unused = true
328
next
329
330
SetTableValue(TypeName[Burrobot], DebugMode_ObjCount, DebugMode_TypesTable)
331
SetTableValue(Burrobot_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
332
SetTableValue(Burrobot_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
333
DebugMode_ObjCount++
334
end event
335
336
337
// ========================
338
// Editor Events
339
// ========================
340
341
event RSDKDraw
342
DrawSprite(3)
343
end event
344
345
346
event RSDKLoad
347
CheckCurrentStageFolder("Zone07")
348
if checkResult == true
349
LoadSpriteSheet("MBZ/Objects.gif")
350
SpriteFrame(-16, -16, 28, 36, 1, 227)
351
SpriteFrame(-16, -16, 28, 36, 30, 227)
352
SpriteFrame(-16, -16, 28, 36, 59, 227)
353
SpriteFrame(-12, -24, 24, 46, 88, 217)
354
SpriteFrame(-12, -24, 24, 46, 113, 217)
355
SpriteFrame(-16, -20, 25, 42, 138, 221)
356
SpriteFrame(-24, -12, 38, 24, 215, 229)
357
else
358
// Both "Zone04" and "DLC_Zone06" will end up here
359
LoadSpriteSheet("LZ/Objects.gif")
360
SpriteFrame(-16, -16, 28, 36, 34, 68)
361
SpriteFrame(-16, -16, 28, 36, 63, 68)
362
SpriteFrame(-16, -16, 28, 36, 194, 90)
363
SpriteFrame(-12, -24, 24, 46, 92, 68)
364
SpriteFrame(-12, -24, 24, 46, 143, 90)
365
SpriteFrame(-16, -20, 25, 42, 168, 90)
366
SpriteFrame(-24, -12, 38, 24, 118, 65)
367
end if
368
369
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
370
end event
371
372