- removed some pointless restrictions from AActor::IsOkayToAttack which prevented its use on normal monsters.

This all made sense as long as the function was only used internally but that's not the case anymore.
This commit is contained in:
Christoph Oelckers 2017-05-09 09:57:38 +02:00
parent c6a516089e
commit 8be7ff01dd

View file

@ -3823,28 +3823,22 @@ DEFINE_ACTION_FUNCTION(AActor, PlayActiveSound)
bool AActor::IsOkayToAttack (AActor *link) bool AActor::IsOkayToAttack (AActor *link)
{ {
if (!(player // Original AActor::IsOkayToAttack was only for players
// || (flags & MF_FRIENDLY) // Maybe let friendly monsters use the function as well?
|| (flags5 & MF5_SUMMONEDMONSTER) // AMinotaurFriend has its own version, generalized to other summoned monsters
|| (flags2 & MF2_SEEKERMISSILE))) // AHolySpirit and AMageStaffFX2 as well, generalized to other seeker missiles
{ // Normal monsters and other actors always return false.
return false;
}
// Standard things to eliminate: an actor shouldn't attack itself, // Standard things to eliminate: an actor shouldn't attack itself,
// or a non-shootable, dormant, non-player-and-non-monster actor. // or a non-shootable, dormant, non-player-and-non-monster actor.
if (link == this) return false; if (link == this) return false;
if (!(link->player||(link->flags3 & MF3_ISMONSTER)))return false; if (!(link->player||(link->flags3 & MF3_ISMONSTER)))return false;
if (!(link->flags & MF_SHOOTABLE)) return false; if (!(link->flags & MF_SHOOTABLE)) return false;
if (link->flags2 & MF2_DORMANT) return false; if (link->flags2 & MF2_DORMANT) return false;
if (link->flags7 & MF7_NEVERTARGET) return false; // NEVERTARGET means just that.
// An actor shouldn't attack friendly actors. The reference depends // An actor shouldn't attack friendly actors. The reference depends
// on the type of actor: for a player's actor, itself; for a projectile, // on the type of actor: for a player's actor, itself; for a projectile,
// its target; and for a summoned minion, its tracer. // its target; and for a summoned minion, its tracer.
AActor * Friend = NULL; AActor * Friend;
if (player) Friend = this; if (flags5 & MF5_SUMMONEDMONSTER) Friend = tracer;
else if (flags5 & MF5_SUMMONEDMONSTER) Friend = tracer;
else if (flags2 & MF2_SEEKERMISSILE) Friend = target; else if (flags2 & MF2_SEEKERMISSILE) Friend = target;
else if ((flags & MF_FRIENDLY) && FriendPlayer) Friend = players[FriendPlayer-1].mo; else if ((flags & MF_FRIENDLY) && FriendPlayer) Friend = players[FriendPlayer-1].mo;
else Friend = this;
// Friend checks // Friend checks
if (link == Friend) return false; if (link == Friend) return false;