mgr: added yb_first_human_restart (resolves #713)
When bots are playing on dedicated server and first human joins a team the game will be restarted if yb_first_human_restart is higher than zero. Co-Authored-By: Max <161382234+dyspose@users.noreply.github.com>
This commit is contained in:
parent
cf9d0cc84f
commit
590471d94c
6 changed files with 47 additions and 3 deletions
|
|
@ -41,10 +41,12 @@ private:
|
|||
int m_lastWinner {}; // the team who won previous round
|
||||
int m_lastDifficulty {}; // last bots difficulty
|
||||
int m_bombSayStatus {}; // some bot is issued whine about bomb
|
||||
int m_numPreviousPlayers {}; // number of players in game im previous player check
|
||||
|
||||
bool m_bombPlanted {}; // is bomb planted ?
|
||||
bool m_botsCanPause {}; // bots can do a little pause ?
|
||||
bool m_roundOver {}; // well, round is over>
|
||||
bool m_resetHud {}; // reset HUD is called for some one
|
||||
|
||||
Array <edict_t *> m_activeGrenades {}; // holds currently active grenades on the map
|
||||
Array <edict_t *> m_interestingEntities {}; // holds currently interesting entities on the map
|
||||
|
|
@ -96,6 +98,7 @@ public:
|
|||
void maintainQuota ();
|
||||
void maintainAutoKill ();
|
||||
void maintainLeaders ();
|
||||
void maintainRoundRestart ();
|
||||
void initQuota ();
|
||||
void initRound ();
|
||||
void decrementQuota (int by = 1);
|
||||
|
|
@ -231,6 +234,10 @@ public:
|
|||
m_teamData[team].lastRadioSlot = radio;
|
||||
}
|
||||
|
||||
void setResetHUD (bool resetHud) {
|
||||
m_resetHud = resetHud;
|
||||
}
|
||||
|
||||
int getLastRadio (const int team) const {
|
||||
return m_teamData[team].lastRadioSlot;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ CR_DECLARE_SCOPED_ENUM (NetMsg,
|
|||
ItemStatus = 22,
|
||||
ScoreInfo = 23,
|
||||
ScoreAttrib = 24,
|
||||
SayText = 25
|
||||
SayText = 25,
|
||||
ResetHUD = 26
|
||||
)
|
||||
|
||||
// vgui menus (since latest steam updates is obsolete, but left for old cs)
|
||||
|
|
@ -124,6 +125,7 @@ private:
|
|||
void netMsgFlashBat ();
|
||||
void netMsgScoreInfo ();
|
||||
void netMsgScoreAttrib ();
|
||||
void netMsgResetHUD ();
|
||||
|
||||
private:
|
||||
Bot *pickBot (int32_t index);
|
||||
|
|
|
|||
|
|
@ -1557,8 +1557,8 @@ void Bot::attackMovement () {
|
|||
m_strafeSetTime = strafeUpdateTime ();
|
||||
}
|
||||
|
||||
const bool wallOnRight = checkWallOnRight (72.0f);
|
||||
const bool wallOnLeft = checkWallOnLeft (72.0f);
|
||||
const bool wallOnRight = checkWallOnRight (96.0f);
|
||||
const bool wallOnLeft = checkWallOnLeft (96.0f);
|
||||
|
||||
if (m_dodgeStrafeDir == Dodge::Left) {
|
||||
if (!wallOnLeft) {
|
||||
|
|
|
|||
|
|
@ -1112,6 +1112,9 @@ void Game::slowFrame () {
|
|||
// ensure the server admin is confident about features he's using
|
||||
ensureHealthyGameEnvironment ();
|
||||
|
||||
// maintain round restart for first human join
|
||||
bots.maintainRoundRestart ();
|
||||
|
||||
// update next update time
|
||||
m_halfSecondFrame = nextUpdate * 0.25f + time ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ ConVar cv_think_fps ("think_fps", "30.0", "Specifies how many times per second b
|
|||
ConVar cv_think_fps_disable ("think_fps_disable", "1", "Allows to completely disable think fps on Xash3D.", true, 0.0f, 1.0f, Var::Xash3D);
|
||||
|
||||
ConVar cv_autokill_delay ("autokill_delay", "0.0", "Specifies amount of time in seconds when bots will be killed if no humans left alive.", true, 0.0f, 90.0f);
|
||||
ConVar cv_first_human_restart ("first_human_restart", "0.0", "Restart the game if first human player joined the bot game.", true, 0.0f, 1.0f);
|
||||
|
||||
ConVar cv_join_after_player ("join_after_player", "0", "Specifies whether bots should join server, only when at least one human player in game.");
|
||||
ConVar cv_join_team ("join_team", "any", "Forces all bots to join team specified here.", false);
|
||||
|
|
@ -471,6 +472,29 @@ void BotManager::maintainLeaders () {
|
|||
}
|
||||
}
|
||||
|
||||
void BotManager::maintainRoundRestart () {
|
||||
if (!cv_first_human_restart || !game.isDedicated ()) {
|
||||
return;
|
||||
}
|
||||
const int totalHumans = getHumansCount (true);
|
||||
const int totalBots = getBotCount ();
|
||||
|
||||
if (totalHumans > 0
|
||||
&& m_numPreviousPlayers == 0
|
||||
&& totalHumans == 1
|
||||
&& totalBots > 0
|
||||
&& !m_resetHud) {
|
||||
|
||||
static ConVarRef sv_restartround ("sv_restartround");
|
||||
|
||||
if (sv_restartround.exists ()) {
|
||||
sv_restartround.set ("1");
|
||||
}
|
||||
}
|
||||
m_numPreviousPlayers = totalHumans;
|
||||
m_resetHud = false;
|
||||
}
|
||||
|
||||
void BotManager::maintainAutoKill () {
|
||||
const float killDelay = cv_autokill_delay.as <float> ();
|
||||
|
||||
|
|
|
|||
|
|
@ -431,6 +431,13 @@ void MessageDispatcher::netMsgFlashBat () {
|
|||
m_bot->m_flashLevel = m_args[value].long_;
|
||||
}
|
||||
|
||||
void MessageDispatcher::netMsgResetHUD () {
|
||||
if (m_bot) {
|
||||
m_bot->spawned ();
|
||||
}
|
||||
bots.setResetHUD (true);
|
||||
}
|
||||
|
||||
MessageDispatcher::MessageDispatcher () {
|
||||
|
||||
// register wanted message
|
||||
|
|
@ -461,6 +468,7 @@ MessageDispatcher::MessageDispatcher () {
|
|||
addWanted ("FlashBat", NetMsg::FlashBat, &MessageDispatcher::netMsgFlashBat);
|
||||
addWanted ("ScoreInfo", NetMsg::ScoreInfo, &MessageDispatcher::netMsgScoreInfo);
|
||||
addWanted ("ScoreAttrib", NetMsg::ScoreAttrib, &MessageDispatcher::netMsgScoreAttrib);
|
||||
addWanted ("ResetHUD", NetMsg::ResetHUD, &MessageDispatcher::netMsgResetHUD);
|
||||
|
||||
// we're need next messages IDs but we're won't handle them, so they will be removed from wanted list as soon as they get engine IDs
|
||||
addWanted ("BotVoice", NetMsg::BotVoice, nullptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue