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/SBZ/FZEggman.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: FZ Eggman 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.invincibilityTimer
14
private alias object.value2 : object.health // health counts up instead of down this time...
15
private alias object.value3 : object.boundsR
16
private alias object.value4 : object.isVulnerable
17
private alias object.value5 : object.floorPos
18
19
// Piston aliases
20
private alias object.value0 : fzPiston.fzEggmanSlot
21
private alias object.propertyValue : fzPiston.hasEggman
22
23
// Piston States
24
private alias 0 : FZPISTON_IDLE
25
private alias 1 : FZPISTON_SETUP_CRUSHING
26
27
// Plasma Emitter Aliases
28
private alias object.xpos : plasmaEmitter.xpos
29
private alias object.ypos : plasmaEmitter.ypos
30
private alias object.state : plasmaEmitter.emitting
31
private alias object.value0 : plasmaEmitter.timer
32
33
// Plasma Ball Aliases
34
private alias object.value1 : plasmaBall.targetPos.x
35
36
// EggMobile aliases
37
private alias object.xpos : eggmobile.xpos
38
private alias object.ypos : eggmobile.ypos
39
private alias object.state : eggmobile.state
40
private alias object.value6 : eggmobile.playerStopPos
41
42
// Eggman States
43
private alias 0 : FZEGGMAN_AWAITPLAYER
44
private alias 1 : FZEGGMAN_STARTFIGHT
45
private alias 2 : FZEGGMAN_SETUP_PISTONATTACK
46
private alias 3 : FZEGGMAN_PISTONATTACK
47
private alias 4 : FZEGGMAN_SETUP_PLASMAATTACK
48
private alias 5 : FZEGGMAN_PLASMAATTACK
49
private alias 6 : FZEGGMAN_FLEE
50
private alias 7 : FZEGGMAN_RUNNINGAWAY
51
private alias 8 : FZEGGMAN_JUMPED
52
53
// Eggman Animations
54
private alias 0 : FZEGGANI_INVISIBLE
55
private alias 1 : FZEGGANI_IDLE
56
private alias 2 : FZEGGANI_LAUGH
57
private alias 3 : FZEGGANI_HIT
58
private alias 4 : FZEGGANI_DEFEATED
59
private alias 5 : FZEGGANI_TOASTED
60
61
// Player Aliases
62
private alias object.state : player.state
63
private alias object.xpos : player.xpos
64
private alias object.xvel : player.xvel
65
private alias object.speed : player.speed
66
private alias object.animation : player.animation
67
private alias object.collisionRight : player.collisionRight
68
private alias object.value16 : player.isSidekick
69
private alias object.value40 : player.hitboxLeft
70
private alias object.value38 : player.hitboxTop
71
private alias object.value41 : player.hitboxRight
72
private alias object.value39 : player.hitboxBottom
73
74
// Path ID Aliases
75
private alias 0 : PATH_A
76
77
78
// ========================
79
// Function Declarations
80
// ========================
81
82
reserve function FZEggman_CheckBossHit
83
84
// ========================
85
// Tables
86
// ========================
87
88
private table FZEggman_destroyFrameTable
89
8, 4, 9, 4
90
end table
91
92
// in pairs of 2
93
// so entities +1 & +2 would go, then +2 & +3, etc etc
94
private table FZEggman_pistonAttackSlots
95
1, 2
96
2, 3
97
3, 4
98
4, 1
99
end table
100
101
102
// ========================
103
// Function Definitions
104
// ========================
105
106
private function FZEggman_CheckBossHit
107
CheckEqual(player[currentPlayer].animation, ANI_JUMPING)
108
temp0 = checkResult
109
CheckEqual(player[currentPlayer].animation, ANI_GLIDING)
110
temp0 |= checkResult
111
CheckEqual(player[currentPlayer].animation, ANI_GLIDING_STOP)
112
temp0 |= checkResult
113
#platform: USE_ORIGINS
114
if stage.playerListPos == PLAYER_AMY
115
if player[currentPlayer].isSidekick == false
116
CheckEqual(player[currentPlayer].animation, ANI_HAMMER_JUMP)
117
temp0 |= checkResult
118
CheckEqual(player[currentPlayer].animation, ANI_HAMMER_DASH)
119
temp0 |= checkResult
120
end if
121
end if
122
#endplatform
123
124
if temp0 == true
125
player[currentPlayer].xvel = 0x30000
126
if player[currentPlayer].xpos < object.xpos
127
FlipSign(player[currentPlayer].xvel)
128
end if
129
130
player[currentPlayer].speed = player[currentPlayer].xvel
131
if player[currentPlayer].animation == ANI_GLIDING
132
player[currentPlayer].animation = ANI_GLIDING_DROP
133
player[currentPlayer].state = Player_State_GlideDrop
134
end if
135
checkResult = true
136
else
137
checkResult = false
138
end if
139
end function
140
141
142
// ========================
143
// Events
144
// ========================
145
146
event ObjectUpdate
147
switch object.state
148
case FZEGGMAN_AWAITPLAYER
149
temp1 = screen.xcenter
150
temp2 = temp1
151
if temp1 == 160
152
temp1 += 16
153
end if
154
155
temp0 = object.ixpos
156
temp0 -= temp1
157
stage.newXBoundary1 = temp0
158
temp0 += temp1
159
temp0 += temp2
160
stage.newXBoundary2 = temp0
161
temp0 = object.entityPos
162
fzPiston[+1].fzEggmanSlot = temp0
163
fzPiston[+2].fzEggmanSlot = temp0
164
fzPiston[+3].fzEggmanSlot = temp0
165
fzPiston[+4].fzEggmanSlot = temp0
166
object.boundsR = object.ixpos
167
object.boundsR += 656
168
object.floorPos = object.ypos
169
object.floorPos -= 0x400000
170
object.state++
171
break
172
173
case FZEGGMAN_STARTFIGHT
174
if player[0].xpos >= object.xpos
175
object.xpos = 0
176
object.ypos = 0
177
object.isVulnerable = true
178
object.state++
179
end if
180
break
181
182
case FZEGGMAN_SETUP_PISTONATTACK
183
object.animation = FZEGGANI_IDLE
184
Rand(temp0, 8)
185
temp1 = temp0
186
temp1 &= 1
187
temp0 &= 6
188
GetTableValue(temp2, temp0, FZEggman_pistonAttackSlots)
189
temp0++
190
GetTableValue(temp3, temp0, FZEggman_pistonAttackSlots)
191
192
arrayPos0 = object.entityPos
193
arrayPos0 += temp2
194
object[arrayPos0].state = FZPISTON_SETUP_CRUSHING
195
if temp1 == 0
196
fzPiston[arrayPos0].hasEggman = true
197
end if
198
199
arrayPos0 = object.entityPos
200
arrayPos0 += temp3
201
object[arrayPos0].state = FZPISTON_SETUP_CRUSHING
202
if temp1 == 1
203
fzPiston[arrayPos0].hasEggman = true
204
end if
205
206
PlaySfx(SfxName[Large Wall], false)
207
object.timer = 160
208
object.state++
209
break
210
211
case FZEGGMAN_PISTONATTACK
212
object.timer--
213
if object.timer <= 0
214
if object.health == 8
215
temp1 = screen.xcenter
216
temp0 = object.boundsR
217
temp0 -= temp1
218
stage.newXBoundary1 = temp0
219
temp0 += temp1
220
temp0 += temp1
221
stage.newXBoundary2 = temp0
222
object.xpos = plasmaEmitter[+5].xpos
223
object.xpos += 0x380000
224
object.ypos = plasmaEmitter[+5].ypos
225
eggmobile[+7].playerStopPos = object.boundsR
226
eggmobile[+7].playerStopPos <<= 16
227
object.direction = FLIP_X
228
arrayPos0 = object.entityPos
229
arrayPos0 += 5
230
ResetObjectEntity(arrayPos0, TypeName[Explosion], 0, object[arrayPos0].xpos, object[arrayPos0].ypos)
231
object.isVulnerable = false // you can't underflow the value if it counts up AND you disable attacks :bigthinker:
232
object.animation = FZEGGANI_TOASTED
233
object.state = FZEGGMAN_FLEE
234
else
235
object.state++
236
end if
237
end if
238
break
239
240
case FZEGGMAN_SETUP_PLASMAATTACK
241
plasmaEmitter[+5].emitting = true
242
plasmaEmitter[+5].timer = 330
243
244
temp0 = 0
245
temp1 = 0
246
while temp0 < 4
247
CreateTempObject(TypeName[Plasma Ball], 0, plasmaEmitter[+5].xpos, plasmaEmitter[+5].ypos)
248
object[tempObjectPos].inkEffect = INK_ADD
249
object[tempObjectPos].alpha = 0x00
250
plasmaBall[tempObjectPos].targetPos.x = 4
251
temp0++
252
plasmaBall[tempObjectPos].targetPos.x = temp1
253
plasmaBall[tempObjectPos].targetPos.x += plasmaEmitter[+5].xpos
254
plasmaBall[tempObjectPos].targetPos.x -= 0x100000
255
Rand(temp2, 32)
256
temp2 -= 16
257
temp2 <<= 16
258
plasmaBall[tempObjectPos].targetPos.x += temp2
259
temp1 -= 0x4F0000
260
loop
261
262
object.timer = 330
263
object.state++
264
break
265
266
case FZEGGMAN_PLASMAATTACK
267
object.timer--
268
if object.timer <= 0
269
object.state = FZEGGMAN_SETUP_PISTONATTACK
270
end if
271
break
272
273
case FZEGGMAN_FLEE
274
object.ypos += object.yvel
275
object.yvel += 0x1000
276
277
if object.ypos >= object.floorPos
278
ObjectTileCollision(CSIDE_FLOOR, 0, 28, PATH_A)
279
if checkResult == true
280
object.animation = FZEGGANI_INVISIBLE
281
object.xvel = 0x10000
282
object.yvel = -0x10000
283
object.timer = 0
284
object.animation = FZEGGANI_TOASTED
285
object.state++
286
end if
287
end if
288
break
289
290
case FZEGGMAN_RUNNINGAWAY
291
object.xpos += object.xvel
292
object.ypos += object.yvel
293
ObjectTileCollision(CSIDE_FLOOR, 0, 28, PATH_A)
294
if checkResult == false
295
object.yvel += 0x1000
296
else
297
object.yvel = 0
298
end if
299
300
temp1 = 0
301
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
302
if player[currentPlayer].xpos > temp1
303
temp1 = player[currentPlayer].xpos
304
end if
305
next
306
307
// fun code
308
temp0 = object.xpos
309
temp0 -= temp1
310
if temp0 < 0
311
object.xvel = 0x50000
312
else
313
object.xvel = 0x40000
314
temp0 -= 0x700000
315
if temp0 >= 0
316
object.xvel -= 0x10000
317
temp0 -= 0x80000
318
if temp0 >= 0
319
object.xvel -= 0x10000
320
temp0 -= 0x80000
321
if temp0 >= 0
322
object.xvel -= 0x8000
323
temp0 -= 0x80000
324
if temp0 >= 0
325
object.xvel -= 0x8000
326
temp0 -= 0x80000
327
if temp0 >= 0
328
object.xvel -= 0x8000
329
temp0 -= 0x380000
330
if temp0 >= 0
331
object.xvel = 0
332
end if
333
end if
334
end if
335
end if
336
end if
337
end if
338
end if
339
340
temp0 = eggmobile[+7].xpos
341
temp0 -= 0x300000
342
if object.xpos >= temp0
343
object.xvel = 0x24000
344
object.yvel = -0x4C000
345
object.state++
346
end if
347
break
348
349
case FZEGGMAN_JUMPED
350
object.xpos += object.xvel
351
object.ypos += object.yvel
352
object.yvel += 0x3400
353
354
if object.xpos >= eggmobile[+7].xpos
355
object.xpos = eggmobile[+7].xpos
356
object.xvel = 0
357
end if
358
359
if object.yvel > 0
360
if object.ypos >= eggmobile[+7].ypos
361
object.ypos = eggmobile[+7].ypos
362
object.yvel = 0
363
eggmobile[+7].state++
364
object.type = TypeName[Blank Object]
365
end if
366
end if
367
break
368
369
end switch
370
371
switch object.animation
372
case FZEGGANI_INVISIBLE
373
object.frame = 0
374
break
375
376
case FZEGGANI_IDLE
377
object.animationTimer++
378
if object.animationTimer == 14
379
object.animationTimer = 0
380
end if
381
object.frame = object.animationTimer
382
object.frame /= 7
383
object.frame++
384
break
385
386
case FZEGGANI_LAUGH
387
if object.yvel == 0
388
object.frame = 3
389
else
390
object.frame = 4
391
end if
392
break
393
394
case FZEGGANI_HIT
395
object.frame = object.invincibilityTimer
396
object.frame &= 1
397
object.frame += 5
398
break
399
400
case FZEGGANI_DEFEATED
401
object.frame = 7
402
break
403
404
case FZEGGANI_TOASTED
405
object.timer++
406
if object.timer >= 28
407
object.timer = 0
408
end if
409
temp0 = object.timer
410
temp0 /= 7
411
GetTableValue(object.frame, temp0, FZEggman_destroyFrameTable)
412
break
413
414
end switch
415
416
if object.invincibilityTimer != 0
417
object.invincibilityTimer--
418
end if
419
420
if object.isVulnerable == true
421
if player[0].xpos < object.xpos
422
object.direction = FLIP_NONE
423
else
424
object.direction = FLIP_X
425
end if
426
427
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
428
#platform: USE_STANDALONE
429
BoxCollisionTest(C_TOUCH, object.entityPos, -33, -37, 33, 6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
430
#endplatform
431
#platform: USE_ORIGINS
432
BoxCollisionTest(C_TOUCH, object.entityPos, -33, -37, 33, 6, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
433
#endplatform
434
if checkResult == true
435
CallFunction(FZEggman_CheckBossHit)
436
if checkResult == true
437
if object.invincibilityTimer == 0
438
if object.health < 8
439
object.animation = FZEGGANI_HIT
440
object.invincibilityTimer = 100
441
PlaySfx(SfxName[Boss Hit], false)
442
#platform: USE_STANDALONE
443
object.health++
444
#endplatform
445
#platform: USE_ORIGINS
446
if game.bossOneLife == false
447
object.health++
448
else
449
object.health = 8
450
end if
451
452
if object.health == 8
453
// Nothing. There's literally nothing here LMAO
454
end if
455
#endplatform
456
end if
457
end if
458
end if
459
end if
460
next
461
end if
462
463
// Handle Stage right boundary
464
// -> This doesn't do anything most of the time, since there's already the wall on the right of the arena
465
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
466
temp0 = player[currentPlayer].collisionRight
467
temp0 <<= 16
468
temp0 += player[currentPlayer].xpos
469
temp1 = stage.curXBoundary2
470
temp1 <<= 16
471
if temp0 > temp1
472
player[currentPlayer].xvel = 0
473
player[currentPlayer].speed = 0
474
player[currentPlayer].xpos = temp1
475
temp0 = player[currentPlayer].collisionRight
476
temp0 <<= 16
477
player[currentPlayer].xpos -= temp0
478
end if
479
next
480
end event
481
482
483
event ObjectDraw
484
if object.state >= FZEGGMAN_PISTONATTACK
485
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
486
end if
487
end event
488
489
490
event ObjectStartup
491
LoadSpriteSheet("SBZ/Objects.gif")
492
SpriteFrame(-22, -23, 38, 51, 1, 209)
493
SpriteFrame(-22, -24, 38, 52, 42, 208)
494
SpriteFrame(-22, -23, 38, 51, 84, 209)
495
SpriteFrame(-16, -16, 46, 44, 350, 165)
496
SpriteFrame(-16, -23, 46, 55, 350, 210)
497
SpriteFrame(-22, -24, 42, 52, 225, 266)
498
SpriteFrame(-22, -32, 42, 64, 225, 319)
499
SpriteFrame(-30, -24, 60, 44, 289, 165)
500
SpriteFrame(-24, -23, 54, 43, 236, 221)
501
SpriteFrame(-21, -25, 51, 52, 296, 213)
502
503
foreach (TypeName[FZ Eggman], arrayPos0, ALL_ENTITIES)
504
object[arrayPos0].priority = PRIORITY_ACTIVE
505
506
// Normally boss health would be set here, as with other bosses, but this boss's health counts up rather that counting down
507
next
508
end event
509
510
511
// ========================
512
// Editor Events
513
// ========================
514
515
event RSDKDraw
516
DrawSprite(0)
517
end event
518
519
520
event RSDKLoad
521
LoadSpriteSheet("SBZ/Objects.gif")
522
SpriteFrame(-22, -23, 38, 51, 1, 209)
523
524
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
525
end event
526
527