forked from zeldaret/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd_a_npc_ne.cpp
More file actions
3511 lines (3192 loc) · 123 KB
/
d_a_npc_ne.cpp
File metadata and controls
3511 lines (3192 loc) · 123 KB
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
/**
* d_a_npc_ne.cpp
* NPC - Cat
*/
#include "d/dolzel_rel.h"
#include "d/actor/d_a_npc_ne.h"
#include "SSystem/SComponent/c_counter.h"
#include "d/d_com_inf_game.h"
#include "d/actor/d_a_player.h"
#include "d/d_procname.h"
#include "d/actor/d_a_mg_rod.h"
#include "d/actor/d_a_mg_fish.h"
#include "SSystem/SComponent/c_math.h"
#include "JSystem/JUtility/JUTReport.h"
#include "f_op/f_op_camera_mng.h"
#include "f_op/f_op_kankyo_mng.h"
#include "c/c_damagereaction.h"
/* 80A925F0-80A92850 000000 0260+00 3/3 0/0 0/0 .data home_path */
static home_path_pnt home_path[38] = {
{0, {561.0f, 87.0f, -1110.0f}},
{1, {306.0f, 87.0f, -849.0f}},
{2, {158.0f, 139.0f, -929.0f}},
{3, {137.0f, 145.0f, -1055.0f}},
{4, {332.0f, 481.0f, -1113.0f}},
{5, {710.0f, 697.0f, -1275.0f}},
{6, {1005.0f, 766.0f, -1423.0f}},
{3, {-6.0f, 178.0f, -990.0f}},
{4, {155.0f, 132.0f, -1606.0f}},
{5, {482.0f, 93.0f, -1997.0f}},
{6, {775.0f, 70.0f, -2280.0f}},
{7, {1185.0f, 75.0f, -2458.0f}},
{2, {107.0f, 127.0f, -556.0f}},
{3, {363.0f, 150.0f, 44.0f}},
{4, {527.0f, 203.0f, 849.0f}},
{5, {989.0f, 94.0f, 1872.0f}},
{6, {1346.0f, 267.0f, 2454.0f}},
{7, {1670.0f, 179.0f, 2923.0f}},
{8, {2129.0f, 100.0f, 3308.0f}},
{9, {2967.0f, 120.0f, 3215.0f}},
{10, {3427.0f, 185.0f, 2506.0f}},
{11, {3675.0f, 185.0f, 1778.0f}},
{12, {4129.0f, 197.0f, 988.0f}},
{13, {4003.0f, 151.0f, 376.0f}},
{14, {3694.0f, 75.0f, -321.0f}},
{2, {107.0f, 127.0f, -556.0f}},
{3, {589.0f, 99.0f, -162.0f}},
{4, {639.0f, 155.0f, 275.0f}},
{2, {107.0f, 127.0f, -556.0f}},
{3, {19.0f, 215.0f, 5.0f}},
{4, {-172.0f, 227.0f, 728.0f}},
{5, {-497.0f, 202.0f, 1467.0f}},
{6, {-992.0f, 115.0f, 2189.0f}},
{7, {-1479.0f, 101.0f, 2711.0f}},
{8, {-1911.0f, 88.0f, 3391.0f}},
{9, {-2173.0f, 75.0f, 4025.0f}},
{10, {-2526.0f, 80.0f, 4260.0f}},
{-1, {0.0f, 0.0f, 0.0f}},
};
/* 80A88CCC-80A88D14 0000EC 0048+00 1/1 0/0 0/0 .text __ct__14daNpc_Ne_HIO_cFv */
daNpc_Ne_HIO_c::daNpc_Ne_HIO_c() :
field_0x04(-1),
mScale(1.0f),
mWalkSpeed(2.5f),
mRunSpeed(12.0f),
mSwimSpeed(2.0f),
field_0x18(0)
{
/* empty function */
}
/* 80A88D14-80A88DC0 000134 00AC+00 19/19 0/0 0/0 .text anm_init__FP12npc_ne_classifUcf
*/
static void anm_init(npc_ne_class* i_this, int i_resNo, f32 i_morf, u8 i_attr, f32 i_speed) {
J3DAnmTransform* anm =
static_cast<J3DAnmTransform*>(dComIfG_getObjectRes(i_this->mResName, i_resNo));
i_this->mpMorf->setAnm(anm, i_attr, i_morf, i_speed, 0.0f, -1.0f, NULL);
i_this->mAnmID = i_resNo;
}
/* 80A88DC0-80A88FC4 0001E0 0204+00 1/1 0/0 0/0 .text nodeCallBack__FP8J3DJointi */
static int nodeCallBack(J3DJoint* i_joint, int param_1) {
if (param_1 == 0) {
int jnt_no = i_joint->getJntNo();
J3DModel* model = j3dSys.getModel();
npc_ne_class* _this = (npc_ne_class*)model->getUserArea();
if (_this != NULL) {
PSMTXCopy(model->getAnmMtx(jnt_no), *calc_mtx);
// head
if (jnt_no == 4) {
mDoMtx_YrotM(*calc_mtx, _this->mHeadAngleY + _this->mHeadBobAngleY);
mDoMtx_XrotM(*calc_mtx, _this->mHeadAngleX + _this->mHeadBobAngleX);
mDoMtx_ZrotM(*calc_mtx, _this->mHeadAngleZ);
}
// backbone1 / backbone2 / neck
if (jnt_no == 1 || jnt_no == 2 || jnt_no == 3) {
mDoMtx_YrotM(*calc_mtx, _this->mBackboneAngleY);
if (jnt_no == 3) {
mDoMtx_YrotM(*calc_mtx, _this->mNeckAngleY);
}
}
// tail1 / tail2
if (jnt_no == 20 || jnt_no == 21) {
if (jnt_no == 20) {
mDoMtx_ZrotM(*calc_mtx, _this->mTailAngle);
} else if (jnt_no == 21) {
if (_this->mTailAngle > 0) {
mDoMtx_ZrotM(*calc_mtx, _this->mTailAngle * 2);
}
}
mDoMtx_ZrotM(*calc_mtx, _this->mTailSwayAngle[jnt_no - 20]);
}
// center
if (jnt_no == 0) {
mDoMtx_YrotM(*calc_mtx, 0);
mDoMtx_XrotM(*calc_mtx, 0);
mDoMtx_ZrotM(*calc_mtx, 0);
}
model->setAnmMtx(jnt_no, *calc_mtx);
PSMTXCopy(*calc_mtx, J3DSys::mCurrentMtx);
}
}
return 1;
}
/* 80A88FC4-80A89160 0003E4 019C+00 1/0 0/0 0/0 .text daNpc_Ne_Draw__FP12npc_ne_class */
static int daNpc_Ne_Draw(npc_ne_class* i_this) {
if (daPy_py_c::linkGrabSubjectNoDraw(i_this)) {
return 1;
}
J3DModel* model = i_this->mpMorf->getModel();
if (i_this->mResName == "Npc_net") {
if (!dComIfGs_wolfeye_effect_check()) {
return 1;
}
g_env_light.settingTevStruct(4, &i_this->current.pos, &i_this->tevStr);
} else {
g_env_light.settingTevStruct(0, &i_this->current.pos, &i_this->tevStr);
}
g_env_light.setLightTevColorType_MAJI(model, &i_this->tevStr);
i_this->mpBtkAnm->entry(model->getModelData());
i_this->mpBtpAnm->entry(model->getModelData());
i_this->mpMorf->entryDL();
if (!fopAcM_checkCarryNow(i_this)) {
cXyz vec(i_this->current.pos.x, i_this->current.pos.y + 100.0f, i_this->current.pos.z);
i_this->mShadowKey = dComIfGd_setShadow(
i_this->mShadowKey, 1, model, &vec, 400.0f, 0.0f, i_this->current.pos.y,
i_this->mAcch.GetGroundH(), i_this->mAcch.m_gnd, &i_this->tevStr,
0, 1.0f, dDlst_shadowControl_c::getSimpleTex()
);
}
if (i_this->mBehavior == npc_ne_class::BHV_DISH) {
g_env_light.setLightTevColorType_MAJI(i_this->mpDishMorf->getModel(), &i_this->tevStr);
i_this->mpDishMorf->entryDL();
}
return 1;
}
/* 80A8919C-80A89298 0005BC 00FC+00 3/3 0/0 0/0 .text other_bg_check__FP10fopAc_ac_cP10fopAc_ac_c
*/
static BOOL other_bg_check(fopAc_ac_c* i_this, fopAc_ac_c* i_actor) {
dBgS_LinChk lin_chk;
if (i_actor != NULL) {
cXyz vec1, vec2;
vec2 = i_actor->current.pos;
vec2.y += 100.0f;
vec1 = i_this->current.pos;
vec1.y += 50.0f;
lin_chk.Set(&vec1, &vec2, i_this);
if (dComIfG_Bgsp().LineCross(&lin_chk)) {
return true;
} else {
return false;
}
}
return true;
}
/* 80A89298-80A892D4 0006B8 003C+00 1/1 0/0 0/0 .text ne_carry_check__FP12npc_ne_class */
static BOOL ne_carry_check(npc_ne_class* i_this) {
if (i_this->mAction != npc_ne_class::ACT_CARRY && fopAcM_checkCarryNow(i_this)) {
i_this->mAction = npc_ne_class::ACT_CARRY;
i_this->mMode = 0;
i_this->mNoFollow = false;
return true;
} else {
return false;
}
}
/* 80A892D4-80A895F8 0006F4 0324+00 2/2 0/0 0/0 .text way_bg_check__FP12npc_ne_classs */
static int way_bg_check(npc_ne_class* i_this, s16 i_angle) {
fopAc_ac_c* _this = static_cast<fopAc_ac_c*>(i_this);
dBgS_LinChk lin_chk;
dBgS_GndChk gnd_chk;
cM3dGPla plane;
cXyz vec1, vec2, vec3;
vec1 = _this->current.pos;
vec1.y += 50.0f;
mDoMtx_YrotS(*calc_mtx, _this->current.angle.y + i_angle);
if (_this->current.angle.x < 0) {
mDoMtx_XrotM(*calc_mtx, _this->current.angle.x);
}
vec3.set(0.0f, 0.0f, 150.0f);
MtxPosition(&vec3, &vec2);
vec2 += vec1;
lin_chk.Set(&vec1, &vec2, _this);
if (dComIfG_Bgsp().LineCross(&lin_chk)) {
dComIfG_Bgsp().GetTriPla(lin_chk, &plane);
if (plane.mNormal.y >= 0.8f) {
return 1;
}
}
mDoMtx_YrotS(*calc_mtx, _this->current.angle.y + i_angle);
vec3.set(0.0f, 150.0f, 150.0f);
MtxPosition(&vec3, &vec2);
vec2 += _this->current.pos;
vec1 = vec2;
vec2.y -= 250.0f;
lin_chk.Set(&vec1, &vec2, _this);
if (!dComIfG_Bgsp().LineCross(&lin_chk)) {
return 2;
}
dBgS_ObjGndChk_Spl gnd_chk_spl;
vec2.y += 200.0f;
gnd_chk.SetPos(&vec2);
f32 cross1 = dComIfG_Bgsp().GroundCross(&gnd_chk);
gnd_chk_spl.SetPos(&vec2);
f32 cross2 = dComIfG_Bgsp().GroundCross(&gnd_chk_spl);
if (cross2 > cross1 && fabsf(vec2.y - cross2) <= 200.0f) {
return 3;
} else {
return 0;
}
}
/* 80A89640-80A897C0 000A60 0180+00 1/1 0/0 0/0 .text water_check__FP12npc_ne_classf */
static int water_check(npc_ne_class* i_this, f32 param_1) {
dBgS_ObjGndChk_Spl gnd_chk_spl;
dBgS_GndChk gnd_chk;
dBgS_LinChk lin_chk;
cXyz vec;
vec.x = i_this->current.pos.x;
vec.y = i_this->current.pos.y + 3000.0f;
vec.z = i_this->current.pos.z;
lin_chk.Set(&i_this->current.pos, &vec, i_this);
if (dComIfG_Bgsp().LineCross(&lin_chk)) {
vec.y = lin_chk.GetCross().y - 10.0f;
}
gnd_chk_spl.SetPos(&vec);
i_this->mWaterY = dComIfG_Bgsp().GroundCross(&gnd_chk_spl);
gnd_chk.SetPos(&vec);
f32 cross = dComIfG_Bgsp().GroundCross(&gnd_chk);
if (i_this->current.pos.y <= i_this->mWaterY
&& i_this->mWaterY - cross > param_1 * 2.0f * i_this->mBaseScale.z)
{
return 1;
} else {
return 0;
}
}
static f32 dummy(f32 param_0) {
return param_0 + 5.0f + 60.0f + 25.0f;
}
/* 80A897C0-80A899C0 000BE0 0200+00 1/1 0/0 0/0 .text climb_angle_get__FP12npc_ne_class
*/
static s16 climb_angle_get(npc_ne_class* i_this) {
dBgS_LinChk lin_chk;
mDoMtx_YrotS(*calc_mtx, i_this->current.angle.y);
mDoMtx_XrotM(*calc_mtx, i_this->current.angle.x);
cXyz vec1, vec2, vec3;
vec3.set(0.0f, 50.0f, 10.0f);
MtxPosition(&vec3, &vec1);
vec1 += i_this->current.pos;
vec3.y = -100.0f;
MtxPosition(&vec3, &vec2);
vec2 += i_this->current.pos;
lin_chk.Set(&vec1, &vec2, i_this);
if (dComIfG_Bgsp().LineCross(&lin_chk)) {
i_this->mClimbPos = lin_chk.GetCross();
vec3.z = 20.0f;
MtxPosition(&vec3, &vec2);
vec2 += i_this->current.pos;
lin_chk.Set(&vec1, &vec2, i_this);
if (dComIfG_Bgsp().LineCross(&lin_chk)) {
vec2 = lin_chk.GetCross();
vec3 = vec2 - i_this->mClimbPos;
return -cM_atan2s(vec3.y, JMAFastSqrt(vec3.x * vec3.x + vec3.z * vec3.z));
}
return 0;
}
return 0;
}
/* 80A92AC4-80A92AC8 -00001 0004+00 2/2 0/0 0/0 .bss None */
/* 80A92AC5 0003+00 data_80A92AC5 None */
static bool l_hioInit;
/* 80A92AD4-80A92AF0 000054 001C+00 11/11 0/0 0/0 .bss l_HIO */
static daNpc_Ne_HIO_c l_HIO;
/* 80A92AF0-80A92B04 000070 0014+00 2/3 0/0 0/0 .bss target_info */
static fopAc_ac_c* target_info[5];
/* 80A92B04-80A92B18 000084 0014+00 0/1 0/0 0/0 .bss target_bgc */
static BOOL target_bgc[5];
/* 80A92B18-80A92B1C 000098 0004+00 2/3 0/0 0/0 .bss target_info_count */
static int target_info_count;
/* 80A899C0-80A89A38 000DE0 0078+00 1/1 0/0 0/0 .text s_bl_sub__FPvPv */
static void* s_bl_sub(void* i_proc, void* i_this) {
if (fopAc_IsActor(i_proc)
&& (fopAcM_GetName(i_proc) == PROC_OBJ_FOOD || fopAcM_GetName(i_proc) == PROC_BD)
&& target_info_count < 5)
{
target_info[target_info_count] = static_cast<fopAc_ac_c*>(i_proc);
target_info_count++;
}
return NULL;
}
/* 80A89A38-80A89AB0 000E58 0078+00 1/1 0/0 0/0 .text s_ss_sub__FPvPv */
static void* s_ss_sub(void* i_proc, void* i_this) {
if (fopAc_IsActor(i_proc)
&& (fopAcM_GetName(i_proc) == PROC_NI || fopAcM_GetName(i_proc) == PROC_BD)
&& target_info_count < 5)
{
target_info[target_info_count] = static_cast<fopAc_ac_c*>(i_proc);
target_info_count++;
}
return NULL;
}
/* 80A89AB0-80A89D28 000ED0 0278+00 3/3 0/0 0/0 .text search_bird__FP12npc_ne_class */
static fopAc_ac_c* search_bird(npc_ne_class* i_this) {
target_info_count = 0;
for (int i = 0; i < 5; i++) {
target_info[i] = NULL;
target_bgc[i] = false;
}
if (i_this->mSearchBall) {
fpcEx_Search(s_bl_sub, i_this);
} else {
fpcEx_Search(s_ss_sub, i_this);
}
f32 f = 200.0f;
if (target_info_count != 0) {
fopAc_ac_c* actor;
int i = 0;
while (i < target_info_count) {
actor = target_info[i];
cXyz eye_delta, delta;
eye_delta.x = actor->current.pos.x - i_this->eyePos.x;
eye_delta.y = actor->current.pos.y + 50.0f - i_this->eyePos.y;
eye_delta.z = actor->current.pos.z - i_this->eyePos.z;
delta.x = actor->current.pos.x - i_this->current.pos.x;
delta.z = actor->current.pos.z - i_this->current.pos.z;
f32 eye_dist = JMAFastSqrt(eye_delta.x * eye_delta.x + eye_delta.z * eye_delta.z);
f32 dist = JMAFastSqrt(delta.x * delta.x + delta.z * delta.z);
if (eye_dist < f && !(dist > i_this->mDistToTarget + 30.0f)) {
if (target_bgc[i] || other_bg_check(i_this, actor)) {
target_bgc[i] = true;
} else {
if (fabsf(actor->current.pos.y + 50.0f - i_this->eyePos.y) <= 100.0f) {
s16 angle = i_this->shape_angle.y - cM_atan2s(eye_delta.x, eye_delta.z);
if (angle < 0x4000 && angle > -0x4000) {
return actor;
}
}
}
}
i++;
if (i == target_info_count) {
i = 0;
f += 200.0f;
if (f > 2000.0f) {
return NULL;
}
}
}
} else {
return NULL;
}
return NULL;
}
/* 80A89D28-80A89EF4 001148 01CC+00 2/2 0/0 0/0 .text way_check__FP12npc_ne_classs */
static BOOL way_check(npc_ne_class* i_this, s16 i_angleY) {
fopAc_ac_c* _this = static_cast<fopAc_ac_c*>(i_this);
f32 fvar1 = 1000.0f;
cXyz vec1, vec2, vec3, vec4;
vec2 = _this->current.pos;
vec2.y += 20.0f;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 0x10; j++) {
mDoMtx_YrotS(*calc_mtx, i_angleY);
vec1.set(0.0f, 100.0f, fvar1);
MtxPosition(&vec1, &vec3);
vec3 += vec2;
dBgS_LinChk lin_chk;
lin_chk.Set(&vec2, &vec3, _this);
if (dComIfG_Bgsp().LineCross(&lin_chk)) {
i_angleY += 0x1000;
} else {
vec4.set(vec3.x, vec3.y - 250.0f, vec3.z);
lin_chk.Set(&vec3, &vec4, _this);
if (!dComIfG_Bgsp().LineCross(&lin_chk)) {
i_angleY += 0x1000;
} else {
i_this->mTargetAngleY = i_angleY;
return true;
}
}
}
fvar1 -= 150.0f;
}
return false;
}
/* 80A89EF4-80A8A234 001314 0340+00 1/1 0/0 0/0 .text npc_ne_wait__FP12npc_ne_class */
static void npc_ne_wait(npc_ne_class* i_this) {
fopAc_ac_c* _this = static_cast<fopAc_ac_c*>(i_this);
daPy_py_c* player = static_cast<daPy_py_c*>(dComIfGp_getPlayer(0));
cLib_addCalc0(&_this->speedF, 1.0f, 1.3f);
if (i_this->mResName == "Npc_net") {
switch (i_this->mMode) {
case 0:
i_this->mTargetAngleY = cM_rndF(0x10000);
// fallthrough
case 1:
if (cM_rndF(1.0f) < 0.5f) {
if (i_this->mAnmID != npc_ne_class::ANM_WAIT) {
anm_init(i_this, npc_ne_class::ANM_WAIT, 20.0f, 2, 1.0f);
}
} else {
if (i_this->mAnmID != npc_ne_class::ANM_SIT_B) {
anm_init(i_this, npc_ne_class::ANM_SIT_B, 20.0f, 0, 1.0f);
}
}
i_this->mTimers[0] = cM_rndF(200.0f) + 500.0f;
i_this->mMode = 2;
break;
case 2:
if (i_this->mTimers[0] == 0) {
i_this->mMode = 1;
}
break;
}
cLib_addCalcAngleS2(&_this->current.angle.y, i_this->mTargetAngleY, 4, 0x400);
i_this->mMessageState = 2;
} else {
i_this->mLookMode = npc_ne_class::LOOK_PLAYER;
s16 angle_diff;
switch (i_this->mMode) {
case 0:
i_this->mAnmSpeed = 1.5f;
anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed);
i_this->mMode++;
if (cM_rndF(1.0f) < 0.5f) {
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0xB000;
} else {
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x5000;
}
// fallthrough
case 1:
cLib_addCalcAngleS2(&_this->current.angle.y, i_this->mTargetAngleY, 4, 0x400);
angle_diff = _this->current.angle.y - i_this->mTargetAngleY;
if (angle_diff < 0x200 && angle_diff > -0x200) {
i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f;
anm_init(i_this, npc_ne_class::ANM_WAIT, 3.0f, 2, i_this->mAnmSpeed);
i_this->mMode++;
i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f;
}
break;
case 2:
angle_diff = _this->current.angle.y - i_this->mAngleToPlayer + 0x8000;
if (angle_diff < 0x800 && angle_diff > -0x800) {
i_this->mMode = 0;
}
if (i_this->mTimers[0] == 1) {
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_SIT_B, 20.0f, 0, i_this->mAnmSpeed);
}
break;
}
if (!(i_this->mCounter & 0xf) && !other_bg_check(_this, player) &&
(!i_this->mNoFollow || i_this->mDistToTarget < 350.0f))
{
i_this->mAction = npc_ne_class::ACT_AWAY;
i_this->mMode = 0;
i_this->mTimers[3] = 0;
i_this->mTimers[2] = 0;
i_this->mTimers[1] = 0;
i_this->mTimers[0] = 0;
}
}
}
/* 80A8A234-80A8A8F4 001654 06C0+00 1/1 0/0 0/0 .text npc_ne_away__FP12npc_ne_class */
static void npc_ne_away(npc_ne_class* i_this) {
if (!i_this->mNoFollow) {
i_this->mAction = npc_ne_class::ACT_TAME;
i_this->mMode = 0;
return;
}
int ivar4;
s16 max_angle_step = 0xa00;
ivar4 = 0;
switch (i_this->mMode) {
case 0:
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed);
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f);
way_check(i_this, i_this->mTargetAngleY);
i_this->mMode++;
i_this->mDistScale = cM_rndFX(0.2f) + 1.0f;
// fallthrough
case 1:
max_angle_step = 0x200;
if (i_this->mTimers[3] == 0) {
i_this->mTimers[3] = cM_rndF(40.0f) + 40.0f;
i_this->mLookNoMoveTimer = cM_rndF(20.0f) + 20.0f;
}
cLib_addCalc2(&i_this->mAnmSpeed, 2.0f, 1.0f, 0.05f);
cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mWalkSpeed,
1.0f, l_HIO.mWalkSpeed * 0.2f);
if (i_this->mDistToTarget > 500.0f) {
i_this->mMode = 2;
if (i_this->mTargetAngleY > (s16)(i_this->mAngleToPlayer + 0x8000)) {
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0xB000;
} else {
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x5000;
}
i_this->mTimers[0] = 20;
i_this->mTimers[1] = 0;
} else if (i_this->mDistToTarget < 200.0f) {
i_this->mMode = 5;
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f);
way_check(i_this, i_this->mTargetAngleY);
i_this->mSound.startSound(Z2SE_CAT_CRY_ANNOY, 0, -1);
} else {
if (i_this->mTimers[1] == 0) {
if (i_this->mCounter & 1) {
ivar4 = way_bg_check(i_this, 0);
}
if (ivar4 || i_this->mAcch.ChkWallHit() || !(i_this->mCounter & 0x1f)) {
i_this->mTargetAngleY =
i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(3000.0f);
way_check(i_this, i_this->mTargetAngleY);
}
if (i_this->mTimers[4] != 0) {
max_angle_step = 0x600;
} else {
max_angle_step = 0x200;
}
} else {
max_angle_step = 0x400;
}
}
break;
case 2:
cLib_addCalc2(&i_this->mAnmSpeed, 2.0f, 1.0f, 0.05f);
cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mWalkSpeed,
1.0f, l_HIO.mWalkSpeed * 0.2f);
if (i_this->mTimers[1] == 0) {
if (way_bg_check(i_this, 0) >= 2) {
i_this->mTimers[1] = cM_rndF(20.0f) + 30.0f;
i_this->mTargetAngleY = i_this->shape_angle.y + 0x8000 + (s16)cM_rndFX(5000.0f);
}
max_angle_step = 0x200;
} else {
max_angle_step = 0x400;
}
i_this->mLookMode = npc_ne_class::LOOK_PLAYER;
if (i_this->mTimers[0] == 0) {
i_this->mAction = npc_ne_class::ACT_WAIT;
i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f;
anm_init(i_this, npc_ne_class::ANM_WAIT, 3.0f, 2, i_this->mAnmSpeed);
i_this->mMode = 2;
i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f;
}
break;
case 5:
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed);
i_this->mMode++;
// fallthrough
case 6:
if (i_this->mTimers[3] == 0) {
i_this->mTimers[3] = cM_rndF(20.0f) + 20.0f;
i_this->mLookNoMoveTimer = cM_rndF(10.0f) + 10.0f;
}
cLib_addCalc2(&i_this->mAnmSpeed, 1.5f, 1.0f, 0.1f);
cLib_addCalc2(&i_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed,
1.0f, l_HIO.mRunSpeed * 0.5f);
if (i_this->mCounter & 1) {
ivar4 = way_bg_check(i_this, 0);
}
if (ivar4 || i_this->mAcch.ChkWallHit() || !(i_this->mCounter & 0xf)) {
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f);
way_check(i_this, i_this->mTargetAngleY);
}
if (i_this->mTimers[0] == 0) {
i_this->mTargetAngleY += (s16)cM_rndFX(4000.0f);
i_this->mTimers[0] = cM_rndF(25.0f) + 20.0f;
}
if (i_this->mDistToTarget > 400.0f && i_this->mTimers[2] == 0) {
i_this->mAction = npc_ne_class::ACT_WAIT;
i_this->mMode = 0;
}
break;
}
s16 prev_angle = i_this->current.angle.y;
cLib_addCalcAngleS2(&i_this->current.angle.y, i_this->mTargetAngleY, 4, max_angle_step);
f32 ang_z = i_this->speedF * (i_this->current.angle.y - prev_angle) * -0.5f;
if (ang_z > 4000.0f) {
ang_z = 4000.0f;
} else if (ang_z < -4000.0f) {
ang_z = -4000.0f;
}
i_this->current.angle.z = ang_z;
if (max_angle_step >= 0x400) {
f32 ang_y = i_this->speedF * (i_this->current.angle.y - prev_angle) * 0.1f;
if (ang_y > 5000.0f) {
ang_y = 5000.0f;
} else if (ang_y < -5000.0f) {
ang_y = -5000.0f;
}
i_this->mBackboneTargetAngleY = ang_y;
}
i_this->mpMorf->setPlaySpeed(i_this->mAnmSpeed);
}
/* 80A8A8F4-80A8AAE8 001D14 01F4+00 1/1 0/0 0/0 .text ground_search__FP12npc_ne_class */
static cXyz ground_search(npc_ne_class* i_this) {
daPy_py_c* player = static_cast<daPy_py_c*>(dComIfGp_getPlayer(0));
dBgS_ObjGndChk_Spl gnd_chk_spl;
dBgS_GndChk gnd_chk;
cXyz vec1, vec2;
for (int i = 0; i <= 4; i++) {
mDoMtx_YrotS(*calc_mtx, player->shape_angle.y);
vec1.y = 100.0f;
if (i == 0) {
vec1.x = 0.0f;
vec1.z = -300.0f;
} else if (i == 1) {
vec1.x = 300.0f;
vec1.z = -100.0f;
} else if (i == 2) {
vec1.x = -300.0f;
vec1.z = -100.0f;
} else if (i == 3) {
vec1.x = -300.0f;
vec1.z = 100.0f;
} else {
vec1.x = -300.0f;
vec1.z = 100.0f;
}
MtxPosition(&vec1, &vec2);
vec2 += player->current.pos;
gnd_chk.SetPos(&vec2);
vec2.y = dComIfG_Bgsp().GroundCross(&gnd_chk);
if (fabsf(vec2.y - player->current.pos.y) < 100.0f) {
gnd_chk_spl.SetPos(&vec2);
if (dComIfG_Bgsp().GroundCross(&gnd_chk_spl) < vec2.y) {
return vec2;
}
}
}
return i_this->current.pos;
}
/* 80A8AAE8-80A8AB70 001F08 0088+00 1/1 0/0 0/0 .text s_fish_sub__FPvPv */
static void* s_fish_sub(void* i_proc, void* i_this) {
npc_ne_class* _this = static_cast<npc_ne_class*>(i_this);
if (fopAc_IsActor(i_proc) && fopAcM_GetName(i_proc) == PROC_MG_FISH) {
mg_fish_class* fish = (mg_fish_class*)i_proc;
if (fish->mCurAction == 0x35 && fish->mActionPhase >= 10) {
_this->mFishID = fopAcM_GetID(fish);
return i_proc;
}
}
return NULL;
}
/* 80A8AB70-80A8B530 001F90 09C0+00 2/1 0/0 0/0 .text npc_ne_tame__FP12npc_ne_class */
static void npc_ne_tame(npc_ne_class* i_this) {
fopAc_ac_c* _this = static_cast<fopAc_ac_c*>(i_this);
if (i_this->mNoFollow) {
i_this->mAction = npc_ne_class::ACT_AWAY;
i_this->mMode = 0;
i_this->mTimers[3] = 0;
i_this->mTimers[2] = 0;
i_this->mTimers[1] = 0;
i_this->mTimers[0] = 0;
} else {
daPy_py_c* player = static_cast<daPy_py_c*>(dComIfGp_getPlayer(0));
s16 angle_max_step = 0;
i_this->mLookMode = npc_ne_class::LOOK_PLAYER;
f32 dist1, dist2, dist3;
if (i_this->mWantsFish) {
dist1 = 250.0f;
dist2 = 350.0f;
dist3 = 150.0f;
} else {
dist1 = 200.0f;
dist2 = 500.0f;
dist3 = 0.0f;
}
int ivar7 = 0;
s16 angle_diff;
switch (i_this->mMode) {
case 0:
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed);
i_this->mMode++;
i_this->mDistScale = cM_rndFX(0.2f) + 1.0f;
// fallthrough
case 1:
i_this->mTargetAngleY = i_this->mAngleToPlayer;
angle_max_step = 0x400;
i_this->mTailTargetAngle = -15000;
i_this->mTailSwayTarget = 3000.0f;
if (i_this->mDistToTarget < dist1) {
cLib_addCalc2(&i_this->mAnmSpeed, 1.0f, 1.0f, 0.05f);
cLib_addCalc0(&_this->speedF, 1.0f, 2.5f);
if (_this->speedF < 4.0f) {
i_this->mTimers[0] = cM_rndF(100.0f) + 200.0f;
i_this->mMode = 2;
i_this->mTimers[1] = 30;
}
} else if (i_this->mDistToTarget > dist2) {
i_this->mMode = 5;
} else {
f32 target_anm_speed = (i_this->mDistToTarget - dist1) * 0.1f;
if (target_anm_speed > 3.5f) {
target_anm_speed = 3.5f;
}
if (target_anm_speed < 2.0f) {
target_anm_speed = 2.0f;
}
cLib_addCalc2(&i_this->mAnmSpeed, target_anm_speed, 1.0f, 0.1f);
cLib_addCalc2(&_this->speedF, i_this->mAnmSpeed * l_HIO.mWalkSpeed,
1.0f, 0.2f * l_HIO.mWalkSpeed);
}
break;
case 2:
i_this->mTargetAngleY = i_this->mAngleToPlayer;
angle_diff = _this->current.angle.y - i_this->mTargetAngleY;
if (i_this->mTimers[1] != 0) {
if (angle_diff > 0x4000 || angle_diff < -0x4000) {
angle_max_step = 0x800;
if (i_this->mAnmID != npc_ne_class::ANM_WALK) {
anm_init(i_this, npc_ne_class::ANM_WALK, 3.0f, 2, 2.0f);
}
} else {
if (i_this->mAnmID != npc_ne_class::ANM_WAIT) {
i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f;
anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed);
}
}
}
if (i_this->mTimers[0] != 0) {
i_this->mTailTargetAngle = -15000;
i_this->mTailSwayTarget = 3000.0f;
}
if (i_this->mDistToTarget < dist3 ||
(i_this->mTimers[3] == 0 && i_this->mAcch.ChkWallHit())) {
i_this->mMode = 7;
i_this->mTimers[3] = 30;
} else if (i_this->mDistToTarget < dist3 + 30.0f) {
if (i_this->mTimers[2] == 0 && i_this->mTimers[1] == 0
&& angle_diff < 0x4000 && angle_diff > -0x4000
&& way_bg_check(i_this, 0x8000) == 0) {
i_this->mTimers[2] = cM_rndF(7.0f) + 15.0f;
anm_init(i_this, npc_ne_class::ANM_WALK, 3.0f, 2, -3.0f);
i_this->mAnmSpeed = -3.0f;
}
} else if (i_this->mDistToTarget > dist1 + 50.0f) {
i_this->mMode = 0;
}
if (i_this->mTimers[2] != 0) {
if (i_this->mTimers[2] == 1) {
i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f;
anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed);
}
cLib_addCalc2(&_this->speedF, -3.5f, 1.0f, 1.0f);
angle_max_step = 0x400;
} else {
cLib_addCalc0(&_this->speedF, 1.0f, 1.0f);
}
if (i_this->mTimers[0] == 1) {
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_SIT_A, 20.0f, 0, i_this->mAnmSpeed);
}
break;
case 5:
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed);
i_this->mMode++;
i_this->mSound.startSound(Z2SE_CAT_CRY_FAMILIER, 0, -1);
// fallthrough
case 6:
i_this->mTargetAngleY = i_this->mAngleToPlayer;
angle_max_step = 0xa00;
cLib_addCalc2(&i_this->mAnmSpeed, 1.5f, 1.0f, 0.1f);
cLib_addCalc2(&_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed,
1.0f, 0.5f * l_HIO.mRunSpeed);
if (i_this->mDistToTarget < dist1 + 100.0f) {
i_this->mAnmSpeed = 3.5f;
anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed);
i_this->mMode = 1;
}
break;
case 7:
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_RUN, 3.0f, 2, i_this->mAnmSpeed);
i_this->mMode++;
i_this->mSound.startSound(Z2SE_CAT_CRY_FAMILIER, 0, -1);
i_this->mTargetAngleY = i_this->mAngleToPlayer + 0x8000;
// fallthrough
case 8:
angle_max_step = 0xa00;
cLib_addCalc2(&i_this->mAnmSpeed, 1.5f, 1.0f, 0.1f);
cLib_addCalc2(&_this->speedF, i_this->mAnmSpeed * l_HIO.mRunSpeed,
1.0f, 0.5f * l_HIO.mRunSpeed);
if (i_this->mCounter & 1) {
ivar7 = way_bg_check(i_this, 0);
}
if (ivar7 != 0 || i_this->mAcch.ChkWallHit() || !(i_this->mCounter & 0xf))
{
i_this->mTargetAngleY =
i_this->mAngleToPlayer + 0x8000 + (s16)cM_rndFX(4000.0f);
way_check(i_this, i_this->mTargetAngleY);
}
if (i_this->mDistToTarget > dist3 + 40.0f) {
i_this->mAnmSpeed = 3.5f;
anm_init(i_this, npc_ne_class::ANM_WALK, 2.0f, 2, i_this->mAnmSpeed);
i_this->mMode = 1;
}
break;
case 10:
case 11:
i_this->mTargetAngleY = i_this->mAngleToPlayer;
cLib_addCalc0(&_this->speedF, 1.0f, 3.0f);
angle_diff = _this->current.angle.y - i_this->mTargetAngleY;
if (i_this->mMode == 10) {
if (angle_diff > 0x400 || angle_diff < -0x400) {
i_this->mAnmSpeed = 1.0f;
anm_init(i_this, npc_ne_class::ANM_WALK, 5.0f, 2, i_this->mAnmSpeed);
i_this->mMode = 11;
}
} else {
angle_max_step = 0x600;
i_this->mLookDownTimer = 0;
if (angle_diff <= 0x400 && angle_diff >= -0x400) {
i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f;
anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed);
i_this->mMode = 10;
}
}
if (i_this->mDistToTarget < dist3) {
i_this->mMode = 7;
i_this->mTimers[2] = 20;
}
break;
}
if (i_this->mMode < 7) {
if (i_this->mTimers[2] == 0) {
ivar7 = way_bg_check(i_this, 0);
if (ivar7 != 0) {
if (ivar7 == -1) {
i_this->mAction = npc_ne_class::ACT_CLIMB;
i_this->mMode = 0;
} else {
i_this->mMode = 10;
i_this->mAnmSpeed = cM_rndF(0.1f) + 0.5f;
anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, i_this->mAnmSpeed);
if (ivar7 >= 2) {
i_this->mLookDownTimer = 30;
}
}
}
}
} else if (i_this->mMode >= 10 && way_bg_check(i_this, 0) == 0) {
i_this->mMode = 0;
}
s16 prev_angle_y = _this->current.angle.y;
cLib_addCalcAngleS2(&_this->current.angle.y, i_this->mTargetAngleY, 4, angle_max_step);
f32 angle = _this->speedF * (_this->current.angle.y - prev_angle_y) * -0.5f;
if (angle > 4000.0f) {
angle = 4000.0f;
} else if (angle < -4000.0f) {
angle = -4000.0f;
}
_this->current.angle.z = angle;
if (angle_max_step > 0x600) {
angle = _this->speedF * (_this->current.angle.y - prev_angle_y) * 0.1f;
if (angle > 5000.0f) {
angle = 5000.0f;
} else if (angle < -5000.0f) {
angle = -5000.0f;
}
i_this->mBackboneTargetAngleY = angle;
}
i_this->mpMorf->setPlaySpeed(i_this->mAnmSpeed);
/* dSv_event_flag_c::F_0470 - Fishing Pond - Reserved for fishing */
if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[470])) {
if (fpcEx_Search(s_fish_sub, _this) != NULL) {
i_this->mAction = npc_ne_class::ACT_HOME;
i_this->mMode = 10;
}
}
if ((i_this->mCounter & 0x1f) == 0xf && other_bg_check(_this, player)) {
i_this->mAction = npc_ne_class::ACT_WAIT;
i_this->mMode = 0;
}
}
}
/* 80A8B530-80A8B61C 002950 00EC+00 1/1 0/0 0/0 .text npc_ne_sanbasi__FP12npc_ne_class */
static void npc_ne_sanbasi(npc_ne_class* i_this) {
switch (i_this->mMode) {
case 0:
anm_init(i_this, npc_ne_class::ANM_WAIT, 5.0f, 2, 1.0f);
i_this->mMode = 1;
break;
case 1:
i_this->mLookDownTimer = 30;
}
if (i_this->mDistToTarget < 500.0f || !i_this->mNoFollow) {
i_this->mAction = npc_ne_class::ACT_TAME;
i_this->mMode = 0;