Browse Source

fix bots quantity on map rotate, add respawn initiation

bot10-respawn-bots-configured
ghost 11 months ago
parent
commit
c7420cfc3e
  1. 29
      dlls/client.cpp

29
dlls/client.cpp

@ -1054,18 +1054,17 @@ void StartFrame( void )
// check if a map was changed via "map" without kicking bots... // check if a map was changed via "map" without kicking bots...
if( previous_time > gpGlobals->time ) if( previous_time > gpGlobals->time )
{ {
respawn_time = 5.0;
bot_check_time = gpGlobals->time + 10.0; bot_check_time = gpGlobals->time + 10.0;
for( index = 0; index < 32; index++ ) // find bots used in previous session and add them to respawn queue
for( i = 0; i < 32; i++ )
{ {
if( ( bot_respawn[index].is_used) && // is this slot used? if( bot_respawn[i].is_used )
( bot_respawn[index].state != BOT_NEED_TO_RESPAWN ) )
{ {
// bot has already been "kicked" by server so just set flag bot_respawn[i].is_used = FALSE;
bot_respawn[index].state = BOT_NEED_TO_RESPAWN; bot_respawn[i].state = BOT_NEED_TO_RESPAWN;
// if the map was changed set the respawn time...
respawn_time = 5.0;
} }
} }
} }
@ -1330,21 +1329,12 @@ void StartFrame( void )
// START BOT // START BOT
// check if time to see if a bot needs to be created... // check if time to see if a bot needs to be created...
if( bot_check_time < gpGlobals->time ) if( online < max_bots && bot_check_time < gpGlobals->time && respawn_time <= gpGlobals->time )
{
// if there are currently less than the maximum number of "players"
// then add another bot using the default skill level...
if ( online < max_bots )
{ {
for( i = 0; i < 32; i++ ) for( i = 0; i < 32; i++ )
{ {
if( !bot_respawn[i].is_used && if( !bot_respawn[i].is_used && bot_respawn[i].state == BOT_NEED_TO_RESPAWN )
bot_respawn[i].state == BOT_NEED_TO_RESPAWN &&
gpGlobals->time >= respawn_time )
{ {
bot_respawn[i].is_used = TRUE;
bot_respawn[i].state = BOT_IS_RESPAWNING;
BotCreate( bot_respawn[i].skin, bot_respawn[i].name, bot_respawn[i].skill ); BotCreate( bot_respawn[i].skin, bot_respawn[i].name, bot_respawn[i].skill );
online++; // increase online of bots and players online++; // increase online of bots and players
@ -1354,7 +1344,6 @@ void StartFrame( void )
break; break;
} }
} }
}
bot_check_time = gpGlobals->time + 10.0; bot_check_time = gpGlobals->time + 10.0;
} }

Loading…
Cancel
Save