Skip to content

Commit

Permalink
Merge pull request #3 from s1lentq/master
Browse files Browse the repository at this point in the history
uptodate
  • Loading branch information
SergeyShorokhov authored Jul 8, 2019
2 parents a5283cf + b669a39 commit feae856
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 25 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
| showtriggers | 0 | 0 | 1 | Debug cvar shows triggers. |
| sv_alltalk | 0 | 0 | 4 | When players can hear each other ([further explanation](../../wiki/sv_alltalk)).<br/>`0` dead don't hear alive<br/>`1` no restrictions<br/>`2` teammates hear each other<br/>`3` Same as 2, but spectators hear everybody<br/>`4` alive hear alive, dead hear dead and alive.
| bot_deathmatch | 0 | 0 | 1 | Set's the mode for the zBot.<br/>`0` disabled<br/>`1` enable mode Deathmatch and not allow to do the scenario |
| 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 |
| 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. |
| 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
16 changes: 16 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,27 @@ mp_round_infinite 0
// The round by expired time will be over, if on a map it does not have the scenario of the game.
// 0 - disabled (default behaviour)
// 1 - enabled
//
// Default value: "0"
mp_roundover 0
// Number of seconds to delay before restarting a round after a win.
//
// Default value: "5"
mp_round_restart_delay 5
// Disable grenade damage through walls
// 0 - disabled
// 1 - enabled
//
// Default value: "0"
mp_hegrenade_penetration 0
// Drop a grenade after player death
// 0 - disabled
// 1 - drop one the grenade
// 2 - drop an everyone grenades
//
// Default value: "0"
mp_nadedrops 0
Expand Down Expand Up @@ -129,11 +133,15 @@ mp_forcerespawn 0
// 1 - from any team (default behaviour)
// 2 - only from CT
// 3 - only from T
//
// Default value: "1"
mp_hostage_hurtable 1
// Show radio icon.
// 0 - disabled
// 1 - enabled (default behavior)
//
// Default value: "1"
mp_show_radioicon 1
// Play "Bomb has been defused" sound instead of "Counter-Terrorists win" when bomb was defused
Expand All @@ -153,10 +161,16 @@ bot_deathmatch 0
// Determines the type of quota.
// normal - default behaviour
// fill - the server will adjust bots to keep N players in the game, where N is bot_quota
// match - the server will maintain a 1:N ratio of humans to bots, where N is bot_quota
//
// Default value: "normal"
bot_quota_mode "normal"

// Prevents bots from joining the server for this many seconds after a map change.
//
// Default value: "0"
bot_join_delay 0

// Debug cvar shows triggers.
// 0 - disabled (default behaviour)
// 1 - enabled
Expand Down Expand Up @@ -217,6 +231,7 @@ mp_allow_point_servercommand "0"
// 3 - show 'HP' field to teammates
// 4 - show 'HP' field to all clients
// 5 - show 'HP' field to teammates and spectators
//
// Default value: "3"
mp_scoreboard_showhealth "3"

