Skip to content

Commit

Permalink
Merge pull request #560 from yapb/chatter-fixes-and-improvements
Browse files Browse the repository at this point in the history
Chatter fixes and improvements
  • Loading branch information
Vladislav4KZ committed May 26, 2024
2 parents eec4101 + 279b1e5 commit 54e7eb4
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 24 deletions.
21 changes: 14 additions & 7 deletions cfg/addons/yapb/conf/chatter.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Event Radio_CoverMe = cover_me, cover_me2
// Event Radio_YouTakePoint =
// Event Radio_HoldPosition =
// Event Radio_RegroupTeam =
Event Radio_FollowMe = lead_on_sir, lead_the_way_sir, lead_the_way, ok_sir_lets_go, lead_on_commander, lead_the_way_commander, ok_cmdr_lets_go
// Event Radio_FollowMe =
Event Radio_TakingFire = taking_fire_need_assistance2, i_could_use_some_help, i_could_use_some_help_over_here, help, need_help, need_help2, im_in_trouble

// Event Radio_GoGoGo =
Expand All @@ -24,8 +24,8 @@ Event Radio_TakingFire = taking_fire_need_assistance2, i_could_use_some_help, i_
Event Radio_ReportTeam = report_in_team, anyone_see_them, anyone_see_anything, where_are_they, where_could_they_be

