/* ============= Bot_ScriptRun returns qtrue if the script completed ============= */ qboolean Bot_ScriptRun(bot_state_t * bs, qboolean force) { bot_script_stack_t *stack; bot_script_stack_item_t *item; int oldScriptId; if(!bs->script.data) { return qtrue; } // turn off flags that get set each frame while they are active bs->script.frameFlags = 0; if(bs->script.status.eventIndex < 0) { return qtrue; } if(!bs->script.data->events) { bs->script.status.eventIndex = -1; return qtrue; } if(!force && (bs->script.pauseTime >= level.time)) { return qtrue; } stack = &bs->script.data->events[bs->script.status.eventIndex].stack; if(!stack->numItems) { bs->script.status.eventIndex = -1; return qtrue; } while(bs->script.status.stackHead < stack->numItems) { item = &bs->script.data->items[stack->startIndex + bs->script.status.stackHead]; bs->script.status.currentItem = item; // if(bs->script.flags & BSFL_FIRST_CALL) { Bot_ScriptLog_Entry(bs, qtrue, Bot_LineText(bs->script.data->events[bs->script.status.eventIndex].text), ""); } // oldScriptId = bs->script.status.id; // // Mad Doc - TDf if(G_IsSinglePlayerGame()) { if(bot_debug.integer) { trap_SendServerCommand(0, va("botdebugprint %i \"Line: %i %s %s\"", bs->client, Bot_Script_GetCurrentLine(bs), item->action->actionString, item->params)); } } if(!item->action->actionFunc(bs, item->params)) { bs->script.flags &= ~BSFL_FIRST_CALL; return qfalse; } // if our script changed, stop execution if(oldScriptId != bs->script.status.id) { return qfalse; } // move to the next action in the script bs->script.status.stackHead++; // record the time that this new item became active bs->script.status.stackChangeTime = level.time; // reset misc stuff bs->script.flags |= BSFL_FIRST_CALL; } Bot_ScriptLog_Entry(bs, qtrue, Bot_LineText(bs->script.data->events[bs->script.status.eventIndex].text), "** FINISHED **"); bs->script.status.eventIndex = -1; return qtrue; }
/* =============== G_CheckMinimumPlayers =============== */ void G_CheckMinimumPlayers( void ) { int minplayers/*, weakestTeam, strongestTeam*/; int humanplayers[TEAM_NUM_TEAMS], botplayers[TEAM_NUM_TEAMS], players[TEAM_NUM_TEAMS]; static int checkminimumplayers_time = 0; // wait until the system is ready if (!level.initStaticEnts) return; //only check once each second if (checkminimumplayers_time < level.time && checkminimumplayers_time > level.time - 1000) { return; } // More safety on initial load for MP if(!G_IsSinglePlayerGame() && level.time - level.startTime < 7500) { return; } humanplayers[TEAM_AXIS] = G_CountHumanPlayers( TEAM_AXIS ); botplayers[TEAM_AXIS] = G_CountBotPlayers( TEAM_AXIS ); players[TEAM_AXIS] = humanplayers[TEAM_AXIS] + botplayers[TEAM_AXIS]; // humanplayers[TEAM_ALLIES] = G_CountHumanPlayers( TEAM_ALLIES ); botplayers[TEAM_ALLIES] = G_CountBotPlayers( TEAM_ALLIES ); players[TEAM_ALLIES] = humanplayers[TEAM_ALLIES] + botplayers[TEAM_ALLIES]; checkminimumplayers_time = level.time; trap_Cvar_Update(&bot_minplayers); minplayers = bot_minplayers.integer; if (minplayers >= g_maxclients.integer / 2) { minplayers = (g_maxclients.integer / 2) -1; } // /* if (players[TEAM_AXIS] < minplayers) { G_AddRandomBot( TEAM_AXIS ); return; } // if (players[TEAM_ALLIES] < minplayers) { G_AddRandomBot( TEAM_ALLIES ); return; } // trap_Cvar_Update(&bot_eventeams); if (bot_eventeams.integer) { if (players[TEAM_AXIS] < players[TEAM_ALLIES]) { weakestTeam = TEAM_AXIS; strongestTeam = TEAM_ALLIES; } else if (players[TEAM_AXIS] > players[TEAM_ALLIES]) { weakestTeam = TEAM_ALLIES; strongestTeam = TEAM_AXIS; } else { return; // no changes required } // // even up the teams // if (!botplayers[strongestTeam] || (minplayers && players[weakestTeam] <= minplayers)) { // we have to add players to the weakestTeam G_AddRandomBot( weakestTeam ); return; } else { // remove players from the strongestTeam G_RemoveRandomBot( strongestTeam ); return; } } else if (minplayers) { // remove bots from teams with too many players if (players[TEAM_AXIS] > minplayers && botplayers[TEAM_AXIS]) { G_RemoveRandomBot( TEAM_AXIS ); return; } if (players[TEAM_ALLIES] > minplayers && botplayers[TEAM_ALLIES]) { G_RemoveRandomBot( TEAM_ALLIES ); return; } }*/ }