diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index fa2a5e4f9..beb447cc6 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -42,6 +42,7 @@ import network.packets.swg.zone.baselines.Baseline.BaselineType; import network.packets.swg.zone.object_controller.PostureUpdate; import resources.HologramColour; import resources.Posture; +import resources.PvpFaction; import resources.PvpFlag; import resources.PvpStatus; import resources.Race; @@ -795,19 +796,15 @@ public class CreatureObject extends TangibleObject { @Override public boolean isEnemy(TangibleObject otherObject) { - if (!super.isEnemy(otherObject)) { - return false; + boolean tangibleEnemy = super.isEnemy(otherObject); + + if (tangibleEnemy || !(otherObject instanceof CreatureObject)) { + return tangibleEnemy; } - if (!(otherObject instanceof CreatureObject)) { - return false; - } - - if (!isPlayer() || !((CreatureObject) otherObject).isPlayer()) { - return false; - } - - return getPvpStatus() == PvpStatus.SPECIALFORCES && otherObject.getPvpStatus() == PvpStatus.SPECIALFORCES; + return isPlayer() && ((CreatureObject) otherObject).isPlayer() + && getPvpStatus() == PvpStatus.SPECIALFORCES + && otherObject.getPvpStatus() == PvpStatus.SPECIALFORCES; } @Override diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 82387002d..06d2ced8d 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -254,16 +254,18 @@ public class TangibleObject extends SWGObject { } public boolean isEnemy(TangibleObject otherObject) { - // They CAN be enemies if they're not from the same faction and neither of them are neutral - PvpFaction otherFaction = otherObject.getPvpFaction(); - - if (hasPvpFlag(PvpFlag.ATTACKABLE) || otherObject.hasPvpFlag(PvpFlag.ATTACKABLE)) { - return true; - } else if (otherFaction != PvpFaction.NEUTRAL && getPvpFaction() != otherFaction) { - return getPvpStatus() != PvpStatus.ONLEAVE && otherObject.getPvpStatus() != PvpStatus.ONLEAVE; - } else { + if (otherObject.hasOptionFlags(OptionFlag.INVULNERABLE)) { return false; } + + if (otherObject.hasPvpFlag(PvpFlag.ATTACKABLE)) { + return true; + } + + PvpFaction otherFaction = otherObject.getPvpFaction(); + + return otherFaction != PvpFaction.NEUTRAL && getPvpFaction() != otherFaction + && getPvpStatus() != PvpStatus.ONLEAVE && otherObject.getPvpStatus() != PvpStatus.ONLEAVE; } public String getCurrentCity() { diff --git a/src/services/combat/CombatManager.java b/src/services/combat/CombatManager.java index 586eae679..496c6d415 100644 --- a/src/services/combat/CombatManager.java +++ b/src/services/combat/CombatManager.java @@ -473,9 +473,7 @@ public class CombatManager extends Manager { if (!(target instanceof TangibleObject)) return CombatStatus.INVALID_TARGET; - TangibleObject tangibleTarget = (TangibleObject) target; - - if (!tangibleTarget.isEnemy(source)) { + if (!source.isEnemy((TangibleObject) target)) { return CombatStatus.INVALID_TARGET; }