| 1695 | extern gentity_t *NPC_SearchForWeapons( void ); |
| 1696 | extern qboolean G_CanPickUpWeapons( gentity_t *other ); |
| 1697 | qboolean 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 | { |
no test coverage detected