MCPcopy Create free account
hub / github.com/JACoders/OpenJK / NPC_BSFlee

Function NPC_BSFlee

code/game/NPC_behavior.cpp:1697–1906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1695extern gentity_t *NPC_SearchForWeapons( void );
1696extern qboolean G_CanPickUpWeapons( gentity_t *other );
1697qboolean NPC_BSFlee( void )
1698{
1699 bool enemyRecentlySeen = false;
1700 float enemyTooCloseDist = 50.0f;
1701 bool reachedEscapePoint = false;
1702 bool hasEscapePoint = false;
1703 bool moveSuccess = false;
1704 bool inSurrender = (level.time<NPCInfo->surrenderTime);
1705
1706
1707
1708 // Check For Enemies And Alert Events
1709 //------------------------------------
1710 NPC_CheckEnemy(qtrue, qfalse);
1711 NPC_CheckAlertEvents(qtrue, qtrue, -1, qfalse, AEL_DANGER, qfalse);
1712 if (NPC->enemy && G_ClearLOS(NPC, NPC->enemy))
1713 {
1714 NPCInfo->enemyLastSeenTime = level.time;
1715 }
1716 enemyRecentlySeen = (NPC->enemy && (level.time - NPCInfo->enemyLastSeenTime)<3000);
1717 if (enemyRecentlySeen)
1718 {
1719 if (NPC->enemy->client && NPC->enemy->client->NPC_class==CLASS_RANCOR)
1720 {
1721 enemyTooCloseDist = 400.0f;
1722 }
1723 enemyTooCloseDist += NPC->maxs[0] + NPC->enemy->maxs[0];
1724 }
1725
1726
1727 // Look For Weapons To Pick Up
1728 //-----------------------------
1729 if (enemyRecentlySeen && // Is There An Enemy Near?
1730 NPC->client->NPC_class!=CLASS_PRISONER && // Prisoners can't pickup weapons
1731 NPCInfo->rank>RANK_CIVILIAN && // Neither can civilians
1732 TIMER_Done(NPC, "panic") && // Panic causes him to run for a bit, don't pickup weapons
1733 TIMER_Done(NPC, "CheckForWeaponToPickup") &&
1734 G_CanPickUpWeapons( NPC ) //Allowed To Pick Up Dropped Weapons
1735 )
1736 {
1737 gentity_t *foundWeap = NPC_SearchForWeapons();
1738
1739 // Ok, There Is A Weapon! Try Going To It!
1740 //------------------------------------------
1741 if (foundWeap && NAV::SafePathExists(NPC->currentOrigin, foundWeap->currentOrigin, NPC->enemy->currentOrigin, 150.0f))
1742 {
1743 NAV::ClearPath(NPC); // Remove Any Old Path
1744
1745 NPCInfo->goalEntity = foundWeap; // Change Our Target Goal
1746 NPCInfo->goalRadius = 30.0f; // 30 good enough?
1747
1748 TIMER_Set(NPC, "CheckForWeaponToPickup", Q_irand(10000, 50000));
1749 }
1750
1751 // Look Again Soon
1752 //-----------------
1753 else
1754 {

Callers 5

NPC_BSCivilian_DefaultFunction · 0.70
NPC_BSHowler_DefaultFunction · 0.70
NPC_BehaviorSet_CharmedFunction · 0.70
NPC_BehaviorSet_DefaultFunction · 0.70
NPC_RunBehaviorFunction · 0.70

Calls 15

G_CanPickUpWeaponsFunction · 0.85
Q_irandFunction · 0.85
DistanceFunction · 0.85
ActivateFunction · 0.85
NPC_JawaFleeSoundFunction · 0.85
NPC_CheckEnemyFunction · 0.70
NPC_CheckAlertEventsFunction · 0.70
G_ClearLOSFunction · 0.70
TIMER_DoneFunction · 0.70
NPC_SearchForWeaponsFunction · 0.70
TIMER_SetFunction · 0.70
Q3_TaskIDPendingFunction · 0.70

Tested by

no test coverage detected