NSMonster: add new alliance type: MAL_NEUTRAL

This commit is contained in:
Marco Cawthorne 2023-10-03 20:18:10 -07:00
parent a48498e5cf
commit 3f0f6b2d0f
Signed by: eukara
GPG key ID: CE2032F0A2882A22
3 changed files with 15 additions and 11 deletions

View file

@ -182,7 +182,8 @@ typedef enum
MAL_FRIEND, /**< 1, friendly towards the player */
MAL_ENEMY, /**< 2, unfriendly towards the player */
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;
/** Movement states */

View file

@ -555,6 +555,9 @@ NSMonster::AlertNoise(void)
bool
NSMonster::IsFriend(int al)
{
/* neutrals are always friendly */
if (m_iAlliance == MAL_NEUTRAL)
return (true);
if (m_iAlliance == MAL_ROGUE)
return (false);
else if (al == m_iAlliance)
@ -617,24 +620,24 @@ bool
NSMonster::IsValidEnemy(entity enny)
{
if (enny == __NULL__)
return FALSE;
return false;
/* dead enny should not be considered valid */
if ((enny.solid == SOLID_CORPSE) || (enny.health <= 0))
return FALSE;
return false;
/* such monster should ignore players */
if ((enny.flags & FL_CLIENT) && HasSpawnFlags(MSF_IGNOREPLAYER))
return FALSE;
return false;
/* monsters ignore enny who uses notarget cheat, useful for development */
if (enny.flags & FL_NOTARGET)
return FALSE;
return false;
/* if they're our friend... ignore */
if (IsFriend(enny.m_iAlliance))
return FALSE;
return false;
/* prevent from shooting non-sentient stuff */
if (!(enny.flags & (FL_MONSTER | FL_CLIENT)))
return FALSE;
return false;
return TRUE;
return true;
}
static bool
@ -708,7 +711,7 @@ NSMonster::SeeThink(void)
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) {
m_eEnemy = NSMonster_FindClosestPlayer(this);
@ -719,7 +722,7 @@ NSMonster::SeeThink(void)
for (entity w = world; (w = findfloat(w, ::takedamage, DAMAGE_YES));) {
/* check if 'w' could be a valid enemy */
if (!IsValidEnemy(w))
if (IsValidEnemy(w) == false)
continue;
/* first, is the potential enemy in our field of view? */

View file

@ -334,7 +334,7 @@ NSTalkMonster::TalkPlayerIdle(void)
for (entity p = world; (p = find(p, ::classname, "player"));) {
if (!IsFriend(p.m_iAlliance)) {
if (IsFriend(p.m_iAlliance) == false) {
continue;
}