Expand All @@ -227,6 +242,7 @@ mp_scoreboard_showhealth "3"
// 3 - show 'Money' field to teammates
// 4 - show 'Money' field to all clients
// 5 - show 'Money' field to teammates and spectators
//
// Default value: "3"
mp_scoreboard_showmoney "3"
Expand Down
10 changes: 9 additions & 1 deletion regamedll/dlls/bot/cs_bot_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ cvar_t cv_bot_difficulty = { "bot_difficulty", "0", FCVAR_SERVER, 0.
cvar_t cv_bot_debug = { "bot_debug", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_quicksave = { "bot_quicksave", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_quota = { "bot_quota", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_prefix = { "bot_prefix", "", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_allow_rogues = { "bot_allow_rogues", "1", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_allow_pistols = { "bot_allow_pistols", "1", FCVAR_SERVER, 0.0f, nullptr };
Expand All @@ -61,6 +60,10 @@ cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVA
#ifdef REGAMEDLL_ADD
cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.0f, nullptr };
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 };
#else
// Migrated to bot_quota_mode, use "match"
cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr };
#endif

void InstallBotControl()
Expand Down Expand Up @@ -99,7 +102,11 @@ void Bot_RegisterCVars()
CVAR_REGISTER(&cv_bot_debug);
CVAR_REGISTER(&cv_bot_quicksave);
CVAR_REGISTER(&cv_bot_quota);

#ifndef REGAMEDLL_ADD
CVAR_REGISTER(&cv_bot_quota_match);
#endif

CVAR_REGISTER(&cv_bot_prefix);
CVAR_REGISTER(&cv_bot_allow_rogues);
CVAR_REGISTER(&cv_bot_allow_pistols);
Expand All @@ -121,6 +128,7 @@ void Bot_RegisterCVars()
#ifdef REGAMEDLL_ADD
CVAR_REGISTER(&cv_bot_deathmatch);
CVAR_REGISTER(&cv_bot_quota_mode);
CVAR_REGISTER(&cv_bot_join_delay);
#endif

}
Expand Down
4 changes: 3 additions & 1 deletion regamedll/dlls/bot/cs_bot_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ extern cvar_t cv_bot_difficulty;
extern cvar_t cv_bot_debug;
extern cvar_t cv_bot_quicksave;
extern cvar_t cv_bot_quota;
extern cvar_t cv_bot_quota_match;
extern cvar_t cv_bot_prefix;
extern cvar_t cv_bot_allow_rogues;
extern cvar_t cv_bot_allow_pistols;
Expand All @@ -61,4 +60,7 @@ extern cvar_t cv_bot_profile_db;
#ifdef REGAMEDLL_ADD
extern cvar_t cv_bot_deathmatch;
extern cvar_t cv_bot_quota_mode;
extern cvar_t cv_bot_join_delay;
#else
extern cvar_t cv_bot_quota_match;
#endif
102 changes: 91 additions & 11 deletions regamedll/dlls/bot/cs_bot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,15 +828,45 @@ void CCSBotManager::MaintainBotQuota()

int desiredBotCount = int(cv_bot_quota.value);
int occupiedBotSlots = UTIL_BotsInGame();
#ifdef REGAMEDLL_ADD
if (Q_stricmp(cv_bot_quota_mode.string, "fill") == 0)
occupiedBotSlots += humanPlayersInGame;
#endif

// isRoundInProgress is true if the round has progressed far enough that new players will join as dead.
bool isRoundInProgress = CSGameRules()->IsGameStarted() &&
!TheCSBots()->IsRoundOver() &&
(CSGameRules()->GetRoundElapsedTime() >= CSGameRules()->GetRoundRespawnTime());

#ifdef REGAMEDLL_ADD
if (FStrEq(cv_bot_quota_mode.string, "fill"))
{
// If bot_quota_mode is 'fill', we want the number of bots and humans together to equal bot_quota
// unless the round is already in progress, in which case we play with what we've been dealt
if (!isRoundInProgress)
{
desiredBotCount = Q_max(0, desiredBotCount - humanPlayersInGame);
}
else
{
desiredBotCount = occupiedBotSlots;
}
}
else if (FStrEq(cv_bot_quota_mode.string, "match"))
{
// If bot_quota_mode is 'match', we want the number of bots to be bot_quota * total humans
// unless the round is already in progress, in which case we play with what we've been dealt
if (!isRoundInProgress)
{
desiredBotCount = Q_max<int>(0, cv_bot_quota.value * humanPlayersInGame);
}
else
{
desiredBotCount = occupiedBotSlots;
}
}
#else // #ifdef REGAMEDLL_ADD
if (cv_bot_quota_match.value > 0.0)
{
desiredBotCount = int(humanPlayersInGame * cv_bot_quota_match.value);
}
#endif // #ifdef REGAMEDLL_ADD

// wait for a player to join, if necessary
if (cv_bot_join_after_player.value > 0.0)
Expand All @@ -845,12 +875,55 @@ void CCSBotManager::MaintainBotQuota()
desiredBotCount = 0;
}

#ifdef REGAMEDLL_ADD
// wait until the map has been loaded for a bit, to allow players to transition across
// the transition without missing the pistol round
if (static_cast<int>(cv_bot_join_delay.value) > CSGameRules()->GetMapElapsedTime())
{
desiredBotCount = 0;
}
#endif

// if bots will auto-vacate, we need to keep one slot open to allow players to join
if (cv_bot_auto_vacate.value > 0.0)
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - (totalHumansInGame + 1));
else
desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - totalHumansInGame);

#ifdef REGAMEDLL_FIXES
// Try to balance teams, if we are in the first specified seconds of a round and bots can join either team.
if (occupiedBotSlots > 0 && desiredBotCount == occupiedBotSlots && CSGameRules()->IsGameStarted())
{
if (CSGameRules()->GetRoundElapsedTime() < CSGameRules()->GetRoundRespawnTime()) // new bots can still spawn during this time
{
if (autoteambalance.value > 0.0f)
{
int numAliveTerrorist;
int numAliveCT;
int numDeadTerrorist;
int numDeadCT;

CSGameRules()->InitializePlayerCounts(numAliveTerrorist, numAliveCT, numDeadTerrorist, numDeadCT);

if (!FStrEq(cv_bot_join_team.string, "T") &&
!FStrEq(cv_bot_join_team.string, "CT"))
{
if (numAliveTerrorist > CSGameRules()->m_iNumCT + 1)
{
if (UTIL_KickBotFromTeam(TERRORIST))
return;
}
else if (numAliveCT > CSGameRules()->m_iNumTerrorist + 1)
{
if (UTIL_KickBotFromTeam(CT))
return;
}
}
}
}
}
#endif // #ifdef REGAMEDLL_FIXES

// add bots if necessary
if (desiredBotCount > occupiedBotSlots)
{
Expand Down Expand Up @@ -900,14 +973,21 @@ void CCSBotManager::MaintainBotQuota()
}

// attempt to kick a bot from the given team
if (UTIL_KickBotFromTeam(kickTeam))
return;
bool atLeastOneKicked = UTIL_KickBotFromTeam(kickTeam);

