1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
|
/*
* File: z_en_tite.c
* Overlay: ovl_En_Tite
* Description: Tektite
*/
#include "z_en_tite.h"
#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h"
#include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h"
#include "libc64/qrand.h"
#include "array_count.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "ichain.h"
#include "printf.h"
#include "segmented_address.h"
#include "sfx.h"
#include "sys_matrix.h"
#include "terminal.h"
#include "translation.h"
#include "z_en_item00.h"
#include "z_lib.h"
#include "effect.h"
#include "play_state.h"
#include "player.h"
#include "assets/objects/object_tite/object_tite.h"
#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE | ACTOR_FLAG_UPDATE_CULLING_DISABLED)
// EnTite_Idle
#define vIdleTimer actionVar1
// EnTite_Attack (vQueuedJumps also used by EnTite_MoveTowardPlayer)
#define vAttackState actionVar1
#define vQueuedJumps actionVar2
// EnTite_FlipOnBack
#define vOnBackTimer actionVar1
#define vLegTwitchTimer actionVar2
typedef enum EnTiteAction {
/* 0x0 */ TEKTITE_DEATH_CRY,
/* 0x1 */ TEKTITE_UNK_1,
/* 0x2 */ TEKTITE_UNK_2,
/* 0x3 */ TEKTITE_RECOIL,
/* 0x4 */ TEKTITE_UNK_4,
/* 0x5 */ TEKTITE_FALL_APART,
/* 0x6 */ TEKTITE_IDLE,
/* 0x7 */ TEKTITE_STUNNED,
/* 0x8 */ TEKTITE_UNK_8,
/* 0x9 */ TEKTITE_ATTACK,
/* 0xA */ TEKTITE_TURN_TOWARD_PLAYER,
/* 0xB */ TEKTITE_UNK9,
/* 0xC */ TEKTITE_MOVE_TOWARD_PLAYER
} EnTiteAction;
typedef enum EnTiteAttackState {
/* 0x0 */ TEKTITE_BEGIN_LUNGE,
/* 0x1 */ TEKTITE_MID_LUNGE,
/* 0x2 */ TEKTITE_LANDED,
/* 0x2 */ TEKTITE_SUBMERGED
} EnTiteAttackState;
typedef enum EnTiteFlipState {
/* 0x0 */ TEKTITE_INITIAL,
/* 0x1 */ TEKTITE_UNFLIPPED,
/* 0x2 */ TEKTITE_FLIPPED
} EnTiteFlipState;
void EnTite_Init(Actor* thisx, PlayState* play);
void EnTite_Destroy(Actor* thisx, PlayState* play);
void EnTite_Update(Actor* thisx, PlayState* play);
void EnTite_Draw(Actor* thisx, PlayState* play);
void EnTite_SetupIdle(EnTite* this);
void EnTite_SetupTurnTowardPlayer(EnTite* this);
void EnTite_SetupMoveTowardPlayer(EnTite* this);
void EnTite_SetupDeathCry(EnTite* this);
void EnTite_SetupFlipUpright(EnTite* this);
void EnTite_Idle(EnTite* this, PlayState* play);
void EnTite_Attack(EnTite* this, PlayState* play);
void EnTite_TurnTowardPlayer(EnTite* this, PlayState* play);
void EnTite_MoveTowardPlayer(EnTite* this, PlayState* play);
void EnTite_Recoil(EnTite* this, PlayState* play);
void EnTite_Stunned(EnTite* this, PlayState* play);
void EnTite_DeathCry(EnTite* this, PlayState* play);
void EnTite_FallApart(EnTite* this, PlayState* play);
void EnTite_FlipOnBack(EnTite* this, PlayState* play);
void EnTite_FlipUpright(EnTite* this, PlayState* play);
ActorProfile En_Tite_Profile = {
/**/ ACTOR_EN_TITE,
/**/ ACTORCAT_ENEMY,
/**/ FLAGS,
/**/ OBJECT_TITE,
/**/ sizeof(EnTite),
/**/ EnTite_Init,
/**/ EnTite_Destroy,
/**/ EnTite_Update,
/**/ EnTite_Draw,
};
static ColliderJntSphElementInit sJntSphElementsInit[] = {
{
{
ELEM_MATERIAL_UNK0,
{ 0xFFCFFFFF, HIT_SPECIAL_EFFECT_NONE, 0x08 },
{ 0xFFCFFFFF, HIT_BACKLASH_NONE, 0x00 },
ATELEM_ON | ATELEM_SFX_NORMAL,
ACELEM_ON | ACELEM_HOOKABLE,
OCELEM_ON,
},
{ 0, { { 0, 1500, 0 }, 20 }, 100 },
},
};
static ColliderJntSphInit sJntSphInit = {
{
COL_MATERIAL_HIT6,
AT_ON | AT_TYPE_ENEMY,
AC_ON | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_1,
COLSHAPE_JNTSPH,
},
ARRAY_COUNT(sJntSphElementsInit),
sJntSphElementsInit,
};
static DamageTable sDamageTable[] = {
/* Deku nut */ DMG_ENTRY(0, 0x1),
/* Deku stick */ DMG_ENTRY(2, 0x0),
/* Slingshot */ DMG_ENTRY(1, 0x0),
/* Explosive */ DMG_ENTRY(2, 0x0),
/* Boomerang */ DMG_ENTRY(0, 0x1),
/* Normal arrow */ DMG_ENTRY(2, 0x0),
/* Hammer swing */ DMG_ENTRY(2, 0x0),
/* Hookshot */ DMG_ENTRY(0, 0x1),
/* Kokiri sword */ DMG_ENTRY(1, 0x0),
/* Master sword */ DMG_ENTRY(2, 0x0),
/* Giant's Knife */ DMG_ENTRY(4, 0x0),
/* Fire arrow */ DMG_ENTRY(2, 0x0),
/* Ice arrow */ DMG_ENTRY(4, 0xF),
/* Light arrow */ DMG_ENTRY(2, 0x0),
/* Unk arrow 1 */ DMG_ENTRY(2, 0x0),
/* Unk arrow 2 */ DMG_ENTRY(2, 0x0),
/* Unk arrow 3 */ DMG_ENTRY(2, 0x0),
/* Fire magic */ DMG_ENTRY(0, 0xE),
/* Ice magic */ DMG_ENTRY(3, 0xF),
/* Light magic */ DMG_ENTRY(0, 0xE),
/* Shield */ DMG_ENTRY(0, 0x0),
/* Mirror Ray */ DMG_ENTRY(0, 0x0),
/* Kokiri spin */ DMG_ENTRY(1, 0x0),
/* Giant spin */ DMG_ENTRY(4, 0x0),
/* Master spin */ DMG_ENTRY(2, 0x0),
/* Kokiri jump */ DMG_ENTRY(2, 0x0),
/* Giant jump */ DMG_ENTRY(8, 0x0),
/* Master jump */ DMG_ENTRY(4, 0x0),
/* Unknown 1 */ DMG_ENTRY(0, 0x0),
/* Unblockable */ DMG_ENTRY(0, 0x0),
/* Hammer jump */ DMG_ENTRY(4, 0x0),
/* Unknown 2 */ DMG_ENTRY(0, 0x0),
};
static InitChainEntry sInitChain[] = {
ICHAIN_S8(naviEnemyId, NAVI_ENEMY_RED_TEKTITE, ICHAIN_CONTINUE),
ICHAIN_F32(lockOnArrowOffset, 2000, ICHAIN_CONTINUE),
ICHAIN_F32(minVelocityY, -40, ICHAIN_CONTINUE),
ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP),
};
static AnimationHeader* D_80B1B634[] = {
&object_tite_Anim_00083C, &object_tite_Anim_0004F8, &object_tite_Anim_00069C, NULL, NULL, NULL,
};
// Some kind of offset for the position of each tektite foot
static Vec3f sFootOffset = { 2800.0f, -200.0f, 0.0f };
// Relative positions to spawn ice chunks when tektite is frozen
static Vec3f sIceChunks[12] = {
{ 20.0f, 20.0f, 0.0f }, { 10.0f, 40.0f, 10.0f }, { -10.0f, 40.0f, 10.0f }, { -20.0f, 20.0f, 0.0f },
{ 10.0f, 40.0f, -10.0f }, { -10.0f, 40.0f, -10.0f }, { 0.0f, 20.0f, -20.0f }, { 10.0f, 0.0f, 10.0f },
{ 10.0f, 0.0f, -10.0f }, { 0.0f, 20.0f, 20.0f }, { -10.0f, 0.0f, 10.0f }, { -10.0f, 0.0f, -10.0f },
};
void EnTite_SetupAction(EnTite* this, EnTiteActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
void EnTite_Init(Actor* thisx, PlayState* play) {
EnTite* this = (EnTite*)thisx;
Actor_ProcessInitChain(thisx, sInitChain);
thisx->attentionRangeType = ATTENTION_RANGE_3;
Actor_SetScale(thisx, 0.01f);
SkelAnime_Init(play, &this->skelAnime, &object_tite_Skel_003A20, &object_tite_Anim_0012E4, this->jointTable,
this->morphTable, 25);
ActorShape_Init(&thisx->shape, -200.0f, ActorShadow_DrawCircle, 70.0f);
this->flipState = TEKTITE_INITIAL;
thisx->colChkInfo.damageTable = sDamageTable;
this->actionVar1 = 0;
this->bodyBreak.val = BODYBREAK_STATUS_FINISHED;
thisx->focus.pos = thisx->world.pos;
thisx->focus.pos.y += 20.0f;
thisx->colChkInfo.health = 2;
thisx->colChkInfo.mass = MASS_HEAVY;
Collider_InitJntSph(play, &this->collider);
Collider_SetJntSph(play, &this->collider, thisx, &sJntSphInit, this->colliderElements);
this->unk_2DC = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4;
if (this->actor.params == TEKTITE_BLUE) {
this->unk_2DC |= UPDBGCHECKINFO_FLAG_6; // Don't use the actor engine's ripple spawning code
thisx->colChkInfo.health = 4;
thisx->naviEnemyId += NAVI_ENEMY_BLUE_TEKTITE - NAVI_ENEMY_RED_TEKTITE;
}
EnTite_SetupIdle(this);
}
void EnTite_Destroy(Actor* thisx, PlayState* play) {
EnTite* this = (EnTite*)thisx;
EnEncount1* spawner;
if (thisx->parent != NULL) {
spawner = (EnEncount1*)thisx->parent;
if (spawner->curNumSpawn > 0) {
spawner->curNumSpawn--;
}
PRINTF("\n\n");
PRINTF(VT_FGCOL(GREEN) T("☆☆☆☆☆ 同時発生数 ☆☆☆☆☆%d\n", "☆☆☆☆☆ Number of simultaneous spawns ☆☆☆☆☆%d\n") VT_RST,
spawner->curNumSpawn);
PRINTF("\n\n");
}
Collider_DestroyJntSph(play, &this->collider);
}
void EnTite_SetupIdle(EnTite* this) {
Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f);
this->action = TEKTITE_IDLE;
this->vIdleTimer = Rand_S16Offset(15, 30);
this->actor.speed = 0.0f;
EnTite_SetupAction(this, EnTite_Idle);
}
void EnTite_Idle(EnTite* this, PlayState* play) {
SkelAnime_Update(&this->skelAnime);
Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f);
if (this->actor.params == TEKTITE_BLUE) {
if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) {
// Float on water surface
this->actor.gravity = 0.0f;
Math_SmoothStepToF(&this->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f);
Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.depthInWater, 1.0f, 2.0f,
0.0f);
} else {
this->actor.gravity = -1.0f;
}
}
if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) &&
(this->actor.velocity.y <= 0.0f)) {
this->actor.velocity.y = 0.0f;
}
if (this->vIdleTimer > 0) {
this->vIdleTimer--;
} else if ((this->actor.xzDistToPlayer < 300.0f) && (this->actor.yDistToPlayer <= 80.0f)) {
EnTite_SetupTurnTowardPlayer(this);
}
}
void EnTite_SetupAttack(EnTite* this) {
Animation_PlayOnce(&this->skelAnime, &object_tite_Anim_00083C);
this->action = TEKTITE_ATTACK;
this->vAttackState = TEKTITE_BEGIN_LUNGE;
this->vQueuedJumps = Rand_S16Offset(1, 3);
this->actor.speed = 0.0f;
this->actor.velocity.y = 0.0f;
this->actor.world.rot.y = this->actor.shape.rot.y;
EnTite_SetupAction(this, EnTite_Attack);
}
void EnTite_Attack(EnTite* this, PlayState* play) {
s16 angleToPlayer;
s32 attackState;
if (SkelAnime_Update(&this->skelAnime)) {
attackState = this->vAttackState; // for deciding whether to change animation
switch (this->vAttackState) {
case TEKTITE_BEGIN_LUNGE:
// Snap to ground or water, then lunge into the air with some initial speed
this->vAttackState = TEKTITE_MID_LUNGE;
if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
if (this->actor.floorHeight > BGCHECK_Y_MIN) {
this->actor.world.pos.y = this->actor.floorHeight;
}
Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_JUMP);
} else {
this->actor.world.pos.y += this->actor.depthInWater;
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP_WATER);
}
this->actor.velocity.y = 8.0f;
this->actor.gravity = -1.0f;
this->actor.speed = 4.0f;
break;
case TEKTITE_MID_LUNGE:
// Continue trajectory until tektite has negative velocity and has landed on ground/water surface
// Snap to ground/water surface, or if falling fast dip into the water and slow fall speed
this->actor.flags |= ACTOR_FLAG_SFX_FOR_PLAYER_BODY_HIT;
if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER))) {
if (this->actor.velocity.y <= 0.0f) {
this->vAttackState = TEKTITE_LANDED;
if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
if (BGCHECK_Y_MIN < this->actor.floorHeight) {
this->actor.world.pos.y = this->actor.floorHeight;
}
this->actor.velocity.y = 0.0f;
this->actor.speed = 0.0f;
} else {
this->actor.gravity = 0.0f;
if (this->actor.velocity.y < -8.0f) {
Vec3f ripplePos = this->actor.world.pos;
ripplePos.y += this->actor.depthInWater;
this->vAttackState++; // TEKTITE_SUBMERGED
this->actor.velocity.y *= 0.75f;
attackState = this->vAttackState;
EffectSsGRipple_Spawn(play, &ripplePos, 0, 500, 0);
} else {
this->actor.velocity.y = 0.0f;
this->actor.speed = 0.0f;
}
}
this->actor.world.rot.y = this->actor.shape.rot.y;
}
}
break;
case TEKTITE_LANDED:
// Get ready to begin another lunge if more lunges are queued, otherwise start turning
if (this->vQueuedJumps != 0) {
this->vQueuedJumps--;
this->vAttackState = TEKTITE_BEGIN_LUNGE;
this->collider.base.atFlags &= ~AT_HIT;
} else {
EnTite_SetupTurnTowardPlayer(this);
}
break;
case TEKTITE_SUBMERGED:
// Check if floated to surface
if (this->actor.depthInWater == 0.0f) {
this->vAttackState = TEKTITE_LANDED;
attackState = this->vAttackState;
}
break;
}
// If switching attack state, change animation (unless tektite is switching between submerged and landed)
if (attackState != this->vAttackState) {
Animation_PlayOnce(&this->skelAnime, D_80B1B634[this->vAttackState]);
}
}
switch (this->vAttackState) {
case TEKTITE_BEGIN_LUNGE:
// Slightly turn to player and switch to turning/idling action if the player is too far
Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 1000, 0);
this->actor.shape.rot.y = this->actor.world.rot.y;
angleToPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
if ((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f)) {
EnTite_SetupIdle(this);
} else if (ABS(angleToPlayer) >= 9000) {
EnTite_SetupTurnTowardPlayer(this);
}
break;
case TEKTITE_MID_LUNGE:
// Generate sparkles at feet upon landing, set jumping animation and attack collider and check if hit player
if (this->actor.velocity.y >= 5.0f) {
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) {
func_800355B8(play, &this->frontLeftFootPos);
func_800355B8(play, &this->frontRightFootPos);
func_800355B8(play, &this->backRightFootPos);
func_800355B8(play, &this->backLeftFootPos);
}
}
if (!(this->collider.base.atFlags & AT_HIT) && (this->actor.flags & ACTOR_FLAG_INSIDE_CULLING_VOLUME)) {
CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base);
} else {
Player* player = GET_PLAYER(play);
this->collider.base.atFlags &= ~AT_HIT;
Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f);
this->actor.speed = -6.0f;
this->actor.world.rot.y = this->actor.yawTowardsPlayer;
if (&player->actor == this->collider.base.at) {
if (!(this->collider.base.atFlags & AT_BOUNCED)) {
Actor_PlaySfx(&player->actor, NA_SE_PL_BODY_HIT);
}
}
EnTite_SetupAction(this, EnTite_Recoil);
}
break;
case TEKTITE_LANDED:
// Slightly turn to player
Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 1500, 0);
break;
case TEKTITE_SUBMERGED:
// Float up to water surface
Math_SmoothStepToF(&this->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f);
Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f);
Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.depthInWater, 1.0f, 2.0f,
0.0f);
break;
}
// Create ripples on water surface where tektite feet landed
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
func_80033480(play, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1);
}
}
// if landed, kill XZ speed and play appropriate sound effect
if (this->actor.params == TEKTITE_BLUE) {
if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) {
this->actor.speed = 0.0f;
if (this->vAttackState == TEKTITE_SUBMERGED) {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER);
} else {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER2);
}
this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH;
} else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND);
}
} else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
this->actor.speed = 0.0f;
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND);
}
}
void EnTite_SetupTurnTowardPlayer(EnTite* this) {
Animation_PlayLoop(&this->skelAnime, &object_tite_Anim_000A14);
this->action = TEKTITE_TURN_TOWARD_PLAYER;
if ((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER))) {
if (this->actor.velocity.y <= 0.0f) {
this->actor.gravity = 0.0f;
this->actor.velocity.y = 0.0f;
this->actor.speed = 0.0f;
}
}
EnTite_SetupAction(this, EnTite_TurnTowardPlayer);
}
void EnTite_TurnTowardPlayer(EnTite* this, PlayState* play) {
s16 angleToPlayer;
s16 turnVelocity;
if (((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER))) &&
(this->actor.velocity.y <= 0.0f)) {
this->actor.gravity = 0.0f;
this->actor.velocity.y = 0.0f;
this->actor.speed = 0.0f;
}
// Calculate turn velocity and animation speed based on angle to player
if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
this->actor.world.pos.y += this->actor.depthInWater;
}
angleToPlayer = Actor_WorldYawTowardActor(&this->actor, &GET_PLAYER(play)->actor) - this->actor.world.rot.y;
if (angleToPlayer > 0) {
turnVelocity = (angleToPlayer / 42.0f) + 10.0f;
this->actor.world.rot.y += (turnVelocity * 2);
} else {
turnVelocity = (angleToPlayer / 42.0f) - 10.0f;
this->actor.world.rot.y += (turnVelocity * 2);
}
if (angleToPlayer > 0) {
this->skelAnime.playSpeed = turnVelocity * 0.01f;
} else {
this->skelAnime.playSpeed = turnVelocity * 0.01f;
}
/**
* Play sound effect once every animation cycle
*/
SkelAnime_Update(&this->skelAnime);
if (((s16)this->skelAnime.curFrame & 7) == 0) {
if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_WALK_WATER);
} else {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_WALK);
}
}
// Idle if player is far enough away from the tektite, move or attack if almost facing player
this->actor.shape.rot.y = this->actor.world.rot.y;
if ((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f)) {
EnTite_SetupIdle(this);
} else if (Actor_IsFacingPlayer(&this->actor, 3640)) {
if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) {
EnTite_SetupAttack(this);
} else {
EnTite_SetupMoveTowardPlayer(this);
}
}
}
void EnTite_SetupMoveTowardPlayer(EnTite* this) {
Animation_PlayLoop(&this->skelAnime, &object_tite_Anim_000C70);
this->action = TEKTITE_MOVE_TOWARD_PLAYER;
this->actor.velocity.y = 10.0f;
this->actor.gravity = -1.0f;
this->actor.speed = 4.0f;
this->vQueuedJumps = Rand_S16Offset(1, 3);
if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP_WATER);
} else {
Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_JUMP);
}
EnTite_SetupAction(this, EnTite_MoveTowardPlayer);
}
/**
* Jumping toward player as a method of travel (different from attacking, has no hitbox)
*/
void EnTite_MoveTowardPlayer(EnTite* this, PlayState* play) {
Math_SmoothStepToF(&this->actor.speed, 0.0f, 0.1f, 1.0f, 0.0f);
SkelAnime_Update(&this->skelAnime);
if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WATER_TOUCH)) {
if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) {
func_80033480(play, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1);
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND);
} else {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER);
}
}
if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH))) {
if (this->vQueuedJumps != 0) {
this->vQueuedJumps--;
} else {
EnTite_SetupIdle(this);
}
}
if (((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) ||
(this->actor.params == TEKTITE_BLUE &&
(this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)))) &&
(this->actor.velocity.y <= 0.0f)) {
// slightly turn toward player upon landing and snap to ground or water.
this->actor.speed = 0.0f;
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 4000, 0);
this->actor.world.rot.y = this->actor.shape.rot.y;
if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
if (this->actor.floorHeight > BGCHECK_Y_MIN) {
this->actor.world.pos.y = this->actor.floorHeight;
}
} else if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) {
Vec3f ripplePos = this->actor.world.pos;
this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH;
ripplePos.y += this->actor.depthInWater;
this->actor.gravity = 0.0f;
this->actor.velocity.y *= 0.75f;
EffectSsGRipple_Spawn(play, &ripplePos, 0, 500, 0);
return;
} else {
// If submerged, float to surface
Math_SmoothStepToF(&this->actor.velocity.y, 0.0f, 1.0f, 2.0f, 0.0f);
Math_SmoothStepToF(&this->actor.world.pos.y, this->actor.world.pos.y + this->actor.depthInWater, 1.0f, 2.0f,
0.0f);
if (this->actor.depthInWater != 0.0f) {
// Do not change state until tekite has floated to surface
return;
}
}
// Idle or turn if player is too far away, otherwise keep jumping
if (((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f))) {
EnTite_SetupIdle(this);
} else if ((this->actor.xzDistToPlayer <= 180.0f) && (this->actor.yDistToPlayer <= 80.0f)) {
if (this->vQueuedJumps <= 0) {
EnTite_SetupTurnTowardPlayer(this);
} else {
this->actor.velocity.y = 10.0f;
this->actor.speed = 4.0f;
this->actor.flags |= ACTOR_FLAG_SFX_FOR_PLAYER_BODY_HIT;
this->actor.gravity = -1.0f;
if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP_WATER);
} else {
Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_JUMP);
}
}
} else {
this->actor.velocity.y = 10.0f;
this->actor.speed = 4.0f;
this->actor.flags |= ACTOR_FLAG_SFX_FOR_PLAYER_BODY_HIT;
this->actor.gravity = -1.0f;
if ((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_JUMP_WATER);
} else {
Actor_PlaySfx(&this->actor, NA_SE_EN_STAL_JUMP);
}
}
// If in midair:
} else {
// Turn slowly toward player
this->actor.flags |= ACTOR_FLAG_SFX_FOR_PLAYER_BODY_HIT;
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 1000, 0);
if (this->actor.velocity.y >= 6.0f) {
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) {
func_800355B8(play, &this->frontLeftFootPos);
func_800355B8(play, &this->frontRightFootPos);
func_800355B8(play, &this->backRightFootPos);
func_800355B8(play, &this->backLeftFootPos);
}
}
}
}
void EnTite_SetupRecoil(EnTite* this) {
this->action = TEKTITE_RECOIL;
Animation_MorphToLoop(&this->skelAnime, &object_tite_Anim_0012E4, 4.0f);
this->actor.speed = -6.0f;
this->actor.world.rot.y = this->actor.yawTowardsPlayer;
this->actor.gravity = -1.0f;
EnTite_SetupAction(this, EnTite_Recoil);
}
/**
* After tektite hits or gets hit, recoils backwards and slides a bit upon landing
*/
void EnTite_Recoil(EnTite* this, PlayState* play) {
s16 angleToPlayer;
// Snap to ground or water surface upon landing
Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f);
if (((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) ||
(this->actor.params == TEKTITE_BLUE && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER))) &&
(this->actor.velocity.y <= 0.0f)) {
if ((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) {
if (this->actor.floorHeight > BGCHECK_Y_MIN) {
this->actor.world.pos.y = this->actor.floorHeight;
}
} else {
this->actor.velocity.y = 0.0f;
this->actor.gravity = 0.0f;
this->actor.world.pos.y += this->actor.depthInWater;
}
}
// play sound effect and generate ripples
if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WATER_TOUCH)) {
if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) {
func_80033480(play, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1);
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND);
} else {
this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH;
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER2);
}
}
// If player is far away, idle. Otherwise attack or move
angleToPlayer = (this->actor.yawTowardsPlayer - this->actor.shape.rot.y);
if ((this->actor.speed == 0.0f) &&
((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)))) {
this->actor.world.rot.y = this->actor.shape.rot.y;
this->collider.base.atFlags &= ~AT_HIT;
if ((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f) &&
(ABS(this->actor.shape.rot.x) < 4000) && (ABS(this->actor.shape.rot.z) < 4000) &&
((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)))) {
EnTite_SetupIdle(this);
} else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) &&
(ABS(angleToPlayer) <= 6000)) {
EnTite_SetupAttack(this);
} else {
EnTite_SetupMoveTowardPlayer(this);
}
}
SkelAnime_Update(&this->skelAnime);
}
void EnTite_SetupStunned(EnTite* this) {
Animation_Change(&this->skelAnime, &object_tite_Anim_0012E4, 0.0f, 0.0f,
(f32)Animation_GetLastFrame(&object_tite_Anim_0012E4), ANIMMODE_LOOP, 4.0f);
this->action = TEKTITE_STUNNED;
this->actor.speed = -6.0f;
this->actor.world.rot.y = this->actor.yawTowardsPlayer;
if (this->damageReaction == 0xF) {
this->spawnIceTimer = 48;
}
Actor_PlaySfx(&this->actor, NA_SE_EN_GOMA_JR_FREEZE);
EnTite_SetupAction(this, EnTite_Stunned);
}
/**
* stunned or frozen
*/
void EnTite_Stunned(EnTite* this, PlayState* play) {
s16 angleToPlayer;
Math_SmoothStepToF(&this->actor.speed, 0.0f, 1.0f, 0.5f, 0.0f);
// Snap to ground or water
if (((this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER))) &&
(this->actor.velocity.y <= 0.0f)) {
if (((this->actor.params != TEKTITE_BLUE) || !(this->actor.bgCheckFlags & BGCHECKFLAG_WATER))) {
if (this->actor.floorHeight > BGCHECK_Y_MIN) {
this->actor.world.pos.y = this->actor.floorHeight;
}
} else {
this->actor.velocity.y = 0.0f;
this->actor.gravity = 0.0f;
this->actor.world.pos.y += this->actor.depthInWater;
}
}
// Play sound effect and spawn dirt effects upon landing
if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_WATER_TOUCH)) {
if (!(this->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH)) {
func_80033480(play, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1);
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND);
} else {
this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER_TOUCH;
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_LAND_WATER2);
}
}
// Decide on next action based on health, flip state and player distance
angleToPlayer = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
if (((this->actor.colorFilterTimer == 0) && (this->actor.speed == 0.0f)) &&
((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)))) {
this->actor.world.rot.y = this->actor.shape.rot.y;
if (this->actor.colChkInfo.health == 0) {
EnTite_SetupDeathCry(this);
} else if (this->flipState == TEKTITE_FLIPPED) {
EnTite_SetupFlipUpright(this);
} else if (((this->actor.xzDistToPlayer > 300.0f) && (this->actor.yDistToPlayer > 80.0f) &&
(ABS(this->actor.shape.rot.x) < 4000) && (ABS(this->actor.shape.rot.z) < 4000)) &&
((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ||
((this->actor.params == TEKTITE_BLUE) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)))) {
EnTite_SetupIdle(this);
} else if ((this->actor.xzDistToPlayer < 180.0f) && (this->actor.yDistToPlayer <= 80.0f) &&
(ABS(angleToPlayer) <= 6000)) {
EnTite_SetupAttack(this);
} else {
EnTite_SetupMoveTowardPlayer(this);
}
}
SkelAnime_Update(&this->skelAnime);
}
void EnTite_SetupDeathCry(EnTite* this) {
this->action = TEKTITE_DEATH_CRY;
this->actor.colorFilterTimer = 0;
this->actor.speed = 0.0f;
EnTite_SetupAction(this, EnTite_DeathCry);
}
/**
* First frame of death. Scream in pain and allocate memory for EnPart data
*/
void EnTite_DeathCry(EnTite* this, PlayState* play) {
EffectSsDeadSound_SpawnStationary(play, &this->actor.projectedPos, NA_SE_EN_TEKU_DEAD, true,
DEADSOUND_REPEAT_MODE_OFF, 40);
this->action = TEKTITE_FALL_APART;
EnTite_SetupAction(this, EnTite_FallApart);
BodyBreak_Alloc(&this->bodyBreak, 24, play);
}
/**
* Spawn EnPart and drop items
*/
void EnTite_FallApart(EnTite* this, PlayState* play) {
if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, this->actor.params + 0xB)) {
if (this->actor.params == TEKTITE_BLUE) {
Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos,
COLLECTIBLE_DROP_RANDOM_PARAMS(COLLECTIBLE_DROP_TABLE_14, false));
} else {
Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos,
COLLECTIBLE_DROP_RANDOM_PARAMS(COLLECTIBLE_DROP_TABLE_4, false));
}
Actor_Kill(&this->actor);
}
}
void EnTite_SetupFlipOnBack(EnTite* this) {
Animation_PlayLoopSetSpeed(&this->skelAnime, &object_tite_Anim_000A14, 1.5f);
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_REVERSE);
this->flipState = TEKTITE_FLIPPED;
this->vOnBackTimer = 500;
this->actor.speed = 0.0f;
this->actor.gravity = -1.0f;
this->vLegTwitchTimer = (Rand_ZeroOne() * 50.0f);
this->actor.velocity.y = 11.0f;
EnTite_SetupAction(this, EnTite_FlipOnBack);
}
/**
* During the flip animation and also while idling on back
*/
void EnTite_FlipOnBack(EnTite* this, PlayState* play) {
Math_SmoothStepToS(&this->actor.shape.rot.z, 0x7FFF, 1, 4000, 0);
// randomly reset the leg wiggling animation whenever timer reaches 0 to give illusion of twitching legs
this->vLegTwitchTimer--;
if (this->vLegTwitchTimer == 0) {
this->vLegTwitchTimer = Rand_ZeroOne() * 30.0f;
this->skelAnime.curFrame = Rand_ZeroOne() * 5.0f;
}
SkelAnime_Update(&this->skelAnime);
if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
// Upon landing, spawn dust and make noise
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 20.0f, 11, 4.0f, 0, 0, false);
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND);
}
this->vOnBackTimer--;
if (this->vOnBackTimer == 0) {
EnTite_SetupFlipUpright(this);
}
} else {
// Gradually increase y offset during flip so that the actor position is at tektite's back instead of feet
if (this->actor.shape.yOffset < 2800.0f) {
this->actor.shape.yOffset += 400.0f;
}
}
}
void EnTite_SetupFlipUpright(EnTite* this) {
this->flipState = TEKTITE_UNFLIPPED;
this->actionVar1 = 1000; // value unused here and overwritten in SetupIdle
//! @bug flying tektite: water sets gravity to 0 so y velocity will never decrease from 13
this->actor.velocity.y = 13.0f;
Actor_PlaySfx(&this->actor, NA_SE_EN_TEKU_REVERSE);
EnTite_SetupAction(this, EnTite_FlipUpright);
}
void EnTite_FlipUpright(EnTite* this, PlayState* play) {
Math_SmoothStepToS(&this->actor.shape.rot.z, 0, 1, 0xFA0, 0);
SkelAnime_Update(&this->skelAnime);
//! @bug flying tektite: the following condition is never met and tektite stays stuck in this action forever
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
func_80033480(play, &this->frontLeftFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->frontRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backRightFootPos, 1.0f, 2, 80, 15, 1);
func_80033480(play, &this->backLeftFootPos, 1.0f, 2, 80, 15, 1);
this->actor.shape.yOffset = 0.0f;
this->actor.world.pos.y = this->actor.floorHeight;
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND);
EnTite_SetupIdle(this);
}
}
void EnTite_CheckDamage(Actor* thisx, PlayState* play) {
EnTite* this = (EnTite*)thisx;
if ((this->collider.base.acFlags & AC_HIT) && (this->action >= TEKTITE_IDLE)) {
this->collider.base.acFlags &= ~AC_HIT;
if (thisx->colChkInfo.damageReaction != 0xE) { // Immune to fire magic
this->damageReaction = thisx->colChkInfo.damageReaction;
Actor_SetDropFlag(thisx, &this->collider.elements[0].base, false);
// Stun if Tektite hit by nut, boomerang, hookshot, ice arrow or ice magic
if ((thisx->colChkInfo.damageReaction == 1) || (thisx->colChkInfo.damageReaction == 0xF)) {
if (this->action != TEKTITE_STUNNED) {
Actor_SetColorFilter(thisx, COLORFILTER_COLORFLAG_BLUE, 120, COLORFILTER_BUFFLAG_OPA, 80);
Actor_ApplyDamage(thisx);
EnTite_SetupStunned(this);
}
// Otherwise apply damage and handle death where necessary
} else {
if ((thisx->colorFilterTimer == 0) || ((thisx->colorFilterParams & 0x4000) == 0)) {
Actor_SetColorFilter(thisx, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8);
Actor_ApplyDamage(thisx);
}
if (thisx->colChkInfo.health == 0) {
EnTite_SetupDeathCry(this);
} else {
// Flip tektite back up if it's on its back
Actor_PlaySfx(thisx, NA_SE_EN_TEKU_DAMAGE);
if (this->flipState != TEKTITE_FLIPPED) {
EnTite_SetupRecoil(this);
} else {
EnTite_SetupFlipUpright(this);
}
}
}
}
// If hammer has recently hit the floor and player is close to tektite, flip over
} else if ((thisx->colChkInfo.health != 0) && (play->actorCtx.unk_02 != 0) && (thisx->xzDistToPlayer <= 400.0f) &&
(thisx->bgCheckFlags & BGCHECKFLAG_GROUND)) {
if (this->flipState == TEKTITE_FLIPPED) {
EnTite_SetupFlipUpright(this);
} else if ((this->action >= TEKTITE_IDLE) || (this->action >= TEKTITE_IDLE)) {
if (1) {}
EnTite_SetupFlipOnBack(this);
}
}
}
void EnTite_Update(Actor* thisx, PlayState* play) {
EnTite* this = (EnTite*)thisx;
char pad[0x4];
CollisionPoly* floorPoly;
WaterBox* waterBox;
f32 waterSurfaceY;
EnTite_CheckDamage(thisx, play);
// Stay still if hit by immunity damage type this frame
if (thisx->colChkInfo.damageReaction != 0xE) {
this->actionFunc(this, play);
Actor_MoveXZGravity(thisx);
Actor_UpdateBgCheckInfo(play, thisx, 25.0f, 40.0f, 20.0f, this->unk_2DC);
// If on water, snap feet to surface and spawn ripples
if ((this->actor.params == TEKTITE_BLUE) && (thisx->bgCheckFlags & BGCHECKFLAG_WATER)) {
floorPoly = thisx->floorPoly;
if ((((play->gameplayFrames % 8) == 0) || (thisx->velocity.y < 0.0f)) &&
(WaterBox_GetSurfaceImpl(play, &play->colCtx, this->backRightFootPos.x, this->backRightFootPos.z,
&waterSurfaceY, &waterBox)) &&
(this->backRightFootPos.y <= waterSurfaceY)) {
this->backRightFootPos.y = waterSurfaceY;
EffectSsGRipple_Spawn(play, &this->backRightFootPos, 0, 220, 0);
}
if (((((play->gameplayFrames + 2) % 8) == 0) || (thisx->velocity.y < 0.0f)) &&
(WaterBox_GetSurfaceImpl(play, &play->colCtx, this->backLeftFootPos.x, this->backLeftFootPos.z,
&waterSurfaceY, &waterBox)) &&
(this->backLeftFootPos.y <= waterSurfaceY)) {
this->backLeftFootPos.y = waterSurfaceY;
EffectSsGRipple_Spawn(play, &this->backLeftFootPos, 0, 220, 0);
}
if (((((play->gameplayFrames + 4) % 8) == 0) || (thisx->velocity.y < 0.0f)) &&
(WaterBox_GetSurfaceImpl(play, &play->colCtx, this->frontLeftFootPos.x, this->frontLeftFootPos.z,
&waterSurfaceY, &waterBox)) &&
(this->frontLeftFootPos.y <= waterSurfaceY)) {
this->frontLeftFootPos.y = waterSurfaceY;
EffectSsGRipple_Spawn(play, &this->frontLeftFootPos, 0, 220, 0);
}
if (((((play->gameplayFrames + 1) % 8) == 0) || (thisx->velocity.y < 0.0f)) &&
(WaterBox_GetSurfaceImpl(play, &play->colCtx, this->frontRightFootPos.x, this->frontRightFootPos.z,
&waterSurfaceY, &waterBox)) &&
(this->frontRightFootPos.y <= waterSurfaceY)) {
this->frontRightFootPos.y = waterSurfaceY;
EffectSsGRipple_Spawn(play, &this->frontRightFootPos, 0, 220, 0);
}
thisx->floorPoly = floorPoly;
}
// If on ground and currently flipped over, set tektite to be fully upside-down
if (thisx->bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
func_800359B8(thisx, thisx->shape.rot.y, &thisx->shape.rot);
if (this->flipState >= TEKTITE_FLIPPED) {
thisx->shape.rot.z += 0x7FFF;
}
// Otherwise ensure the tektite is rotating back upright
} else {
Math_SmoothStepToS(&thisx->shape.rot.x, 0, 1, 1000, 0);
if (this->flipState <= TEKTITE_UNFLIPPED) {
Math_SmoothStepToS(&thisx->shape.rot.z, 0, 1, 1000, 0);
if (thisx->shape.yOffset > 0) {
thisx->shape.yOffset -= 400.0f;
}
}
}
}
thisx->focus.pos = thisx->world.pos;
thisx->focus.pos.y += 20.0f;
CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base);
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
}
void EnTite_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** limbDList, Vec3s* rot, void* thisx) {
EnTite* this = (EnTite*)thisx;
switch (limbIndex) {
case 8:
Matrix_MultVec3f(&sFootOffset, &this->backRightFootPos);
break;
case 13:
Matrix_MultVec3f(&sFootOffset, &this->frontRightFootPos);
break;
case 18:
Matrix_MultVec3f(&sFootOffset, &this->backLeftFootPos);
break;
case 23:
Matrix_MultVec3f(&sFootOffset, &this->frontLeftFootPos);
break;
}
BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 24, 24, limbDList, BODYBREAK_OBJECT_SLOT_DEFAULT);
}
void EnTite_Draw(Actor* thisx, PlayState* play) {
EnTite* this = (EnTite*)thisx;
OPEN_DISPS(play->state.gfxCtx, "../z_en_tite.c", 1704);
Gfx_SetupDL_25Opa(play->state.gfxCtx);
Collider_UpdateSpheres(0, &this->collider);
if (this->actor.params == TEKTITE_BLUE) {
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001300));
gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001700));
gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001900));
} else {
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001B00));
gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(object_tite_Tex_001F00));
gSPSegment(POLY_OPA_DISP++, 0x0A, SEGMENTED_TO_VIRTUAL(object_tite_Tex_002100));
}
SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnTite_PostLimbDraw, thisx);
CLOSE_DISPS(play->state.gfxCtx, "../z_en_tite.c", 1735);
if (this->spawnIceTimer != 0) {
// Spawn chunks of ice all over the tektite's body
thisx->colorFilterTimer++;
this->spawnIceTimer--;
if ((this->spawnIceTimer & 3) == 0) {
Vec3f iceChunk;
s32 idx = this->spawnIceTimer >> 2;
iceChunk.x = thisx->world.pos.x + sIceChunks[idx].x;
iceChunk.y = thisx->world.pos.y + sIceChunks[idx].y;
iceChunk.z = thisx->world.pos.z + sIceChunks[idx].z;
EffectSsEnIce_SpawnFlyingVec3f(play, &this->actor, &iceChunk, 150, 150, 150, 250, 235, 245, 255, 1.0f);
}
}
}
|