#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_utils.h"
#include "l_log.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
#include "be_aas_def.h"
Include dependency graph for be_aas_entity.c:

Go to the source code of this file.
Defines | |
| #define | MASK_SOLID CONTENTS_PLAYERCLIP |
Enumerations | |
| enum | { ET_GENERAL, ET_PLAYER, ET_ITEM, ET_MISSILE, ET_MOVER } |
Functions | |
| int | AAS_BestReachableEntityArea (int entnum) |
| void | AAS_EntityBSPData (int entnum, bsp_entdata_t *entdata) |
| void | AAS_EntityInfo (int entnum, aas_entityinfo_t *info) |
| int | AAS_EntityModelindex (int entnum) |
| int | AAS_EntityModelNum (int entnum) |
| void | AAS_EntityOrigin (int entnum, vec3_t origin) |
| void | AAS_EntitySize (int entnum, vec3_t mins, vec3_t maxs) |
| int | AAS_EntityType (int entnum) |
| void | AAS_InvalidateEntities (void) |
| int | AAS_NearestEntity (vec3_t origin, int modelindex) |
| int | AAS_NextEntity (int entnum) |
| int | AAS_OriginOfMoverWithModelNum (int modelnum, vec3_t origin) |
| void | AAS_ResetEntityLinks (void) |
| void | AAS_UnlinkInvalidEntities (void) |
| int | AAS_UpdateEntity (int entnum, bot_entitystate_t *state) |
|
|
Definition at line 46 of file be_aas_entity.c. Referenced by BotRoamGoal(), BotValidChatPosition(), CanDamage(), CG_OffsetThirdPersonView(), FinishSpawningItem(), and G_CheckProxMinePosition(). |
|
|
Definition at line 49 of file be_aas_entity.c. 00049 {
00050 ET_GENERAL,
00051 ET_PLAYER,
00052 ET_ITEM,
00053 ET_MISSILE,
00054 ET_MOVER
00055 };
|
|
|
Definition at line 414 of file be_aas_entity.c. References AAS_BestReachableLinkArea(), aas_entity_t, aasworld, aas_entity_s::areas, and aas_s::entities. 00415 {
00416 aas_entity_t *ent;
00417
00418 ent = &aasworld.entities[entnum];
00419 return AAS_BestReachableLinkArea(ent->areas);
00420 } //end of the function AAS_BestReachableEntityArea
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 308 of file be_aas_entity.c. References aas_entity_t, aasworld, bsp_entdata_s::absmaxs, bsp_entdata_s::absmins, bsp_entdata_s::angles, aas_entityinfo_s::angles, bsp_entdata_t, aas_s::entities, aas_entity_s::i, aas_entityinfo_s::maxs, aas_entityinfo_s::mins, aas_entityinfo_s::modelindex, bsp_entdata_s::modelnum, bsp_entdata_s::origin, aas_entityinfo_s::origin, aas_entityinfo_s::solid, bsp_entdata_s::solid, VectorAdd, and VectorCopy. 00309 {
00310 aas_entity_t *ent;
00311
00312 ent = &aasworld.entities[entnum];
00313 VectorCopy(ent->i.origin, entdata->origin);
00314 VectorCopy(ent->i.angles, entdata->angles);
00315 VectorAdd(ent->i.origin, ent->i.mins, entdata->absmins);
00316 VectorAdd(ent->i.origin, ent->i.maxs, entdata->absmaxs);
00317 entdata->solid = ent->i.solid;
00318 entdata->modelnum = ent->i.modelindex - 1;
00319 } //end of the function AAS_EntityBSPData
|
|
||||||||||||
|
Definition at line 171 of file be_aas_entity.c. References aas_entityinfo_t, aasworld, botimport, Com_Memcpy(), Com_Memset(), aas_s::entities, aas_entity_s::i, aas_s::initialized, aas_s::maxentities, and PRT_FATAL. Referenced by BotFindEntityForLevelItem(), BotItemGoalInVisButNotVisible(), BotUpdateEntityItems(), and GrappleState(). 00172 {
00173 if (!aasworld.initialized)
00174 {
00175 botimport.Print(PRT_FATAL, "AAS_EntityInfo: aasworld not initialized\n");
00176 Com_Memset(info, 0, sizeof(aas_entityinfo_t));
00177 return;
00178 } //end if
00179
00180 if (entnum < 0 || entnum >= aasworld.maxentities)
00181 {
00182 botimport.Print(PRT_FATAL, "AAS_EntityInfo: entnum %d out of range\n", entnum);
00183 Com_Memset(info, 0, sizeof(aas_entityinfo_t));
00184 return;
00185 } //end if
00186
00187 Com_Memcpy(info, &aasworld.entities[entnum].i, sizeof(aas_entityinfo_t));
00188 } //end of the function AAS_EntityInfo
|
Here is the call graph for this function:

