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

Method PlayerInSpot

src/SB/Game/zNPCGoalRobo.cpp:1558–1618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1556}
1557
1558S32 zNPCGoalAlertHammer::PlayerInSpot(F32 dt)
1559{
1560 // TODO: Variable names.
1561
1562 S32 plyrInSpot;
1563 zNPCRobot* npc;
1564
1565 xVec3 r1_0x30;
1566 xVec3 r1_0x24;
1567 xVec3 r1_0x18;
1568 xVec3 r1_0x0C;
1569
1570 F32 f0;
1571 F32 f1;
1572 F32 f2;
1573 F32 f3;
1574
1575 plyrInSpot = 0;
1576 npc = (zNPCRobot*)(psyche->clt_owner);
1577 f1 = xsqrt(npc->XZDstSqToPlayer(&r1_0x30, &f2));
1578 f2 = __fabs(f2);
1579 if (f1 < 2.25f)
1580 {
1581 return 1;
1582 }
1583 else if (f2 > 3.75f)
1584 {
1585 return 0;
1586 }
1587 else if (f1 < 0.4f)
1588 {
1589 return 1;
1590 }
1591 else
1592 {
1593 r1_0x30 *= (1.0f / f1);
1594 if (xVec3Dot(&r1_0x30, (xVec3*)NPCC_faceDir(npc)) < 0.5f)
1595 {
1596 return 0;
1597 }
1598 else
1599 {
1600 xVec3SMul(&r1_0x24, (xVec3*)NPCC_faceDir(npc), 3.5f);
1601 xVec3AddTo(&r1_0x24, (xVec3*)npc->Pos());
1602 xVec3Copy(&r1_0x18, (xVec3*)xEntGetPos(&globals.player.ent));
1603 f0 = xsqrt(NPCC_DstSq(&r1_0x24, (xVec3*)xEntGetPos(&globals.player.ent), NULL));
1604 f3 = MAX(npc->spd_throttle, 12.0f);
1605 zEntPlayer_PredictPos(&r1_0x18, MIN((f0 / f3) + 0.5f, 2.0f), 1.0f, 0);
1606 xVec3Sub(&r1_0x0C, &r1_0x18, &r1_0x24);
1607 if ((F32)__fabs(r1_0x0C.y) < 2.5f)
1608 {
1609 r1_0x0C.y = 0.0f;
1610 if (xVec3Length2(&r1_0x0C) < 1.25f)
1611 {
1612 plyrInSpot = 1;
1613 }
1614 }
1615 }

Callers

nothing calls this directly

Calls 10

xsqrtFunction · 0.85
NPCC_faceDirFunction · 0.85
xVec3SMulFunction · 0.85
xVec3AddToFunction · 0.85
xVec3CopyFunction · 0.85
xEntGetPosFunction · 0.85
xVec3SubFunction · 0.85
xVec3Length2Function · 0.85
zEntPlayer_PredictPosFunction · 0.70
PosMethod · 0.45

Tested by

no test coverage detected