From 00afe2790072402f3880c240a8611a95076f9404 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 1 Sep 2024 20:13:01 -0500 Subject: [PATCH] stealing from mobs works again --- src/engine/gameManager/PowersManager.java | 36 +++++++++++-------- .../powers/poweractions/StealPowerAction.java | 19 ++++++++-- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 08891311..0a814d30 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -432,15 +432,20 @@ public enum PowersManager { float range = pb.getRange(); // verify target is in range + if(pb.token != 429396028) { + + if (verifyInvalidRange(playerCharacter, target, range)) + // (pc.getLoc().distance(target.getLoc()) > pb.getRange()) { + // TODO send message that target is out of range + return true; +// verify target is valid type + if (!validateTarget(target, playerCharacter, pb)) + return true; + }else{ + pb.isSpell = false; + } - if (verifyInvalidRange(playerCharacter, target, range)) - // (pc.getLoc().distance(target.getLoc()) > pb.getRange()) { - // TODO send message that target is out of range - return true; - // verify target is valid type - if (!validateTarget(target, playerCharacter, pb)) - return true; if (AbstractWorldObject.IsAbstractCharacter(target)) @@ -584,7 +589,9 @@ public enum PowersManager { } // update cast (use skill) fail condition - playerCharacter.cancelOnCast(); + if(pb.token != 429396028) { + playerCharacter.cancelOnCast(); + } // update castSpell (use spell) fail condition if spell if (pb.isSpell()) @@ -874,15 +881,16 @@ public enum PowersManager { } float range = pb.getRange() + speedRange; + if(pb.token != 429396028) { - if (verifyInvalidRange(playerCharacter, mainTarget, range)) { + if (verifyInvalidRange(playerCharacter, mainTarget, range)) { - sendPowerMsg(playerCharacter, 8, msg); - return; + sendPowerMsg(playerCharacter, 8, msg); + return; + } + // (pc.getLoc().distance(target.getLoc()) > pb.getRange()) { + // TODO send message that target is out of range } - // (pc.getLoc().distance(target.getLoc()) > pb.getRange()) { - // TODO send message that target is out of range - } diff --git a/src/engine/powers/poweractions/StealPowerAction.java b/src/engine/powers/poweractions/StealPowerAction.java index 545137d1..f27d9289 100644 --- a/src/engine/powers/poweractions/StealPowerAction.java +++ b/src/engine/powers/poweractions/StealPowerAction.java @@ -78,7 +78,7 @@ public class StealPowerAction extends AbstractPowerAction { @Override protected void _startAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, int trains, ActionsBase ab, PowersBase pb) { - if (source == null || awo == null || !(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) || !(awo.getObjectType().equals(Enum.GameObjectType.Item))) + if (source == null || awo == null || !(source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter))) return; PlayerCharacter sourcePlayer = (PlayerCharacter) source; @@ -131,8 +131,23 @@ public class StealPowerAction extends AbstractPowerAction { //Handle target attacking back if in combat and has no other target CombatManager.handleRetaliate(ownerAC, sourcePlayer); - } else + } else if (owner.getObjectType().equals(Enum.GameObjectType.Mob)){ + Mob ownerMob = (Mob) owner; + + if (ownerMob.isSafeMode() || sourcePlayer.inSafeZone()) + return; + + if (ownerMob.getLoc().distanceSquared(sourcePlayer.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) + return; + + //mark thief and target as player aggressive + sourcePlayer.setLastPlayerAttackTime(); + + //Handle target attacking back if in combat and has no other target + CombatManager.handleRetaliate(ownerAC, sourcePlayer); + }else{ return; + } ClientConnection origin = sourcePlayer.getClientConnection();