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/WFZ/EggmanLaser.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Eggman Laser 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.boundsL
14
private alias object.value2 : object.boundsR
15
private alias object.value3 : object.coreOffset.y
16
private alias object.value4 : object.laserFrame
17
private alias object.value5 : object.laserHeight
18
private alias object.value6 : object.health
19
private alias object.value7 : object.invincibilityTimer
20
private alias object.value8 : object.explodeState
21
private alias object.value9 : object.flashPaletteIndex
22
23
// States
24
private alias 0 : WFZEGGMANLASER_SETUP
25
private alias 1 : WFZEGGMANLASER_ENTERDELAY
26
private alias 2 : WFZEGGMANLASER_ENTERBOSS
27
private alias 3 : WFZEGGMANLASER_MOVING
28
private alias 4 : WFZEGGMANLASER_OPENSHELL
29
private alias 5 : WFZEGGMANLASER_CORESHOWDELAY
30
private alias 6 : WFZEGGMANLASER_SHOWCORE
31
private alias 7 : WFZEGGMANLASER_LASERDELAY
32
private alias 8 : WFZEGGMANLASER_SETUPLASER
33
private alias 9 : WFZEGGMANLASER_CHARGELASER
34
private alias 10 : WFZEGGMANLASER_FIRINGLASER
35
private alias 11 : WFZEGGMANLASER_LASERMOVE
36
private alias 12 : WFZEGGMANLASER_HIDECORE
37
private alias 13 : WFZEGGMANLASER_CLOSESHELL
38
private alias 14 : WFZEGGMANLASER_DESTROYED
39
private alias 15 : WFZEGGMANLASER_RESETBOUNDS
40
41
// Explode States
42
private alias 0 : WFZEGGMANLASER_BOSS_ACTIVE
43
private alias 1 : WFZEGGMANLASER_BOSS_EXPLODE
44
private alias 2 : WFZEGGMANLASER_BOSS_DESTROYED
45
46
// WFZEggman States
47
private alias 2 : WFZEGGMAN_ESCAPE
48
49
// WFZEggmanDispenser Aliases
50
private alias object.value0 : wfzEggmanDispenser.timer
51
private alias object.value8 : wfzEggmanDispenser.exploding
52
53
// WFZEggmanDispenser States
54
private alias 14 : WFZEGGMANDISPENSER_DESTROYED
55
56
// WFZEggmanPlatform States
57
private alias 2 : WFZEGGMANPLATFORM_DESTROYED
58
59
// WFZEggmanBarrier Aliases
60
private alias object.value0 : wfzEggmanBarrier.timer
61
62
// Player Aliases
63
private alias object.xpos : player.xpos
64
private alias object.value40 : player.hitboxLeft
65
private alias object.value38 : player.hitboxTop
66
private alias object.value41 : player.hitboxRight
67
private alias object.value39 : player.hitboxBottom
68
69
70
// ========================
71
// Static Values
72
// ========================
73
74
private value EggmanLaser_laserSheetX = 0
75
76
77
// ========================
78
// Events
79
// ========================
80
81
event ObjectUpdate
82
switch object.state
83
case WFZEGGMANLASER_SETUP
84
object.boundsL = object.xpos
85
object.boundsL -= 0x600000
86
object.boundsR = object.xpos
87
object.boundsR += 0x600000
88
object.laserFrame = 6
89
object.drawOrder = 4
90
object.inkEffect = 3
91
92
CheckCurrentStageFolder("Zone11")
93
if checkResult == true
94
object.flashPaletteIndex = 196
95
else
96
object.flashPaletteIndex = 192
97
end if
98
99
#platform: USE_STANDALONE
100
object.health = 8
101
#endplatform
102
#platform: USE_ORIGINS
103
if game.bossOneLife == false
104
object.health = 8
105
else
106
object.health = 1
107
end if
108
#endplatform
109
// [Fallthrough]
110
111
case WFZEGGMANLASER_ENTERDELAY
112
object.timer++
113
if object.timer >= 90
114
object.timer = 0
115
object.state = WFZEGGMANLASER_ENTERBOSS
116
end if
117
break
118
119
case WFZEGGMANLASER_ENTERBOSS
120
object.ypos += 0x4000
121
122
object.timer++
123
if object.timer >= 96
124
object.timer = 0
125
object[-1].type = TypeName[Eggman Dispenser]
126
object.state = WFZEGGMANLASER_MOVING
127
128
if player[0].xpos < object.xpos
129
object.xvel = -0x10000
130
else
131
object.xvel = 0x10000
132
end if
133
end if
134
break
135
136
case WFZEGGMANLASER_MOVING
137
object.timer++
138
if object.timer > 112
139
object.timer = 0
140
object.state = WFZEGGMANLASER_OPENSHELL
141
else
142
object.xpos += object.xvel
143
if object.xvel > 0
144
if object.xpos >= object.boundsR
145
FlipSign(object.xvel)
146
end if
147
else
148
if object.xpos <= object.boundsL
149
FlipSign(object.xvel)
150
end if
151
end if
152
end if
153
break
154
155
case WFZEGGMANLASER_OPENSHELL
156
object.animationTimer++
157
if object.animationTimer == 6
158
object.animationTimer = 0
159
160
object.frame++
161
if object.frame == 3
162
object.state = WFZEGGMANLASER_CORESHOWDELAY
163
end if
164
end if
165
break
166
167
case WFZEGGMANLASER_CORESHOWDELAY
168
object.timer++
169
if object.timer > 26
170
object.timer = 0
171
object.state = WFZEGGMANLASER_SHOWCORE
172
end if
173
break
174
175
case WFZEGGMANLASER_SHOWCORE
176
object.coreOffset.y += 0x10000
177
178
object.timer++
179
if object.timer > 12
180
object.timer = 0
181
object.state = WFZEGGMANLASER_LASERDELAY
182
end if
183
break
184
185
case WFZEGGMANLASER_LASERDELAY
186
object.timer++
187
if object.timer > 60
188
object.timer = 15
189
object.animationTimer = 15
190
object.laserHeight = 8
191
object.alpha = 0x200
192
object.state = WFZEGGMANLASER_SETUPLASER
193
end if
194
break
195
196
case WFZEGGMANLASER_SETUPLASER
197
if object.animationTimer > 2
198
object.laserFrame = 6
199
else
200
object.laserFrame = 5
201
end if
202
203
object.animationTimer--
204
if object.animationTimer == 0
205
object.timer--
206
if object.timer == 0
207
object.state = WFZEGGMANLASER_CHARGELASER
208
else
209
object.animationTimer = object.timer
210
if object.timer == 13
211
PlaySfx(SfxName[Laser Charge], false)
212
end if
213
end if
214
end if
215
break
216
217
case WFZEGGMANLASER_CHARGELASER
218
object.laserFrame -= 5
219
object.laserFrame ^= 1
220
object.laserFrame += 5
221
222
object.timer++
223
if object.timer > 64
224
object.timer = 0
225
object.alpha = 0xA0
226
object.state = WFZEGGMANLASER_FIRINGLASER
227
object.laserFrame = 5
228
PlaySfx(SfxName[Large Laser], false)
229
end if
230
break
231
232
case WFZEGGMANLASER_FIRINGLASER
233
object.laserHeight += 0x20
234
if object.laserHeight >= 0x80
235
object.alpha += 0x20
236
object.laserHeight = 167
237
object.timer = 0
238
239
if player[0].xpos < object.xpos
240
object.xvel = -0x10000
241
else
242
object.xvel = 0x10000
243
end if
244
245
object.state = WFZEGGMANLASER_LASERMOVE
246
end if
247
break
248
249
case WFZEGGMANLASER_LASERMOVE
250
object.timer++
251
object.alpha--
252
253
if object.timer > 112
254
object.timer = 0
255
object.state = WFZEGGMANLASER_HIDECORE
256
else
257
object.xpos += object.xvel
258
if object.xvel > 0
259
if object.xpos >= object.boundsR
260
object.xvel = 0
261
end if
262
else
263
if object.xpos <= object.boundsL
264
object.xvel = 0
265
end if
266
end if
267
end if
268
break
269
270
case WFZEGGMANLASER_HIDECORE
271
object.coreOffset.y -= 0x10000
272
object.alpha -= 24
273
274
object.timer++
275
if object.timer > 12
276
object.timer = 0
277
object.animationTimer = 0
278
object.state = WFZEGGMANLASER_CLOSESHELL
279
end if
280
break
281
282
case WFZEGGMANLASER_CLOSESHELL
283
object.animationTimer++
284
if object.animationTimer == 6
285
object.animationTimer = 0
286
287
object.frame--
288
if object.frame == 0
289
if player[0].xpos < object.xpos
290
object.xvel = -0x10000
291
else
292
object.xvel = 0x10000
293
end if
294
295
object.state = WFZEGGMANLASER_MOVING
296
end if
297
end if
298
break
299
300
case WFZEGGMANLASER_DESTROYED
301
if object.alpha > 0
302
object.alpha -= 24
303
end if
304
305
object.timer++
306
if object.timer >= 180
307
object.timer = 0
308
object.explodeState = WFZEGGMANLASER_BOSS_DESTROYED
309
object.state = WFZEGGMANLASER_RESETBOUNDS
310
end if
311
break
312
313
case WFZEGGMANLASER_RESETBOUNDS
314
temp0 = tileLayer[0].ysize
315
temp0 <<= 7
316
stage.newYBoundary2 = temp0
317
318
temp0 <<= 16
319
stage.deathBoundary = temp0
320
321
#platform: USE_ORIGINS
322
if game.oneStageFlag != false
323
game.callbackResult = -1
324
CallNativeFunction4(NotifyCallback, NOTIFY_STAGE_RETRY, 1, stage.listPos, 0)
325
326
// (State 16 doesn't do anything)
327
object.state = 16
328
end if
329
#endplatform
330
break
331
332
end switch
333
334
if object.health != 0
335
if object.invincibilityTimer > 0
336
object.invincibilityTimer--
337
GetBit(temp0, object.invincibilityTimer, 0)
338
if temp0 == true
339
SetPaletteEntry(0, object.flashPaletteIndex, 0xE0E0E0)
340
else
341
SetPaletteEntry(0, object.flashPaletteIndex, 0x000000)
342
end if
343
end if
344
345
if object.coreOffset.y > 0
346
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
347
BoxCollisionTest(C_TOUCH, object.entityPos, -16, 0, 16, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
348
if checkResult == true
349
if object.invincibilityTimer == 0
350
CallFunction(Player_CheckHit)
351
if checkResult == true
352
object.health--
353
if object.health == 0
354
#platform: USE_ORIGINS
355
CallNativeFunction2(NotifyCallback, NOTIFY_KILL_BOSS, 0)
356
CallNativeFunction2(NotifyCallback, NOTIFY_BOSS_END, 1)
357
stage.timeEnabled = false
358
CallNativeFunction2(NotifyCallback, NOTIFY_ACT_FINISH, 0)
359
#endplatform
360
361
player.score += 1000
362
object.explodeState = WFZEGGMANLASER_BOSS_EXPLODE
363
object.timer = 0
364
object.state = WFZEGGMANLASER_DESTROYED
365
366
object[-4].state = WFZEGGMAN_ESCAPE
367
368
wfzEggmanBarrier[-3].timer = 240
369
wfzEggmanBarrier[-2].timer = 240
370
371
wfzEggmanDispenser[-1].exploding = true
372
wfzEggmanDispenser[-1].timer = 0
373
object[-1].state = WFZEGGMANDISPENSER_DESTROYED
374
375
CreateTempObject(TypeName[Explosion], 0, object[+1].xpos, object[+1].ypos)
376
object[+1].state = WFZEGGMANPLATFORM_DESTROYED
377
378
CreateTempObject(TypeName[Explosion], 0, object[+2].xpos, object[+2].ypos)
379
object[+2].state = WFZEGGMANPLATFORM_DESTROYED
380
381
CreateTempObject(TypeName[Explosion], 0, object[+3].xpos, object[+3].ypos)
382
object[+3].state = WFZEGGMANPLATFORM_DESTROYED
383
384
StopSfx(SfxName[Laser Charge])
385
StopSfx(SfxName[Large Laser])
386
else
387
object.invincibilityTimer = 32
388
PlaySfx(SfxName[Boss Hit], false)
389
end if
390
end if
391
end if
392
else
393
if object.state == WFZEGGMANLASER_LASERMOVE
394
BoxCollisionTest(C_TOUCH, object.entityPos, -16, 0, 16, 168, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
395
if checkResult == true
396
CallFunction(Player_Hit)
397
end if
398
end if
399
end if
400
next
401
end if
402
end if
403
404
if object.explodeState == WFZEGGMANLASER_BOSS_EXPLODE
405
temp0 = oscillation
406
temp0 &= 7
407
if temp0 == 0
408
Rand(temp0, 96)
409
temp0 -= 48
410
temp0 <<= 16
411
temp0 += object.xpos
412
Rand(temp1, 48)
413
temp1 -= 24
414
temp1 <<= 16
415
temp1 += object.ypos
416
CreateTempObject(TypeName[Explosion], 0, temp0, temp1)
417
object[tempObjectPos].drawOrder = 5
418
PlaySfx(SfxName[Explosion], false)
419
end if
420
end if
421
end event
422
423
424
event ObjectDraw
425
if object.explodeState < WFZEGGMANLASER_BOSS_DESTROYED
426
// Draw Core
427
temp1 = object.ypos
428
temp1 += object.coreOffset.y
429
DrawSpriteXY(4, object.xpos, temp1)
430
431
// Draw Shell
432
DrawSprite(object.frame)
433
434
// Draw Laser
435
temp0 = 168
436
temp0 -= object.laserHeight
437
EditFrame(5, -16, 0, 32, object.laserHeight, EggmanLaser_laserSheetX, temp0)
438
DrawSpriteFX(object.laserFrame, FX_INK, object.xpos, temp1)
439
end if
440
end event
441
442
443
event ObjectStartup
444
CheckCurrentStageFolder("Zone11")
445
if checkResult == true
446
LoadSpriteSheet("SCZ/Objects.gif")
447
SpriteFrame(-32, -8, 64, 23, 311, 1) // Shell - Frame 1 - #0
448
SpriteFrame(-32, -8, 64, 22, 311, 25) // Shell - Frame 2 - #1
449
SpriteFrame(-32, -8, 64, 19, 311, 48) // Shell - Frame 3 - #2
450
SpriteFrame(-32, -8, 64, 13, 311, 68) // Shell - Frame 4 - #3
451
SpriteFrame(-16, -8, 32, 16, 376, 1) // Core - #4
452
SpriteFrame(-16, 0, 32, 168, 261, 1) // Laser Beam - #5
453
SpriteFrame(0, 0, 1, 1, 261, 168) // Laser Bottom - #6
454
EggmanLaser_laserSheetX = 261
455
else
456
LoadSpriteSheet("MBZ/Objects.gif")
457
SpriteFrame(-32, -8, 64, 23, 513, 139) // Shell - Frame 1 - #0
458
SpriteFrame(-32, -8, 64, 22, 578, 139) // Shell - Frame 2 - #1
459
SpriteFrame(-32, -8, 64, 19, 643, 139) // Shell - Frame 3 - #2
460
SpriteFrame(-32, -8, 64, 13, 578, 162) // Shell - Frame 4 - #3
461
SpriteFrame(-16, -8, 32, 16, 397, 1) // Core - #4
462
SpriteFrame(-16, 0, 32, 168, 480, 1) // Laser Beam - #5
463
SpriteFrame(0, 0, 1, 1, 480, 168) // Laser Bottom - #6
464
EggmanLaser_laserSheetX = 480
465
end if
466
end event
467
468
469
// ========================
470
// Editor Events
471
// ========================
472
473
event RSDKDraw
474
DrawSprite(0)
475
end event
476
477
478
event RSDKLoad
479
CheckCurrentStageFolder("Zone11")
480
if checkResult == true
481
LoadSpriteSheet("SCZ/Objects.gif")
482
SpriteFrame(-32, -8, 64, 23, 311, 1)
483
else
484
LoadSpriteSheet("MBZ/Objects.gif")
485
SpriteFrame(-32, -8, 64, 23, 513, 139)
486
end if
487
488
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
489
end event
490
491