|
|
Definition at line 212 of file be_aas_entity.c. References aasworld, botimport, aas_s::entities, aas_entity_s::i, aas_s::maxentities, aas_entityinfo_s::modelindex, and PRT_FATAL. Referenced by BotFindEntityForLevelItem(), BotMoveToGoal(), BotReachabilityArea(), and BotUpdateEntityItems(). 00213 {
00214 if (entnum < 0 || entnum >= aasworld.maxentities)
00215 {
00216 botimport.Print(PRT_FATAL, "AAS_EntityModelindex: entnum %d out of range\n", entnum);
00217 return 0;
00218 } //end if
00219 return aasworld.entities[entnum].i.modelindex;
00220 } //end of the function AAS_EntityModelindex
|
|
|
Definition at line 244 of file be_aas_entity.c. References aasworld, botimport, aas_s::entities, aas_entity_s::i, aas_s::initialized, aas_s::maxentities, aas_entityinfo_s::modelindex, and PRT_FATAL. Referenced by BotOnMover(). 00245 {
00246 if (!aasworld.initialized) return 0;
00247
00248 if (entnum < 0 || entnum >= aasworld.maxentities)
00249 {
00250 botimport.Print(PRT_FATAL, "AAS_EntityModelNum: entnum %d out of range\n", entnum);
00251 return 0;
00252 } //end if
00253 return aasworld.entities[entnum].i.modelindex;
00254 } //end of the function AAS_EntityModelNum
|
|
||||||||||||
|
Definition at line 195 of file be_aas_entity.c. References aasworld, botimport, aas_s::entities, aas_entity_s::i, aas_s::maxentities, aas_entityinfo_s::origin, PRT_FATAL, VectorClear, and VectorCopy. 00196 {
00197 if (entnum < 0 || entnum >= aasworld.maxentities)
00198 {
00199 botimport.Print(PRT_FATAL, "AAS_EntityOrigin: entnum %d out of range\n", entnum);
00200 VectorClear(origin);
00201 return;
00202 } //end if
00203
00204 VectorCopy(aasworld.entities[entnum].i.origin, origin);
00205 } //end of the function AAS_EntityOrigin
|
|
||||||||||||||||
|
Definition at line 286 of file be_aas_entity.c. References aas_entity_t, aasworld, botimport, aas_s::entities, aas_entity_s::i, aas_s::initialized, aas_s::maxentities, aas_entityinfo_s::maxs, aas_entityinfo_s::mins, PRT_FATAL, and VectorCopy. 00287 {
00288 aas_entity_t *ent;
00289
00290 if (!aasworld.initialized) return;
00291
00292 if (entnum < 0 || entnum >= aasworld.maxentities)
00293 {
00294 botimport.Print(PRT_FATAL, "AAS_EntitySize: entnum %d out of range\n", entnum);
00295 return;
00296 } //end if
00297
00298 ent = &aasworld.entities[entnum];
00299 VectorCopy(ent->i.mins, mins);
00300 VectorCopy(ent->i.maxs, maxs);
00301 } //end of the function AAS_EntitySize
|
|
|
Definition at line 227 of file be_aas_entity.c. References aasworld, botimport, aas_s::entities, aas_entity_s::i, aas_s::initialized, aas_s::maxentities, PRT_FATAL, and aas_entityinfo_s::type. Referenced by BotUpdateEntityItems(), and GrappleState(). 00228 {
00229 if (!aasworld.initialized) return 0;
00230
00231 if (entnum < 0 || entnum >= aasworld.maxentities)
00232 {
00233 botimport.Print(PRT_FATAL, "AAS_EntityType: entnum %d out of range\n", entnum);
00234 return 0;
00235 } //end if
00236 return aasworld.entities[entnum].i.type;
00237 } //end of the AAS_EntityType
|
|
|
Definition at line 341 of file be_aas_entity.c. References aasworld, aas_s::entities, aas_entity_s::i, i, aas_s::maxentities, aas_entityinfo_s::number, and aas_entityinfo_s::valid. Referenced by AAS_Setup(), and AAS_StartFrame(). 00342 {
00343 int i;
00344 for (i = 0; i < aasworld.maxentities; i++)
00345 {
00346 aasworld.entities[i].i.valid = qfalse;
00347 aasworld.entities[i].i.number = i;
00348 } //end for
00349 } //end of the function AAS_InvalidateEntities
|
|
||||||||||||
|
Definition at line 379 of file be_aas_entity.c. References aas_entity_t, aasworld, abs(), aas_s::entities, aas_entity_s::i, i, aas_s::maxentities, aas_entityinfo_s::modelindex, aas_entityinfo_s::origin, vec3_t, VectorLength(), and VectorSubtract. 00380 {
00381 int i, bestentnum;
00382 float dist, bestdist;
00383 aas_entity_t *ent;
00384 vec3_t dir;
00385
00386 bestentnum = 0;
00387 bestdist = 99999;
00388 for (i = 0; i < aasworld.maxentities; i++)
00389 {
00390 ent = &aasworld.entities[i];
00391 if (ent->i.modelindex != modelindex) continue;
00392 VectorSubtract(ent->i.origin, origin, dir);
00393 if (abs(dir[0]) < 40)
00394 {
00395 if (abs(dir[1]) < 40)
00396 {
00397 dist = VectorLength(dir);
00398 if (dist < bestdist)
00399 {
00400 bestdist = dist;
00401 bestentnum = i;
00402 } //end if
00403 } //end if
00404 } //end if
00405 } //end for
00406 return bestentnum;
00407 } //end of the function AAS_NearestEntity
|
Here is the call graph for this function:

