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
|
|
@ -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