From 69fdddfc71b6b334082b744cd140a97e80bc7e03 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 29 Aug 2023 21:01:00 -0500 Subject: [PATCH] hate value fix --- .../InterestManagement/InterestManager.java | 4 +-- src/engine/devcmd/cmds/aiInfoCmd.java | 4 +-- src/engine/gameManager/CombatManager.java | 3 ++- src/engine/gameManager/PowersManager.java | 4 --- src/engine/mobileAI/MobAI.java | 14 +++++----- src/engine/objects/AbstractCharacter.java | 24 ----------------- src/engine/objects/Mob.java | 27 +------------------ .../poweractions/ApplyEffectPowerAction.java | 5 ++-- 8 files changed, 17 insertions(+), 68 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index ab6ea532..2c70765c 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -467,7 +467,7 @@ public enum InterestManager implements Runnable { if (awonpc.despawned == true) continue; - awonpc.playerAgroMap.put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), 0f); ((Mob) awonpc).setCombatTarget(null); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); @@ -480,7 +480,7 @@ public enum InterestManager implements Runnable { if (!awonpc.isAlive()) continue; - awonpc.playerAgroMap.put(player.getObjectUUID(), false); + awonpc.playerAgroMap.put(player.getObjectUUID(), 0f); if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE))) ((Mob) awonpc).setCombatTarget(null); diff --git a/src/engine/devcmd/cmds/aiInfoCmd.java b/src/engine/devcmd/cmds/aiInfoCmd.java index 7d8c6785..4a524c34 100644 --- a/src/engine/devcmd/cmds/aiInfoCmd.java +++ b/src/engine/devcmd/cmds/aiInfoCmd.java @@ -77,8 +77,8 @@ public class aiInfoCmd extends AbstractDevCmd { if (mob.playerAgroMap.size() > 0) { output += "Players Loaded:" + newline; } - for (Map.Entry entry : mob.playerAgroMap.entrySet()) { - output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline; + for (Map.Entry entry : mob.playerAgroMap.entrySet()) { + output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline; } if (mob.getCombatTarget() != null) output += "Current Target: " + mob.getCombatTarget().getName() + newline; diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 0587e384..53347204 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -826,7 +826,8 @@ public enum CombatManager { damage *= 2.5f; //increase damage if sitting if (tarAc.getObjectType() == GameObjectType.Mob) { - ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER); + if(ac.getObjectType().equals(GameObjectType.PlayerCharacter)) + ((Mob)tarAc).playerAgroMap.put(ac.getObjectUUID(), ((Mob) tarAc).playerAgroMap.get(ac.getObjectUUID()) + damage); ((Mob) tarAc).handleDirectAggro(ac); } diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 9e15abc2..b66f1dd0 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -839,8 +839,6 @@ public enum PowersManager { return; } - playerCharacter.setHateValue(pb.getHateValue(trains)); - //Send Cast Message. // PerformActionMsg castMsg = new PerformActionMsg(msg); // castMsg.setNumTrains(9999); @@ -891,8 +889,6 @@ public enum PowersManager { //Power is aiding a target, handle aggro if combat target is a Mob. if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pcTarget = (PlayerCharacter) target; - if (!pb.isHarmful()) - Mob.HandleAssistedAggro(playerCharacter, pcTarget); } // update target of used power timer diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index d56075ca..6aed514a 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -708,7 +708,7 @@ public class MobAI { if (!aiAgent.isAlive()) return; - ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; + ConcurrentHashMap loadedPlayers = aiAgent.playerAgroMap; for (Entry playerEntry : loadedPlayers.entrySet()) { @@ -956,8 +956,8 @@ public class MobAI { PowersManager.useMobPower(mob, mob, recall, 40); mob.setCombatTarget(null); - for (Entry playerEntry : mob.playerAgroMap.entrySet()) - PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); + for (Integer playerEntry : mob.playerAgroMap.keySet()) + mob.playerAgroMap.put(playerEntry,0f); } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); @@ -1204,7 +1204,7 @@ public class MobAI { if (!mob.isAlive()) return; - ConcurrentHashMap loadedPlayers = mob.playerAgroMap; + ConcurrentHashMap loadedPlayers = mob.playerAgroMap; for (Entry playerEntry : loadedPlayers.entrySet()) { @@ -1364,7 +1364,7 @@ public class MobAI { float CurrentHateValue = 0; if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) - CurrentHateValue = ((PlayerCharacter) mob.getCombatTarget()).getHateValue(); + CurrentHateValue = mob.playerAgroMap.get(mob.combatTarget.getObjectUUID()).floatValue(); AbstractWorldObject mostHatedTarget = null; @@ -1375,8 +1375,8 @@ public class MobAI { if (potentialTarget.equals(mob.getCombatTarget())) continue; - if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { - CurrentHateValue = potentialTarget.getHateValue(); + if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { + CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue(); mostHatedTarget = potentialTarget; } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index e890b809..3d788dbe 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -117,7 +117,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { protected boolean movingUp = false; private float desiredAltitude = 0; private long takeOffTime = 0; - private float hateValue = 0; private long lastHateUpdate = 0; private byte aoecntr = 0; public final ConcurrentHashMap siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); @@ -1767,29 +1766,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.inBuildingID = inBuildingID; } - public float getHateValue() { - if (this.hateValue <= 0) { - this.hateValue = 0; - return hateValue; - } - - if (this.lastHateUpdate == 0) { - this.lastHateUpdate = System.currentTimeMillis(); - return this.hateValue; - } - long duration = System.currentTimeMillis() - this.lastHateUpdate; - //convert duration to seconds and multiply Hate Delimiter. - float modAmount = duration / 1000 * MBServerStatics.PLAYER_HATE_DELIMITER; - this.hateValue -= modAmount; - this.lastHateUpdate = System.currentTimeMillis(); - return this.hateValue; - } - - public void setHateValue(float hateValue) { - this.lastHateUpdate = System.currentTimeMillis(); - this.hateValue = hateValue; - } - public int getInFloorID() { return inFloorID; } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 34d67481..97acd7ee 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -45,7 +45,7 @@ public class Mob extends AbstractIntelligenceAgent { private static int staticID = 0; //mob specific - public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); + public final ConcurrentHashMap playerAgroMap = new ConcurrentHashMap<>(); //key = Player value = hate value public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); public long nextCastTime = 0; @@ -589,28 +589,6 @@ public class Mob extends AbstractIntelligenceAgent { return skill.getModifiedAmount(); } - public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) { - - HashSet mobsInRange = WorldGrid.getObjectsInRangePartial(source, MobAIThread.AI_DROP_AGGRO_RANGE, MBServerStatics.MASK_MOB); - - for (AbstractWorldObject awo : mobsInRange) { - Mob mob = (Mob) awo; - - //Mob is not attacking anyone, skip. - if (mob.getCombatTarget() == null) - continue; - - //Mob not attacking target's target, let's not be failmu and skip this target. - if (mob.getCombatTarget() != target) - continue; - - //target is mob's combat target, LETS GO. - - if (source.getHateValue() > target.getHateValue()) - mob.setCombatTarget(source); - } - } - public static void submitUpgradeJob(Mob mob) { if (mob.getUpgradeDateTime() == null) { @@ -1792,9 +1770,6 @@ public class Mob extends AbstractIntelligenceAgent { if (player.getObjectUUID() == this.getCombatTarget().getObjectUUID()) return; - if (this.getCombatTarget().getObjectType() == GameObjectType.PlayerCharacter) - if (ac.getHateValue() > ((PlayerCharacter) this.getCombatTarget()).getHateValue()) - this.setCombatTarget(player); } public void setRank(int newRank) { diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index d96d3a54..3f2a9c4b 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -127,10 +127,11 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { if (this.effectID.equals("TAUNT")) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) { - ((Mob) awo).setCombatTarget(source); + //((Mob) awo).setCombatTarget(source); LOL DUMB + ChatSystemMsg msg = ChatManager.CombatInfo(source, awo); DispatchMessage.sendToAllInRange(source, msg); - ((Mob)awo).refresh(); + //((Mob)awo).refresh(); why the fuck? causes a blink effect and players to lose target of the mob } } if (awo != null && awo.getObjectType() == GameObjectType.Mob) {