From 4318849127a413ea7c0c5bcb18fe632285dea8c5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 2 Sep 2023 19:34:08 -0500 Subject: [PATCH] minion relatiate handled inside retaliate function --- src/engine/gameManager/CombatManager.java | 52 +++++++++++++---------- src/engine/objects/AbstractCharacter.java | 4 -- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 53347204..0f90188b 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -1268,61 +1268,69 @@ public enum CombatManager { } //Called when character takes damage. - public static void handleRetaliate(AbstractCharacter tarAc, AbstractCharacter ac) { + public static void handleRetaliate(AbstractCharacter target, AbstractCharacter attacker) { - if (ac == null || tarAc == null) + if (attacker == null || target == null) return; - if (ac.equals(tarAc)) + if (attacker.equals(target)) return; - if (tarAc.isMoving() && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) + if (target.isMoving() && target.getObjectType().equals(GameObjectType.PlayerCharacter)) return; - if (!tarAc.isAlive() || !ac.isAlive()) + if (!target.isAlive() || !attacker.isAlive()) return; - boolean isCombat = tarAc.isCombat(); + boolean isCombat = target.isCombat(); //If target in combat and has no target, then attack back - AbstractWorldObject awoCombTar = tarAc.getCombatTarget(); + AbstractWorldObject awoCombTar = target.getCombatTarget(); - if ((tarAc.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || tarAc.isCombat() && NotInRange(tarAc, awoCombTar, tarAc.getRange()))) || (tarAc != null && tarAc.getObjectType() == GameObjectType.Mob && ((Mob) tarAc).isSiege())) - if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target + if ((target.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || target.isCombat() && NotInRange(target, awoCombTar, target.getRange()))) || (target != null && target.getObjectType() == GameObjectType.Mob && ((Mob) target).isSiege())) + if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target - PlayerCharacter pc = (PlayerCharacter) tarAc; - tarAc.setCombatTarget(ac); - pc.setLastTarget(ac.getObjectType(), ac.getObjectUUID()); + PlayerCharacter pc = (PlayerCharacter) target; + target.setCombatTarget(attacker); + pc.setLastTarget(attacker.getObjectType(), attacker.getObjectUUID()); - if (tarAc.getTimers() != null) - if (!tarAc.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND)) - CombatManager.AttackTarget((PlayerCharacter) tarAc, tarAc.getCombatTarget()); + if (target.getTimers() != null) + if (!target.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND)) + CombatManager.AttackTarget((PlayerCharacter) target, target.getCombatTarget()); } //Handle pet retaliate if assist is on and pet doesn't have a target. - if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { + if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { - Mob pet = ((PlayerCharacter) tarAc).getPet(); + Mob pet = ((PlayerCharacter) target).getPet(); if (pet != null && pet.assist && pet.getCombatTarget() == null) - pet.setCombatTarget(ac); + pet.setCombatTarget(attacker); } //Handle Mob Retaliate. - if (tarAc.getObjectType() == GameObjectType.Mob) { + if (target.getObjectType() == GameObjectType.Mob) { - Mob retaliater = (Mob) tarAc; + Mob retaliater = (Mob) target; if (retaliater.getCombatTarget() != null && !retaliater.isSiege()) return; - if (ac.getObjectType() == GameObjectType.Mob && retaliater.isSiege()) + if (attacker.getObjectType() == GameObjectType.Mob && retaliater.isSiege()) return; - retaliater.setCombatTarget(ac); + //handle minion informing his captain of the attack + if(attacker.getObjectType().equals(GameObjectType.Mob)){ + Mob mob = (Mob)attacker; + if(mob.agentType.equals(AIAgentType.GUARDMINION) && mob.guardCaptain != null && mob.guardCaptain.isAlive()) + if(mob.guardCaptain.combatTarget == null) + mob.guardCaptain.combatTarget = attacker; + } + + retaliater.setCombatTarget(attacker); } } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 604b112c..ebd2cbdf 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -1121,10 +1121,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } } } - //handle minion informing his captain of the attack - if(this.getObjectType().equals(GameObjectType.Mob) && ((Mob)this).agentType.equals(AIAgentType.GUARDMINION)) - if(((Mob)this).guardCaptain.combatTarget == null) - ((Mob)this).guardCaptain.combatTarget = value; this.combatTarget = value;