MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / NPCC_aimVary

Function NPCC_aimVary

src/SB/Game/zNPCSupport.cpp:683–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681}
682
683F32 NPCC_aimVary(xVec3* dir_aim, xVec3* pos_src, xVec3* pos_tgt, F32 dst_vary, S32 flg_vary,
684 xVec3* pos_aimPoint)
685{
686 F32 dst_toFake = 0.0f;
687 xVec3 dir_left = {};
688 xVec3 dir_toFake = {};
689 xVec3 dir_toReal = {};
690 xVec3 vec_offset = {};
691 xVec3 pos_tgtFake = {};
692
693 xVec3Sub(&dir_toReal, pos_tgt, pos_src);
694
695 if (flg_vary & 0x10)
696 {
697 dir_toReal.y = 0.0f;
698 }
699
700 F32 mag_vary = xVec3Length(&dir_toReal);
701 if (mag_vary < 0.001f)
702 {
703 if (mag_vary > 0.0f)
704 {
705 xVec3SMulBy(&dir_toReal, 100000.0f);
706 xVec3Normalize(&dir_toReal, &dir_toReal);
707 }
708 else
709 {
710 xVec3Copy(dir_aim, &g_X3);
711 }
712
713 if (pos_aimPoint)
714 {
715 xVec3Copy(pos_aimPoint, pos_tgt);
716 }
717
718 return mag_vary;
719 }
720
721 xVec3SMulBy(&dir_toReal, 1.0f / mag_vary);
722 xVec3Cross(&dir_left, &g_Y3, &dir_toReal);
723
724 F32 mag_updown;
725 if (flg_vary & 0x8)
726 {
727 mag_updown = dst_vary;
728 }
729 else
730 {
731 mag_updown = 2.0f * (xurand() - 0.5f) * dst_vary;
732
733 F32 fv;
734 if ((flg_vary & 0x1) && (flg_vary & 0x2))
735 {
736 fv = 2.0f * (xurand() - 0.5f);
737 }
738 else if (flg_vary == 0x1)
739 {
740 fv = xurand();

Callers 2

CalcNewDirMethod · 0.70
NPCC_aimMissFunction · 0.70

Calls 9

xVec3SubFunction · 0.85
xVec3LengthFunction · 0.85
xVec3SMulByFunction · 0.85
xVec3CopyFunction · 0.85
xVec3CrossFunction · 0.85
xurandFunction · 0.85
xVec3AddScaledFunction · 0.85
xVec3AddFunction · 0.85
xVec3NormalizeFunction · 0.50

Tested by

no test coverage detected