AiBaseTeamBrain *AiBaseTeamBrain::GetBrainForTeam( int team ) { if( team < TEAM_PLAYERS || team >= GS_MAX_TEAMS ) { AI_FailWith( "AiBaseTeamBrain", "GetBrainForTeam(): Illegal team %d\n", team ); } if( !teamBrains[team - 1] ) { AI_FailWith( "AiBaseTeamBrain", "GetBrainForTeam(): Team brain for team %d is not instantiated atm\n", team ); } return teamBrains[team - 1]; }
void G_SpawnAI( edict_t *ent, float skillLevel ) { if (ent->ai) AI_FailWith("G_SpawnAI()", "Entity AI has been already initialized\n"); if (!(ent->r.svflags & SVF_FAKECLIENT)) AI_FailWith("G_SpawnAI()", "Only fake clients are supported\n"); size_t memSize = sizeof(ai_handle_t) + sizeof(Bot); size_t alignmentBytes = 0; if (sizeof(ai_handle_t) % 16) alignmentBytes = 16 - sizeof(ai_handle_t) % 16; memSize += alignmentBytes; char *mem = (char *)G_Malloc(memSize); ent->ai = (ai_handle_t *)mem; ent->ai->type = AI_ISBOT; char *botMem = mem + sizeof(ai_handle_t) + alignmentBytes; ent->ai->botRef = new(botMem) Bot(ent, skillLevel); ent->ai->aiRef = ent->ai->botRef; AiManager::Instance()->LinkAi(ent->ai); }