MCPcopy Create free account
hub / github.com/JACoders/OpenJK / NPC_CheckLookTarget

Function NPC_CheckLookTarget

code/game/NPC_utils.cpp:1490–1516  ·  view source on GitHub ↗

------------------------- NPC_CheckLookTarget ------------------------- */

Source from the content-addressed store, hash-verified

1488-------------------------
1489*/
1490qboolean NPC_CheckLookTarget( gentity_t *self )
1491{
1492 if ( self->client )
1493 {
1494 if ( self->client->renderInfo.lookTarget >= 0 && self->client->renderInfo.lookTarget < ENTITYNUM_WORLD )
1495 {//within valid range
1496 if ( (&g_entities[self->client->renderInfo.lookTarget] == NULL) || !g_entities[self->client->renderInfo.lookTarget].inuse )
1497 {//lookTarget not inuse or not valid anymore
1498 NPC_ClearLookTarget( self );
1499 }
1500 else if ( self->client->renderInfo.lookTargetClearTime && self->client->renderInfo.lookTargetClearTime < level.time )
1501 {//Time to clear lookTarget
1502 NPC_ClearLookTarget( self );
1503 }
1504 else if ( g_entities[self->client->renderInfo.lookTarget].client && self->enemy && (&g_entities[self->client->renderInfo.lookTarget] != self->enemy) )
1505 {//should always look at current enemy if engaged in battle... FIXME: this could override certain scripted lookTargets...???
1506 NPC_ClearLookTarget( self );
1507 }
1508 else
1509 {
1510 return qtrue;
1511 }
1512 }
1513 }
1514
1515 return qfalse;
1516}
1517
1518/*
1519-------------------------

Callers 3

NPC_TempLookTargetFunction · 0.70
G_ClearEnemyFunction · 0.70
NPC_ExecuteBStateFunction · 0.70

Calls 1

NPC_ClearLookTargetFunction · 0.70

Tested by

no test coverage detected