Skip to content

Commit

Permalink
add new CVar "bot_agressive"
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaqtincha committed Jun 8, 2021
1 parent 2c52c4f commit 689430a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| bot_quota_mode | normal | - | - | Determines the type of quota.<br/>`normal` default behaviour<br/>`fill` the server will adjust bots to keep `N` players in the game, where `N` is bot_quota<br/>`match` the server will maintain a `1:N` ratio of humans to bots, where `N` is bot_quota |
| bot_join_delay | 0 | - | - | Prevents bots from joining the server for this many seconds after a map change. |
| bot_freeze | 0 | 0 | 1 | Prevents bots on your server from moving.<br/>`0` disabled<br/>`1` enabled |
| bot_agressive | 1 | 0 | 2 | Bots can chastise friendly fire from humans.<br/>`0` disabled<br/>`1` only hunt due to teammate death<br/>`2` same as 1, but also when injuring |
| mp_item_staytime | 300 | - | - | Time to remove item that have been dropped from the players. |
| mp_legacy_bombtarget_touch | 1 | 0 | 1 | Legacy func_bomb_target touch. New one is more strict. <br/>`0` New behavior<br/>`1` Legacy behavior|
| mp_respawn_immunitytime | 0 | 0 | - | Specifies the players defense time after respawn. (in seconds).<br/>`0` disabled<br/>`>0.00001` time delay to remove protection |
Expand Down
8 changes: 8 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ bot_join_delay 0
// Default value: "0"
bot_freeze 0
// Bots can chastise friendly fire from humans.
// 0 - disabled
// 1 - only hunt due to teammate death (default behavior)
// 2 - same as 1, but also when injuring
//
// Default value: "1"
bot_agressive 1
// Debug cvar shows triggers.
// 0 - disabled (default behaviour)
// 1 - enabled
Expand Down
43 changes: 26 additions & 17 deletions regamedll/dlls/bot/cs_bot_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,38 @@ void CCSBot::OnEvent(GameEventType event, CBaseEntity *pEntity, CBaseEntity *pOt
// automatically acquire our dead friend's killer
if (!IsAttacking() && (GetDisposition() == ENGAGE_AND_INVESTIGATE || GetDisposition() == OPPORTUNITY_FIRE))
{
if (event == EVENT_PLAYER_DIED)
if (event == EVENT_PLAYER_DIED ||
#ifdef REGAMEDLL_ADD
event == EVENT_PLAYER_TOOK_DAMAGE
#endif
)
{
if (BotRelationship(pPlayer) == BOT_TEAMMATE)
{
CBasePlayer *pKiller = static_cast<CBasePlayer *>(pOther);

// check that attacker is an enemy (for friendly fire, etc)
if (pKiller && pKiller->IsPlayer())
#ifdef REGAMEDLL_ADD
if ((event == EVENT_PLAYER_DIED && cv_bot_agressive.value != 0) || (event == EVENT_PLAYER_TOOK_DAMAGE && cv_bot_agressive.value > 1))
#endif
{
// check if we saw our friend die - dont check FOV - assume we're aware of our surroundings in combat
// snipers stay put
if (!IsSniper() && IsVisible(&pPlayer->pev->origin))
{
// people are dying - we should hurry
Hurry(RANDOM_FLOAT(10.0f, 15.0f));
CBasePlayer *pKiller = static_cast<CBasePlayer *>(pOther);

// if we're hiding with only our knife, be a little more cautious
const float knifeAmbushChance = 50.0f;
if (!IsHiding() || !IsUsingKnife() || RANDOM_FLOAT(0, 100) < knifeAmbushChance)
// check that attacker is an enemy (for friendly fire, etc)
if (pKiller && pKiller->IsPlayer())
{
// check if we saw our friend die - dont check FOV - assume we're aware of our surroundings in combat
// snipers stay put
if (!IsSniper() && IsVisible(&pPlayer->pev->origin))
{
PrintIfWatched("Attacking our friend's killer!\n");
Attack(pKiller);
return;
// people are dying - we should hurry
Hurry(RANDOM_FLOAT(10.0f, 15.0f));

// if we're hiding with only our knife, be a little more cautious
const float knifeAmbushChance = 50.0f;
if (!IsHiding() || !IsUsingKnife() || RANDOM_FLOAT(0, 100) < knifeAmbushChance)
{
PrintIfWatched("Attacking our friend's killer!\n");
Attack(pKiller);
return;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/bot/cs_bot_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.
cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_join_delay = { "bot_join_delay", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_freeze = { "bot_freeze", "0", 0, 0.0f, nullptr };
cvar_t cv_bot_agressive = { "bot_agressive", "1", FCVAR_SERVER, 0.0f, nullptr };
#else
// Migrated to bot_quota_mode, use "match"
cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr };
Expand Down Expand Up @@ -131,6 +132,7 @@ void Bot_RegisterCVars()
CVAR_REGISTER(&cv_bot_quota_mode);
CVAR_REGISTER(&cv_bot_join_delay);
CVAR_REGISTER(&cv_bot_freeze);
CVAR_REGISTER(&cv_bot_agressive);
#endif

}
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/bot/cs_bot_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ extern cvar_t cv_bot_deathmatch;
extern cvar_t cv_bot_quota_mode;
extern cvar_t cv_bot_join_delay;
extern cvar_t cv_bot_freeze;
extern cvar_t cv_bot_agressive;
#else
extern cvar_t cv_bot_quota_match;
#endif

0 comments on commit 689430a

Please sign in to comment.