| 738 | |
| 739 | |
| 740 | void CBot::MainAI() |
| 741 | { |
| 742 | // Default bots will run forward |
| 743 | m_pMyEnt->move = 1; |
| 744 | |
| 745 | // Default bots won't strafe |
| 746 | m_pMyEnt->strafe = 0; |
| 747 | |
| 748 | // Whatever the bot is doing, check for needed crouch |
| 749 | if(CheckCrouch()) m_pMyEnt->trycrouch = true; |
| 750 | else m_pMyEnt->trycrouch = false; |
| 751 | |
| 752 | if (!BotManager.BotsShoot() && m_pMyEnt->enemy) |
| 753 | m_pMyEnt->enemy = NULL; // Clear enemy when bots may not shoot |
| 754 | |
| 755 | if (m_bGoToDebugGoal) // For debugging the waypoint navigation |
| 756 | { |
| 757 | if (!HeadToGoal()) |
| 758 | { |
| 759 | ResetWaypointVars(); |
| 760 | m_vGoal = g_vecZero; |
| 761 | } |
| 762 | else |
| 763 | AddDebugText("Heading to debug goal..."); |
| 764 | } |
| 765 | if (BotManager.BotsShoot() && FindEnemy()) // Combat |
| 766 | { |
| 767 | CheckReload(); |
| 768 | CheckScope(); |
| 769 | AddDebugText("has enemy"); |
| 770 | // Use best weapon |
| 771 | ChoosePreferredWeapon(); |
| 772 | // Shoot at enemy |
| 773 | ShootEnemy(); |
| 774 | |
| 775 | if (m_eCurrentBotState != STATE_ENEMY) |
| 776 | { |
| 777 | m_vGoal = g_vecZero; |
| 778 | ResetWaypointVars(); |
| 779 | } |
| 780 | |
| 781 | m_eCurrentBotState = STATE_ENEMY; |
| 782 | if (!CheckJump()) |
| 783 | DoCombatNav(); |
| 784 | } |
| 785 | else if (CheckHunt() && HuntEnemy()) |
| 786 | { |
| 787 | CheckReload(); |
| 788 | CheckScope(); |
| 789 | AddDebugText("Hunting to %s", m_pHuntTarget->name); |
| 790 | m_eCurrentBotState = STATE_HUNT; |
| 791 | } |
| 792 | // Heading to an interesting entity(ammo, armour etc) |
| 793 | else if (CheckItems()) |
| 794 | { |
| 795 | CheckReload(); |
| 796 | AddDebugText("has ent"); |
| 797 | m_eCurrentBotState = STATE_ENT; |
nothing calls this directly
no test coverage detected