Added support for combat command ranges

This commit is contained in:
Mads Boddum
2016-10-23 07:35:01 +02:00
parent 2ee2946966
commit d58733995c
6 changed files with 74 additions and 54 deletions
@@ -794,20 +794,16 @@ public class CreatureObject extends TangibleObject {
public boolean isEnemy(TangibleObject otherObject) {
boolean enemy = super.isEnemy(otherObject);
if(enemy) {
// If these are both creatures, there's a chance both of them are players!
if (this instanceof CreatureObject && otherObject instanceof CreatureObject) {
CreatureObject thisCreature = (CreatureObject) this;
CreatureObject otherCreature = (CreatureObject) otherObject;
if (enemy && otherObject instanceof CreatureObject) {
PvpStatus ourStatus = getPvpStatus();
PvpStatus theirStatus = otherObject.getPvpStatus();
// If they're both players, both of them might be special force
if (thisCreature.isPlayer() && otherCreature.isPlayer()) {
// They are enemies if they're both players and members of the special force!
return getPvpStatus() == PvpStatus.SPECIALFORCES && otherObject.getPvpStatus() == PvpStatus.SPECIALFORCES;
}
if (isPlayer() && ((CreatureObject) otherObject).isPlayer()) {
// They are enemies if both players are SF
return ourStatus == PvpStatus.SPECIALFORCES && theirStatus == PvpStatus.SPECIALFORCES;
}
}
return enemy;
}
@@ -257,14 +257,12 @@ public class TangibleObject extends SWGObject {
// They CAN be enemies if they're not from the same faction and neither of them are neutral
PvpFaction otherFaction = otherObject.getPvpFaction();
if (otherFaction != PvpFaction.NEUTRAL && getPvpFaction() != otherFaction) {
if (getPvpStatus() != PvpStatus.ONLEAVE && otherObject.getPvpStatus() != PvpStatus.ONLEAVE) {
// Both objects are not players. In this case, both just need to be combatants.
return true;
}
if (hasPvpFlag(PvpFlag.ATTACKABLE) || otherObject.hasPvpFlag(PvpFlag.ATTACKABLE)) {
return true;
} else {
return otherFaction != PvpFaction.NEUTRAL && getPvpFaction() != otherFaction
&& getPvpStatus() != PvpStatus.ONLEAVE && otherObject.getPvpStatus() != PvpStatus.ONLEAVE;
}
return false;
}
public String getCurrentCity() {