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

Function NPC_CheckLookTarget

codeJK2/game/NPC_utils.cpp:1404–1430  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1402-------------------------
1403*/
1404qboolean NPC_CheckLookTarget( gentity_t *self )
1405{
1406 if ( self->client )
1407 {
1408 if ( self->client->renderInfo.lookTarget >= 0 && self->client->renderInfo.lookTarget < ENTITYNUM_WORLD )
1409 {//within valid range
1410 if ( (&g_entities[self->client->renderInfo.lookTarget] == NULL) || !g_entities[self->client->renderInfo.lookTarget].inuse )
1411 {//lookTarget not inuse or not valid anymore
1412 NPC_ClearLookTarget( self );
1413 }
1414 else if ( self->client->renderInfo.lookTargetClearTime && self->client->renderInfo.lookTargetClearTime < level.time )
1415 {//Time to clear lookTarget
1416 NPC_ClearLookTarget( self );
1417 }
1418 else if ( g_entities[self->client->renderInfo.lookTarget].client && self->enemy && (&g_entities[self->client->renderInfo.lookTarget] != self->enemy) )
1419 {//should always look at current enemy if engaged in battle... FIXME: this could override certain scripted lookTargets...???
1420 NPC_ClearLookTarget( self );
1421 }
1422 else
1423 {
1424 return qtrue;
1425 }
1426 }
1427 }
1428
1429 return qfalse;
1430}
1431
1432/*
1433-------------------------

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