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/Grounder.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Grounder 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.startPos.y
15
private alias object.value3 : object.targetPlayer
16
private alias object.value4 : object.targetPlayerDistance
17
18
// States
19
private alias 0 : GROUNDER_HIDDEN
20
private alias 1 : GROUNDER_APPEAR
21
private alias 2 : GROUNDER_MOVING
22
private alias 3 : GROUNDER_TURNING
23
24
// Player Aliases
25
private alias object.xpos : player.xpos
26
private alias object.value40 : player.hitboxLeft
27
private alias object.value38 : player.hitboxTop
28
private alias object.value41 : player.hitboxRight
29
private alias object.value39 : player.hitboxBottom
30
31
private alias object.value17 : debugMode.currentSelection
32
33
// Path ID Aliases
34
private alias 0 : PATH_A
35
36
37
// ========================
38
// Function Declarations
39
// ========================
40
41
reserve function Grounder_DebugDraw
42
reserve function Grounder_DebugSpawn
43
44
45
// ========================
46
// Static Values
47
// ========================
48
49
private value Grounder_startDebugID = 0
50
51
52
// ========================
53
// Function Definitions
54
// ========================
55
56
private function Grounder_DebugDraw
57
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
58
end function
59
60
61
private function Grounder_DebugSpawn
62
temp0 = debugMode[0].currentSelection
63
temp0 -= Grounder_startDebugID
64
65
CreateTempObject(TypeName[Grounder], temp0, object.xpos, object.ypos)
66
object[tempObjectPos].startPos.x = object.xpos
67
object[tempObjectPos].startPos.y = object.ypos
68
end function
69
70
71
// ========================
72
// Events
73
// ========================
74
75
event ObjectUpdate
76
switch object.state
77
case GROUNDER_HIDDEN
78
object.priority = PRIORITY_ACTIVE
79
if object.propertyValue == 1
80
ObjectTileGrip(CSIDE_FLOOR, 0, 20, PATH_A)
81
object.state = GROUNDER_APPEAR
82
object.timer = 17
83
end if
84
85
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
86
BoxCollisionTest(C_TOUCH, object.entityPos, -96, -256, 96, 256, currentPlayer, -1, -1, 1, 1)
87
if checkResult == true
88
CreateTempObject(TypeName[Brick], 1, object.xpos, object.ypos)
89
object[tempObjectPos].xvel = -0x10000
90
object[tempObjectPos].yvel = -0x40000
91
92
CreateTempObject(TypeName[Brick], 3, object.xpos, object.ypos)
93
object[tempObjectPos].xvel = 0x40000
94
object[tempObjectPos].yvel = -0x30000
95
96
CreateTempObject(TypeName[Brick], 1, object.xpos, object.ypos)
97
object[tempObjectPos].xvel = 0x20000
98
object[tempObjectPos].yvel = 0
99
100
CreateTempObject(TypeName[Brick], 2, object.xpos, object.ypos)
101
object[tempObjectPos].xvel = -0x30000
102
object[tempObjectPos].yvel = -0x10000
103
104
CreateTempObject(TypeName[Brick], 1, object.xpos, object.ypos)
105
object[tempObjectPos].xvel = -0x30000
106
object[tempObjectPos].yvel = -0x30000
107
108
CreateTempObject(TypeName[Brick], 0, object.xpos, object.ypos)
109
object[tempObjectPos].ypos -= 0x140000
110
object[tempObjectPos].xvel = 0x10000
111
object[tempObjectPos].yvel = -0x20000
112
113
CreateTempObject(TypeName[Brick], 0, object.xpos, object.ypos)
114
object[tempObjectPos].xpos += 0x100000
115
object[tempObjectPos].ypos -= 0x40000
116
object[tempObjectPos].xvel = 0x10000
117
object[tempObjectPos].yvel = -0x10000
118
119
CreateTempObject(TypeName[Brick], 0, object.xpos, object.ypos)
120
object[tempObjectPos].ypos += 0xC0000
121
object[tempObjectPos].xvel = -0x10000
122
object[tempObjectPos].yvel = -0x20000
123
124
CreateTempObject(TypeName[Brick], 0, object.xpos, object.ypos)
125
object[tempObjectPos].xpos -= 0x100000
126
object[tempObjectPos].ypos -= 0x40000
127
object[tempObjectPos].xvel = -0x10000
128
object[tempObjectPos].yvel = -0x10000
129
130
ObjectTileGrip(CSIDE_FLOOR, 0, 20, PATH_A)
131
object.state = GROUNDER_APPEAR
132
end if
133
next
134
break
135
136
case GROUNDER_APPEAR
137
object.timer++
138
if object.timer == 8
139
object.frame = 1
140
end if
141
142
if object.timer == 18
143
object.timer = 0
144
object.frame = 2
145
object.state = GROUNDER_MOVING
146
147
object.targetPlayerDistance = 0x7FFFFFFF
148
object.targetPlayer = 0
149
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
150
temp0 = player[currentPlayer].xpos
151
temp0 -= object.xpos
152
if temp0 < 0
153
temp1 = FLIP_NONE
154
FlipSign(temp0)
155
else
156
temp1 = FLIP_X
157
end if
158
159
if temp0 < object.targetPlayerDistance
160
object.targetPlayerDistance = temp0
161
object.targetPlayer = currentPlayer
162
object.direction = temp1
163
end if
164
next
165
166
if object.direction == FLIP_NONE
167
object.xvel = -0x10000
168
else
169
object.xvel = 0x10000
170
end if
171
end if
172
break
173
174
case GROUNDER_MOVING
175
object.xpos += object.xvel
176
177
temp0 = object.ypos
178
temp1 = object.ypos
179
ObjectTileGrip(CSIDE_FLOOR, 0, 20, PATH_A)
180
temp2 = checkResult
181
temp1 -= object.ypos
182
183
if temp1 <= -0xC0000
184
object.ypos = temp0
185
temp2 = 0
186
end if
187
188
if temp1 > 0x10000
189
object.ypos = temp0
190
temp2 = 0
191
end if
192
193
if temp2 == 0
194
object.timer = 60
195
object.state = GROUNDER_TURNING
196
end if
197
198
object.animationTimer++
199
if object.animationTimer == 12
200
object.animationTimer = 0
201
end if
202
object.frame = object.animationTimer
203
object.frame >>= 2
204
object.frame += 2
205
break
206
207
case GROUNDER_TURNING
208
object.timer--
209
if object.timer == 0
210
object.direction ^= FLIP_X
211
FlipSign(object.xvel)
212
object.state = GROUNDER_MOVING
213
end if
214
break
215
216
end switch
217
218
if object.outOfBounds == true
219
temp0 = object.xpos
220
temp1 = object.ypos
221
object.xpos = object.startPos.x
222
object.ypos = object.startPos.y
223
if object.outOfBounds == true
224
object.state = GROUNDER_HIDDEN
225
object.timer = 0
226
object.animationTimer = 0
227
object.frame = 0
228
object.priority = PRIORITY_BOUNDS
229
else
230
object.xpos = temp0
231
object.ypos = temp1
232
end if
233
end if
234
235
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
236
BoxCollisionTest(C_TOUCH, object.entityPos, -12, -20, 12, 20, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
237
if checkResult == true
238
CallFunction(Player_BadnikBreak)
239
end if
240
next
241
end event
242
243
244
event ObjectDraw
245
if object.state == GROUNDER_HIDDEN
246
temp0 = object.xpos
247
temp1 = object.ypos
248
249
temp1 -= 0x140000
250
DrawSpriteFX(5, FX_FLIP, temp0, temp1)
251
252
temp1 += 0x100000
253
temp0 -= 0x100000
254
DrawSpriteFX(5, FX_FLIP, temp0, temp1)
255
256
temp0 += 0x200000
257
DrawSpriteFX(5, FX_FLIP, temp0, temp1)
258
259
temp1 += 0x100000
260
temp0 -= 0x100000
261
DrawSpriteFX(5, FX_FLIP, temp0, temp1)
262
else
263
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
264
end if
265
end event
266
267
268
event ObjectStartup
269
CheckCurrentStageFolder("Zone03")
270
if checkResult == true
271
LoadSpriteSheet("ARZ/Objects.gif")
272
273
// Emerging From Wall Frames
274
SpriteFrame(-14, -12, 28, 32, 133, 1)
275
SpriteFrame(-16, -16, 32, 36, 162, 1)
276
277
// Normal Frames
278
SpriteFrame(-16, -20, 32, 40, 34, 1)
279
SpriteFrame(-16, -20, 32, 40, 67, 1)
280
SpriteFrame(-16, -20, 32, 40, 100, 1)
281
282
// Brick Cover Frame
283
SpriteFrame(-16, -8, 32, 16, 18, 128)
284
else
285
LoadSpriteSheet("MBZ/Objects.gif")
286
287
// Emerging From Wall Frames
288
SpriteFrame(-14, -12, 28, 32, 374, 256)
289
SpriteFrame(-16, -16, 32, 36, 403, 256)
290
291
// Normal Frames
292
SpriteFrame(-16, -20, 32, 40, 275, 256)
293
SpriteFrame(-16, -20, 32, 40, 308, 256)
294
SpriteFrame(-16, -20, 32, 40, 341, 256)
295
296
// Brick Cover Frame
297
SpriteFrame(-16, -8, 32, 16, 436, 306)
298
end if
299
300
foreach (TypeName[Grounder], arrayPos0, ALL_ENTITIES)
301
object[arrayPos0].startPos.x = object[arrayPos0].xpos
302
object[arrayPos0].startPos.y = object[arrayPos0].ypos
303
next
304
305
temp0 = 0
306
Grounder_startDebugID = DebugMode_ObjCount
307
Grounder_startDebugID--
308
while temp0 < 2
309
SetTableValue(TypeName[Grounder], DebugMode_ObjCount, DebugMode_TypesTable)
310
SetTableValue(Grounder_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
311
SetTableValue(Grounder_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
312
DebugMode_ObjCount++
313
temp0++
314
loop
315
end event
316
317
318
// ========================
319
// Editor Events
320
// ========================
321
322
event RSDKEdit
323
if editor.returnVariable == true
324
switch editor.variableID
325
case EDIT_VAR_PROPVAL // property value
326
checkResult = object.propertyValue
327
break
328
329
case 0 // type
330
GetBit(checkResult, object.propertyValue, 0)
331
break
332
333
end switch
334
else
335
switch editor.variableID
336
case EDIT_VAR_PROPVAL // property value
337
object.propertyValue = editor.variableValue
338
break
339
340
case 0 // type
341
CheckNotEqual(editor.variableValue, 0)
342
SetBit(object.propertyValue, 0, checkResult)
343
break
344
345
end switch
346
end if
347
end event
348
349
350
event RSDKDraw
351
object.frame = object.propertyValue
352
object.frame <<= 1
353
354
DrawSprite(object.frame)
355
end event
356
357
358
event RSDKLoad
359
CheckCurrentStageFolder("Zone03")
360
if checkResult == true
361
LoadSpriteSheet("ARZ/Objects.gif")
362
SpriteFrame(-14, -12, 28, 32, 133, 1)
363
SpriteFrame(-16, -16, 32, 36, 162, 1)
364
SpriteFrame(-16, -20, 32, 40, 34, 1)
365
SpriteFrame(-16, -20, 32, 40, 67, 1)
366
SpriteFrame(-16, -20, 32, 40, 100, 1)
367
SpriteFrame(-16, -8, 32, 16, 18, 128)
368
else
369
LoadSpriteSheet("MBZ/Objects.gif")
370
SpriteFrame(-14, -12, 28, 32, 374, 256)
371
SpriteFrame(-16, -16, 32, 36, 403, 256)
372
SpriteFrame(-16, -20, 32, 40, 275, 256)
373
SpriteFrame(-16, -20, 32, 40, 308, 256)
374
SpriteFrame(-16, -20, 32, 40, 341, 256)
375
SpriteFrame(-16, -8, 32, 16, 436, 306)
376
end if
377
378
AddEditorVariable("type")
379
SetActiveVariable("type")
380
AddEnumVariable("Start Hidden", 0)
381
AddEnumVariable("Not Hidden", 1)
382
end event
383
384