Fix bot: do reset of the target when are the target (player or bot) left the game.

This commit is contained in:
s1lent 2017-02-06 02:49:19 +07:00
parent 507688c745
commit cd96c9133d
4 changed files with 26 additions and 1 deletions

View File

@ -1500,3 +1500,23 @@ void CCSBotManager::ResetRadioMessageTimestamps()
}
}
}
void CCSBotManager::OnFreeEntPrivateData(CBaseEntity *pEntity)
{
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer || pPlayer->IsDormant())
continue;
if (pPlayer->IsBot())
{
CCSBot *pBot = static_cast<CCSBot *>(pPlayer);
if (pBot->m_attacker == pEntity)
pBot->m_attacker = NULL;
if (pBot->m_bomber == pEntity)
pBot->m_bomber = NULL;
}
}
}

View File

@ -76,6 +76,7 @@ public:
public:
void ValidateMapData();
void OnFreeEntPrivateData(CBaseEntity *pEntity);
bool IsLearningMap() const { return IMPL(m_isLearningMap); }
void SetLearningMapFlag() { IMPL(m_isLearningMap) = true; }
bool IsAnalysisRequested() const { return IMPL(m_isAnalysisRequested); }

View File

@ -456,7 +456,6 @@ void AttackState::__MAKE_VHOOK(OnUpdate)(CCSBot *me)
if (gpGlobals->time > m_reacquireTimestamp)
me->FireWeaponAtEnemy();
// do dodge behavior
// If sniping or crouching, stand still.
if (m_dodge && !me->IsUsingSniperRifle() && !m_crouchAndHold)

View File

@ -1067,4 +1067,9 @@ void EXT_FUNC OnFreeEntPrivateData(edict_t *pEnt)
}
#endif
#ifdef REGAMEDLL_FIXES
if (TheCSBots()) {
TheCSBots()->OnFreeEntPrivateData(pEntity);
}
#endif
}