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/Stegway.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Stegway 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.showJet
16
private alias object.value4 : object.jetAnimTimer
17
private alias object.value5 : object.wheelFrame
18
private alias object.value6 : object.wheelAnimTimer
19
private alias object.value7 : object.noFloor
20
21
// States
22
private alias 0 : STEGWAY_MOVING
23
private alias 1 : STEGWAY_TURN
24
private alias 2 : STEGWAY_REVUP
25
private alias 3 : STEGWAY_REVRELEASE
26
private alias 4 : STEGWAY_DASH
27
28
// Animations
29
private alias 0 : STEGWAY_ANI_MOVE
30
private alias 1 : STEGWAY_ANI_REVRELEASE
31
private alias 2 : STEGWAY_ANI_REVUP
32
private alias 3 : STEGWAY_ANI_DASH
33
34
// Player Aliases
35
private alias object.value40 : player.hitboxLeft
36
private alias object.value38 : player.hitboxTop
37
private alias object.value41 : player.hitboxRight
38
private alias object.value39 : player.hitboxBottom
39
40
// Path ID Aliases
41
private alias 0 : PATH_A
42
43
44
// ========================
45
// Function Declarations
46
// ========================
47
48
reserve function Stegway_DebugDraw
49
reserve function Stegway_DebugSpawn
50
51
52
// ========================
53
// Function Definitions
54
// ========================
55
56
private function Stegway_DebugDraw
57
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
58
end function
59
60
61
private function Stegway_DebugSpawn
62
CreateTempObject(TypeName[Stegway], 0, object.xpos, object.ypos)
63
if object.direction == FACING_RIGHT
64
object[tempObjectPos].direction = FLIP_NONE
65
object[tempObjectPos].xvel = -0x4000
66
else
67
object[tempObjectPos].direction = FLIP_X
68
object[tempObjectPos].xvel = 0x4000
69
end if
70
end function
71
72
73
// ========================
74
// Events
75
// ========================
76
77
event ObjectUpdate
78
switch object.state
79
case STEGWAY_MOVING
80
if object.priority != PRIORITY_XBOUNDS_DESTROY
81
object.priority = PRIORITY_ACTIVE
82
end if
83
84
object.xpos += object.xvel
85
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
86
if object.direction == FLIP_NONE
87
BoxCollisionTest(C_TOUCH, object.entityPos, -96, -32, 0, 14, currentPlayer, 0, 0, 0, 0)
88
else
89
BoxCollisionTest(C_TOUCH, object.entityPos, 0, -32, 96, 14, currentPlayer, 0, 0, 0, 0)
90
end if
91
92
if checkResult == true
93
object.state = STEGWAY_REVUP
94
object.animation = STEGWAY_ANI_DASH
95
end if
96
next
97
98
if object.direction == FLIP_NONE
99
ObjectTileGrip(CSIDE_FLOOR, -12, 16, PATH_A)
100
else
101
ObjectTileGrip(CSIDE_FLOOR, 12, 16, PATH_A)
102
end if
103
104
if checkResult == false
105
object.state = STEGWAY_TURN
106
object.animation = STEGWAY_ANI_DASH
107
object.showJet = false
108
if object.frame == 3
109
object.frame = 2
110
end if
111
end if
112
break
113
114
case STEGWAY_TURN
115
if object.timer < 29
116
object.timer++
117
else
118
object.timer = 0
119
object.state = STEGWAY_MOVING
120
object.animation = STEGWAY_ANI_MOVE
121
object.direction ^= FLIP_X
122
if object.direction == FLIP_NONE
123
object.xvel = -0x4000
124
else
125
object.xvel = 0x4000
126
end if
127
end if
128
break
129
130
case STEGWAY_REVUP
131
object.timer++
132
if object.timer == 8
133
object.timer = 0
134
object.state = STEGWAY_REVRELEASE
135
object.animation = STEGWAY_ANI_REVUP
136
PlaySfx(SfxName[Rev Up], false)
137
end if
138
break
139
140
case STEGWAY_REVRELEASE
141
object.timer++
142
if object.timer == 32
143
object.timer = 0
144
object.state = STEGWAY_DASH
145
object.animation = STEGWAY_ANI_REVRELEASE
146
object.showJet = true
147
object.xvel *= 12
148
PlaySfx(SfxName[Release], false)
149
end if
150
break
151
152
case STEGWAY_DASH
153
object.xpos += object.xvel
154
155
if object.direction == FLIP_NONE
156
if object.noFloor == false
157
temp0 = object.ypos
158
ObjectTileGrip(CSIDE_FLOOR, -64, 16, PATH_A)
159
if checkResult == false
160
object.noFloor = true
161
end if
162
163
object.ypos = temp0
164
end if
165
166
ObjectTileGrip(CSIDE_FLOOR, -12, 16, PATH_A)
167
else
168
if object.noFloor == false
169
temp0 = object.ypos
170
ObjectTileGrip(0, 64, 16, PATH_A)
171
if checkResult == false
172
object.noFloor = true
173
end if
174
175
object.ypos = temp0
176
end if
177
178
ObjectTileGrip(CSIDE_FLOOR, 12, 16, PATH_A)
179
end if
180
181
if object.noFloor == true
182
if ringTimer == 0
183
CreateTempObject(TypeName[Dust Puff], 0, object.xpos, object.ypos)
184
if object.direction == FLIP_NONE
185
object[tempObjectPos].ixpos += 10
186
else
187
object[tempObjectPos].ixpos -= 10
188
end if
189
object[tempObjectPos].iypos += 16
190
end if
191
192
if object.xvel >= 0x4000
193
object.xvel -= 0xA00
194
if object.xvel < 0x4000
195
object.xvel = 0x4000
196
object.state = STEGWAY_MOVING
197
object.animation = STEGWAY_ANI_MOVE
198
object.animationTimer = 0
199
object.frame = 1
200
object.showJet = false
201
object.noFloor = false
202
end if
203
end if
204
205
if object.xvel <= -0x4000
206
object.xvel += 0xA00
207
if object.xvel > -0x4000
208
object.xvel = -0x4000
209
object.state = STEGWAY_MOVING
210
object.animation = STEGWAY_ANI_MOVE
211
object.animationTimer = 0
212
object.frame = 1
213
object.showJet = false
214
object.noFloor = false
215
end if
216
end if
217
end if
218
219
if checkResult == false
220
object.state = STEGWAY_TURN
221
object.animation = STEGWAY_ANI_DASH
222
object.showJet = false
223
object.noFloor = false
224
if object.frame == 3
225
object.frame = 2
226
end if
227
end if
228
break
229
230
end switch
231
232
if object.outOfBounds == true
233
temp0 = object.xpos
234
temp1 = object.ypos
235
object.xpos = object.startPos.x
236
object.ypos = object.startPos.y
237
if object.outOfBounds == true
238
if object.propertyValue == 0
239
object.direction = FLIP_NONE
240
object.xvel = -0x4000
241
else
242
object.direction = FLIP_X
243
object.xvel = 0x4000
244
end if
245
246
object.animation = STEGWAY_ANI_MOVE
247
if object.priority != PRIORITY_XBOUNDS_DESTROY
248
object.priority = PRIORITY_BOUNDS
249
end if
250
251
object.showJet = false
252
object.wheelFrame = 0
253
object.jetAnimTimer = 0
254
object.noFloor = false
255
object.state = STEGWAY_MOVING
256
else
257
object.xpos = temp0
258
object.ypos = temp1
259
end if
260
end if
261
262
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
263
BoxCollisionTest(C_TOUCH, object.entityPos, -20, -14, 20, 14, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
264
if checkResult == true
265
CallFunction(Player_BadnikBreak)
266
end if
267
next
268
269
switch object.animation
270
case STEGWAY_ANI_MOVE
271
if object.animationTimer == 0
272
object.frame++
273
object.frame %= 3
274
switch object.frame
275
case 0
276
object.animationTimer = 14
277
break
278
279
case 1
280
object.animationTimer = 6
281
break
282
283
case 2
284
object.animationTimer = 10
285
break
286
end switch
287
else
288
object.animationTimer--
289
end if
290
291
object.wheelAnimTimer++
292
object.wheelAnimTimer &= 15
293
object.wheelFrame = object.wheelAnimTimer
294
object.wheelFrame >>= 3
295
break
296
297
case STEGWAY_ANI_REVRELEASE
298
object.frame = 3
299
object.wheelAnimTimer++
300
object.wheelAnimTimer %= 6
301
if object.noFloor == true
302
object.wheelFrame = 0
303
else
304
object.wheelFrame = object.wheelAnimTimer
305
object.wheelFrame /= 3
306
end if
307
break
308
309
case STEGWAY_ANI_REVUP
310
object.frame = 2
311
object.wheelAnimTimer++
312
object.wheelAnimTimer &= 3
313
object.wheelFrame = object.wheelAnimTimer
314
object.wheelFrame >>= 1
315
break
316
317
case STEGWAY_ANI_DASH
318
break
319
320
end switch
321
322
if object.showJet == true
323
object.jetAnimTimer++
324
object.jetAnimTimer &= 3
325
end if
326
end event
327
328
329
event ObjectDraw
330
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
331
332
if object.wheelFrame == 1
333
DrawSpriteFX(4, FX_FLIP, object.xpos, object.ypos)
334
end if
335
336
if object.showJet == true
337
temp0 = object.jetAnimTimer
338
temp0 >>= 1
339
temp0 += 5
340
DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
341
end if
342
end event
343
344
345
event ObjectStartup
346
LoadSpriteSheet("HPZ/Objects.gif")
347
SpriteFrame(-24, -16, 48, 32, 40, 57) // moving 1 - #0
348
SpriteFrame(-24, -16, 48, 32, 89, 57) // moving 2 - #1
349
SpriteFrame(-24, -16, 48, 32, 82, 90) // dashing 1 - #2
350
SpriteFrame(-24, -16, 48, 32, 33, 90) // dashing 2 - #3
351
SpriteFrame(0, 0, 24, 16, 198, 29) // wheel - #4
352
SpriteFrame(24, 4, 7, 6, 206, 7) // jet 1 - #5
353
SpriteFrame(24, 4, 8, 6, 206, 14) // jet 2 - #6
354
355
foreach (TypeName[Stegway], arrayPos0, ALL_ENTITIES)
356
object[arrayPos0].startPos.x = object[arrayPos0].xpos
357
object[arrayPos0].startPos.y = object[arrayPos0].ypos
358
if object[arrayPos0].propertyValue == 0
359
object[arrayPos0].direction = FLIP_NONE
360
object[arrayPos0].xvel = -0x4000
361
else
362
object[arrayPos0].direction = FLIP_X
363
object[arrayPos0].xvel = 0x4000
364
end if
365
next
366
367
SetTableValue(TypeName[Stegway], DebugMode_ObjCount, DebugMode_TypesTable)
368
SetTableValue(Stegway_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
369
SetTableValue(Stegway_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
370
DebugMode_ObjCount++
371
end event
372
373
374
// ========================
375
// Editor Events
376
// ========================
377
378
event RSDKEdit
379
if editor.returnVariable == true
380
switch editor.variableID
381
case EDIT_VAR_PROPVAL // property value
382
checkResult = object.propertyValue
383
checkResult &= 1
384
break
385
386
case 0 // direction
387
GetBit(checkResult, object.propertyValue, 0)
388
break
389
390
end switch
391
else
392
switch editor.variableID
393
case EDIT_VAR_PROPVAL // property value
394
object.propertyValue = editor.variableValue
395
object.propertyValue &= 1
396
break
397
398
case 0 // direction
399
CheckNotEqual(editor.variableValue, 0)
400
SetBit(object.propertyValue, 0, checkResult)
401
break
402
403
end switch
404
end if
405
end event
406
407
408
event RSDKDraw
409
GetBit(object.direction, object.propertyValue, 0)
410
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
411
end event
412
413
414
event RSDKLoad
415
LoadSpriteSheet("HPZ/Objects.gif")
416
SpriteFrame(-24, -16, 48, 32, 40, 57)
417
418
AddEditorVariable("direction")
419
SetActiveVariable("direction")
420
AddEnumVariable("Left", 0)
421
AddEnumVariable("Right", 1)
422
end event
423
424