/* * AI_InitEntitiesData */ void AI_InitEntitiesData( void ) { int newlinks, newjumplinks; edict_t *ent; if( !nav.num_nodes ) { if( g_numbots->integer ) trap_Cvar_Set( "g_numbots", "0" ); return; } // create nodes for navigable map entities ( must happen after finding teams ) for( ent = game.edicts + 1 + gs.maxclients; ENTNUM( ent ) < game.numentities; ent++ ) AI_AddNavigableEntity( ent ); // add all clients to goalEntities so they can be tracked as enemies for( ent = game.edicts + 1; PLAYERNUM( ent ) < gs.maxclients; ent++ ) AI_AddGoalEntity( ent ); // link all newly added nodes newlinks = AI_LinkServerNodes( nav.serverNodesStart ); newjumplinks = AI_LinkCloseNodes_JumpPass( nav.serverNodesStart ); if( developer->integer ) { G_Printf( " : added nodes:%i.\n", nav.num_nodes - nav.serverNodesStart ); G_Printf( " : total nodes:%i.\n", nav.num_nodes ); G_Printf( " : added links:%i.\n", newlinks ); G_Printf( " : added jump links:%i.\n", newjumplinks ); } G_Printf( " : AI Navigation Initialized.\n" ); nav.loaded = qtrue; }
//========================================== // AI_EnemyAdded // Add the Player to our list //========================================== void AI_EnemyAdded( edict_t *ent ) { AI_AddGoalEntity( ent ); }
/* * Finish_SpawningItem */ static void Finish_SpawningItem( edict_t *ent ) { trace_t tr; vec3_t dest; gsitem_t *item = ent->item; assert( item ); ent->s.itemNum = item->tag; VectorCopy( item_box_mins, ent->r.mins ); VectorCopy( item_box_maxs, ent->r.maxs ); if( ent->model ) { ent->s.modelindex = trap_ModelIndex( ent->model ); } else { if( item->world_model[0] ) ent->s.modelindex = trap_ModelIndex( item->world_model[0] ); if( item->world_model[1] ) ent->s.modelindex2 = trap_ModelIndex( item->world_model[1] ); } ent->r.solid = SOLID_TRIGGER; ent->r.svflags &= ~SVF_NOCLIENT; ent->movetype = MOVETYPE_TOSS; ent->touch = Touch_Item; ent->attenuation = 1; if( ent->spawnflags & 1 ) ent->gravity = 0; G_Trace( &tr, ent->s.origin, ent->r.mins, ent->r.maxs, ent->s.origin, ent, MASK_SOLID ); if( tr.startsolid ) { vec3_t end; // move it 16 units up, cause it's typical they share the leaf with the floor VectorCopy( ent->s.origin, end ); end[2] += 16; G_Trace( &tr, end, ent->r.mins, ent->r.maxs, ent->s.origin, ent, MASK_SOLID ); if( tr.startsolid ) { G_Printf( "Warning: %s %s spawns inside solid. Inhibited\n", ent->classname, vtos( ent->s.origin ) ); G_FreeEdict( ent ); return; } VectorCopy( tr.endpos, ent->s.origin ); } // drop the item to floor if( ent->gravity ) { VectorSet( dest, ent->s.origin[0], ent->s.origin[1], ent->s.origin[2] - 128 ); G_Trace( &tr, ent->s.origin, ent->r.mins, ent->r.maxs, dest, ent, MASK_SOLID ); VectorCopy( tr.endpos, ent->s.origin ); } if( item->type & IT_HEALTH ) { if( item->tag == HEALTH_SMALL || item->tag == HEALTH_ULTRA ) ent->style = HEALTH_IGNORE_MAX; else if( item->tag == HEALTH_MEGA ) ent->style = HEALTH_IGNORE_MAX|HEALTH_TIMED; } if( ent->team ) { ent->flags &= ~FL_TEAMSLAVE; ent->chain = ent->teamchain; ent->teamchain = NULL; ent->r.svflags |= SVF_NOCLIENT; ent->r.solid = SOLID_NOT; // team slaves and targeted items aren't present at start if( ent == ent->teammaster && !ent->targetname ) { ent->nextThink = level.time + 1; ent->think = DoRespawn; GClip_LinkEntity( ent ); } } else if( ent->targetname ) { ent->r.svflags |= SVF_NOCLIENT; ent->r.solid = SOLID_NOT; } GClip_LinkEntity( ent ); AI_AddGoalEntity( ent ); }