Skip to content

Commit

Permalink
wait to start match timer
Browse files Browse the repository at this point in the history
- match will now wait without forefeit until a player joins and selects a loadout
- game timer will start at 0
- if a player joins and leaves wait for a new player
  • Loading branch information
WantedDV committed Oct 12, 2024
1 parent ea43f93 commit 33c322a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions data/cdata/custom_scripts/mp/bots.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ main()
replacefunc(scripts\mp\bots\bots::bot_connect_monitor, ::bot_connect_monitor);
replacefunc(scripts\mp\bots\bots_util::bot_get_client_limit, ::bot_get_client_limit);
replacefunc(scripts\mp\hostmigration::waitlongdurationwithhostmigrationpause, ::_wait);
replacefunc(scripts\mp\gamelogic::waitforplayers, ::waitforplayers);
}

initDvars()
{
// setdvar("bots_enabled", 1);
// setdvar("bot_difficulty", 0);
// setdvar("party_maxplayers", 18); // controls how many bots are allowed to spawn
setdvar("scr_game_graceperiod", 15);
setdvar("scr_game_playerwaittime", 5);
setdvar("scr_game_matchstarttime", 5);
level.ready_to_start = 0;
}

initLevelVariables()
Expand Down Expand Up @@ -58,6 +63,34 @@ _wait(time)
wait(time);
}

waitForPlayers( maxTime )
{
startTime = gettime();
endTime = startTime + maxTime * 1000 - 200;

if ( maxTime > 5 )
minTime = gettime() + getDvarInt( "min_wait_for_players" ) * 1000;
else
minTime = 0;

numToWaitFor = ( level.connectingPlayers/3 );

for ( ;; )
{
if ( isDefined( game["roundsPlayed"] ) && game["roundsPlayed"] )
break;

totalSpawnedPlayers = level.maxPlayerCount;

curTime = gettime();

if( level.ready_to_start )
break;

wait 0.05;
}
}

human()
{
if ( !isplayer( self ) || isai( self ) )
Expand Down Expand Up @@ -105,7 +138,10 @@ wait_for_human_player()
wait(0.25);
}

if(!isdefined( player )) wait_for_human_player(); // if the player leaves wait for new player

level.pausing_bot_connect_monitor = 0;
level.ready_to_start = 1;

return 1;
}
Expand Down

0 comments on commit 33c322a

Please sign in to comment.