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/Jellygnite.txt
1482 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Jellygnite 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.frontTentacleAngle
16
private alias object.value4 : object.tentacleOffset.x
17
private alias object.value5 : object.tentacleOffset.y
18
private alias object.value6 : object.tentaclePos.x
19
private alias object.value7 : object.tentaclePos.y
20
private alias object.value8 : object.oscillateAngle
21
private alias object.value9 : object.frontTentacleFrame
22
private alias object.value10 : object.backTentacleFrame
23
private alias object.value11 : object.drawIndex
24
private alias object.value12 : object.grabbedPlayer
25
private alias object.value13 : object.shakeTimer
26
private alias object.value14 : object.shakeCount
27
private alias object.value15 : object.lastShakeFlags
28
29
// States
30
private alias 0 : JELLYGNITE_SWIMMING
31
private alias 1 : JELLYGNITE_GRABBEDPLAYER
32
private alias 2 : JELLYGNITE_EXPLODE
33
34
// Animations
35
private alias 0 : JELLYGNITE_ANI_IDLE
36
private alias 1 : JELLYGNITE_ANI_GRABBED
37
private alias 2 : JELLYGNITE_ANI_EXPLODING
38
39
// Player Aliases
40
private alias object.state : player.state
41
private alias object.xpos : player.xpos
42
private alias object.ypos : player.ypos
43
private alias object.xvel : player.xvel
44
private alias object.yvel : player.yvel
45
private alias object.speed : player.speed
46
private alias object.gravity : player.gravity
47
private alias object.frame : player.frame
48
private alias object.animationTimer : player.animationTimer
49
private alias object.animation : player.animation
50
private alias object.left : player.left
51
private alias object.right : player.right
52
53
private alias object.value1 : player.timer
54
private alias object.value40 : player.hitboxLeft
55
private alias object.value38 : player.hitboxTop
56
private alias object.value41 : player.hitboxRight
57
private alias object.value39 : player.hitboxBottom
58
59
// ========================
60
// Function Declarations
61
// ========================
62
63
reserve function Jellygnite_DebugDraw
64
reserve function Jellygnite_DebugSpawn
65
reserve function Jellygnite_HandleGrabbedPlayer
66
67
private function Jellygnite_DebugDraw
68
DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
69
end function
70
71
72
private function Jellygnite_DebugSpawn
73
CreateTempObject(TypeName[Jellygnite], 0, object.xpos, object.ypos)
74
object[tempObjectPos].startPos.x = object[tempObjectPos].xpos
75
object[tempObjectPos].startPos.y = object[tempObjectPos].ypos
76
object[tempObjectPos].grabbedPlayer = 0x7FFFFFFF
77
end function
78
79
80
private function Jellygnite_HandleGrabbedPlayer
81
if object.grabbedPlayer != 0x7FFFFFFF
82
currentPlayer = object.grabbedPlayer
83
if object.lastShakeFlags != 0
84
object.shakeTimer--
85
if object.shakeTimer == 0
86
object.shakeCount = 0
87
object.lastShakeFlags = 0
88
end if
89
90
temp0 = 0
91
if player[currentPlayer].left != false
92
temp0 |= 1
93
end if
94
95
if player[currentPlayer].right != false
96
temp0 |= 2
97
end if
98
99
if temp0 != 0
100
if temp0 != 3
101
if temp0 != object.lastShakeFlags
102
object.lastShakeFlags = temp0
103
object.shakeCount++
104
if object.shakeCount >= 4
105
#platform: USE_STANDALONE
106
player[currentPlayer].state = Player_State_Air
107
#endplatform
108
#platform: USE_ORIGINS
109
player[currentPlayer].state = Player_State_Air_NoDropDash
110
#endplatform
111
object.grabbedPlayer = 0x7FFFFFFF
112
else
113
object.shakeTimer = 32
114
end if
115
end if
116
end if
117
end if
118
else
119
if player[currentPlayer].left != false
120
object.lastShakeFlags |= 1
121
object.shakeTimer = 32
122
end if
123
124
if player[currentPlayer].right != false
125
object.lastShakeFlags |= 2
126
object.shakeTimer = 32
127
end if
128
end if
129
130
player[currentPlayer].xpos = object.xpos
131
player[currentPlayer].ypos = object.ypos
132
player[currentPlayer].ypos += 0xC0000
133
end if
134
end function
135
136
137
// ========================
138
// Events
139
// ========================
140
141
event ObjectUpdate
142
switch object.state
143
case JELLYGNITE_SWIMMING
144
if object.priority != PRIORITY_XBOUNDS_DESTROY
145
object.priority = PRIORITY_ACTIVE
146
end if
147
148
object.angle += 4
149
object.angle &= 0x1FF
150
Sin(object.frontTentacleAngle, object.angle)
151
object.frontTentacleAngle <<= 1
152
153
object.oscillateAngle++
154
object.oscillateAngle &= 0x1FF
155
Sin(object.xpos, object.oscillateAngle)
156
object.xpos <<= 11
157
object.xpos += object.startPos.x
158
159
temp1 = 0x7FFFFFFF
160
temp2 = 0
161
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
162
temp0 = object.xpos
163
temp0 -= player[currentPlayer].xpos
164
Abs(temp0)
165
if temp0 < temp1
166
temp1 = temp0
167
temp2 = currentPlayer
168
end if
169
next
170
171
currentPlayer = temp2
172
if player[currentPlayer].ypos > stage.newWaterLevel
173
temp2 = player[currentPlayer].ypos
174
temp2 -= 0x200000
175
if object.ypos > temp2
176
object.yvel -= 0x800
177
if object.yvel < -0xC000
178
object.yvel = -0xC000
179
end if
180
else
181
object.yvel += 0x800
182
if object.yvel > 0xC000
183
object.yvel = 0xC000
184
end if
185
end if
186
else
187
object.yvel >>= 1
188
end if
189
object.ypos += object.yvel
190
break
191
192
case JELLYGNITE_GRABBEDPLAYER
193
if object.frontTentacleAngle < 0x600
194
object.frontTentacleAngle += 0x80
195
else
196
object.state = JELLYGNITE_EXPLODE
197
object.animation = JELLYGNITE_ANI_EXPLODING
198
PlaySfx(SfxName[Electricity], false)
199
end if
200
201
currentPlayer = object.grabbedPlayer
202
player[currentPlayer].xpos = object.xpos
203
player[currentPlayer].ypos = object.ypos
204
player[currentPlayer].ypos += 0xC0000
205
player[currentPlayer].frame = 0
206
player[currentPlayer].animationTimer = 0
207
break
208
209
case JELLYGNITE_EXPLODE
210
CallFunction(Jellygnite_HandleGrabbedPlayer)
211
object.timer++
212
if object.timer == 60
213
if object.grabbedPlayer != 0x7FFFFFFF
214
currentPlayer = object.grabbedPlayer
215
if player[currentPlayer].state != Player_State_Drown
216
#platform: USE_STANDALONE
217
player[currentPlayer].state = Player_State_Air
218
#endplatform
219
#platform: USE_ORIGINS
220
player[currentPlayer].state = Player_State_Air_NoDropDash
221
#endplatform
222
CallFunction(Player_Hit)
223
end if
224
object.grabbedPlayer = 0x7FFFFFFF
225
end if
226
227
ResetObjectEntity(object.entityPos, TypeName[Smoke Puff], 0, object.xpos, object.ypos)
228
object.drawOrder = 4
229
PlaySfx(SfxName[Destroy], false)
230
end if
231
break
232
233
end switch
234
235
if object.type == TypeName[Jellygnite]
236
if object.outOfBounds == true
237
temp0 = object.xpos
238
temp1 = object.ypos
239
object.xpos = object.startPos.x
240
object.ypos = object.startPos.y
241
if object.outOfBounds == true
242
object.animation = JELLYGNITE_ANI_IDLE
243
if object.priority != PRIORITY_XBOUNDS_DESTROY
244
object.priority = PRIORITY_BOUNDS
245
end if
246
object.state = JELLYGNITE_SWIMMING
247
else
248
object.xpos = temp0
249
object.ypos = temp1
250
end if
251
end if
252
253
temp7 = object.grabbedPlayer
254
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
255
if currentPlayer != temp7
256
BoxCollisionTest(C_TOUCH, object.entityPos, -14, -14, 14, 14, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
257
if checkResult == true
258
if object.state == JELLYGNITE_SWIMMING
259
if player[currentPlayer].ypos < object.ypos
260
CallFunction(Player_BadnikBreak)
261
else
262
object.state = JELLYGNITE_GRABBEDPLAYER
263
object.animation = JELLYGNITE_ANI_GRABBED
264
object.grabbedPlayer = currentPlayer
265
player[currentPlayer].xvel = 0
266
player[currentPlayer].yvel = 0
267
player[currentPlayer].speed = 0
268
player[currentPlayer].timer = 0
269
player[currentPlayer].state = Player_State_Static
270
player[currentPlayer].gravity = GRAVITY_AIR
271
player[currentPlayer].animation = ANI_GRABBED
272
end if
273
else
274
if player[currentPlayer].ypos < object.ypos
275
CallFunction(Player_BadnikBreak)
276
end if
277
end if
278
end if
279
end if
280
next
281
282
if object.type == TypeName[Jellygnite]
283
switch object.animation
284
case JELLYGNITE_ANI_IDLE
285
object.frame = 0
286
object.frontTentacleFrame = 3
287
object.backTentacleFrame = 5
288
break
289
290
case JELLYGNITE_ANI_GRABBED
291
object.frame = 1
292
object.frontTentacleFrame = 3
293
object.backTentacleFrame = 5
294
break
295
296
case JELLYGNITE_ANI_EXPLODING
297
object.frame = object.animationTimer
298
object.frame >>= 5
299
300
object.frontTentacleFrame = object.frame
301
object.frontTentacleFrame += 3
302
object.backTentacleFrame = object.frame
303
object.backTentacleFrame += 5
304
305
object.frame++
306
307
object.animationTimer += object.timer
308
object.animationTimer &= 0x3F
309
break
310
end switch
311
else
312
if temp7 != 0x7FFFFFFF
313
currentPlayer = temp7
314
if player[currentPlayer].state == Player_State_Static
315
#platform: USE_STANDALONE
316
player[currentPlayer].state = Player_State_Air
317
#endplatform
318
#platform: USE_ORIGINS
319
player[currentPlayer].state = Player_State_Air_NoDropDash
320
#endplatform
321
end if
322
end if
323
end if
324
else
325
if object.grabbedPlayer != 0x7FFFFFFF
326
currentPlayer = object.grabbedPlayer
327
if player[currentPlayer].state == Player_State_Static
328
player[currentPlayer].state = Player_State_Air
329
end if
330
end if
331
end if
332
end event
333
334
335
event ObjectDraw
336
if object.drawIndex == 0
337
// Back Tentacle
338
temp1 = object.angle
339
temp1 &= 0x1FF
340
temp0 = 0
341
temp2 = object.ypos
342
temp2 += 0x70000
343
while temp0 < 4
344
Cos(object.tentaclePos.x, temp1)
345
object.tentaclePos.x <<= 9
346
object.tentaclePos.x += object.xpos
347
348
Sin(object.tentaclePos.y, temp1)
349
object.tentaclePos.y <<= 8
350
object.tentaclePos.y += temp2
351
352
DrawSpriteXY(object.backTentacleFrame, object.tentaclePos.x, object.tentaclePos.y)
353
temp0++
354
temp1 += 0x20
355
temp1 &= 0x1FF
356
temp2 += 0x60000
357
loop
358
AddDrawListEntityRef(4, object.entityPos)
359
else
360
// Front Tentacle
361
temp0 = 0
362
temp4 = object.frontTentacleAngle
363
object.tentacleOffset.x = 0
364
object.tentacleOffset.y = 0
365
while temp0 < 4
366
temp5 = temp4
367
temp5 >>= 7
368
temp5 &= 0x1FF
369
Sin(temp2, temp5)
370
temp2 *= 0x312
371
object.tentacleOffset.x += temp2
372
373
Cos(temp3, temp5)
374
temp3 *= 0x312
375
object.tentacleOffset.y += temp3
376
377
object.tentaclePos.x = object.tentacleOffset.x
378
object.tentaclePos.x += object.xpos
379
object.tentaclePos.x -= 0xD0000
380
381
object.tentaclePos.y = object.tentacleOffset.y
382
object.tentaclePos.y += object.ypos
383
object.tentaclePos.y += 0x10000
384
385
DrawSpriteXY(object.frontTentacleFrame, object.tentaclePos.x, object.tentaclePos.y)
386
387
object.tentaclePos.x = object.tentacleOffset.x
388
FlipSign(object.tentaclePos.x)
389
object.tentaclePos.x += object.xpos
390
object.tentaclePos.x += 0xD0000
391
DrawSpriteXY(object.frontTentacleFrame, object.tentaclePos.x, object.tentaclePos.y)
392
393
temp0++
394
temp4 += object.frontTentacleAngle
395
loop
396
397
// Body
398
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
399
end if
400
401
object.drawIndex ^= 1
402
end event
403
404
405
event ObjectStartup
406
LoadSpriteSheet("HPZ/Objects.gif")
407
SpriteFrame(-16, -16, 32, 20, 33, 123)
408
SpriteFrame(-16, -16, 32, 20, 66, 123)
409
SpriteFrame(-16, -16, 32, 20, 40, 144)
410
SpriteFrame(-3, -3, 6, 6, 198, 50)
411
SpriteFrame(-3, -3, 6, 6, 131, 97)
412
SpriteFrame(-3, -3, 6, 6, 33, 144)
413
SpriteFrame(-3, -3, 6, 6, 131, 90)
414
415
foreach (TypeName[Jellygnite], arrayPos0, ALL_ENTITIES)
416
object[arrayPos0].startPos.x = object[arrayPos0].xpos
417
object[arrayPos0].startPos.y = object[arrayPos0].ypos
418
object[arrayPos0].grabbedPlayer = 0x7FFFFFFF
419
next
420
421
SetTableValue(TypeName[Jellygnite], DebugMode_ObjCount, DebugMode_TypesTable)
422
SetTableValue(Jellygnite_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
423
SetTableValue(Jellygnite_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
424
DebugMode_ObjCount++
425
end event
426
427
428
// ========================
429
// Editor Events
430
// ========================
431
432
event RSDKDraw
433
object.frame = 0
434
object.frontTentacleFrame = 3
435
object.backTentacleFrame = 5
436
437
// Back Tentacle
438
temp1 = object.angle
439
temp1 &= 0x1FF
440
temp0 = 0
441
temp2 = object.ypos
442
temp2 += 0x70000
443
while temp0 < 4
444
Cos(object.tentaclePos.x, temp1)
445
object.tentaclePos.x <<= 9
446
object.tentaclePos.x += object.xpos
447
448
Sin(object.tentaclePos.y, temp1)
449
object.tentaclePos.y <<= 8
450
object.tentaclePos.y += temp2
451
452
DrawSpriteXY(object.backTentacleFrame, object.tentaclePos.x, object.tentaclePos.y)
453
temp0++
454
temp1 += 0x20
455
temp1 &= 0x1FF
456
temp2 += 0x60000
457
loop
458
459
// Front Tentacle
460
temp0 = 0
461
temp4 = object.frontTentacleAngle
462
object.tentacleOffset.x = 0
463
object.tentacleOffset.y = 0
464
while temp0 < 4
465
temp5 = temp4
466
temp5 >>= 7
467
temp5 &= 0x1FF
468
Sin(temp2, temp5)
469
temp2 *= 0x312
470
object.tentacleOffset.x += temp2
471
472
Cos(temp3, temp5)
473
temp3 *= 0x312
474
object.tentacleOffset.y += temp3
475
476
object.tentaclePos.x = object.tentacleOffset.x
477
object.tentaclePos.x += object.xpos
478
object.tentaclePos.x -= 0xD0000
479
480
object.tentaclePos.y = object.tentacleOffset.y
481
object.tentaclePos.y += object.ypos
482
object.tentaclePos.y += 0x10000
483
484
DrawSpriteXY(object.frontTentacleFrame, object.tentaclePos.x, object.tentaclePos.y)
485
486
object.tentaclePos.x = object.tentacleOffset.x
487
FlipSign(object.tentaclePos.x)
488
object.tentaclePos.x += object.xpos
489
object.tentaclePos.x += 0xD0000
490
DrawSpriteXY(object.frontTentacleFrame, object.tentaclePos.x, object.tentaclePos.y)
491
492
temp0++
493
temp4 += object.frontTentacleAngle
494
loop
495
496
// Body
497
DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
498
end event
499
500
501
event RSDKLoad
502
LoadSpriteSheet("HPZ/Objects.gif")
503
SpriteFrame(-16, -16, 32, 20, 33, 123)
504
SpriteFrame(-16, -16, 32, 20, 66, 123)
505
SpriteFrame(-16, -16, 32, 20, 40, 144)
506
SpriteFrame(-3, -3, 6, 6, 198, 50)
507
SpriteFrame(-3, -3, 6, 6, 131, 97)
508
SpriteFrame(-3, -3, 6, 6, 33, 144)
509
SpriteFrame(-3, -3, 6, 6, 131, 90)
510
511
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
512
end event
513
514