Skip to content

Commit

Permalink
only the victim bot is aggressive when injured
Browse files Browse the repository at this point in the history
minor fix check "bot_agressive"
  • Loading branch information
Vaqtincha committed Jun 12, 2021
1 parent 404cd78 commit 2a4e5c0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion regamedll/dlls/bot/cs_bot_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOt
#ifdef REGAMEDLL_ADD
&&
cv_bot_agressive.value == 0) ||
(cv_bot_agressive.value == 1 && event == EVENT_PLAYER_DIED) ||
(cv_bot_agressive.value >= 1 && event == EVENT_PLAYER_DIED) ||
(cv_bot_agressive.value == 2 && event == EVENT_PLAYER_TOOK_DAMAGE
#endif
))
Expand Down
46 changes: 30 additions & 16 deletions regamedll/game_shared/bot/bot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,29 +218,43 @@ const char *CBotManager::GetNavMapFilename() const
// TODO: This has become the game-wide event dispatcher. We should restructure this.
void CBotManager::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOther)
{
// propogate event to all bots
for (int i = 1; i <= gpGlobals->maxClients; i++)
#ifdef REGAMEDLL_ADD
if (event == EVENT_PLAYER_TOOK_DAMAGE)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
CBasePlayer *pAttacker = static_cast<CBasePlayer *>(pOther);
if (pAttacker && !pAttacker->IsBot())
{
CBot *bot = static_cast<CBot *>(pEntity);
bot->OnEvent(event, pEntity, pOther);
}
}
else
#endif
{
// propogate event to all bots
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);

if (!pPlayer)
continue;
if (!pPlayer)
continue;

if (FNullEnt(pPlayer->pev))
continue;
if (FNullEnt(pPlayer->pev))
continue;

if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue;
if (FStrEq(STRING(pPlayer->pev->netname), ""))
continue;

if (!pPlayer->IsBot())
continue;
if (!pPlayer->IsBot())
continue;

// do not send self-generated event
if (pEntity == pPlayer)
continue;
// do not send self-generated event
if (pEntity == pPlayer)
continue;

CBot *bot = static_cast<CBot *>(pPlayer);
bot->OnEvent(event, pEntity, pOther);
CBot *bot = static_cast<CBot *>(pPlayer);
bot->OnEvent(event, pEntity, pOther);
}
}

if (TheTutor)
Expand Down

0 comments on commit 2a4e5c0

Please sign in to comment.