Event Radio_Affirmative = affirmative, roger_that, me_too, ill_come_with_you, ill_go_with_you, ill_go_too, i_got_your_back, i_got_your_back2, im_with_you, im_with_you, sounds_like_a_plan, good_idea
Event Radio_EnemySpotted = one_guy, two_of_them, three, three_of_them, a_bunch_of_them, theyre_all_over_the_place2, theyre_everywhere2, theres_too_many_of_them, theres_too_many, too_many2, the_actions_hot_here, its_a_party
Event Radio_NeedBackup = taking_fire_need_assistance2, i_could_use_some_help, i_could_use_some_help_over_here, help, need_help, need_help2, im_in_trouble
// Event Radio_EnemySpotted =
// Event Radio_NeedBackup =
Event Radio_SectorClear = clear, clear2, clear3, clear4, area_clear, all_clear_here, nothing_moving_over_here, all_quiet, nothing_happening_over_here, i_got_nothing, nothing, nothing_here, theres_nobody_home
Event Radio_InPosition = lets_wait_here, lets_hold_up_here_for_a_minute, im_gonna_hang_back, im_going_to_wait_here, im_waiting_here
Event Radio_ReportingIn = reporting_in
Expand All @@ -41,10 +41,9 @@ Event Chatter_GotBlinded = ive_been_blinded, my_eyes, i_cant_see, im_blind
Event Chatter_GoingToPlantBomb = im_gonna_go_plant, im_gonna_go_plant_the_bomb
Event Chatter_RescuingHostages = the_hostages_are_with_me, taking_the_hostages_to_safety, ive_got_the_hostages, i_have_the_hostages
Event Chatter_GoingToCamp = im_going_to_camp
Event Chatter_HearSomething = hang_on_i_heard_something, i_hear_something, i_hear_them, i_heard_them, i_heard_something_over_there
Event Chatter_TeamKill = what_happened, noo, oh_my_god, oh_man, oh_no_sad, what_have_you_done
Event Chatter_ReportingIn = reporting_in
Event Chatter_GuardDroppedC4 = bombsite, bombsite2
Event Chatter_GuardingPlantedC4 = bombsite_secure, bombsite_under_control
Event Chatter_Camp = im_waiting_here
Event Chatter_PlantingC4 = planting_the_bomb, planting
Event Chatter_DefusingC4 = defusing, defusing_bomb, defusing_bomb_now
Expand All @@ -58,27 +57,35 @@ Event Chatter_WonTheRound = good_job_team, nice_work_team, way_to_be_team, well_
Event Chatter_QuicklyWonTheRound = i_am_dangerous, do_not_mess_with_me, we_owned_them, they_never_knew_what_hit_them, thats_the_way_this_is_done, and_thats_how_its_done, owned, yesss, yesss2, yea_baby, whoo, whoo2, oh_yea, oh_yea2
Event Chatter_ScaredEmotion = whoa, uh_oh, oh_no, yikes, oh, oh_boy, oh_boy2, aah
Event Chatter_HeardEnemy = i_hear_them, hang_on_i_heard_something, i_hear_something, i_heard_them, i_heard_something_over_there
Event Chatter_SpottedOneEnemy = one_guy
Event Chatter_SpottedTwoEnemies = two_of_them
Event Chatter_SpottedThreeEnemies = three, three_of_them
Event Chatter_TooManyEnemies = a_bunch_of_them, theyre_all_over_the_place2, theyre_everywhere2, theres_too_many_of_them, theres_too_many, too_many2, the_actions_hot_here, its_a_party
Event Chatter_SniperWarning = sniper, sniper2, watch_it_theres_a_sniper
Event Chatter_SniperKilled = got_the_sniper, got_the_sniper2, sniper_down, took_out_the_sniper, the_sniper_is_dead
Event Chatter_VIPSpotted = i_see_our_target, target_spotted, target_acquired
Event Chatter_GuardingEscapeZone = watching_the_escape_zone, watching_the_escape_route, they_will_not_escape, im_at_the_escape_zone, guarding_the_escape_zone, guarding_the_escape_zone2
Event Chatter_GuardingVipSafety = watching_the_escape_route, im_at_the_escape_zone, watching_the_escape_zone, guarding_the_escape_zone, guarding_the_escape_zone2
Event Chatter_GoingToGuardEscapeZone = im_going_to_keep_an_eye_on_the_escape, im_going_to_watch_the_escape_zone, im_going_to_cover_the_escape_zone
Event Chatter_GoingToGuardRescueZone = im_going_to_watch_the_rescue_zone, im_going_to_keep_an_eye_on_the_rescue
Event Chatter_GoingToGuardVIPSafety = im_going_to_cover_the_escape_zone, im_going_to_watch_the_escape_zone, im_going_to_keep_an_eye_on_the_escape, heading_to_the_escape_zone
Event Chatter_OneEnemyLeft = one_guy_left, theres_one_left
Event Chatter_TwoEnemiesLeft = two_enemies_left, two_to_go
Event Chatter_ThreeEnemiesLeft = three_left, three_to_go, three_to_go2
Event Chatter_NoEnemiesLeft = that_was_the_last_one, that_was_it, that_was_the_last_guy
Event Chatter_FoundBombPlace = theres_the_bomb, theres_the_bomb2
Event Chatter_WhereIsTheBomb = wheres_the_bomb, wheres_the_bomb2, wheres_the_bomb3, where_is_it
Event Chatter_DefendingBombSite = bombsite, bombsite2
Event Chatter_DefendingBombSite = bombsite_secured, bombsite_under_control
Event Chatter_BarelyDefused = i_wasnt_worried_for_a_minute, that_was_a_close_one, well_done, whew_that_was_close
Event Chatter_NiceshotCommander = good_one_sir, good_one_sir2, nice_shot_sir, nice_one_sir
Event Chatter_NiceshotPall = good_one, good_one2, nice_shot, nice_shot2, good_shot, good_shot2, nice, nice2, very_nice
Event Chatter_GoingToGuardHostages = camping_hostages, im_going_to_camp_the_hostages, im_going_to_guard_the_hostages, im_going_to_guard_the_hostages2
Event Chatter_GoingToGuardDoppedBomb = im_going_to_guard_the_bomb, im_going_to_guard_the_bomb2, im_going_to_keep_an_eye_on_the_bomb, im_going_to_watch_the_bomb
Event Chatter_GoingToGuardDroppedBomb = im_going_to_guard_the_bomb, im_going_to_guard_the_bomb2, im_going_to_keep_an_eye_on_the_bomb, im_going_to_watch_the_bomb
Event Chatter_OnMyWay = on_my_way, on_my_way2, im_coming, hang_on_im_coming, be_right_there
Event Chatter_LeadOnSir = lead_on_sir, lead_the_way_sir, lead_the_way, ok_sir_lets_go, lead_on_commander, lead_the_way_commander, ok_cmdr_lets_go
Event Chatter_Pinned_Down = they_got_me_pinned_down_here, im_pinned_down
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
11 changes: 9 additions & 2 deletions inc/constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ CR_DECLARE_SCOPED_ENUM (Chatter,
GoingToPlantBomb,
RescuingHostages,
GoingToCamp,
HeardNoise,
TeamAttack,
TeamKill,
ReportingIn,
GuardingDroppedC4,
GuardingPlantedC4,
Camping,
PlantingBomb,
DefusingBomb,
Expand All @@ -196,10 +195,17 @@ CR_DECLARE_SCOPED_ENUM (Chatter,
WonTheRound,
ScaredEmotion,
HeardTheEnemy,
SpottedOneEnemy,
SpottedTwoEnemies,
SpottedThreeEnemies,
TooManyEnemies,
SniperWarning,
SniperKilled,
VIPSpotted,
GuardingEscapeZone,
GuardingVIPSafety,
GoingToGuardEscapeZone,
GoingToGuardRescueZone,
GoingToGuardVIPSafety,
QuickWonRound,
OneEnemyLeft,
Expand All @@ -224,6 +230,7 @@ CR_DECLARE_SCOPED_ENUM (Chatter,
CoverMe,
BehindSmoke,
BombsiteSecured,
OnARoll,
Count
)

Expand Down
6 changes: 4 additions & 2 deletions inc/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ CR_DECLARE_SCOPED_ENUM (TextMsgCache,
CR_DECLARE_SCOPED_ENUM (StatusIconCache,
NeedHandle = cr::bit (0),
BuyZone = cr::bit (1),
VipSafety = cr::bit (2),
C4 = cr::bit (3)
Escape = cr::bit (2),
Rescue = cr::bit (3),
VipSafety = cr::bit (4),
C4 = cr::bit (5)
)

class MessageDispatcher final : public Singleton <MessageDispatcher> {
Expand Down
5 changes: 5 additions & 0 deletions inc/yapb.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class Bot final {
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
Expand Down Expand Up @@ -285,6 +286,8 @@ class Bot final {
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
Expand Down Expand Up @@ -656,6 +659,8 @@ class Bot final {
bool m_ignoreBuyDelay {}; // when reaching buyzone in the middle of the round don't do pauses
bool m_inBombZone {}; // bot in the bomb zone or not
bool m_inBuyZone {}; // bot currently in buy zone
bool m_inEscapeZone {}; // bot currently in escape zone
bool m_inRescueZone {}; // bot currently in rescue zone
bool m_inVIPZone {}; // bot in the vip safety zone
bool m_buyingFinished {}; // done with buying
bool m_buyPending {}; // bot buy is pending
Expand Down
69 changes: 61 additions & 8 deletions src/botlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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 ()) {
Expand Down Expand Up @@ -2182,13 +2197,21 @@ void Bot::startTask (Task id, float desire, int data, float time, bool resume) {

if (rg.chance (25) && tid == Task::Camp) {
if (game.mapIs (MapFlags::Demolition) && bots.isBombPlanted ()) {
pushChatterMessage (Chatter::GuardingDroppedC4);
pushChatterMessage (Chatter::GuardingPlantedC4);
}
else {
pushChatterMessage (Chatter::GoingToCamp);
}
}

if (rg.chance (75) && tid == Task::Camp && m_team == Team::CT && m_inEscapeZone) {
pushChatterMessage (Chatter::GoingToGuardEscapeZone);
}

if (rg.chance (75) && tid == Task::Camp && m_team == Team::Terrorist && m_inRescueZone) {
pushChatterMessage (Chatter::GoingToGuardRescueZone);
}

if (rg.chance (75) && tid == Task::Camp && m_team == Team::Terrorist && m_inVIPZone) {
pushChatterMessage (Chatter::GoingToGuardVIPSafety);
}
Expand Down Expand Up @@ -2322,7 +2345,7 @@ void Bot::checkRadioQueue () {


// don't allow bot listen you if bot is busy
if (getCurrentTaskId () == Task::DefuseBomb || getCurrentTaskId () == Task::PlantBomb || m_hasHostage || m_hasC4 || m_isCreature) {
if (m_radioOrder != Radio::ReportInTeam && (getCurrentTaskId () == Task::DefuseBomb || getCurrentTaskId () == Task::PlantBomb || m_hasHostage || m_hasC4 || m_isCreature)) {
m_radioOrder = 0;
return;
}
Expand Down Expand Up @@ -2440,6 +2463,10 @@ void Bot::checkRadioQueue () {

case Radio::EnemySpotted:
case Radio::NeedBackup:
case Chatter::SpottedOneEnemy:
case Chatter::SpottedTwoEnemies:
case Chatter::SpottedThreeEnemies:
case Chatter::TooManyEnemies:
case Chatter::ScaredEmotion:
case Chatter::PinnedDown:
if (((game.isNullEntity (m_enemy) && seesEntity (m_radioEntity->v.origin)) || distanceSq < cr::sqrf (2048.0f) || !m_moveToC4)
Expand Down Expand Up @@ -2626,21 +2653,21 @@ void Bot::checkRadioQueue () {
const Path &path = graph[getTask ()->data];

if (path.flags & NodeFlag::Goal) {
if (game.mapIs (MapFlags::Demolition) && m_team == Team::Terrorist && m_hasC4) {
if (m_hasC4) {
pushChatterMessage (Chatter::GoingToPlantBomb);
}
else {
pushChatterMessage (Chatter::Nothing);
}
}
else if (path.flags & NodeFlag::Rescue) {
else if (m_hasHostage) {
pushChatterMessage (Chatter::RescuingHostages);
}
else if ((path.flags & NodeFlag::Camp) && rg.chance (75)) {
pushChatterMessage (Chatter::GoingToCamp);
}
else {
pushChatterMessage (Chatter::HeardNoise);
else if (m_states & Sense::HearingEnemy) {
pushChatterMessage (Chatter::HeardTheEnemy);
}
}
else if (rg.chance (30)) {
Expand All @@ -2657,7 +2684,10 @@ void Bot::checkRadioQueue () {
case Task::Camp:
if (rg.chance (40)) {
if (bots.isBombPlanted () && m_team == Team::Terrorist) {
pushChatterMessage (Chatter::GuardingDroppedC4);
pushChatterMessage (Chatter::GuardingPlantedC4);
}
else if (m_inEscapeZone && m_team == Team::CT) {
pushChatterMessage (Chatter::GuardingEscapeZone);
}
else if (m_inVIPZone && m_team == Team::Terrorist) {
pushChatterMessage (Chatter::GuardingVIPSafety);
Expand All @@ -2677,7 +2707,30 @@ void Bot::checkRadioQueue () {
break;

case Task::Attack:
pushChatterMessage (Chatter::InCombat);
if (rg.chance (50)) {
pushChatterMessage (Chatter::InCombat);
}
else {
if (cv_radio_mode.as <int> () == 2) {
switch (numEnemiesNear (pev->origin, 384.0f)) {
case 1:
pushChatterMessage (Chatter::SpottedOneEnemy);
break;
case 2:
pushChatterMessage (Chatter::SpottedTwoEnemies);
break;
case 3:
pushChatterMessage (Chatter::SpottedThreeEnemies);
break;
default:
pushChatterMessage (Chatter::TooManyEnemies);
break;
}
}
else if (cv_radio_mode.as <int> () == 1) {
pushRadioMessage (Radio::EnemySpotted);
}
}
break;

case Task::Hide:
Expand Down
20 changes: 19 additions & 1 deletion src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,25 @@ bool Bot::lookupEnemies () {
}
else {
if (m_seeEnemyTime + 3.0f < game.time () && (m_hasC4 || m_hasHostage || !game.isNullEntity (m_targetEntity))) {
pushRadioMessage (Radio::EnemySpotted);
if (cv_radio_mode.as <int> () == 2) {
switch (numEnemiesNear (pev->origin, 384.0f)) {
case 1:
pushChatterMessage (Chatter::SpottedOneEnemy);
break;
case 2:
pushChatterMessage (Chatter::SpottedTwoEnemies);
break;
case 3:
pushChatterMessage (Chatter::SpottedThreeEnemies);
break;
default:
pushChatterMessage (Chatter::TooManyEnemies);
break;
}
}
else if (cv_radio_mode.as <int> () == 1) {
pushRadioMessage (Radio::EnemySpotted);
}
}
m_targetEntity = nullptr; // stop following when we see an enemy...

Expand Down
14 changes: 11 additions & 3 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,12 @@ void BotConfig::loadChatterConfig () {
{ "Radio_EnemyDown", Radio::EnemyDown, 10.0f },
{ "Chatter_DiePain", Chatter::DiePain, kMaxChatterRepeatInterval },
{ "Chatter_GoingToPlantBomb", Chatter::GoingToPlantBomb, 5.0f },
{ "Chatter_GoingToGuardEscapeZone", Chatter::GoingToGuardEscapeZone, kMaxChatterRepeatInterval },
{ "Chatter_GoingToGuardRescueZone", Chatter::GoingToGuardRescueZone, kMaxChatterRepeatInterval },
{ "Chatter_GoingToGuardVIPSafety", Chatter::GoingToGuardVIPSafety, kMaxChatterRepeatInterval },
{ "Chatter_RescuingHostages", Chatter::RescuingHostages, kMaxChatterRepeatInterval },
{ "Chatter_TeamKill", Chatter::TeamKill, kMaxChatterRepeatInterval },
{ "Chatter_GuardingEscapeZone", Chatter::GuardingEscapeZone, kMaxChatterRepeatInterval },
{ "Chatter_GuardingVipSafety", Chatter::GuardingVIPSafety, kMaxChatterRepeatInterval },
{ "Chatter_PlantingC4", Chatter::PlantingBomb, 10.0f },
{ "Chatter_InCombat", Chatter::InCombat, kMaxChatterRepeatInterval },
Expand All @@ -290,19 +293,23 @@ void BotConfig::loadChatterConfig () {
{ "Chatter_VIPSpotted", Chatter::VIPSpotted, 5.3f },
{ "Chatter_FriendlyFire", Chatter::FriendlyFire, 2.1f },
{ "Chatter_GotBlinded", Chatter::Blind, 12.0f },
{ "Chatter_GuardDroppedC4", Chatter::GuardingDroppedC4, 3.0f },
{ "Chatter_GuardingPlantedC4", Chatter::GuardingPlantedC4, 3.0f },
{ "Chatter_DefusingC4", Chatter::DefusingBomb, 3.0f },
{ "Chatter_FoundC4", Chatter::FoundC4, 5.5f },
{ "Chatter_ScaredEmotion", Chatter::ScaredEmotion, 6.1f },
{ "Chatter_HeardEnemy", Chatter::ScaredEmotion, 12.8f },
{ "Chatter_HeardEnemy", Chatter::HeardTheEnemy, 12.8f },
{ "Chatter_SpottedOneEnemy", Chatter::SpottedOneEnemy, 4.0f },
{ "Chatter_SpottedTwoEnemies", Chatter::SpottedTwoEnemies, 4.0f },
{ "Chatter_SpottedThreeEnemies", Chatter::SpottedThreeEnemies, 4.0f },
{ "Chatter_TooManyEnemies", Chatter::TooManyEnemies, 4.0f },
{ "Chatter_SniperWarning", Chatter::SniperWarning, 14.3f },
{ "Chatter_SniperKilled", Chatter::SniperKilled, 12.1f },
{ "Chatter_OneEnemyLeft", Chatter::OneEnemyLeft, 12.5f },
{ "Chatter_TwoEnemiesLeft", Chatter::TwoEnemiesLeft, 12.5f },
{ "Chatter_ThreeEnemiesLeft", Chatter::ThreeEnemiesLeft, 12.5f },
{ "Chatter_NiceshotPall", Chatter::NiceShotPall, 2.0f },
{ "Chatter_GoingToGuardHostages", Chatter::GoingToGuardHostages, 3.0f },
{ "Chatter_GoingToGuardDoppedBomb", Chatter::GoingToGuardDroppedC4, 6.0f },
{ "Chatter_GoingToGuardDroppedBomb", Chatter::GoingToGuardDroppedC4, 6.0f },
{ "Chatter_OnMyWay", Chatter::OnMyWay, 1.5f },
{ "Chatter_LeadOnSir", Chatter::LeadOnSir, 5.0f },
{ "Chatter_Pinned_Down", Chatter::PinnedDown, 5.0f },
Expand All @@ -315,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)) {
Expand Down
Loading

0 comments on commit 54e7eb4

Please sign in to comment.