Browse Source

minion relatiate handled inside retaliate function

feature-workorder
FatBoy-DOTC 1 year ago
parent
commit
4318849127
  1. 52
      src/engine/gameManager/CombatManager.java
  2. 4
      src/engine/objects/AbstractCharacter.java

52
src/engine/gameManager/CombatManager.java

@ -1268,61 +1268,69 @@ public enum CombatManager { @@ -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);
}
}

4
src/engine/objects/AbstractCharacter.java

@ -1121,10 +1121,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @@ -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;

Loading…
Cancel
Save