NSMonster: add new alliance type: MAL_NEUTRAL
This commit is contained in:
parent
a48498e5cf
commit
3f0f6b2d0f
3 changed files with 15 additions and 11 deletions
|
@ -182,7 +182,8 @@ typedef enum
|
||||||
MAL_FRIEND, /**< 1, friendly towards the player */
|
MAL_FRIEND, /**< 1, friendly towards the player */
|
||||||
MAL_ENEMY, /**< 2, unfriendly towards the player */
|
MAL_ENEMY, /**< 2, unfriendly towards the player */
|
||||||
MAL_ALIEN, /**< 3, unfriendly towards anyone but themselves */
|
MAL_ALIEN, /**< 3, unfriendly towards anyone but themselves */
|
||||||
MAL_ROGUE /**< 4, no allies, not even amongst themselves */
|
MAL_ROGUE, /**< 4, no allies, not even amongst themselves */
|
||||||
|
MAL_NEUTRAL /**< 5, neutral - will not attack, will not be attacked */
|
||||||
} allianceState_t;
|
} allianceState_t;
|
||||||
|
|
||||||
/** Movement states */
|
/** Movement states */
|
||||||
|
|
|
@ -555,6 +555,9 @@ NSMonster::AlertNoise(void)
|
||||||
bool
|
bool
|
||||||
NSMonster::IsFriend(int al)
|
NSMonster::IsFriend(int al)
|
||||||
{
|
{
|
||||||
|
/* neutrals are always friendly */
|
||||||
|
if (m_iAlliance == MAL_NEUTRAL)
|
||||||
|
return (true);
|
||||||
if (m_iAlliance == MAL_ROGUE)
|
if (m_iAlliance == MAL_ROGUE)
|
||||||
return (false);
|
return (false);
|
||||||
else if (al == m_iAlliance)
|
else if (al == m_iAlliance)
|
||||||
|
@ -617,24 +620,24 @@ bool
|
||||||
NSMonster::IsValidEnemy(entity enny)
|
NSMonster::IsValidEnemy(entity enny)
|
||||||
{
|
{
|
||||||
if (enny == __NULL__)
|
if (enny == __NULL__)
|
||||||
return FALSE;
|
return false;
|
||||||
/* dead enny should not be considered valid */
|
/* dead enny should not be considered valid */
|
||||||
if ((enny.solid == SOLID_CORPSE) || (enny.health <= 0))
|
if ((enny.solid == SOLID_CORPSE) || (enny.health <= 0))
|
||||||
return FALSE;
|
return false;
|
||||||
/* such monster should ignore players */
|
/* such monster should ignore players */
|
||||||
if ((enny.flags & FL_CLIENT) && HasSpawnFlags(MSF_IGNOREPLAYER))
|
if ((enny.flags & FL_CLIENT) && HasSpawnFlags(MSF_IGNOREPLAYER))
|
||||||
return FALSE;
|
return false;
|
||||||
/* monsters ignore enny who uses notarget cheat, useful for development */
|
/* monsters ignore enny who uses notarget cheat, useful for development */
|
||||||
if (enny.flags & FL_NOTARGET)
|
if (enny.flags & FL_NOTARGET)
|
||||||
return FALSE;
|
return false;
|
||||||
/* if they're our friend... ignore */
|
/* if they're our friend... ignore */
|
||||||
if (IsFriend(enny.m_iAlliance))
|
if (IsFriend(enny.m_iAlliance))
|
||||||
return FALSE;
|
return false;
|
||||||
/* prevent from shooting non-sentient stuff */
|
/* prevent from shooting non-sentient stuff */
|
||||||
if (!(enny.flags & (FL_MONSTER | FL_CLIENT)))
|
if (!(enny.flags & (FL_MONSTER | FL_CLIENT)))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -708,7 +711,7 @@ NSMonster::SeeThink(void)
|
||||||
|
|
||||||
m_flSeeTime = time + 0.25f;
|
m_flSeeTime = time + 0.25f;
|
||||||
|
|
||||||
/* a horse type monster always knows where the nearest player is */
|
/* a horde type monster always knows where the nearest player is */
|
||||||
if (m_iFlags & MSF_HORDE) {
|
if (m_iFlags & MSF_HORDE) {
|
||||||
m_eEnemy = NSMonster_FindClosestPlayer(this);
|
m_eEnemy = NSMonster_FindClosestPlayer(this);
|
||||||
|
|
||||||
|
@ -719,7 +722,7 @@ NSMonster::SeeThink(void)
|
||||||
|
|
||||||
for (entity w = world; (w = findfloat(w, ::takedamage, DAMAGE_YES));) {
|
for (entity w = world; (w = findfloat(w, ::takedamage, DAMAGE_YES));) {
|
||||||
/* check if 'w' could be a valid enemy */
|
/* check if 'w' could be a valid enemy */
|
||||||
if (!IsValidEnemy(w))
|
if (IsValidEnemy(w) == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* first, is the potential enemy in our field of view? */
|
/* first, is the potential enemy in our field of view? */
|
||||||
|
|
|
@ -334,7 +334,7 @@ NSTalkMonster::TalkPlayerIdle(void)
|
||||||
|
|
||||||
for (entity p = world; (p = find(p, ::classname, "player"));) {
|
for (entity p = world; (p = find(p, ::classname, "player"));) {
|
||||||
|
|
||||||
if (!IsFriend(p.m_iAlliance)) {
|
if (IsFriend(p.m_iAlliance) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue