From 9d7b037e05f6484685f309e61623c9f010963b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D1=81=D0=BB=D0=B0=D0=B2=20?= =?UTF-8?q?=D0=A1=D1=83=D1=85=D0=BE=D0=B2?= <22411953+Vladislav4KZ@users.noreply.github.com> Date: Mon, 20 May 2024 19:58:59 +0000 Subject: [PATCH] add: OnARoll chatter event with phrases that bots will say when completing a kill streak in a short amount of time --- cfg/addons/yapb/conf/chatter.cfg | 1 + inc/constant.h | 1 + inc/yapb.h | 3 +++ src/botlib.cpp | 15 +++++++++++++++ src/config.cpp | 1 + 5 files changed, 21 insertions(+) diff --git a/cfg/addons/yapb/conf/chatter.cfg b/cfg/addons/yapb/conf/chatter.cfg index d77fe72..cb37a45 100644 --- a/cfg/addons/yapb/conf/chatter.cfg +++ b/cfg/addons/yapb/conf/chatter.cfg @@ -88,3 +88,4 @@ Event Chatter_GottaFindTheBomb = theres_the_bomb, theres_the_bomb2 Event Chatter_Lost_The_Commander = weve_lost_the_commander, the_commander_is_down, the_commander_is_down_repeat Event Chatter_CoverMe = cover_me, cover_me2 Event Chatter_BombSiteSecured = i_wasnt_worried_for_a_minute, that_was_a_close_one, well_done, whew_that_was_close +Event Chatter_OnARoll = i_got_more_where_that_came_from, who_wants_some_more, i_am_on_fire, look_out_brag, thats_right, whos_the_man diff --git a/inc/constant.h b/inc/constant.h index cdc2eb6..75c6b26 100644 --- a/inc/constant.h +++ b/inc/constant.h @@ -230,6 +230,7 @@ CR_DECLARE_SCOPED_ENUM (Chatter, CoverMe, BehindSmoke, BombsiteSecured, + OnARoll, Count ) diff --git a/inc/yapb.h b/inc/yapb.h index b2e2bdc..ecc0a7e 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -226,6 +226,7 @@ private: int m_tryOpenDoor {}; // attempt's to open the door int m_liftState {}; // state of lift handling int m_radioSelect {}; // radio entry + int m_killsCount {}; // the kills count of a bot int m_lastPredictIndex { kInvalidNodeIndex }; // last predicted path index int m_lastPredictLength {}; // last predicted path length @@ -286,6 +287,8 @@ private: float m_breakableTime {}; // breakable acquired time float m_stuckTimestamp {}; // last time was stuck float m_timeDebugUpdateTime {}; // time to update last debug timestamp + float m_lastVictimTime {}; // time when bot killed an enemy + float m_killsInterval {}; // interval between kills bool m_moveToGoal {}; // bot currently moving to goal?? bool m_isStuck {}; // bot is stuck diff --git a/src/botlib.cpp b/src/botlib.cpp index 00d97db..b0ff656 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -1806,6 +1806,7 @@ void Bot::refreshEnemyPredict () { void Bot::setLastVictim (edict_t *ent) { m_lastVictim = ent; m_lastVictimOrigin = ent->v.origin; + m_lastVictimTime = game.time (); m_forgetLastVictimTimer.start (rg (1.0f, 2.0f)); } @@ -1870,6 +1871,20 @@ void Bot::setConditions () { } } } + else { + auto currentTime = game.time(); + + m_killsInterval = currentTime - m_lastVictimTime; + if (m_killsInterval <= 5) { + m_killsCount++; + if (m_killsCount > 2) { + pushChatterMessage(Chatter::OnARoll); + } + } + else { + m_killsCount = 0; + } + } // if no more enemies found AND bomb planted, switch to knife to get to bomb place faster if (m_team == Team::CT && !usesKnife () && m_numEnemiesLeft == 0 && bots.isBombPlanted ()) { diff --git a/src/config.cpp b/src/config.cpp index e1075da..cb1be2b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -322,6 +322,7 @@ void BotConfig::loadChatterConfig () { { "Chatter_BombSiteSecured", Chatter::BombsiteSecured, 3.5f }, { "Chatter_GoingToCamp", Chatter::GoingToCamp, 30.0f }, { "Chatter_Camp", Chatter::Camping, 10.0f }, + { "Chatter_OnARoll", Chatter::OnARoll, kMaxChatterRepeatInterval}, }; while (file.getLine (line)) {