diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 48ff4cae..e6c83c23 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -1867,8 +1867,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject { // Siege engines switch to whoever damages them, players and pets alike. // Misses and non-damaging powers do not pull them. - if (target.isSiege() && value < 0f && attacker != null && !attacker.equals(target)) + if (target.isSiege() && value < 0f && attacker != null && !attacker.equals(target)) { target.setCombatTarget(attacker); + flagSiegeAttackerHostile(target, attacker); + } if (attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) { @@ -1903,6 +1905,41 @@ public abstract class AbstractCharacter extends AbstractWorldObject { return 0; } + private static void flagSiegeAttackerHostile(Mob siegeEngine, AbstractCharacter attacker) { + + // Damaging a siege engine on a city grid flags the player hostile to that + // city, unless they belong to the city's nation or an allied nation. + // Pets flag their owner. + + City city; + AbstractCharacter flagged; + Guild cityNation; + + city = ZoneManager.getCityAtLocation(siegeEngine.loc); + + if (city == null) + return; + + flagged = attacker; + + if (attacker.getObjectType().equals(GameObjectType.Mob)) + flagged = ((Mob) attacker).guardCaptain; + + if (flagged == null || !flagged.getObjectType().equals(GameObjectType.PlayerCharacter)) + return; + + cityNation = city.getGuild().getNation(); + + if (flagged.getGuild().getNation().equals(cityNation)) + return; + + if (cityNation.getAllyList().contains(flagged.getGuild().getNation())) + return; + + if (!city.cityOutlaws.contains(flagged.getObjectUUID())) + city.cityOutlaws.add(flagged.getObjectUUID()); + } + public float getCurrentHitpoints() { return this.health.get(); }