|
|
Definition at line 427 of file be_aas_entity.c. References aasworld, aas_s::entities, aas_entity_s::i, aas_s::loaded, aas_s::maxentities, and aas_entityinfo_s::valid. Referenced by BotFindEntityForLevelItem(), BotUpdateEntityItems(), and GrappleState(). 00428 {
00429 if (!aasworld.loaded) return 0;
00430
00431 if (entnum < 0) entnum = -1;
00432 while(++entnum < aasworld.maxentities)
00433 {
00434 if (aasworld.entities[entnum].i.valid) return entnum;
00435 } //end while
00436 return 0;
00437 } //end of the function AAS_NextEntity
|
|
||||||||||||
|
Definition at line 261 of file be_aas_entity.c. References aas_entity_t, aasworld, aas_s::entities, i, aas_entity_s::i, aas_s::maxentities, aas_entityinfo_s::modelindex, aas_entityinfo_s::origin, aas_entityinfo_s::type, and VectorCopy. Referenced by BotFuncBobStartEnd(), BotOnMover(), MoverBottomCenter(), and MoverDown(). 00262 {
00263 int i;
00264 aas_entity_t *ent;
00265
00266 for (i = 0; i < aasworld.maxentities; i++)
00267 {
00268 ent = &aasworld.entities[i];
00269 if (ent->i.type == ET_MOVER)
00270 {
00271 if (ent->i.modelindex == modelnum)
00272 {
00273 VectorCopy(ent->i.origin, origin);
00274 return qtrue;
00275 } //end if
00276 } //end if
00277 } //end for
00278 return qfalse;
00279 } //end of the function AAS_OriginOfMoverWithModelNum
|
|
|
Definition at line 326 of file be_aas_entity.c. References aasworld, aas_entity_s::areas, aas_s::entities, i, aas_entity_s::leaves, and aas_s::maxentities. Referenced by AAS_LoadFiles(). 00327 {
00328 int i;
00329 for (i = 0; i < aasworld.maxentities; i++)
00330 {
00331 aasworld.entities[i].areas = NULL;
00332 aasworld.entities[i].leaves = NULL;
00333 } //end for
00334 } //end of the function AAS_ResetEntityLinks
|
|
|
Definition at line 356 of file be_aas_entity.c. References aas_entity_t, AAS_UnlinkFromAreas(), AAS_UnlinkFromBSPLeaves(), aasworld, aas_entity_s::areas, aas_s::entities, aas_entity_s::i, i, aas_entity_s::leaves, aas_s::maxentities, and aas_entityinfo_s::valid. Referenced by AAS_StartFrame(). 00357 {
00358 int i;
00359 aas_entity_t *ent;
00360
00361 for (i = 0; i < aasworld.maxentities; i++)
00362 {
00363 ent = &aasworld.entities[i];
00364 if (!ent->i.valid)
00365 {
00366 AAS_UnlinkFromAreas( ent->areas );
00367 ent->areas = NULL;
00368 AAS_UnlinkFromBSPLeaves( ent->leaves );
00369 ent->leaves = NULL;
00370 } //end for
00371 } //end for
00372 } //end of the function AAS_UnlinkInvalidEntities
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 63 of file be_aas_entity.c. References AAS_BSPLinkEntity(), AAS_BSPModelMinsMaxsOrigin(), aas_entity_t, AAS_LinkEntityClientBBox(), AAS_Time(), AAS_UnlinkFromAreas(), AAS_UnlinkFromBSPLeaves(), aasworld, aas_entityinfo_s::angles, bot_entitystate_s::angles, aas_entity_s::areas, bot_entitystate_t, botimport, aas_s::entities, bot_entitystate_s::event, aas_entityinfo_s::event, bot_entitystate_s::eventParm, aas_entityinfo_s::eventParm, bot_entitystate_s::flags, aas_entityinfo_s::flags, bot_entitystate_s::frame, aas_entityinfo_s::frame, bot_entitystate_s::groundent, aas_entityinfo_s::groundent, aas_entity_s::i, aas_entityinfo_s::lastvisorigin, aas_entity_s::leaves, bot_entitystate_s::legsAnim, aas_entityinfo_s::legsAnim, aas_s::loaded, aas_entityinfo_s::ltime, bot_entitystate_s::maxs, aas_entityinfo_s::maxs, bot_entitystate_s::mins, aas_entityinfo_s::mins, bot_entitystate_s::modelindex, aas_entityinfo_s::modelindex, bot_entitystate_s::modelindex2, aas_entityinfo_s::modelindex2, NULL, aas_entityinfo_s::number, aas_s::numframes, aas_entityinfo_s::old_origin, bot_entitystate_s::old_origin, bot_entitystate_s::origin, aas_entityinfo_s::origin, bot_entitystate_s::powerups, aas_entityinfo_s::powerups, PRESENCE_NORMAL, PRT_MESSAGE, relink, bot_entitystate_s::solid, aas_entityinfo_s::solid, state, bot_entitystate_s::torsoAnim, aas_entityinfo_s::torsoAnim, bot_entitystate_s::type, aas_entityinfo_s::type, aas_entityinfo_s::update_time, aas_entityinfo_s::valid, vec3_t, VectorAdd, VectorCompare(), VectorCopy, bot_entitystate_s::weapon, and aas_entityinfo_s::weapon. Referenced by Export_BotLibUpdateEntity(). 00064 {
00065 int relink;
00066 aas_entity_t *ent;
00067 vec3_t absmins, absmaxs;
00068
00069 if (!aasworld.loaded)
00070 {
00071 botimport.Print(PRT_MESSAGE, "AAS_UpdateEntity: not loaded\n");
00072 return BLERR_NOAASFILE;
00073 } //end if
00074
00075 ent = &aasworld.entities[entnum];
00076
00077 if (!state) {
00078 //unlink the entity
00079 AAS_UnlinkFromAreas(ent->areas);
00080 //unlink the entity from the BSP leaves
00081 AAS_UnlinkFromBSPLeaves(ent->leaves);
00082 //
00083 ent->areas = NULL;
00084 //
00085 ent->leaves = NULL;
00086 return BLERR_NOERROR;
00087 }
00088
00089 ent->i.update_time = AAS_Time() - ent->i.ltime;
00090 ent->i.type = state->type;
00091 ent->i.flags = state->flags;
00092 ent->i.ltime = AAS_Time();
00093 VectorCopy(ent->i.origin, ent->i.lastvisorigin);
00094 VectorCopy(state->old_origin, ent->i.old_origin);
00095 ent->i.solid = state->solid;
00096 ent->i.groundent = state->groundent;
00097 ent->i.modelindex = state->modelindex;
00098 ent->i.modelindex2 = state->modelindex2;
00099 ent->i.frame = state->frame;
00100 ent->i.event = state->event;
00101 ent->i.eventParm = state->eventParm;
00102 ent->i.powerups = state->powerups;
00103 ent->i.weapon = state->weapon;
00104 ent->i.legsAnim = state->legsAnim;
00105 ent->i.torsoAnim = state->torsoAnim;
00106 //number of the entity
00107 ent->i.number = entnum;
00108 //updated so set valid flag
00109 ent->i.valid = qtrue;
00110 //link everything the first frame
00111 if (aasworld.numframes == 1) relink = qtrue;
00112 else relink = qfalse;
00113 //
00114 if (ent->i.solid == SOLID_BSP)
00115 {
00116 //if the angles of the model changed
00117 if (!VectorCompare(state->angles, ent->i.angles))
00118 {
00119 VectorCopy(state->angles, ent->i.angles);
00120 relink = qtrue;
00121 } //end if
00122 //get the mins and maxs of the model
00123 //FIXME: rotate mins and maxs
00124 AAS_BSPModelMinsMaxsOrigin(ent->i.modelindex, ent->i.angles, ent->i.mins, ent->i.maxs, NULL);
00125 } //end if
00126 else if (ent->i.solid == SOLID_BBOX)
00127 {
00128 //if the bounding box size changed
00129 if (!VectorCompare(state->mins, ent->i.mins) ||
00130 !VectorCompare(state->maxs, ent->i.maxs))
00131 {
00132 VectorCopy(state->mins, ent->i.mins);
00133 VectorCopy(state->maxs, ent->i.maxs);
00134 relink = qtrue;
00135 } //end if
00136 VectorCopy(state->angles, ent->i.angles);
00137 } //end if
00138 //if the origin changed
00139 if (!VectorCompare(state->origin, ent->i.origin))
00140 {
00141 VectorCopy(state->origin, ent->i.origin);
00142 relink = qtrue;
00143 } //end if
00144 //if the entity should be relinked
00145 if (relink)
00146 {
00147 //don't link the world model
00148 if (entnum != ENTITYNUM_WORLD)
00149 {
00150 //absolute mins and maxs
00151 VectorAdd(ent->i.mins, ent->i.origin, absmins);
00152 VectorAdd(ent->i.maxs, ent->i.origin, absmaxs);
00153 //unlink the entity
00154 AAS_UnlinkFromAreas(ent->areas);
00155 //relink the entity to the AAS areas (use the larges bbox)
00156 ent->areas = AAS_LinkEntityClientBBox(absmins, absmaxs, entnum, PRESENCE_NORMAL);
00157 //unlink the entity from the BSP leaves
00158 AAS_UnlinkFromBSPLeaves(ent->leaves);
00159 //link the entity to the world BSP tree
00160 ent->leaves = AAS_BSPLinkEntity(absmins, absmaxs, entnum, 0);
00161 } //end if
00162 } //end if
00163 return BLERR_NOERROR;
00164 } //end of the function AAS_UpdateEntity
|
Here is the call graph for this function:

1.3.9.1