//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void BotInitInfoEntities( void ) { char classname[MAX_EPAIRKEY]; maplocation_t *ml; campspot_t *cs; int ent, numlocations, numcampspots; BotFreeInfoEntities(); // numlocations = 0; numcampspots = 0; for ( ent = AAS_NextBSPEntity( 0 ); ent; ent = AAS_NextBSPEntity( ent ) ) { if ( !AAS_ValueForBSPEpairKey( ent, "classname", classname, MAX_EPAIRKEY ) ) { continue; } //map locations if ( !strcmp( classname, "target_location" ) ) { ml = (maplocation_t *) GetClearedMemory( sizeof( maplocation_t ) ); AAS_VectorForBSPEpairKey( ent, "origin", ml->origin ); AAS_ValueForBSPEpairKey( ent, "message", ml->name, sizeof( ml->name ) ); ml->areanum = AAS_PointAreaNum( ml->origin ); ml->next = maplocations; maplocations = ml; numlocations++; } //end if //camp spots else if ( !strcmp( classname, "info_camp" ) ) { cs = (campspot_t *) GetClearedMemory( sizeof( campspot_t ) ); AAS_VectorForBSPEpairKey( ent, "origin", cs->origin ); //cs->origin[2] += 16; AAS_ValueForBSPEpairKey( ent, "message", cs->name, sizeof( cs->name ) ); AAS_FloatForBSPEpairKey( ent, "range", &cs->range ); AAS_FloatForBSPEpairKey( ent, "weight", &cs->weight ); AAS_FloatForBSPEpairKey( ent, "wait", &cs->wait ); AAS_FloatForBSPEpairKey( ent, "random", &cs->random ); cs->areanum = AAS_PointAreaNum( cs->origin ); if ( !cs->areanum ) { botimport.Print( PRT_MESSAGE, "camp spot at %1.1f %1.1f %1.1f in solid\n", cs->origin[0], cs->origin[1], cs->origin[2] ); FreeMemory( cs ); continue; } //end if cs->next = campspots; campspots = cs; //AAS_DrawPermanentCross(cs->origin, 4, LINECOLOR_YELLOW); numcampspots++; } //end else if } //end for if ( bot_developer ) { botimport.Print( PRT_MESSAGE, "%d map locations\n", numlocations ); botimport.Print( PRT_MESSAGE, "%d camp spots\n", numcampspots ); } //end if } //end of the function BotInitInfoEntities
static void BotInitInfoEntities() { BotFreeInfoEntities(); int numlocations = 0; int numcampspots = 0; for ( int ent = AAS_NextBSPEntity( 0 ); ent; ent = AAS_NextBSPEntity( ent ) ) { char classname[ MAX_EPAIRKEY ]; if ( !AAS_ValueForBSPEpairKey( ent, "classname", classname, MAX_EPAIRKEY ) ) { continue; } //map locations if ( !String::Cmp( classname, "target_location" ) ) { maplocation_t* ml = ( maplocation_t* )Mem_ClearedAlloc( sizeof ( maplocation_t ) ); AAS_VectorForBSPEpairKey( ent, "origin", ml->origin ); AAS_ValueForBSPEpairKey( ent, "message", ml->name, sizeof ( ml->name ) ); ml->areanum = AAS_PointAreaNum( ml->origin ); ml->next = maplocations; maplocations = ml; numlocations++; } //camp spots else if ( !String::Cmp( classname, "info_camp" ) ) { campspot_t* cs = ( campspot_t* )Mem_ClearedAlloc( sizeof ( campspot_t ) ); AAS_VectorForBSPEpairKey( ent, "origin", cs->origin ); AAS_ValueForBSPEpairKey( ent, "message", cs->name, sizeof ( cs->name ) ); AAS_FloatForBSPEpairKey( ent, "range", &cs->range ); AAS_FloatForBSPEpairKey( ent, "weight", &cs->weight ); AAS_FloatForBSPEpairKey( ent, "wait", &cs->wait ); AAS_FloatForBSPEpairKey( ent, "random", &cs->random ); cs->areanum = AAS_PointAreaNum( cs->origin ); if ( !cs->areanum ) { BotImport_Print( PRT_MESSAGE, "camp spot at %1.1f %1.1f %1.1f in solid\n", cs->origin[ 0 ], cs->origin[ 1 ], cs->origin[ 2 ] ); Mem_Free( cs ); continue; } cs->next = campspots; campspots = cs; numcampspots++; } } if ( bot_developer ) { BotImport_Print( PRT_MESSAGE, "%d map locations\n", numlocations ); BotImport_Print( PRT_MESSAGE, "%d camp spots\n", numcampspots ); } }
void AAS_AddTeleporterPortals(void) { int j, area2num, facenum, otherareanum; char *target, *targetname, *classname; bsp_entity_t *entities, *ent, *dest; vec3_t origin, destorigin, mins, maxs, end; vec3_t bbmins, bbmaxs; aas_area_t *area; aas_face_t *face; aas_trace_t trace; aas_link_t *areas, *link; entities = AAS_ParseBSPEntities(); for (ent = entities; ent; ent = ent->next) { classname = AAS_ValueForBSPEpairKey(ent, "classname"); if (classname && !strcmp(classname, "misc_teleporter")) { if (!AAS_VectorForBSPEpairKey(ent, "origin", origin)) { botimport.Print(PRT_ERROR, "teleporter (%s) without origin\n", target); continue; } //end if // target = AAS_ValueForBSPEpairKey(ent, "target"); if (!target) { botimport.Print(PRT_ERROR, "teleporter (%s) without target\n", target); continue; } //end if for (dest = entities; dest; dest = dest->next) { classname = AAS_ValueForBSPEpairKey(dest, "classname"); if (classname && !strcmp(classname, "misc_teleporter_dest")) { targetname = AAS_ValueForBSPEpairKey(dest, "targetname"); if (targetname && !strcmp(targetname, target)) { break; } //end if } //end if } //end for if (!dest) { botimport.Print(PRT_ERROR, "teleporter without destination (%s)\n", target); continue; } //end if if (!AAS_VectorForBSPEpairKey(dest, "origin", destorigin)) { botimport.Print(PRT_ERROR, "teleporter destination (%s) without origin\n", target); continue; } //end if destorigin[2] += 24; //just for q2e1m2, the dork has put the telepads in the ground VectorCopy(destorigin, end); end[2] -= 100; trace = AAS_TraceClientBBox(destorigin, end, PRESENCE_CROUCH, -1); if (trace.startsolid) { botimport.Print(PRT_ERROR, "teleporter destination (%s) in solid\n", target); continue; } //end if VectorCopy(trace.endpos, destorigin); area2num = AAS_PointAreaNum(destorigin); //reset all cluster fields for (j = 0; j < aasworld.numareas; j++) { aasworld.areasettings[j].cluster = 0; } //end for // VectorSet(mins, -8, -8, 8); VectorSet(maxs, 8, 8, 24); // AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bbmins, bbmaxs); // VectorAdd(origin, mins, mins); VectorAdd(origin, maxs, maxs); //add bounding box size VectorSubtract(mins, bbmaxs, mins); VectorSubtract(maxs, bbmins, maxs); //link an invalid (-1) entity areas = AAS_AASLinkEntity(mins, maxs, -1); // for (link = areas; link; link = link->next_area) { if (!AAS_AreaGrounded(link->areanum)) continue; //add the teleporter portal mark aasworld.areasettings[link->areanum].contents |= AREACONTENTS_CLUSTERPORTAL | AREACONTENTS_TELEPORTAL; } //end for // for (link = areas; link; link = link->next_area) { if (!AAS_AreaGrounded(link->areanum)) continue; //find a non-portal area adjacent to the portal area and flood //the cluster from there area = &aasworld.areas[link->areanum]; for (j = 0; j < area->numfaces; j++) { facenum = abs(aasworld.faceindex[area->firstface + j]); face = &aasworld.faces[facenum]; // if (face->frontarea != link->areanum) otherareanum = face->frontarea; else otherareanum = face->backarea; // if (!otherareanum) continue; // if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) { continue; } //end if // AAS_FloodCluster_r(otherareanum, 1); } //end for } //end for //if the teleport destination IS in the same cluster if (aasworld.areasettings[area2num].cluster) { for (link = areas; link; link = link->next_area) { if (!AAS_AreaGrounded(link->areanum)) continue; //add the teleporter portal mark aasworld.areasettings[link->areanum].contents &= ~(AREACONTENTS_CLUSTERPORTAL | AREACONTENTS_TELEPORTAL); } //end for } //end if } //end if } //end for AAS_FreeBSPEntities(entities); } //end of the function AAS_AddTeleporterPortals
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void BotInitLevelItems( void ) { int i, spawnflags; char classname[MAX_EPAIRKEY]; vec3_t origin; int ent; itemconfig_t *ic; levelitem_t *li; //initialize the map locations and camp spots BotInitInfoEntities(); //initialize the level item heap InitLevelItemHeap(); levelitems = NULL; numlevelitems = 0; // ic = itemconfig; if ( !ic ) { return; } //if there's no AAS file loaded if ( !AAS_Loaded() ) { return; } //update the modelindexes of the item info for ( i = 0; i < ic->numiteminfo; i++ ) { //ic->iteminfo[i].modelindex = AAS_IndexFromModel(ic->iteminfo[i].model); if ( !ic->iteminfo[i].modelindex ) { Log_Write( "item %s has modelindex 0", ic->iteminfo[i].classname ); } //end if } //end for for ( ent = AAS_NextBSPEntity( 0 ); ent; ent = AAS_NextBSPEntity( ent ) ) { if ( !AAS_ValueForBSPEpairKey( ent, "classname", classname, MAX_EPAIRKEY ) ) { continue; } // spawnflags = 0; AAS_IntForBSPEpairKey( ent, "spawnflags", &spawnflags ); //FIXME: don't do this // for now skip all floating entities if ( spawnflags & 1 ) { continue; } // for ( i = 0; i < ic->numiteminfo; i++ ) { if ( !strcmp( classname, ic->iteminfo[i].classname ) ) { //get the origin of the item if ( AAS_VectorForBSPEpairKey( ent, "origin", origin ) ) { li = AllocLevelItem(); if ( !li ) { return; } // li->number = ++numlevelitems; li->timeout = 0; li->entitynum = 0; // AAS_IntForBSPEpairKey( ent, "notfree", &li->notfree ); AAS_IntForBSPEpairKey( ent, "notteam", &li->notteam ); AAS_IntForBSPEpairKey( ent, "notsingle", &li->notsingle ); //if not a stationary item if ( !( spawnflags & 1 ) ) { if ( !AAS_DropToFloor( origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs ) ) { botimport.Print( PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n", classname, origin[0], origin[1], origin[2] ); } //end if } //end if //item info of the level item li->iteminfo = i; //origin of the item VectorCopy( origin, li->origin ); //get the item goal area and goal origin li->goalareanum = AAS_BestReachableArea( origin, ic->iteminfo[i].mins, ic->iteminfo[i].maxs, li->goalorigin ); // AddLevelItemToList( li ); } //end if else { botimport.Print( PRT_ERROR, "item %s without origin\n", classname ); } //end else break; } //end if } //end for if ( i >= ic->numiteminfo ) { Log_Write( "entity %s unknown item\r\n", classname ); } //end if } //end for botimport.Print( PRT_MESSAGE, "found %d level items\n", numlevelitems ); } //end of the function BotInitLevelItems
void BotInitLevelItems() { //initialize the map locations and camp spots BotInitInfoEntities(); //initialize the level item heap InitLevelItemHeap(); levelitems = NULL; numlevelitems = 0; itemconfig_t* ic = itemconfig; if ( !ic ) { return; } //if there's no AAS file loaded if ( !AAS_Loaded() ) { return; } //update the modelindexes of the item info for ( int i = 0; i < ic->numiteminfo; i++ ) { if ( !ic->iteminfo[ i ].modelindex ) { Log_Write( "item %s has modelindex 0", ic->iteminfo[ i ].classname ); } } for ( int ent = AAS_NextBSPEntity( 0 ); ent; ent = AAS_NextBSPEntity( ent ) ) { char classname[ MAX_EPAIRKEY ]; if ( !AAS_ValueForBSPEpairKey( ent, "classname", classname, MAX_EPAIRKEY ) ) { continue; } int spawnflags = 0; AAS_IntForBSPEpairKey( ent, "spawnflags", &spawnflags ); int i; for ( i = 0; i < ic->numiteminfo; i++ ) { if ( !String::Cmp( classname, ic->iteminfo[ i ].classname ) ) { break; } } if ( i >= ic->numiteminfo ) { Log_Write( "entity %s unknown item\r\n", classname ); continue; } //get the origin of the item vec3_t origin; if ( !AAS_VectorForBSPEpairKey( ent, "origin", origin ) ) { BotImport_Print( PRT_ERROR, "item %s without origin\n", classname ); continue; } int goalareanum = 0; //if it is a floating item if ( spawnflags & 1 ) { if ( !( GGameType & GAME_Quake3 ) ) { continue; } //if the item is not floating in water if ( !( AAS_PointContents( origin ) & BSP46CONTENTS_WATER ) ) { vec3_t end; VectorCopy( origin, end ); end[ 2 ] -= 32; bsp_trace_t trace = AAS_Trace( origin, ic->iteminfo[ i ].mins, ic->iteminfo[ i ].maxs, end, -1, BSP46CONTENTS_SOLID | BSP46CONTENTS_PLAYERCLIP ); //if the item not near the ground if ( trace.fraction >= 1 ) { //if the item is not reachable from a jumppad goalareanum = AAS_BestReachableFromJumpPadArea( origin, ic->iteminfo[ i ].mins, ic->iteminfo[ i ].maxs ); Log_Write( "item %s reachable from jumppad area %d\r\n", ic->iteminfo[ i ].classname, goalareanum ); if ( !goalareanum ) { continue; } } } } levelitem_t* li = AllocLevelItem(); if ( !li ) { return; } li->number = ++numlevelitems; li->timeout = 0; li->entitynum = 0; li->flags = 0; int value; AAS_IntForBSPEpairKey( ent, "notfree", &value ); if ( value ) { li->flags |= IFL_NOTFREE; } AAS_IntForBSPEpairKey( ent, "notteam", &value ); if ( value ) { li->flags |= IFL_NOTTEAM; } AAS_IntForBSPEpairKey( ent, "notsingle", &value ); if ( value ) { li->flags |= IFL_NOTSINGLE; } if ( GGameType & GAME_Quake3 ) { AAS_IntForBSPEpairKey( ent, "notbot", &value ); if ( value ) { li->flags |= IFL_NOTBOT; } if ( !String::Cmp( classname, "item_botroam" ) ) { li->flags |= IFL_ROAM; AAS_FloatForBSPEpairKey( ent, "weight", &li->weight ); } } //if not a stationary item if ( !( spawnflags & 1 ) ) { if ( !AAS_DropToFloor( origin, ic->iteminfo[ i ].mins, ic->iteminfo[ i ].maxs ) ) { BotImport_Print( PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n", classname, origin[ 0 ], origin[ 1 ], origin[ 2 ] ); } } //item info of the level item li->iteminfo = i; //origin of the item VectorCopy( origin, li->origin ); if ( goalareanum ) { li->goalareanum = goalareanum; VectorCopy( origin, li->goalorigin ); } else { //get the item goal area and goal origin li->goalareanum = AAS_BestReachableArea( origin, ic->iteminfo[ i ].mins, ic->iteminfo[ i ].maxs, li->goalorigin ); if ( !li->goalareanum ) { BotImport_Print( PRT_MESSAGE, "%s not reachable for bots at (%1.1f %1.1f %1.1f)\n", classname, origin[ 0 ], origin[ 1 ], origin[ 2 ] ); } } AddLevelItemToList( li ); } BotImport_Print( PRT_MESSAGE, "found %d level items\n", numlevelitems ); }