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/SLZ/Fireball.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Fireball 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.interval
14
private alias object.value2 : object.fireballDir
15
private alias object.value3 : object.finalY
16
17
private alias 0 : FIREBALL_SPAWNER
18
private alias 1 : FIREBALL_MOVE_GRAVITY
19
private alias 2 : FIREBALL_MOVE_UP
20
private alias 3 : FIREBALL_MOVE_DOWN
21
private alias 4 : FIREBALL_MOVE_LEFT
22
private alias 5 : FIREBALL_MOVE_RIGHT
23
private alias 6 : FIREBALL_DISSIPATE
24
25
// Player Aliases
26
private alias object.value17 : debugMode.currentSelection
27
28
// Path ID Aliases
29
private alias 0 : PATH_A
30
31
32
// ========================
33
// Function Declarations
34
// ========================
35
36
reserve function Fireball_DebugDraw
37
reserve function Fireball_DebugSpawn
38
39
40
// ========================
41
// Static Values
42
// ========================
43
44
private value Fireball_startDebugID = 0
45
46
47
// ========================
48
// Function Definitions
49
// ========================
50
51
private function Fireball_DebugDraw
52
temp0 = debugMode[0].currentSelection
53
temp0 -= Fireball_startDebugID
54
temp1 = object.direction
55
56
switch temp0
57
case 0
58
object.direction = FLIP_Y
59
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
60
break
61
62
case 1
63
if object.direction == FLIP_NONE
64
object.direction = FLIP_Y
65
end if
66
67
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
68
break
69
70
case 2
71
DrawSpriteFX(3, FX_FLIP, object.xpos, object.ypos)
72
break
73
74
end switch
75
object.direction = temp1
76
end function
77
78
79
private function Fireball_DebugSpawn
80
CreateTempObject(TypeName[Fireball], 0, object.xpos, object.ypos)
81
object[tempObjectPos].interval = 60
82
temp0 = debugMode[0].currentSelection
83
temp0 -= Fireball_startDebugID
84
switch temp0
85
case 0
86
object[tempObjectPos].propertyValue = FIREBALL_MOVE_GRAVITY
87
object[tempObjectPos].yvel = -0x40000
88
object[tempObjectPos].fireballDir = FLIP_Y
89
break
90
91
case 1
92
if object.direction == FLIP_NONE
93
object[tempObjectPos].propertyValue = FIREBALL_MOVE_UP
94
object[tempObjectPos].yvel = -0x20000
95
object[tempObjectPos].fireballDir = FLIP_Y
96
else
97
object[tempObjectPos].propertyValue = 3
98
object[tempObjectPos].yvel = 0x20000
99
object[tempObjectPos].fireballDir = FLIP_NONE
100
end if
101
break
102
103
case 2
104
if object.direction == FLIP_NONE
105
object[tempObjectPos].propertyValue = FIREBALL_MOVE_RIGHT
106
object[tempObjectPos].xvel = 0x20000
107
object[tempObjectPos].fireballDir = FLIP_NONE
108
else
109
object[tempObjectPos].propertyValue = FIREBALL_MOVE_LEFT
110
object[tempObjectPos].xvel = -0x20000
111
object[tempObjectPos].fireballDir = FLIP_X
112
end if
113
break
114
115
end switch
116
end function
117
118
119
// ========================
120
// Events
121
// ========================
122
123
event ObjectUpdate
124
switch object.state
125
case FIREBALL_SPAWNER
126
object.timer++
127
if object.timer == object.interval
128
object.timer = 0
129
temp0 = object.ixpos
130
temp0 -= camera[0].xpos
131
Abs(temp0)
132
if temp0 < screen.xcenter
133
temp0 = object.iypos
134
temp0 -= camera[0].ypos
135
Abs(temp0)
136
if temp0 < screen.ycenter
137
CreateTempObject(TypeName[Fireball], 0, object.xpos, object.ypos)
138
object[tempObjectPos].state = object.propertyValue
139
object[tempObjectPos].xvel = object.xvel
140
object[tempObjectPos].yvel = object.yvel
141
object[tempObjectPos].finalY = object.ypos
142
object[tempObjectPos].fireballDir = object.fireballDir
143
PlaySfx(SfxName[Small Fireball], false)
144
end if
145
end if
146
end if
147
break
148
149
case FIREBALL_MOVE_GRAVITY
150
object.yvel += 0x1800
151
object.ypos += object.yvel
152
if object.yvel > 0
153
object.fireballDir = FLIP_NONE
154
end if
155
156
if object.ypos > object.finalY
157
object.type = TypeName[Blank Object]
158
end if
159
160
object.frame = object.animationTimer
161
object.frame /= 12
162
object.direction = object.animationTimer
163
object.direction /= 6
164
object.direction &= FLIP_X
165
object.direction += object.fireballDir
166
object.animationTimer++
167
object.animationTimer %= 24
168
break
169
170
case FIREBALL_MOVE_UP
171
object.ypos += object.yvel
172
object.frame = object.animationTimer
173
object.frame /= 12
174
object.direction = object.animationTimer
175
object.direction /= 6
176
object.direction &= FLIP_X
177
object.direction += object.fireballDir
178
object.animationTimer++
179
object.animationTimer %= 24
180
181
ObjectTileCollision(CSIDE_ROOF, 0, -8, PATH_A)
182
if checkResult == true
183
object.state = FIREBALL_DISSIPATE
184
object.frame = 2 // dissipate (V)
185
end if
186
187
if object.outOfBounds == true
188
object.type = TypeName[Blank Object]
189
end if
190
break
191
192
case FIREBALL_MOVE_DOWN
193
object.ypos += object.yvel
194
object.frame = object.animationTimer
195
object.frame /= 12
196
object.direction = object.animationTimer
197
object.direction /= 6
198
object.direction &= FLIP_X
199
object.direction += object.fireballDir
200
object.animationTimer++
201
object.animationTimer %= 24
202
203
ObjectTileCollision(CSIDE_FLOOR, 0, 8, PATH_A)
204
if checkResult == true
205
object.state = FIREBALL_DISSIPATE
206
object.frame = 2 // dissipate (V)
207
end if
208
209
if object.outOfBounds == true
210
object.type = TypeName[Blank Object]
211
end if
212
break
213
214
case FIREBALL_MOVE_LEFT
215
object.xpos += object.xvel
216
object.frame = object.animationTimer
217
object.frame /= 12
218
object.frame += 3
219
object.direction = object.animationTimer
220
object.direction /= 6
221
object.direction &= FLIP_X
222
object.direction <<= 1 // turn it into either FLIP_Y or FLIP_NONE
223
object.direction += object.fireballDir
224
object.animationTimer++
225
object.animationTimer %= 24
226
227
ObjectTileCollision(CSIDE_RWALL, -8, 0, PATH_A)
228
if checkResult == true
229
object.state = FIREBALL_DISSIPATE
230
object.frame = 5 // dissipate (H)
231
end if
232
233
if object.outOfBounds == true
234
object.type = TypeName[Blank Object]
235
end if
236
break
237
238
case FIREBALL_MOVE_RIGHT
239
object.xpos += object.xvel
240
object.frame = object.animationTimer
241
object.frame /= 12
242
object.frame += 3
243
object.direction = object.animationTimer
244
object.direction /= 6
245
object.direction &= FLIP_X
246
object.direction <<= 1 // turn it into either FLIP_Y or FLIP_NONE
247
object.direction += object.fireballDir
248
object.animationTimer++
249
object.animationTimer %= 24
250
251
ObjectTileCollision(CSIDE_LWALL, 8, 0, PATH_A)
252
if checkResult == true
253
object.state = FIREBALL_DISSIPATE
254
object.frame = 5 // dissipate (H)
255
end if
256
257
if object.outOfBounds == true
258
object.type = TypeName[Blank Object]
259
end if
260
break
261
262
case FIREBALL_DISSIPATE
263
object.timer++
264
if object.timer == 8
265
object.type = TypeName[Blank Object]
266
end if
267
break
268
269
end switch
270
271
if object.state > FIREBALL_SPAWNER
272
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
273
BoxCollisionTest(C_TOUCH, object.entityPos, -6, -6, 6, 6, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
274
if checkResult == true
275
CallFunction(Player_FireHit)
276
end if
277
next
278
end if
279
end event
280
281
282
event ObjectDraw
283
if object.state > FIREBALL_SPAWNER
284
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
285
end if
286
end event
287
288
289
event ObjectStartup
290
LoadSpriteSheet("SLZ/Objects.gif")
291
SpriteFrame(-7, -23, 15, 31, 1, 1) // Vertical 1 - #0
292
SpriteFrame(-8, -24, 16, 32, 17, 1) // Vertical 2 - #1
293
SpriteFrame(-8, -15, 16, 23, 34, 1) // Vertical Dissipate - #2
294
SpriteFrame(-23, -8, 31, 15, 2, 34) // Horizontal 1 - #3
295
SpriteFrame(-24, -8, 32, 15, 1, 50) // Horizontal 2 - #4
296
SpriteFrame(-15, -8, 23, 16, 10, 66) // Horizontal Dissipate - #5
297
298
foreach (TypeName[Fireball], arrayPos0, ALL_ENTITIES)
299
object[arrayPos0].interval = object[arrayPos0].propertyValue
300
object[arrayPos0].interval >>= 4
301
object[arrayPos0].interval *= 30
302
object[arrayPos0].interval += 30
303
304
object[arrayPos0].propertyValue &= 7
305
switch object[arrayPos0].propertyValue
306
case 0
307
object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY
308
object[arrayPos0].yvel = -0x40000
309
object[arrayPos0].fireballDir = FLIP_Y
310
break
311
312
case 1
313
object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY
314
object[arrayPos0].yvel = -0x50000
315
object[arrayPos0].fireballDir = FLIP_Y
316
break
317
318
case 2
319
object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY
320
object[arrayPos0].yvel = -0x60000
321
object[arrayPos0].fireballDir = FLIP_Y
322
break
323
324
case 3
325
object[arrayPos0].propertyValue = FIREBALL_MOVE_GRAVITY
326
object[arrayPos0].yvel = -0x70000
327
object[arrayPos0].fireballDir = FLIP_Y
328
break
329
330
case 4
331
object[arrayPos0].propertyValue = FIREBALL_MOVE_UP
332
object[arrayPos0].yvel = -0x20000
333
object[arrayPos0].fireballDir = FLIP_Y
334
break
335
336
case 5
337
object[arrayPos0].propertyValue = FIREBALL_MOVE_DOWN
338
object[arrayPos0].yvel = 0x20000
339
object[arrayPos0].fireballDir = FLIP_NONE
340
break
341
342
case 6
343
object[arrayPos0].propertyValue = FIREBALL_MOVE_LEFT
344
object[arrayPos0].xvel = -0x20000
345
object[arrayPos0].fireballDir = FLIP_X
346
break
347
348
case 7
349
object[arrayPos0].propertyValue = FIREBALL_MOVE_RIGHT
350
object[arrayPos0].xvel = 0x20000
351
object[arrayPos0].fireballDir = FLIP_NONE
352
break
353
354
end switch
355
next
356
357
temp0 = 0
358
Fireball_startDebugID = DebugMode_ObjCount
359
while temp0 < 3
360
SetTableValue(TypeName[Fireball], DebugMode_ObjCount, DebugMode_TypesTable)
361
SetTableValue(Fireball_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
362
SetTableValue(Fireball_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
363
DebugMode_ObjCount++
364
temp0++
365
loop
366
end event
367
368
369
// ========================
370
// Editor Events
371
// ========================
372
373
event RSDKEdit
374
if editor.returnVariable == true
375
switch editor.variableID
376
case EDIT_VAR_PROPVAL // property value
377
checkResult = object.propertyValue
378
break
379
380
case 0 // type
381
checkResult = object.propertyValue
382
checkResult &= 7
383
break
384
385
case 1 // interval
386
checkResult = object.propertyValue
387
checkResult >>= 4
388
checkResult &= 0x0F
389
break
390
391
end switch
392
else
393
switch editor.variableID
394
case EDIT_VAR_PROPVAL // property value
395
object.propertyValue = editor.variableValue
396
break
397
398
case 0 // type
399
temp0 = 7
400
Not(temp0)
401
object.propertyValue &= temp0
402
403
editor.variableValue &= 7
404
object.propertyValue |= editor.variableValue
405
break
406
407
case 1 // interval
408
object.propertyValue &= 0x0F
409
410
editor.variableValue &= 15
411
object.propertyValue |= editor.variableValue
412
break
413
414
end switch
415
end if
416
end event
417
418
419
event RSDKDraw
420
temp1 = object.direction
421
422
temp0 = object.propertyValue
423
temp0 &= 7
424
switch temp0
425
case 0
426
object.frame = 0
427
object.direction = FLIP_Y
428
break
429
430
case 1
431
object.frame = 0
432
object.direction = FLIP_Y
433
break
434
435
case 2
436
object.frame = 0
437
object.direction = FLIP_Y
438
break
439
440
case 3
441
object.frame = 0
442
object.direction = FLIP_Y
443
break
444
445
case 4
446
object.frame = 0
447
object.direction = FLIP_Y
448
break
449
450
case 5
451
object.frame = 0
452
object.direction = FLIP_NONE
453
break
454
455
case 6
456
object.frame = 3
457
object.direction = FLIP_X
458
break
459
460
case 7
461
object.frame = 3
462
object.direction = FLIP_NONE
463
break
464
465
end switch
466
467
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
468
object.direction = temp1
469
end event
470
471
472
event RSDKLoad
473
LoadSpriteSheet("SLZ/Objects.gif")
474
SpriteFrame(-7, -23, 15, 31, 1, 1) // Vertical 1 - #0
475
SpriteFrame(-8, -24, 16, 32, 17, 1) // Vertical 2 - #1
476
SpriteFrame(-8, -15, 16, 23, 34, 1) // Vertical Dissipate - #2
477
SpriteFrame(-23, -8, 31, 15, 2, 34) // Horizontal 1 - #3
478
SpriteFrame(-24, -8, 32, 15, 1, 50) // Horizontal 2 - #4
479
SpriteFrame(-15, -8, 23, 16, 10, 66) // Horizontal Dissipate - #5
480
481
AddEditorVariable("type")
482
SetActiveVariable("type")
483
AddEnumVariable("Eject Up (Slowest)", 0)
484
AddEnumVariable("Eject Up (Slow)", 1)
485
AddEnumVariable("Eject Up (Fast)", 2)
486
AddEnumVariable("Eject Up (Fastest)", 3)
487
AddEnumVariable("Travel Up", 4)
488
AddEnumVariable("Travel Down", 5)
489
AddEnumVariable("Travel Left", 6)
490
AddEnumVariable("Travel Right", 7)
491
492
AddEditorVariable("interval")
493
SetActiveVariable("interval")
494
AddEnumVariable("Every 30 Frames", 0)
495
AddEnumVariable("Every 60 Frames", 1)
496
AddEnumVariable("Every 90 Frames", 2)
497
AddEnumVariable("Every 120 Frames", 3)
498
AddEnumVariable("Every 150 Frames", 4)
499
AddEnumVariable("Every 180 Frames", 5)
500
AddEnumVariable("Every 210 Frames", 6)
501
AddEnumVariable("Every 240 Frames", 7)
502
AddEnumVariable("Every 270 Frames", 8)
503
AddEnumVariable("Every 300 Frames", 9)
504
AddEnumVariable("Every 330 Frames", 10)
505
AddEnumVariable("Every 360 Frames", 11)
506
AddEnumVariable("Every 390 Frames", 12)
507
AddEnumVariable("Every 420 Frames", 13)
508
AddEnumVariable("Every 450 Frames", 14)
509
AddEnumVariable("Every 480 Frames", 15)
510
end event
511
512