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

Method CheckSpot

src/SB/Game/zNPCGoalRobo.cpp:614–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614S32 zNPCGoalAlertFodder::CheckSpot(F32 dt)
615{
616 S32 plyrInSpot;
617 zNPCRobot* npc = (zNPCRobot*)this->psyche->clt_owner;
618 xVec3 pos_plyr;
619 xVec3 dir_plyr;
620 F32 dy;
621 F32 dst_plyr;
622 F32 dot_plyr;
623
624 zEntPlayer_PredictPos(&pos_plyr, 0.5f, 1.0f, 1);
625 dst_plyr = npc->XZDstSqToPos(&pos_plyr, NULL, NULL);
626 if (npc->XZDstSqToPlayer(NULL, NULL) < dst_plyr)
627 {
628 pos_plyr = *xEntGetPos(&globals.player.ent);
629 }
630 dst_plyr = npc->XZDstSqToPos(&pos_plyr, &dir_plyr, &dy);
631 dst_plyr = xsqrt(dst_plyr);
632 if (xabs(dy) > 3.4f)
633 {
634 plyrInSpot = 0;
635 }
636 else if (dst_plyr < 0.35f)
637 {
638 plyrInSpot = 1;
639 }
640 else if (dst_plyr > 1.5f)
641 {
642 plyrInSpot = 0;
643 }
644 else
645 {
646 dir_plyr *= 1.0f / dst_plyr;
647 dot_plyr = xVec3Dot(&dir_plyr, NPCC_faceDir(npc));
648 plyrInSpot = (dot_plyr < 0.86f) ? 0 : 1;
649 }
650 if (npc->DBG_IsNormLog(eNPCDCAT_Thirteen, 2) != 0)
651 {
652 xDrawSetColor(g_GRAY50);
653 xDrawSphere2(&pos_plyr, 0.1f, 12);
654 xDrawSetColor(g_PINK);
655 xDrawCyl(npc->Pos(), 1.5f, 3.4f, 0x2020C);
656 xVec3 pos_head = *npc->Pos();
657 pos_head.y += 1.0f;
658 xDrawCyl(&pos_head, 0.35f, 0.2f, 0x2020C);
659 }
660 return plyrInSpot;
661}
662
663void zNPCGoalAlertFodder::FlankPlayer(F32 dt)
664{

Callers

nothing calls this directly

Calls 8

xEntGetPosFunction · 0.85
xsqrtFunction · 0.85
NPCC_faceDirFunction · 0.85
xDrawSetColorFunction · 0.85
xDrawCylFunction · 0.85
zEntPlayer_PredictPosFunction · 0.70
xDrawSphere2Function · 0.70
PosMethod · 0.45

Tested by

no test coverage detected