MCPcopy Create free account
hub / github.com/assaultcube/AC / Think

Method Think

source/src/bot/bot_waypoint.cpp:542–616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540}
541
542void CWaypointClass::Think()
543{
544#ifdef WP_FLOOD
545 FloodThink();
546#endif
547
548 if (m_bAutoWaypoint) // is auto waypoint on?
549 {
550 // find the distance from the last used waypoint
551 float flDistance = GetDistance(m_vLastCreatedWP, player1->o);
552
553 bool NoLastCreatedWP = ((m_vLastCreatedWP.x == 0) && (m_vLastCreatedWP.y == 0) &&
554 (m_vLastCreatedWP.z == 0));
555
556 if ((flDistance > 3.0f) || NoLastCreatedWP)
557 {
558 // check that no other reachable waypoints are nearby...
559 if (!GetNearestWaypoint(player1, 10.0f))
560 {
561 AddWaypoint(player1->o, true); // place a waypoint here
562 }
563 }
564 }
565
566 // Draw info for nearest waypoint?
567 if (m_bDrawWPText)
568 {
569 node_s *nearestwp = GetNearestWaypoint(player1, 20.0f);
570
571#ifdef WP_FLOOD
572 if (!nearestwp)
573 nearestwp = GetNearestFloodWP(player1, 10.0f);
574#endif
575
576 if (nearestwp)
577 {
578 char szWPInfo[256];
579 sprintf(szWPInfo, "Distance nearest waypoint: %f", GetDistance(player1->o, nearestwp->v_origin));
580 AddScreenText(szWPInfo);
581
582 strcpy(szWPInfo, "Flags: ");
583 if (nearestwp->iFlags & W_FL_TELEPORT)
584 strcat(szWPInfo, "Teleport ");
585 if (nearestwp->iFlags & W_FL_TELEPORTDEST)
586 strcat(szWPInfo, "Teleport destination ");
587 if (nearestwp->iFlags & W_FL_JUMP)
588 strcat(szWPInfo, "Jump ");
589 if (nearestwp->iFlags & W_FL_TRIGGER)
590 {
591 char sz[32];
592 sprintf(sz, "Trigger(nr %d) ", nearestwp->sTriggerNr);
593 strcat(szWPInfo, sz);
594 }
595 if (nearestwp->iFlags & W_FL_INTAG)
596 strcat(szWPInfo, "In tagged cube(s) ");
597 if (strlen(szWPInfo) == 7)
598 strcat(szWPInfo, "None");
599

Callers

nothing calls this directly

Calls 3

GetDistanceFunction · 0.85
AddScreenTextFunction · 0.85
NodeCountMethod · 0.80

Tested by

no test coverage detected