/* ================ Bot_ScriptThink ================ */ void Bot_ScriptThink(void) { int i; bot_state_t *bs; for(i = 0; i < level.maxclients; i++) { // get the bot for this entity num bs = &botstates[i]; // if there's no bot here, skip it if(!bs->inuse) { continue; } // if the bot is dead, skip it if(BotIsDead(bs)) { continue; } Bot_ScriptRun(bs, qfalse); } }
/* ================ Bot_ScriptChange ================ */ void Bot_ScriptChange(bot_state_t *bs, int newScriptNum) { bot_script_status_t statusBackup; bs->script.callIndex++; // backup the current scripting statusBackup = bs->script.status; // set the new script to this cast, and reset script status bs->script.status.stackHead = 0; bs->script.status.stackChangeTime = level.time; bs->script.status.eventIndex = newScriptNum; bs->script.status.id = statusBackup.id + 1; // first call bs->script.flags |= BSFL_FIRST_CALL; Bot_ScriptLog_Entry(bs, qfalse, Bot_LineText(bs->script.data->events[bs->script.status.eventIndex].text), "** NEW EVENT **\r\n"); // try and run the script, if it doesn't finish, then abort the current script (discard backup) if (Bot_ScriptRun(bs, qtrue)) { // completed successfully bs->script.status.stackHead = statusBackup.stackHead; bs->script.status.stackChangeTime = statusBackup.stackChangeTime; bs->script.status.eventIndex = statusBackup.eventIndex; bs->script.status.id = statusBackup.id; // bs->script.flags &= ~BSFL_FIRST_CALL; // returned to previous event if (statusBackup.eventIndex > -1) { Bot_ScriptLog_Entry(bs, qfalse, Bot_LineText(bs->script.data->events[statusBackup.eventIndex].text), "**RESUMED**\r\n"); } } else { // still running, previous script is terminated if (statusBackup.eventIndex > -1 && statusBackup.eventIndex != bs->script.status.eventIndex) { Bot_ScriptLog_Entry(bs, qfalse, Bot_LineText(bs->script.data->events[statusBackup.eventIndex].text), "**TERMINATED**\r\n"); } } }