From 1394d08a28fde73a5bfb5469a4f6c56f09021bd0 Mon Sep 17 00:00:00 2001 From: jeefo Date: Thu, 19 Jun 2025 00:21:34 +0300 Subject: [PATCH] 0bot: allow bots to check breakable team (fix #693) --- inc/constant.h | 10 +++++++++- inc/engine.h | 7 ++++++- src/botlib.cpp | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/inc/constant.h b/inc/constant.h index 210d7e7..cdcdc7f 100644 --- a/inc/constant.h +++ b/inc/constant.h @@ -114,7 +114,7 @@ CR_DECLARE_SCOPED_ENUM (CollisionState, StrafeRight ) -// counter-strike team id's +// counter-strike team id's (internal for bot) CR_DECLARE_SCOPED_ENUM (Team, Terrorist = 0, CT, @@ -123,6 +123,14 @@ CR_DECLARE_SCOPED_ENUM (Team, Invalid = -1 ) +// counter-strike team id's (used by gamedll, for reference) +CR_DECLARE_SCOPED_ENUM (CSTeam, + Unassigned = 0, + Terrorist, + CT, + Spectator +) + // item status for StatusIcon message CR_DECLARE_SCOPED_ENUM (ItemStatus, Nightvision = cr::bit (0), diff --git a/inc/engine.h b/inc/engine.h index 6118649..56fc325 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -366,7 +366,12 @@ public: return util.getClient (indexOfPlayer (ent)).team2; } - // sets the precache to uninitialize + // get real gamedll team (matches gamedll indices) + int getGameTeam (edict_t *ent) const { + return getRealTeam (ent) + 1; + } + + // sets the precache to uninitialized void setUnprecached () { m_precached = false; } diff --git a/src/botlib.cpp b/src/botlib.cpp index 7bf2607..573a7ed 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -281,6 +281,12 @@ edict_t *Bot::lookupBreakable () { if (game.isNullEntity (ent)) { return false; } + + // check breakable team, needed for some plugins + if (ent->v.team > 0 && ent->v.team != game.getGameTeam (this->ent ())) { + return false; + } + for (const auto &br : m_ignoredBreakable) { if (br == ent) { return false;