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/HPZ/HPZSetup.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: HPZ Setup 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.value9 : object.clrDivisor_R
13
private alias object.value10 : object.clrDivisor_G
14
private alias object.value11 : object.clrDivisor_B
15
private alias object.value12 : object.waterClrDivisor_R
16
private alias object.value13 : object.waterClrDivisor_G
17
private alias object.value14 : object.waterClrDivisor_B
18
19
private alias object.value0 : object.deformTimer
20
private alias object.value1 : object.paletteTimer
21
private alias object.value2 : object.orb1AniTileDelay
22
private alias object.value3 : object.orb1AniTileFrame
23
private alias object.value4 : object.orb2AniTileDelay
24
private alias object.value5 : object.orb2AniTileFrame
25
private alias object.value6 : object.orb3AniTileDelay
26
private alias object.value7 : object.orb3AniTileFrame
27
private alias object.value8 : object.orbFrameTimer
28
private alias object.value16 : object.waterfallLoopTimer
29
private alias object.value17 : object.playingWaterfallLoop
30
31
// Player Aliases
32
private alias object.state : player.state
33
private alias object.xpos : player.xpos
34
private alias object.ypos : player.ypos
35
private alias object.direction : player.direction
36
private alias object.gravity : player.gravity
37
private alias object.collisionBottom : player.collisionBottom
38
39
// Tile Flag Aliases
40
private alias 1 : TILE_WATERSLIDE
41
42
// Tile Info ID Aliases
43
private alias 8 : TILEINFO_ANGLEB
44
45
// Tracks
46
private alias 0 : TRACK_STAGE
47
private alias 1 : TRACK_ACTFINISH
48
private alias 2 : TRACK_INVINCIBLE
49
private alias 3 : TRACK_CONTINUE
50
private alias 4 : TRACK_BOSS
51
private alias 5 : TRACK_GAMEOVER
52
private alias 6 : TRACK_DROWNING
53
private alias 7 : TRACK_SUPER
54
55
// Reserved object slots
56
private alias 10 : SLOT_ZONESETUP
57
private alias 25 : SLOT_MUSICEVENT_CHANGE
58
private alias 26 : SLOT_MUSICEVENT_BOSS
59
60
// Music Events
61
private alias 2 : MUSICEVENT_TRANSITION
62
63
private alias 0 : MUSICEVENT_FLAG_NOCHANGE
64
private alias 1 : MUSICEVENT_FLAG_SPEEDUP
65
private alias 2 : MUSICEVENT_FLAG_SLOWDOWN
66
67
// Music Loops
68
69
// There's something weird about the normal stage song's loop point:
70
// - The initial setup for this stage uses 18671
71
// - This is what the Sound Test uses as well
72
// - However, the loop point set when slowing down the tracks is 18672
73
// - This may just be a one sample difference but I assure you, it's quite important because now it makes everything more complicated
74
// - Here, I've just decided to label the slow-down version as the proper one, I do hope you'll understand...
75
private alias 18672 : MUSIC_LOOP_MCZ_2P
76
private alias 15272 : MUSIC_LOOP_MCZ_2P_F
77
78
private alias 59852 : MUSIC_LOOP_PPZ
79
80
private alias 38679 : MUSIC_LOOP_INV
81
private alias 30897 : MUSIC_LOOP_INV_F
82
83
// Achievement Aliases
84
private alias 7 : ACHIEVEMENT_ASECRETREVEALED
85
86
87
// ========================
88
// Function Declarations
89
// ========================
90
91
reserve function HPZSetup_getClrDivisor
92
reserve function HPZSetup_InitSuperSonicPal
93
reserve function HPZSetup_InitSuperTailsPal
94
reserve function HPZSetup_InitSuperKnuxPal
95
reserve function HPZSetup_InitSuperAmyPal
96
reserve function HPZSetup_SpeedUpMusic
97
reserve function HPZSetup_SlowDownMusic
98
99
100
// ========================
101
// Static Values
102
// ========================
103
104
public value Water_flashTimer = 0 // Uses "Water_" since all water objects use it from the setup so its easier to make new objs this way
105
public value HPZSetup_bossFightActive = 0
106
public value HPZSetup_glowingOrbFrame = 0
107
private value HPZSetup_hasAchievement = 0
108
109
110
// ========================
111
// Tables
112
// ========================
113
114
private table HPZSetup_greenOrbFramesTable1
115
768, 18
116
770, 9
117
772, 18
118
770, 9
119
end table
120
121
private table HPZSetup_purpleOrbFramesTable1
122
774, 18
123
776, 9
124
778, 18
125
776, 9
126
end table
127
128
private table HPZSetup_greenOrbFramesTable2
129
780, 18
130
783, 9
131
786, 18
132
783, 9
133
end table
134
135
private table HPZSetup_purpleOrbFramesTable2
136
789, 18
137
792, 9
138
795, 18
139
792, 9
140
end table
141
142
private table HPZSetup_orbFrameTable
143
0, 0, 1, 2, 3, 3, 2
144
1, 2, 3, 3, 2, 1, 0
145
end table
146
147
148
// ========================
149
// Function Definitions
150
// ========================
151
152
// Wacky function to take a normal color and turn it into an underwater color
153
private function HPZSetup_getClrDivisor
154
// Regular Color
155
object.clrDivisor_R = temp1
156
object.clrDivisor_R >>= 16
157
158
object.clrDivisor_G = temp1
159
object.clrDivisor_G >>= 8
160
object.clrDivisor_G &= 0xFF
161
162
object.clrDivisor_B = temp1
163
object.clrDivisor_B &= 0xFF
164
165
// Underwater Color
166
object.waterClrDivisor_R = temp2
167
object.waterClrDivisor_R >>= 16
168
169
object.waterClrDivisor_G = temp2
170
object.waterClrDivisor_G >>= 8
171
object.waterClrDivisor_G &= 0xFF
172
173
object.waterClrDivisor_B = temp2
174
object.waterClrDivisor_B &= 0xFF
175
176
// Minimum of 1 (you cant divide by zero)
177
if object.waterClrDivisor_R == 0
178
object.waterClrDivisor_R = 1
179
end if
180
181
if object.waterClrDivisor_G == 0
182
object.waterClrDivisor_G = 1
183
end if
184
185
if object.waterClrDivisor_B == 0
186
object.waterClrDivisor_B = 1
187
end if
188
189
object.clrDivisor_R <<= 8
190
object.clrDivisor_G <<= 8
191
object.clrDivisor_B <<= 8
192
object.clrDivisor_R /= object.waterClrDivisor_R
193
object.clrDivisor_G /= object.waterClrDivisor_G
194
object.clrDivisor_B /= object.waterClrDivisor_B
195
196
if object.clrDivisor_R == 0
197
object.clrDivisor_R = 0x100
198
end if
199
200
if object.clrDivisor_G == 0
201
object.clrDivisor_G = 0x100
202
end if
203
204
if object.clrDivisor_B == 0
205
object.clrDivisor_B = 0x100
206
end if
207
end function
208
209
210
private function HPZSetup_InitSuperSonicPal
211
temp0 = 0
212
213
// First Set of colors is just the regular underwater palette
214
GetPaletteEntry(1, 2, temp1)
215
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
216
temp0++
217
218
GetPaletteEntry(1, 3, temp1)
219
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
220
temp0++
221
222
GetPaletteEntry(1, 4, temp1)
223
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
224
temp0++
225
226
GetPaletteEntry(1, 5, temp1)
227
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
228
temp0++
229
230
CopyPalette(1, 0, 4, 2, 4)
231
while temp0 < 64
232
GetTableValue(temp1, temp0, Player_SonicSuperPal)
233
SetPaletteEntry(3, 0, temp1)
234
temp0++
235
236
GetTableValue(temp1, temp0, Player_SonicSuperPal)
237
SetPaletteEntry(3, 1, temp1)
238
temp0++
239
240
GetTableValue(temp1, temp0, Player_SonicSuperPal)
241
SetPaletteEntry(3, 2, temp1)
242
temp0++
243
244
GetTableValue(temp1, temp0, Player_SonicSuperPal)
245
SetPaletteEntry(3, 3, temp1)
246
temp0 -= 3
247
248
// Just mix the 2 palettes, we'll use the results as our new colors
249
SetPaletteFade(5, 3, 4, 48, 0, 4)
250
251
GetPaletteEntry(5, 0, temp1)
252
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
253
temp0++
254
255
GetPaletteEntry(5, 1, temp1)
256
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
257
temp0++
258
259
GetPaletteEntry(5, 2, temp1)
260
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
261
temp0++
262
263
GetPaletteEntry(5, 3, temp1)
264
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
265
temp0++
266
loop
267
end function
268
269
270
private function HPZSetup_InitSuperTailsPal
271
temp0 = 0
272
273
GetPaletteEntry(1, 13, temp1)
274
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
275
temp0++
276
277
GetPaletteEntry(1, 17, temp1)
278
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
279
temp0++
280
281
GetPaletteEntry(1, 18, temp1)
282
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
283
temp0++
284
285
GetPaletteEntry(1, 16, temp1)
286
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
287
temp0++
288
289
while temp0 < 24
290
GetPaletteEntry(0, 13, temp1)
291
GetPaletteEntry(1, 13, temp2)
292
293
CallFunction(HPZSetup_getClrDivisor)
294
295
GetTableValue(temp1, temp0, Player_TailsSuperPal)
296
297
temp2 = temp1
298
temp2 >>= 8
299
temp2 &= 0xFF
300
301
temp3 = temp1
302
temp3 &= 0xFF
303
304
temp1 >>= 16
305
306
temp1 *= 0xF8
307
temp1 /= object.clrDivisor_R
308
309
temp2 *= 0xF8
310
temp2 /= object.clrDivisor_G
311
312
temp3 *= 0xF8
313
temp3 /= object.clrDivisor_B
314
315
temp1 &= 0xF0
316
temp2 &= 0xF0
317
temp3 &= 0xF0
318
319
if temp1 > 0xE0
320
temp1 = 0xE0
321
end if
322
323
if temp2 > 0xE0
324
temp2 = 0xE0
325
end if
326
327
if temp3 > 0xE0
328
temp3 = 0xE0
329
end if
330
331
temp1 <<= 16
332
temp2 <<= 8
333
temp1 += temp2
334
temp1 += temp3
335
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
336
temp0++
337
338
339
GetPaletteEntry(0, 17, temp1)
340
GetPaletteEntry(1, 17, temp2)
341
342
CallFunction(HPZSetup_getClrDivisor)
343
344
GetTableValue(temp1, temp0, Player_TailsSuperPal)
345
346
temp2 = temp1
347
temp2 >>= 8
348
temp2 &= 0xFF
349
350
temp3 = temp1
351
temp3 &= 0xFF
352
353
temp1 >>= 16
354
355
temp1 *= 0x100
356
temp1 /= object.clrDivisor_R
357
358
temp2 *= 0x100
359
temp2 /= object.clrDivisor_G
360
361
temp3 *= 0x100
362
temp3 /= object.clrDivisor_B
363
364
temp1 &= 0xF0
365
temp2 &= 0xF0
366
temp3 &= 0xF0
367
368
if temp1 > 0xE0
369
temp1 = 0xE0
370
end if
371
372
if temp2 > 0xE0
373
temp2 = 0xE0
374
end if
375
376
if temp3 > 0xE0
377
temp3 = 0xE0
378
end if
379
380
temp1 <<= 16
381
temp2 <<= 8
382
temp1 += temp2
383
temp1 += temp3
384
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
385
temp0++
386
387
388
GetPaletteEntry(0, 18, temp1)
389
GetPaletteEntry(1, 18, temp2)
390
391
CallFunction(HPZSetup_getClrDivisor)
392
393
GetTableValue(temp1, temp0, Player_TailsSuperPal)
394
395
temp2 = temp1
396
temp2 >>= 8
397
temp2 &= 0xFF
398
399
temp3 = temp1
400
temp3 &= 0xFF
401
402
temp1 >>= 16
403
404
temp1 *= 0x100
405
temp1 /= object.clrDivisor_R
406
407
temp2 *= 0x100
408
temp2 /= object.clrDivisor_G
409
410
temp3 *= 0x100
411
temp3 /= object.clrDivisor_B
412
413
temp1 &= 0xF0
414
temp2 &= 0xF0
415
temp3 &= 0xF0
416
417
if temp1 > 0xE0
418
temp1 = 0xE0
419
end if
420
421
if temp2 > 0xE0
422
temp2 = 0xE0
423
end if
424
425
if temp3 > 0xE0
426
temp3 = 0xE0
427
end if
428
429
temp1 <<= 16
430
temp2 <<= 8
431
temp1 += temp2
432
temp1 += temp3
433
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
434
temp0++
435
436
437
GetPaletteEntry(0, 16, temp1)
438
GetPaletteEntry(1, 16, temp2)
439
440
CallFunction(HPZSetup_getClrDivisor)
441
442
GetTableValue(temp1, temp0, Player_TailsSuperPal)
443
444
temp2 = temp1
445
temp2 >>= 8
446
temp2 &= 0xFF
447
448
temp3 = temp1
449
temp3 &= 0xFF
450
451
temp1 >>= 16
452
453
temp1 *= 0x100
454
temp1 /= object.clrDivisor_R
455
456
temp2 *= 0x100
457
temp2 /= object.clrDivisor_G
458
459
temp3 *= 0x100
460
temp3 /= object.clrDivisor_B
461
462
temp1 &= 0xF0
463
temp2 &= 0xF0
464
temp3 &= 0xF0
465
466
if temp1 > 0xE0
467
temp1 = 0xE0
468
end if
469
470
if temp2 > 0xE0
471
temp2 = 0xE0
472
end if
473
474
if temp3 > 0xE0
475
temp3 = 0xE0
476
end if
477
478
temp1 <<= 16
479
temp2 <<= 8
480
temp1 += temp2
481
temp1 += temp3
482
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
483
temp0++
484
loop
485
end function
486
487
488
private function HPZSetup_InitSuperKnuxPal
489
temp0 = 0
490
491
GetPaletteEntry(1, 26, temp1)
492
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
493
temp0++
494
495
GetPaletteEntry(1, 27, temp1)
496
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
497
temp0++
498
499
GetPaletteEntry(1, 28, temp1)
500
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
501
temp0++
502
end function
503
504
505
private function HPZSetup_InitSuperAmyPal
506
#platform: USE_ORIGINS
507
temp0 = 0
508
509
GetPaletteEntry(1, 54, temp1)
510
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
511
temp0++
512
513
GetPaletteEntry(1, 50, temp1)
514
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
515
temp0++
516
517
GetPaletteEntry(1, 51, temp1)
518
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
519
temp0++
520
521
GetPaletteEntry(1, 52, temp1)
522
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
523
temp0++
524
525
GetPaletteEntry(1, 53, temp1)
526
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
527
temp0++
528
529
while temp0 < 30
530
temp4 = temp0
531
temp4 -= 5
532
533
GetTableValue(temp1, temp4, Player_AmySuperAltPal)
534
535
temp2 = temp1
536
temp2 >>= 8
537
temp2 &= 255
538
539
temp3 = temp1
540
temp3 &= 255
541
542
temp1 >>= 16
543
temp1 += 32
544
if temp1 > 255
545
temp1 = 255
546
end if
547
548
temp2 += 32
549
if temp2 > 255
550
temp2 = 255
551
end if
552
553
temp3 += 32
554
if temp3 > 255
555
temp3 = 255
556
end if
557
558
temp1 <<= 16
559
temp2 <<= 8
560
temp1 += temp2
561
temp1 += temp3
562
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
563
temp0++
564
loop
565
566
temp6 = 25
567
while temp0 < 50
568
temp5 = 0
569
while temp5 < 5
570
temp4 = temp6
571
temp4 += temp5
572
GetTableValue(temp1, temp4, Player_AmySuperAltPal)
573
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
574
temp0++
575
temp5++
576
loop
577
578
temp6 -= 5
579
loop
580
#endplatform
581
end function
582
583
584
private function HPZSetup_SpeedUpMusic
585
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
586
temp0 = checkResult
587
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
588
temp0 &= checkResult
589
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
590
temp0 &= checkResult
591
if temp0 == false
592
switch music.currentTrack
593
case TRACK_STAGE
594
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
595
SwapMusicTrack("MysticCave2_F.ogg", TRACK_STAGE, MUSIC_LOOP_MCZ_2P_F, 8000)
596
break
597
598
case TRACK_INVINCIBLE
599
SetMusicTrack("MysticCave2_F.ogg", TRACK_STAGE, MUSIC_LOOP_MCZ_2P_F)
600
SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)
601
break
602
603
case TRACK_BOSS
604
case TRACK_DROWNING
605
case TRACK_SUPER
606
SetMusicTrack("MysticCave2_F.ogg", TRACK_STAGE, MUSIC_LOOP_MCZ_2P_F)
607
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
608
break
609
610
end switch
611
else
612
stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP
613
end if
614
end function
615
616
617
private function HPZSetup_SlowDownMusic
618
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
619
temp0 = checkResult
620
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
621
temp0 &= checkResult
622
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
623
temp0 &= checkResult
624
if temp0 == false
625
switch music.currentTrack
626
case TRACK_STAGE
627
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
628
SwapMusicTrack("MysticCave2.ogg", TRACK_STAGE, MUSIC_LOOP_MCZ_2P, 12500)
629
break
630
631
case TRACK_INVINCIBLE
632
SetMusicTrack("MysticCave2.ogg", TRACK_STAGE, MUSIC_LOOP_MCZ_2P)
633
SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)
634
break
635
636
case TRACK_BOSS
637
case TRACK_DROWNING
638
case TRACK_SUPER
639
SetMusicTrack("MysticCave2.ogg", TRACK_STAGE, MUSIC_LOOP_MCZ_2P)
640
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
641
break
642
643
end switch
644
else
645
stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN
646
end if
647
end function
648
649
650
// ========================
651
// Events
652
// ========================
653
654
event ObjectUpdate
655
if stage.actNum == 1
656
// If in act 1 - the Hidden Palace act encountered in normal play - set the correct water level for before and after the boss arena
657
if player[0].xpos > 0xE800000
658
stage.newWaterLevel = 0x6140000
659
else
660
stage.newWaterLevel = 0x74C0000
661
end if
662
end if
663
664
object.deformTimer++
665
if object.deformTimer == 2
666
tileLayer[0].deformationOffsetW++
667
end if
668
669
if object.deformTimer == 4
670
tileLayer[0].deformationOffsetW++
671
tileLayer[1].deformationOffsetW++
672
object.deformTimer = 0
673
end if
674
675
object.paletteTimer++
676
if object.paletteTimer == 5
677
object.paletteTimer = 0
678
RotatePalette(0, 185, 188, true)
679
end if
680
681
if object.orb1AniTileDelay < 2
682
GetTableValue(temp0, object.orb1AniTileFrame, HPZSetup_greenOrbFramesTable1)
683
Copy16x16Tile(738, temp0)
684
685
temp0++
686
Copy16x16Tile(739, temp0)
687
688
GetTableValue(temp0, object.orb1AniTileFrame, HPZSetup_purpleOrbFramesTable1)
689
Copy16x16Tile(744, temp0)
690
691
temp0++
692
Copy16x16Tile(745, temp0)
693
694
GetTableValue(temp0, object.orb1AniTileFrame, HPZSetup_greenOrbFramesTable2)
695
Copy16x16Tile(750, temp0)
696
697
temp0++
698
Copy16x16Tile(751, temp0)
699
700
temp0++
701
Copy16x16Tile(752, temp0)
702
703
GetTableValue(temp0, object.orb1AniTileFrame, HPZSetup_purpleOrbFramesTable2)
704
Copy16x16Tile(759, temp0)
705
706
temp0++
707
Copy16x16Tile(760, temp0)
708
709
temp0++
710
Copy16x16Tile(761, temp0)
711
712
object.orb1AniTileFrame++
713
GetTableValue(object.orb1AniTileDelay, object.orb1AniTileFrame, HPZSetup_greenOrbFramesTable1)
714
715
object.orb1AniTileFrame++
716
object.orb1AniTileFrame &= 7
717
else
718
object.orb1AniTileDelay--
719
end if
720
721
if object.orb2AniTileDelay < 2
722
GetTableValue(temp0, object.orb2AniTileFrame, HPZSetup_greenOrbFramesTable1)
723
Copy16x16Tile(740, temp0)
724
725
temp0++
726
Copy16x16Tile(741, temp0)
727
728
GetTableValue(temp0, object.orb2AniTileFrame, HPZSetup_purpleOrbFramesTable1)
729
Copy16x16Tile(746, temp0)
730
731
temp0++
732
Copy16x16Tile(747, temp0)
733
734
GetTableValue(temp0, object.orb2AniTileFrame, HPZSetup_greenOrbFramesTable2)
735
Copy16x16Tile(753, temp0)
736
737
temp0++
738
Copy16x16Tile(754, temp0)
739
740
temp0++
741
Copy16x16Tile(755, temp0)
742
743
GetTableValue(temp0, object.orb2AniTileFrame, HPZSetup_purpleOrbFramesTable2)
744
Copy16x16Tile(762, temp0)
745
746
temp0++
747
Copy16x16Tile(763, temp0)
748
749
temp0++
750
Copy16x16Tile(764, temp0)
751
752
object.orb2AniTileFrame++
753
GetTableValue(object.orb2AniTileDelay, object.orb2AniTileFrame, HPZSetup_greenOrbFramesTable1)
754
755
object.orb2AniTileFrame++
756
object.orb2AniTileFrame &= 7
757
else
758
object.orb2AniTileDelay--
759
end if
760
761
if object.orb3AniTileDelay < 2
762
GetTableValue(temp0, object.orb3AniTileFrame, HPZSetup_greenOrbFramesTable1)
763
Copy16x16Tile(742, temp0)
764
temp0++
765
766
Copy16x16Tile(743, temp0)
767
768
GetTableValue(temp0, object.orb3AniTileFrame, HPZSetup_purpleOrbFramesTable1)
769
Copy16x16Tile(748, temp0)
770
temp0++
771
772
Copy16x16Tile(749, temp0)
773
774
GetTableValue(temp0, object.orb3AniTileFrame, HPZSetup_greenOrbFramesTable2)
775
Copy16x16Tile(756, temp0)
776
777
temp0++
778
Copy16x16Tile(757, temp0)
779
780
temp0++
781
Copy16x16Tile(758, temp0)
782
783
GetTableValue(temp0, object.orb3AniTileFrame, HPZSetup_purpleOrbFramesTable2)
784
Copy16x16Tile(765, temp0)
785
786
temp0++
787
Copy16x16Tile(766, temp0)
788
789
temp0++
790
Copy16x16Tile(767, temp0)
791
792
object.orb3AniTileFrame++
793
GetTableValue(object.orb3AniTileDelay, object.orb3AniTileFrame, HPZSetup_greenOrbFramesTable1)
794
795
object.orb3AniTileFrame++
796
object.orb3AniTileFrame &= 7
797
else
798
object.orb3AniTileDelay--
799
end if
800
801
if Water_flashTimer > 0
802
Water_flashTimer--
803
end if
804
805
temp0 = object.orbFrameTimer
806
temp0 /= 6
807
GetTableValue(HPZSetup_glowingOrbFrame, temp0, HPZSetup_orbFrameTable)
808
object.orbFrameTimer++
809
object.orbFrameTimer %= 84
810
811
// Check if any players are on waterslides
812
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
813
temp1 = player[currentPlayer].xpos
814
temp1 >>= 16
815
816
temp2 = player[currentPlayer].ypos
817
temp2 >>= 16
818
temp2 += player[currentPlayer].collisionBottom
819
temp2--
820
821
if player[currentPlayer].gravity == GRAVITY_GROUND
822
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEB)
823
if temp0 == TILE_WATERSLIDE
824
player[currentPlayer].state = Player_State_Waterslide
825
player[currentPlayer].direction = FACING_RIGHT
826
end if
827
end if
828
next
829
830
// Waterslide Sfx
831
if player[0].state == Player_State_Waterslide
832
if object.waterfallLoopTimer == 0
833
if object.playingWaterfallLoop == false
834
PlaySfx(SfxName[Waterfall], false)
835
StopSfx(SfxName[Waterfall Loop])
836
object.playingWaterfallLoop = true
837
else
838
StopSfx(SfxName[Waterfall])
839
PlaySfx(SfxName[Waterfall Loop], false)
840
end if
841
end if
842
843
object.waterfallLoopTimer++
844
object.waterfallLoopTimer &= 0x3F
845
else
846
if object.waterfallLoopTimer != 0
847
object.waterfallLoopTimer++
848
object.waterfallLoopTimer &= 0x3F
849
else
850
object.waterfallLoopTimer = 0
851
object.playingWaterfallLoop = false
852
end if
853
end if
854
855
if HPZSetup_hasAchievement == false
856
if stage.debugMode == false
857
if options.stageSelectFlag == false
858
if object[30].type == TypeName[Act Finish]
859
HPZSetup_hasAchievement = true
860
861
// Grant the "A Secret Revealed" Achievement
862
CallNativeFunction2(SetAchievement, ACHIEVEMENT_ASECRETREVEALED, 100)
863
end if
864
end if
865
end if
866
end if
867
end event
868
869
870
event ObjectDraw
871
temp0 = stage.waterLevel
872
temp0 -= screen.yoffset
873
if temp0 < 0
874
temp0 = 0
875
end if
876
877
if temp0 > screen.ysize
878
temp0 = screen.ysize
879
end if
880
881
SetActivePalette(0, 0, temp0)
882
if Water_flashTimer > 0
883
SetActivePalette(2, temp0, screen.ysize)
884
else
885
SetActivePalette(1, temp0, screen.ysize)
886
end if
887
888
AddDrawListEntityRef(2, object.entityPos)
889
end event
890
891
892
event ObjectStartup
893
if stage.actNum == 1
894
// Act 1 is the normal Hidden Palace Zone, as reachable in a normal playthrough
895
SetMusicTrack("MysticCave2.ogg", TRACK_STAGE, 18671) // see note up top as for why MUSIC_LOOP_MCZ_2P isn't being used here
896
SpeedUpMusic = HPZSetup_SpeedUpMusic
897
SlowDownMusic = HPZSetup_SlowDownMusic
898
else
899
// Act 2 is Proto Palace Zone, as a secret in the Sound Test
900
SetMusicTrack("Extra.ogg", TRACK_STAGE, MUSIC_LOOP_PPZ)
901
end if
902
903
if stage.player2Enabled == true
904
player[1].xpos = player[0].xpos
905
end if
906
907
animalType1 = TypeName[Rocky]
908
animalType2 = TypeName[Mocky]
909
910
SetPaletteEntry(0, 192, 0x000000)
911
912
object[SLOT_ZONESETUP].type = TypeName[HPZ Setup]
913
object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE
914
object[SLOT_ZONESETUP].drawOrder = 0
915
object[SLOT_ZONESETUP].orb2AniTileFrame = 2
916
object[SLOT_ZONESETUP].orb3AniTileFrame = 4
917
918
// Load the water palette
919
LoadPalette("HPZ_WaterPal.act", 1, 0, 0, 256)
920
921
// Initialize the Super palettes
922
CallFunction(HPZSetup_InitSuperSonicPal)
923
CallFunction(HPZSetup_InitSuperTailsPal)
924
CallFunction(HPZSetup_InitSuperKnuxPal)
925
#platform: USE_ORIGINS
926
CallFunction(HPZSetup_InitSuperAmyPal)
927
#endplatform
928
929
// Load the electric flash palette in case the player gets an eletric shield
930
LoadPalette("ElectricFlash.act", 2, 0, 0, 256)
931
932
Water_flashTimer = 0
933
HPZSetup_bossFightActive = false
934
935
// The Stage List Pos should be set to HPZ's entry already, but double-check just in case
936
stage.activeList = REGULAR_STAGE
937
stage.listPos = 20
938
939
SetLayerDeformation(1, 64, 2, 0, 0, 0)
940
941
temp0 = 0
942
while temp0 < 0x100
943
Rand(temp1, 4)
944
SetLayerDeformation(3, 16, temp1, 1, temp0, 16)
945
temp0 += 16
946
loop
947
end event
948
949
950
// ========================
951
// Editor Events
952
// ========================
953
954
event RSDKDraw
955
DrawSprite(0)
956
end event
957
958
959
event RSDKLoad
960
LoadSpriteSheet("Global/Display.gif")
961
SpriteFrame(-16, -16, 32, 32, 1, 143)
962
963
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
964
end event
965
966