Skip to content

Commit

Permalink
fix: allow to plant bomb only when icon blinking (ref #323)
Browse files Browse the repository at this point in the history
fix: random bots shoots and enemy ignorance on es_industrial (ref #323)
  • Loading branch information
jeefo committed Feb 27, 2024
1 parent b56a598 commit 9201daf
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ext/linkage
2 changes: 1 addition & 1 deletion inc/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Frustum : public Singleton <Frustum> {
public:
using Planes = Plane[static_cast <int> (PlaneSide::Num)];

private:
public:
static constexpr float kFov = 75.0f;
static constexpr float kAspectRatio = 16.0f / 9.0f;
static constexpr float kMaxViewDistance = 4096.0f;
Expand Down
9 changes: 7 additions & 2 deletions src/botlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ void Bot::checkMsgQueue () {
}

// prevent terrorists from buying on es maps
if (game.mapIs (MapFlags::Escape) && m_team == Team::Terrorist) {
if (game.mapIs (MapFlags::Escape) && m_team == Team::Terrorist && !m_inBuyZone) {
m_buyState = BuyState::Done;
}

Expand Down Expand Up @@ -3475,7 +3475,12 @@ void Bot::takeBlind (int alpha) {
// this function gets called by network message handler, when screenfade message get's send
// it's used to make bot blind from the grenade.

m_maxViewDistance = rg.get (10.0f, 20.0f);
m_viewDistance = rg.get (10.0f, 20.0f);

// do not take in effect some unique map effects on round start
if (bots.getRoundStartTime () + 5.0f < game.time ()) {
m_viewDistance = m_maxViewDistance;
}
m_blindTime = game.time () + static_cast <float> (alpha - 200) / 16.0f;

if (m_blindTime < game.time ()) {
Expand Down
2 changes: 1 addition & 1 deletion src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ bool Bot::lookupEnemies () {
continue;
}

// extra skill player can see thru smoke... if beeing attacked
// extra skill player can see through smoke... if being attacked
if (cv_whose_your_daddy.bool_ () && (player->v.button & (IN_ATTACK | IN_ATTACK2)) && m_viewDistance < m_maxViewDistance) {
nearestDistanceSq = cr::sqrf (m_maxViewDistance);
}
Expand Down
8 changes: 4 additions & 4 deletions src/linkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

ConVar cv_version ("version", product.version.chars (), Var::ReadOnly);

gamefuncs_t dllapi;
newgamefuncs_t newapi;
enginefuncs_t engfuncs;
gamedll_funcs_t dllfuncs;
gamefuncs_t dllapi {};
newgamefuncs_t newapi {};
enginefuncs_t engfuncs {};
gamedll_funcs_t dllfuncs {};

meta_globals_t *gpMetaGlobals = nullptr;
gamedll_funcs_t *gpGamedllFuncs = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ int BotManager::getPlayerPriority (edict_t *ent) {
}

// give bots some priority
if (bot->m_hasC4 || bot->m_isVIP || bot->m_hasHostage || bot->m_healthValue < ent->v.health) {
if (bot->m_hasC4 || bot->m_isVIP || bot->m_hasHostage || bot->m_healthValue < ent->v.health || (bot->m_currentTravelFlags & PathFlag::Jump)) {
return bot->entindex () + kHighPriority;
}
auto task = bot->getCurrentTaskId ();
Expand Down Expand Up @@ -1452,8 +1452,8 @@ void Bot::newRound () {
m_changeViewTime = game.time () + (rg.chance (25) ? mp_freezetime.float_ () : 0.0f);
m_aimErrorTime = game.time ();

m_viewDistance = 4096.0f;
m_maxViewDistance = 4096.0f;
m_viewDistance = Frustum::kMaxViewDistance;
m_maxViewDistance = Frustum::kMaxViewDistance;

m_liftEntity = nullptr;
m_pickupItem = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ AStarResult AStarAlgo::find (int botTeam, int srcIndex, int destIndex, NodeAdder
auto rsRandomizer = 1.0f;

// randomize path on round start now and then
if (cv_path_randomize_on_round_start.bool_ () && bots.getRoundStartTime () + mp_freezetime.float_ () + 2.0f > game.time ()) {
if (cv_path_randomize_on_round_start.bool_ () && bots.getRoundStartTime () + 4.0f > game.time ()) {
rsRandomizer = rg.get (0.5f, static_cast <float> (botTeam) * 2.0f + 5.0f);
}

Expand Down
2 changes: 1 addition & 1 deletion src/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void Bot::normal_ () {
pushChatterMessage (Chatter::GoingToGuardVIPSafety); // play info about that
}
}
else if (game.mapIs (MapFlags::Demolition) && ((m_pathFlags & NodeFlag::Goal) || m_inBombZone)) {
else if (game.mapIs (MapFlags::Demolition) && ((m_pathFlags & NodeFlag::Goal) && m_inBombZone)) {
// is it a terrorist carrying the bomb?
if (m_hasC4) {
if ((m_states & Sense::SeeingEnemy) && numFriendsNear (pev->origin, 768.0f) == 0) {
Expand Down

0 comments on commit 9201daf

Please sign in to comment.