// if there were no bots on the team, kick a bot from the other team
if (kickTeam == TERRORIST)
UTIL_KickBotFromTeam(CT);
else
UTIL_KickBotFromTeam(TERRORIST);
if (!atLeastOneKicked)
{
// if there were no bots on the team, kick a bot from the other team
if (kickTeam == TERRORIST)
atLeastOneKicked = UTIL_KickBotFromTeam(CT);
else
atLeastOneKicked = UTIL_KickBotFromTeam(TERRORIST);
}

if (atLeastOneKicked)
{
CONSOLE_ECHO("These bots kicked to maintain quota.\n");
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class CBaseEntity {
// This entity's classname.
const char *GetClassname() const { return pev->classname.str(); }

bool IsProxy() const { return (pev->flags & FL_PROXY) == FL_PROXY; }
bool IsDormant() const { return (pev->flags & FL_DORMANT) == FL_DORMANT; }
BOOL IsLockedByMaster() { return FALSE; }

Expand Down
24 changes: 22 additions & 2 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,16 @@ void ProcessKickVote(CBasePlayer *pVotingPlayer, CBasePlayer *pKickPlayer)

if (iVotesNeeded >= int(fKickPercent))
{
#ifdef REGAMEDLL_FIXES
SERVER_COMMAND(UTIL_VarArgs("kick #%d \"You have been voted off.\"\n", iVoteID));
SERVER_EXECUTE();
#endif

UTIL_ClientPrintAll(HUD_PRINTCENTER, "#Game_kicked", STRING(pKickPlayer->pev->netname));

#ifndef REGAMEDLL_FIXES
SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iVoteID));
#endif
pTempEntity = nullptr;

while ((pTempEntity = UTIL_FindEntityByClassname(pTempEntity, "player")))
Expand Down Expand Up @@ -1767,17 +1775,26 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *pPlayer, int slot)
{
team = (RANDOM_LONG(0, 1) == 0) ? TERRORIST : CT;

if (!UTIL_KickBotFromTeam(team))
bool atLeastOneLeft = UTIL_KickBotFromTeam(team);

if (!atLeastOneLeft)
{
// no bots on that team, try the other
team = (team == CT) ? TERRORIST : CT;

if (!UTIL_KickBotFromTeam(team))
atLeastOneLeft = UTIL_KickBotFromTeam(team);

if (!atLeastOneLeft)
{
// couldn't kick any bots, fail
team = UNASSIGNED;
}
}

if (atLeastOneLeft)
{
CONSOLE_ECHO("These bots has left the game to make room for human players.\n");
}
}
}

Expand Down Expand Up @@ -1905,7 +1922,10 @@ BOOL EXT_FUNC __API_HOOK(HandleMenu_ChooseTeam)(CBasePlayer *pPlayer, int slot)
if (cv_bot_auto_vacate.value > 0 && !pPlayer->IsBot())
{
if (UTIL_KickBotFromTeam(team))
{
CONSOLE_ECHO("These bots has left the game to make room for human players.\n");
madeRoom = true;
}
}

if (!madeRoom)
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ class CHalfLifeMultiplay: public CGameRules
float GetRoundRemainingTime() const { return m_iRoundTimeSecs - gpGlobals->time + m_fRoundStartTime; }
float GetRoundRemainingTimeReal() const;
float GetTimeLeft() const { return m_flTimeLimit - gpGlobals->time; }
float GetRoundElapsedTime() const { return gpGlobals->time - m_fRoundStartTime; }
float GetMapElapsedTime() const { return gpGlobals->time; }

BOOL TeamFull(int team_id);
BOOL TeamStacked(int newTeam_id, int curTeam_id);
Expand Down Expand Up @@ -668,6 +670,8 @@ class CHalfLifeMultiplay: public CGameRules
float GetRoundRespawnTime() const;
float GetRoundRestartDelay() const;

bool IsGameStarted() const { return m_bGameStarted; }

// has a style of gameplay when aren't any teams
bool IsFreeForAll() const;
bool CanPlayerBuy(CBasePlayer *pPlayer) const;
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/hostage/hostage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ void CHostage::ApplyHostagePenalty(CBasePlayer *pAttacker)
else if (pAttacker->m_iHostagesKilled >= iHostagePenalty)
{
#ifdef REGAMEDLL_FIXES
SERVER_COMMAND(UTIL_VarArgs("kick #%d\n", GETPLAYERUSERID(pAttacker->edict())));
SERVER_COMMAND(UTIL_VarArgs("kick #%d \"For killing too many hostages\"\n", GETPLAYERUSERID(pAttacker->edict())));
#else
CLIENT_COMMAND(pAttacker->edict(), "disconnect\n");
#endif
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3806,7 +3806,11 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerKilled)(CBasePlayer *pVictim,
int iUserID = GETPLAYERUSERID(killer->edict());
if (iUserID != -1)
{
#ifdef REGAMEDLL_FIXES
SERVER_COMMAND(UTIL_VarArgs("kick #%d \"For killing too many teammates\"\n", iUserID));
#else
SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iUserID));
#endif
}
}

Expand Down
Loading

0 comments on commit feae856

Please sign in to comment.