All entities even non-monsters have a
int Classify()
method that returns its
classification, here is the table of them (
cbase.h
):
Constant | Value | What does it mean for the entity |
---|
CLASS_NONE | 0 | This entity does not need a classification. |
CLASS_MACHINE | 1 | This entity is a machine (sentry, turret). |
CLASS_PLAYER | 2 | This entity is a player. |
CLASS_HUMAN_PASSIVE | 3 | This entity is a passive human (scientist). |
CLASS_HUMAN_MILITARY | 4 | This entity is a human with military knowledge (Barney). |
CLASS_ALIEN_MILITARY | 5 | This entity is an alien with military knowledge (alien grunt). |
CLASS_ALIEN_PASSIVE | 6 | This entity is a passive alien (not used by any existing monster). |
CLASS_ALIEN_MONSTER | 7 | This entity is a not so friendly alien monster (Big Momma, Gargantua). |
CLASS_ALIEN_PREY | 8 | This entity is an alien prey for predators (headcrab). |
CLASS_ALIEN_PREDATOR | 9 | This entity is an alien predator on the hunt for preys (bullsquid). |
CLASS_INSECT | 10 | This entity is an insect (cockroach). |
CLASS_PLAYER_ALLY | 11 | This entity is an ally for the player (Barney & scientist). |
CLASS_PLAYER_BIOWEAPON | 12 | This entity is an alien projectile fired by a player (player hornets). |
CLASS_ALIEN_BIOWEAPON | 13 | This entity is an alien projectile fired by an alien monster (alien grunt hornets). |
CLASS_BARNACLE | 99 | Special classification for barnacles. |
Whenever a
relationship needs to be tested, a call to the method
IRelationship
is made and returns one of the following values (
monsters.h
):
Constant | Value | What does it mean for the monster |
---|
R_AL | -2 | Ally - This monster is my ally and a friend. |
R_FR | -1 | Fear - I am afraid of this monster, I need to get away from him. |
R_NO | 0 | No relationship - Not my friend but not my enemy either. |
R_DL | 1 | Dislike - This is an enemy I need to attack him. |
R_HT | 2 | Hate - I hate this enemy and I will attack him in priority. |
R_NM | 3 | Nemesis - I really hate this enemy and I want him dead no matter what. |
All of them means "enemy" but the difference is the severity or priority of the threat when choosing the enemy to attack if many of them are present.
- "Dislike" can be compared to "low priority" or "I can deal with it later if there is a more important enemy".
- "Hate" is the "medium priority", in other words, this is the entity thinking "I should probably take care of this kind of target first before dealing with the rest".
- "Nemesis" is the "highest priority", the entity will prioritize this target no matter what, anything else does not matter.
A matrix is built to determine the
relationship between two entities based on their
classification, that matrix is (
static int iEnemy[14][14]
defined in
int CBaseMonster::IRelationship( CBaseEntity *pTarget )
):
Matrix | CLASS_NONE | CLASS_MACHINE | CLASS_PLAYER | CLASS_HUMAN_PASSIVE | CLASS_HUMAN_MILITARY | CLASS_ALIEN_MILITARY | CLASS_ALIEN_PASSIVE | CLASS_ALIEN_MONSTER | CLASS_ALIEN_PREY | CLASS_ALIEN_PREDATOR | CLASS_INSECT | CLASS_PLAYER_ALLY | CLASS_PLAYER_BIOWEAPON | CLASS_ALIEN_BIOWEAPON |
---|
CLASS_NONE | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) |
CLASS_MACHINE | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) |
CLASS_PLAYER | R_NO (ignore) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) |
CLASS_HUMAN_PASSIVE | R_NO (ignore) | R_NO (ignore) | R_AL (ally) | R_AL (ally) | R_HT (hate) | R_FR (fear) | R_NO (ignore) | R_HT (hate) | R_DL (dislike) | R_FR (fear) | R_NO (ignore) | R_AL (ally) | R_NO (ignore) | R_NO (ignore) |
CLASS_HUMAN_MILITARY | R_NO (ignore) | R_NO (ignore) | R_HT (hate) | R_DL (dislike) | R_NO (ignore) | R_HT (hate) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_HT (hate) | R_NO (ignore) | R_NO (ignore) |
CLASS_ALIEN_MILITARY | R_NO (ignore) | R_DL (dislike) | R_HT (hate) | R_DL (dislike) | R_HT (hate) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) |
CLASS_ALIEN_PASSIVE | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) |
CLASS_ALIEN_MONSTER | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) |
CLASS_ALIEN_PREY | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_FR (fear) | R_NO (ignore) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) |
CLASS_ALIEN_PREDATOR | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_HT (hate) | R_DL (dislike) | R_NO (ignore) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) |
CLASS_INSECT | R_FR (fear) | R_FR (fear) | R_FR (fear) | R_FR (fear) | R_FR (fear) | R_NO (ignore) | R_FR (fear) | R_FR (fear) | R_FR (fear) | R_FR (fear) | R_NO (ignore) | R_FR (fear) | R_NO (ignore) | R_NO (ignore) |
CLASS_PLAYER_ALLY | R_NO (ignore) | R_DL (dislike) | R_AL (ally) | R_AL (ally) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) | R_NO (ignore) |
CLASS_PLAYER_BIOWEAPON | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_DL (dislike) | R_NO (ignore) | R_DL (dislike) |
CLASS_ALIEN_BIOWEAPON | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_DL (dislike) | R_AL (ally) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) | R_NO (ignore) | R_DL (dislike) | R_DL (dislike) | R_NO (ignore) |
The way to read this matrix is simple, the correct line is the entity's
classification determining the
relationship and the column is the target's
classification.
Keep in mind that entities can override
int IRelationship( CBaseEntity *pTarget )
and thus have a specific
relationship with one or more specific entities in specific cases.
Let's take a look at the human grunt (
int CHGrunt::IRelationship( CBaseEntity *pTarget )
)
relationship code for an example:
int CHGrunt::IRelationship( CBaseEntity *pTarget )
{
if ( FClassnameIs( pTarget->pev, "monster_alien_grunt" ) || ( FClassnameIs( pTarget->pev, "monster_gargantua" ) ) )
{
return R_NM;
}
return CSquadMonster::IRelationship( pTarget );
}
We can determine that human grunts are really pissed off against alien grunts and gargantuas that they want them dead at all costs because they treat them as "nemesis".
There is no override of
int IRelationship( CBaseEntity *pTarget )
in
CSquadMonster
(the human grunt's base class) so we fall back to the matrix shown above defined in
CBaseMonster
instead.
From there, we have multiple cases depending on the target:
- They hate players, alien military and player allies like Barney (
R_HT
on CLASS_PLAYER
, CLASS_ALIEN_MILITARY
and CLASS_PLAYER_ALLY
). - They dislike passive humans like scientists, passive aliens, alien monsters like Vortigaunts, alien preys like headcrabs, alien predators like bullsquids (
R_DL
on CLASS_HUMAN_PASSIVE
, CLASS_ALIEN_PASSIVE
, CLASS_ALIEN_MONSTER
, CLASS_ALIEN_PREY
and CLASS_ALIEN_PREDATOR
). - They ignore the rest (
R_NO
on classifications not mentioned in this list).