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

Function NPC_ValidEnemy

codeJK2/game/NPC_utils.cpp:931–982  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

929*/
930
931qboolean NPC_ValidEnemy( gentity_t *ent )
932{
933 //Must be a valid pointer
934 if ( ent == NULL )
935 return qfalse;
936
937 //Must not be me
938 if ( ent == NPC )
939 return qfalse;
940
941 //Must not be deleted
942 if ( ent->inuse == qfalse )
943 return qfalse;
944
945 //Must be alive
946 if ( ent->health <= 0 )
947 return qfalse;
948
949 //In case they're in notarget mode
950 if ( ent->flags & FL_NOTARGET )
951 return qfalse;
952
953 //Must be an NPC
954 if ( ent->client == NULL )
955 {
956 if ( ent->svFlags&SVF_NONNPC_ENEMY )
957 {//still potentially valid
958 if ( ent->noDamageTeam == NPC->client->playerTeam )
959 {
960 return qfalse;
961 }
962 else
963 {
964 return qtrue;
965 }
966 }
967 else
968 {
969 return qfalse;
970 }
971 }
972
973 //Can't be on the same team
974 if ( ent->client->playerTeam == NPC->client->playerTeam )
975 return qfalse;
976
977 //if haven't seen him in a while, give up
978 //if ( NPCInfo->enemyLastSeenTime != 0 && level.time - NPCInfo->enemyLastSeenTime > 7000 )//FIXME: make a stat?
979 // return qfalse;
980
981 return qtrue;
982}
983
984/*
985-------------------------

Callers 6

Jedi_CheckAmbushPlayerFunction · 0.70
Jedi_PatrolFunction · 0.70
Jedi_AttackFunction · 0.70
NPC_FindNearestEnemyFunction · 0.70
NPC_FindEnemyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected