From 6bac4d830a4d0f04c1dab31e9d6ebb6e6fa331fd Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 8 Mar 2025 20:07:11 -0600 Subject: [PATCH] attempt to fix boxed combat --- src/engine/devcmd/cmds/InfoCmd.java | 3 +- src/engine/gameManager/CombatManager.java | 21 +++++----- src/engine/objects/PlayerCharacter.java | 49 +++++++---------------- 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 0f80bb00..96db357f 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -346,7 +346,8 @@ public class InfoCmd extends AbstractDevCmd { output += "Hidden : " + targetPC.getHidden() + newline; output += "Target Loc: " + targetPC.loc + newline; output += "Player Loc: " + pc.loc + newline; - output += "Distance Squared: " + pc.loc.distanceSquared(targetPC.loc); + output += "Distance Squared: " + pc.loc.distanceSquared(targetPC.loc) + newline; + output += "IsBoxed: " + pc.isBoxed; break; case NPC: diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index b91a28ac..6fbb4f2e 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -241,16 +241,6 @@ public enum CombatManager { if (ac == null) return; - if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)){ - PlayerCharacter pc = (PlayerCharacter)ac; - if(pc.isBoxed){ - if(pc.combatTarget != null && pc.combatTarget.getObjectType().equals(GameObjectType.PlayerCharacter)) { - ChatManager.chatSystemInfo(pc, " You Are PvE Flagged: Cannot Attack Players."); - return; - } - } - } - // Attempt to eat null targets until we can clean // up this unholy mess and refactor it into a thread. @@ -322,6 +312,7 @@ public enum CombatManager { if(pet.combatTarget == null && pet.assist) pet.setCombatTarget(attacker.combatTarget); } + } @@ -513,6 +504,16 @@ public enum CombatManager { } } + if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){ + PlayerCharacter pc = (PlayerCharacter)abstractCharacter; + if(pc.isBoxed){ + if(target.getObjectType().equals(GameObjectType.PlayerCharacter)) { + ChatManager.chatSystemInfo(pc, "You Are PvE Flagged: Cannot Attack Players."); + attackFailure = true; + } + } + } + //TODO Verify attacker has los (if not ranged weapon). if (!attackFailure) { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index ef4620c7..6f11ab6c 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -5244,45 +5244,26 @@ public class PlayerCharacter extends AbstractCharacter { Logger.error("UPDATE ISSUE: " + e); } } - public static void unboxPlayer(PlayerCharacter player){ + public static void unboxPlayer(PlayerCharacter player) { String machineID = player.getClientConnection().machineID; ArrayList sameMachine = new ArrayList<>(); - for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){ - if(!pc.equals(player) && pc. isActive && pc.isEnteredWorld() && pc.getClientConnection().machineID.equals(machineID)){ + for (PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()) { + if (!pc.equals(player) && pc.isActive && pc.isEnteredWorld() && pc.getClientConnection().machineID.equals(machineID)) { sameMachine.add(pc); } } - - boolean valid = true; - for(PlayerCharacter pc : sameMachine){ - if(!pc.safeZone) - valid = false; - } - if(valid) { - for (PlayerCharacter pc : sameMachine) { - pc.isBoxed = true; - if (!pc.title.equals(CharacterTitle.PVE)) { - pc.title = CharacterTitle.PVE; - InterestManager.setObjectDirty(pc); - InterestManager.reloadCharacter(pc, true); - pc.setDirtyLoad(true); - //pc.getClientConnection().forceDisconnect(); - } - } - player.isBoxed = false; - if (!player.title.equals(CharacterTitle.NONE)) { - player.title = CharacterTitle.NONE; - InterestManager.setObjectDirty(player); - InterestManager.reloadCharacter(player, true); - player.setDirtyLoad(true); - //player.getClientConnection().forceDisconnect(); - } - //if (player.containsEffect(1672601862)) { - // player.removeEffectBySource(EffectSourceType.DeathShroud, 41, false); - //} - }else{ - ChatManager.chatSystemInfo(player, "All Boxes Must Be In Safezone To Switch"); - } + for (PlayerCharacter pc : sameMachine) { + if(pc.equals(player)) + continue; + pc.isBoxed = true; + pc.title = CharacterTitle.PVE; + InterestManager.setObjectDirty(pc); + InterestManager.reloadCharacter(pc, false); + } + player.isBoxed = false; + player.title = CharacterTitle.NONE; + InterestManager.setObjectDirty(player); + InterestManager.reloadCharacter(player, false); } public static boolean checkIfBoxed(PlayerCharacter player){ if(ConfigManager.MB_WORLD_BOXLIMIT.getValue().equals("false")) {