Skip to content

Commit

Permalink
Fix bot: do reset of the target when are the target (player or bot) l…
Browse files Browse the repository at this point in the history
…eft the game.
  • Loading branch information
s1lentq committed Feb 5, 2017
1 parent 507688c commit cd96c91
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
20 changes: 20 additions & 0 deletions regamedll/dlls/bot/cs_bot_manager.cpp
Expand Up @@ -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;
}
}
}
1 change: 1 addition & 0 deletions regamedll/dlls/bot/cs_bot_manager.h
Expand Up @@ -76,6 +76,7 @@ class CCSBotManager: public CBotManager

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); }
Expand Down
1 change: 0 additions & 1 deletion regamedll/dlls/bot/states/cs_bot_attack.cpp
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions regamedll/dlls/cbase.cpp
Expand Up @@ -1067,4 +1067,9 @@ void EXT_FUNC OnFreeEntPrivateData(edict_t *pEnt)
}
#endif

#ifdef REGAMEDLL_FIXES
if (TheCSBots()) {
TheCSBots()->OnFreeEntPrivateData(pEntity);
}
#endif
}

0 comments on commit cd96c91

Please sign in to comment.