/* ============== BotAI ============== */ int BotAI( int client, float thinktime ) { bot_state_t *bs; char buf[1024], *args; int j; trap_EA_ResetInput( client, NULL ); // bs = botstates[client]; if ( !bs || !bs->inuse ) { BotAI_Print( PRT_FATAL, "client %d hasn't been setup\n", client ); return BLERR_AICLIENTNOTSETUP; } //retrieve the current client state BotAI_GetClientState( client, &bs->cur_ps ); //retrieve any waiting console messages while ( trap_BotGetServerCommand( client, buf, sizeof( buf ) ) ) { //have buf point to the command and args to the command arguments args = strchr( buf, ' ' ); if ( !args ) { continue; } *args++ = '\0'; //remove color espace sequences from the arguments Q_CleanStr( args ); //botai_import.Print(PRT_MESSAGE, "ConsoleMessage: \"%s\"\n", buf); if ( !Q_stricmp( buf, "cp " ) ) { /*CenterPrintf*/ } else if ( !Q_stricmp( buf, "cs" ) ) { /*ConfigStringModified*/ } else if ( !Q_stricmp( buf, "print" ) ) { trap_BotQueueConsoleMessage( bs->cs, CMS_NORMAL, args ); } else if ( !Q_stricmp( buf, "chat" ) ) { trap_BotQueueConsoleMessage( bs->cs, CMS_CHAT, args ); } else if ( !Q_stricmp( buf, "tchat" ) ) { trap_BotQueueConsoleMessage( bs->cs, CMS_CHAT, args ); } else if ( !Q_stricmp( buf, "scores" ) ) { /*FIXME: parse scores?*/ } else if ( !Q_stricmp( buf, "clientLevelShot" ) ) { /*ignore*/ } } //add the delta angles to the bot's current view angles for ( j = 0; j < 3; j++ ) { bs->viewangles[j] = AngleMod( bs->viewangles[j] + SHORT2ANGLE( bs->cur_ps.delta_angles[j] ) ); } //increase the local time of the bot bs->ltime += thinktime; // bs->thinktime = thinktime; //origin of the bot VectorCopy( bs->cur_ps.origin, bs->origin ); //eye coordinates of the bot VectorCopy( bs->cur_ps.origin, bs->eye ); bs->eye[2] += bs->cur_ps.viewheight; //get the area the bot is in bs->areanum = BotPointAreaNum( bs->origin ); //the real AI BotDeathmatchAI( bs, thinktime ); //set the weapon selection every AI frame trap_EA_SelectWeapon( bs->client, bs->weaponnum ); //subtract the delta angles for ( j = 0; j < 3; j++ ) { bs->viewangles[j] = AngleMod( bs->viewangles[j] - SHORT2ANGLE( bs->cur_ps.delta_angles[j] ) ); } //everything was ok return BLERR_NOERROR; }
/* ============== BotAI ============== */ int BotAI(int playernum, float thinktime) { bot_state_t *bs; char buf[1024], *args; int j; EA_ResetInput(playernum); // bs = botstates[playernum]; if (!bs || !bs->inuse) { BotAI_Print(PRT_FATAL, "BotAI: player %d is not setup\n", playernum); return qfalse; } //retrieve the current player state if (!BotAI_GetPlayerState( playernum, &bs->cur_ps )) { BotAI_Print(PRT_FATAL, "BotAI: failed to get player state for player %d\n", playernum); return qfalse; } //retrieve any waiting server commands while( trap_BotGetServerCommand(playernum, buf, sizeof(buf)) ) { //have buf point to the command and args to the command arguments args = strchr( buf, ' '); if (!args) continue; *args++ = '\0'; //remove color espace sequences from the arguments RemoveColorEscapeSequences( args ); if (!Q_stricmp(buf, "cp ")) { /*CenterPrintf*/ } else if (!Q_stricmp(buf, "cs")) { /*ConfigStringModified*/ } else if (!Q_stricmp(buf, "print")) { //remove first and last quote from the chat message memmove(args, args+1, strlen(args)); args[strlen(args)-1] = '\0'; BotQueueConsoleMessage(bs->cs, CMS_NORMAL, args); } else if (!Q_stricmp(buf, "chat") || !Q_stricmp(buf, "tell")) { //remove first and last quote from the chat message memmove(args, args+1, strlen(args)); args[strlen(args)-1] = '\0'; BotQueueConsoleMessage(bs->cs, CMS_CHAT, args); } else if (!Q_stricmp(buf, "tchat")) { //remove first and last quote from the chat message memmove(args, args+1, strlen(args)); args[strlen(args)-1] = '\0'; BotQueueConsoleMessage(bs->cs, CMS_CHAT, args); } #ifdef MISSIONPACK else if (!Q_stricmp(buf, "vchat")) { BotVoiceChatCommand(bs, SAY_ALL, args); } else if (!Q_stricmp(buf, "vtchat")) { BotVoiceChatCommand(bs, SAY_TEAM, args); } else if (!Q_stricmp(buf, "vtell")) { BotVoiceChatCommand(bs, SAY_TELL, args); } #endif else if (!Q_stricmp(buf, "scores")) { /*FIXME: parse scores?*/ } else if (!Q_stricmp(buf, "clientLevelShot")) { /*ignore*/ } } //add the delta angles to the bot's current view angles for (j = 0; j < 3; j++) { bs->viewangles[j] = AngleMod(bs->viewangles[j] + SHORT2ANGLE(bs->cur_ps.delta_angles[j])); } //increase the local time of the bot bs->ltime += thinktime; // bs->thinktime = thinktime; //origin of the bot VectorCopy(bs->cur_ps.origin, bs->origin); //eye coordinates of the bot VectorCopy(bs->cur_ps.origin, bs->eye); bs->eye[2] += bs->cur_ps.viewheight; //get the area the bot is in bs->areanum = BotPointAreaNum(bs->origin); //the real AI BotDeathmatchAI(bs, thinktime); //set the weapon selection every AI frame EA_SelectWeapon(bs->playernum, bs->weaponnum); //subtract the delta angles for (j = 0; j < 3; j++) { bs->viewangles[j] = AngleMod(bs->viewangles[j] - SHORT2ANGLE(bs->cur_ps.delta_angles[j])); } //everything was ok return qtrue; }
/* * BotAI */ int BotAI(int client, float thinktime) { bot_state_t *bs; char buf[1024], *args; int j; trap_EA_ResetInput(client); bs = botstates[client]; if(!bs || !bs->inuse){ BotAI_Print(PRT_FATAL, "BotAI: client %d is not setup\n", client); return qfalse; } /* retrieve the current client state */ BotAI_GetClientState(client, &bs->cur_ps); /* retrieve any waiting server commands */ while(trap_BotGetServerCommand(client, buf, sizeof(buf))){ /* have buf point to the command and args to the command arguments */ args = strchr(buf, ' '); if(!args) continue; *args++ = '\0'; /* remove color espace sequences from the arguments */ RemoveColorEscapeSequences(args); if(!Q_stricmp(buf, "cp ")){ /*CenterPrintf*/ }else if(!Q_stricmp(buf, "cs")){/*ConfigStringModified*/ }else if(!Q_stricmp(buf, "print")){ /* remove first and last quote from the chat message */ memmove(args, args+1, strlen(args)); args[strlen(args)-1] = '\0'; trap_BotQueueConsoleMessage(bs->cs, CMS_NORMAL, args); }else if(!Q_stricmp(buf, "chat")){ /* remove first and last quote from the chat message */ memmove(args, args+1, strlen(args)); args[strlen(args)-1] = '\0'; trap_BotQueueConsoleMessage(bs->cs, CMS_CHAT, args); }else if(!Q_stricmp(buf, "tchat")){ /* remove first and last quote from the chat message */ memmove(args, args+1, strlen(args)); args[strlen(args)-1] = '\0'; trap_BotQueueConsoleMessage(bs->cs, CMS_CHAT, args); } #ifdef MISSIONPACK else if(!Q_stricmp(buf, "vchat")) BotVoiceChatCommand(bs, SAY_ALL, args); else if(!Q_stricmp(buf, "vtchat")) BotVoiceChatCommand(bs, SAY_TEAM, args); else if(!Q_stricmp(buf, "vtell")) BotVoiceChatCommand(bs, SAY_TELL, args); #endif else if(!Q_stricmp(buf, "scores")){ /*FIXME: parse scores?*/ }else if(!Q_stricmp(buf, "clientLevelShot")){ /*ignore*/ } } /* add the delta angles to the bot's current view angles */ for(j = 0; j < 3; j++) bs->viewangles[j] = modeuler(bs->viewangles[j] + SHORT2ANGLE(bs->cur_ps.delta_angles[j])); /* increase the local time of the bot */ bs->ltime += thinktime; bs->thinktime = thinktime; /* origin of the bot */ copyv3(bs->cur_ps.origin, bs->origin); /* eye coordinates of the bot */ copyv3(bs->cur_ps.origin, bs->eye); bs->eye[2] += bs->cur_ps.viewheight; /* get the area the bot is in */ bs->areanum = BotPointAreaNum(bs->origin); /* the real AI */ BotDeathmatchAI(bs, thinktime); /* set the weapon selection every AI frame */ trap_EA_SelectWeapon(bs->client, bs->weaponnum); /* subtract the delta angles */ for(j = 0; j < 3; j++) bs->viewangles[j] = modeuler(bs->viewangles[j] - SHORT2ANGLE(bs->cur_ps.delta_angles[j])); /* everything was ok */ return qtrue; }