diff --git a/source/basecode.cpp b/source/basecode.cpp index d111506..c4fc211 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -104,7 +104,7 @@ bool Bot::CheckVisibility (entvars_t *targetEntity, Vector *origin, byte *bodyPa { // this function checks visibility of a bot target. - Vector botHead = EyePosition (); + const Vector &botHead = EyePosition (); TraceResult tr; *bodyPart = 0; @@ -2896,11 +2896,11 @@ void Bot::ChooseAimDirection (void) GetValidWaypoint (); // check if last enemy vector valid - if (m_lastEnemyOrigin != nullvec) + if (m_seeEnemyTime + 7.0 < GetWorldTime () && m_lastEnemyOrigin != nullvec) { TraceLine (EyePosition (), m_lastEnemyOrigin, false, true, GetEntity (), &tr); - if ((pev->origin - m_lastEnemyOrigin).GetLength () >= 1600 && IsEntityNull (m_enemy) && !UsesSniper () || (tr.flFraction <= 0.2 && tr.pHit == g_hostEntity) && m_seeEnemyTime + 7.0 < GetWorldTime ()) + if ((pev->origin - m_lastEnemyOrigin).GetLength () >= 1600 && IsEntityNull (m_enemy) && !UsesSniper () || (tr.flFraction <= 0.2 && tr.pHit == g_hostEntity)) { if ((m_aimFlags & (AIM_LAST_ENEMY | AIM_PREDICT_PATH)) && m_wantsToFire) m_wantsToFire = false; @@ -2909,12 +2909,13 @@ void Bot::ChooseAimDirection (void) m_aimFlags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH); flags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH); + flags = m_aimFlags; } } else { m_aimFlags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH); - flags &= ~(AIM_LAST_ENEMY | AIM_PREDICT_PATH); + flags = m_aimFlags; } // don't allow bot to look at danger positions under certain circumstances @@ -4853,32 +4854,34 @@ void Bot::BotAI (void) SetConditions (); // some stuff required by by chatter engine - if ((m_states & STATE_SEEING_ENEMY) && !IsEntityNull (m_enemy)) + if (yb_communication_type.GetInt () == 2) { - if (Random.Long (0, 100) < 45 && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && (m_enemy->v.weapons & (1 << WEAPON_C4))) - ChatterMessage (Chatter_SpotTheBomber); + if ((m_states & STATE_SEEING_ENEMY) && !IsEntityNull (m_enemy)) + { + if (Random.Long (0, 100) < 45 && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && (m_enemy->v.weapons & (1 << WEAPON_C4))) + ChatterMessage (Chatter_SpotTheBomber); - if (Random.Long (0, 100) < 45 && m_team == TEAM_TF && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && *g_engfuncs.pfnInfoKeyValue (g_engfuncs.pfnGetInfoKeyBuffer (m_enemy), "model") == 'v') - ChatterMessage (Chatter_VIPSpotted); + if (Random.Long (0, 100) < 45 && m_team == TEAM_TF && GetNearbyFriendsNearPosition (pev->origin, 512) == 0 && *g_engfuncs.pfnInfoKeyValue (g_engfuncs.pfnGetInfoKeyBuffer (m_enemy), "model") == 'v') + ChatterMessage (Chatter_VIPSpotted); - if (Random.Long (0, 100) < 50 && GetNearbyFriendsNearPosition (pev->origin, 450) == 0 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384)) - ChatterMessage (Chatter_ScaredEmotion); + if (Random.Long (0, 100) < 50 && GetNearbyFriendsNearPosition (pev->origin, 450) == 0 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384)) + ChatterMessage (Chatter_ScaredEmotion); - if (Random.Long (0, 100) < 40 && GetNearbyFriendsNearPosition (pev->origin, 1024) == 0 && ((m_enemy->v.weapons & (1 << WEAPON_AWP)) || (m_enemy->v.weapons & (1 << WEAPON_SCOUT)) || (m_enemy->v.weapons & (1 << WEAPON_G3SG1)) || (m_enemy->v.weapons & (1 << WEAPON_SG550)))) - ChatterMessage (Chatter_SniperWarning); + if (Random.Long (0, 100) < 40 && GetNearbyFriendsNearPosition (pev->origin, 1024) == 0 && ((m_enemy->v.weapons & (1 << WEAPON_AWP)) || (m_enemy->v.weapons & (1 << WEAPON_SCOUT)) || (m_enemy->v.weapons & (1 << WEAPON_G3SG1)) || (m_enemy->v.weapons & (1 << WEAPON_SG550)))) + ChatterMessage (Chatter_SniperWarning); + } + + // if bot is trapped under shield yell for help ! + if (GetTaskId () == TASK_CAMP && HasShield () && IsShieldDrawn () && GetNearbyEnemiesNearPosition (pev->origin, 650) >= 2 && IsEnemyViewable (m_enemy)) + InstantChatterMessage (Chatter_Pinned_Down); + + // if bomb planted warn teammates ! + if (g_canSayBombPlanted && g_bombPlanted && GetTeam (GetEntity ()) == TEAM_CF) + { + g_canSayBombPlanted = false; + ChatterMessage (Chatter_GottaFindTheBomb); + } } - - // if bot is trapped under shield yell for help ! - if (GetTaskId () == TASK_CAMP && HasShield() && IsShieldDrawn () && GetNearbyEnemiesNearPosition (pev->origin, 650) >= 2 && IsEnemyViewable(m_enemy)) - InstantChatterMessage(Chatter_Pinned_Down); - - // if bomb planted warn teammates ! - if (g_canSayBombPlanted && g_bombPlanted && GetTeam (GetEntity()) == TEAM_CF) - { - g_canSayBombPlanted = false; - ChatterMessage (Chatter_GottaFindTheBomb); - } - Vector src, destination; m_checkTerrain = true; @@ -5781,7 +5784,7 @@ byte Bot::ThrottledMsec (void) if (newMsec < 10) { - msecVal = msecVal - static_cast (newMsec) + m_msecValRest; + msecVal -= static_cast (newMsec) + m_msecValRest; msecRest = static_cast (msecVal); m_msecValRest = msecVal - static_cast (msecRest); diff --git a/source/combat.cpp b/source/combat.cpp index e4dd7f6..bfe14b1 100644 --- a/source/combat.cpp +++ b/source/combat.cpp @@ -191,7 +191,7 @@ bool Bot::LookupEnemy (void) if (friendBot != NULL) { - if (friendBot->m_seeEnemyTime + 2.0 < GetWorldTime () || IsEntityNull (friendBot->m_lastEnemy)) + if (friendBot->m_seeEnemyTime + 2.0f < GetWorldTime () || IsEntityNull (friendBot->m_lastEnemy)) { if (IsVisible (pev->origin, ENT (friendBot->pev))) { @@ -213,7 +213,7 @@ bool Bot::LookupEnemy (void) if (!IsAlive (newEnemy)) { m_enemy = NULL; - + // shoot at dying players if no new enemy to give some more human-like illusion if (m_seeEnemyTime + 0.1 > GetWorldTime ()) { @@ -648,49 +648,6 @@ void Bot::FireWeapon (void) selectId = WEAPON_KNIFE; // no available ammo, use knife! } - // ignore enemies protected by shields - if (IsEnemyProtectedByShield (m_enemy) && !(m_currentWeapon == WEAPON_KNIFE) && IsEnemyViewable (m_enemy)) - { - if (!g_bombPlanted && Random.Float (0, 100) < 50) - StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (5, 10), true); - - } - - // check if bot has shield - if (HasShield () && m_shieldCheckTime < GetWorldTime () && GetTaskId () != TASK_CAMP && IsEnemyViewable (m_enemy)) - { - if (IsGroupOfEnemies (pev->origin, 3, 750) && !IsShieldDrawn () && !g_bombPlanted) - StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + Random.Float (10, 20), true); - - if (distance >= 750 || ((m_enemy->v.button & IN_ATTACK) && !IsShieldDrawn())) - { - pev->button |= IN_ATTACK2; // draw the shield - pev->button &= ~IN_DUCK; - - if (IsGroupOfEnemies (pev->origin, 3, 550) || (GetNearbyEnemiesNearPosition (pev->origin, 550) >= 3 && IsShieldDrawn ())) - { - ChooseAimDirection(); - FacePosition (); - } - else if(!g_bombPlanted) - StartTask (TASK_CAMP, TASKPRI_PAUSE, -1, GetWorldTime () + Random.Float (10, 20), true); - - if (IsEnemyProtectedByShield (m_lastEnemy) && !(m_currentWeapon == WEAPON_KNIFE) && IsEnemyViewable (m_lastEnemy)) - { - pev->button &= ~IN_ATTACK; - StartTask (TASK_CAMP, TASKPRI_CAMP, -1, GetWorldTime () + Random.Float (10, 20), true); - } - } - else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && (m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable (m_enemy))) - { - pev->button |= (IN_ATTACK2 | IN_DUCK); // draw out the shield - - if (!g_bombPlanted) - StartTask (TASK_SEEKCOVER, TASKPRI_SEEKCOVER, -1, GetWorldTime () + Random.Float (10, 25), true); - } - m_shieldCheckTime = GetWorldTime () + 0.5; - } - WeaponSelectEnd: // we want to fire weapon, don't reload now if (!m_isReloading)