Browse Source

hate value fix

combat-2
FatBoy-DOTC 1 year ago
parent
commit
69fdddfc71
  1. 4
      src/engine/InterestManagement/InterestManager.java
  2. 4
      src/engine/devcmd/cmds/aiInfoCmd.java
  3. 3
      src/engine/gameManager/CombatManager.java
  4. 4
      src/engine/gameManager/PowersManager.java
  5. 14
      src/engine/mobileAI/MobAI.java
  6. 24
      src/engine/objects/AbstractCharacter.java
  7. 27
      src/engine/objects/Mob.java
  8. 5
      src/engine/powers/poweractions/ApplyEffectPowerAction.java

4
src/engine/InterestManagement/InterestManager.java

@ -467,7 +467,7 @@ public enum InterestManager implements Runnable {
if (awonpc.despawned == true) if (awonpc.despawned == true)
continue; continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false); awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
((Mob) awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);
lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii()); lcm = new LoadCharacterMsg(awonpc, PlayerCharacter.hideNonAscii());
@ -480,7 +480,7 @@ public enum InterestManager implements Runnable {
if (!awonpc.isAlive()) if (!awonpc.isAlive())
continue; continue;
awonpc.playerAgroMap.put(player.getObjectUUID(), false); awonpc.playerAgroMap.put(player.getObjectUUID(), 0f);
if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE))) if ((awonpc.agentType.equals(Enum.AIAgentType.MOBILE)))
((Mob) awonpc).setCombatTarget(null); ((Mob) awonpc).setCombatTarget(null);

4
src/engine/devcmd/cmds/aiInfoCmd.java

@ -77,8 +77,8 @@ public class aiInfoCmd extends AbstractDevCmd {
if (mob.playerAgroMap.size() > 0) { if (mob.playerAgroMap.size() > 0) {
output += "Players Loaded:" + newline; output += "Players Loaded:" + newline;
} }
for (Map.Entry<Integer, Boolean> entry : mob.playerAgroMap.entrySet()) { for (Map.Entry<Integer, Float> entry : mob.playerAgroMap.entrySet()) {
output += "Player ID: " + entry.getKey() + " Hate Value: " + (PlayerCharacter.getPlayerCharacter(entry.getKey())).getHateValue() + newline; output += "Player ID: " + entry.getKey() + " Hate Value: " + entry.getValue() + newline;
} }
if (mob.getCombatTarget() != null) if (mob.getCombatTarget() != null)
output += "Current Target: " + mob.getCombatTarget().getName() + newline; output += "Current Target: " + mob.getCombatTarget().getName() + newline;

3
src/engine/gameManager/CombatManager.java

@ -826,7 +826,8 @@ public enum CombatManager {
damage *= 2.5f; //increase damage if sitting damage *= 2.5f; //increase damage if sitting
if (tarAc.getObjectType() == GameObjectType.Mob) { 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); ((Mob) tarAc).handleDirectAggro(ac);
} }

4
src/engine/gameManager/PowersManager.java

@ -839,8 +839,6 @@ public enum PowersManager {
return; return;
} }
playerCharacter.setHateValue(pb.getHateValue(trains));
//Send Cast Message. //Send Cast Message.
// PerformActionMsg castMsg = new PerformActionMsg(msg); // PerformActionMsg castMsg = new PerformActionMsg(msg);
// castMsg.setNumTrains(9999); // castMsg.setNumTrains(9999);
@ -891,8 +889,6 @@ public enum PowersManager {
//Power is aiding a target, handle aggro if combat target is a Mob. //Power is aiding a target, handle aggro if combat target is a Mob.
if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) { if (!pb.isHarmful() && target.getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter pcTarget = (PlayerCharacter) target; PlayerCharacter pcTarget = (PlayerCharacter) target;
if (!pb.isHarmful())
Mob.HandleAssistedAggro(playerCharacter, pcTarget);
} }
// update target of used power timer // update target of used power timer

14
src/engine/mobileAI/MobAI.java

@ -708,7 +708,7 @@ public class MobAI {
if (!aiAgent.isAlive()) if (!aiAgent.isAlive())
return; return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = aiAgent.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = aiAgent.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry playerEntry : loadedPlayers.entrySet()) {
@ -956,8 +956,8 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
for (Entry playerEntry : mob.playerAgroMap.entrySet()) for (Integer playerEntry : mob.playerAgroMap.keySet())
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0); mob.playerAgroMap.put(playerEntry,0f);
} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckToSendMobHome" + " " + e.getMessage());
@ -1204,7 +1204,7 @@ public class MobAI {
if (!mob.isAlive()) if (!mob.isAlive())
return; return;
ConcurrentHashMap<Integer, Boolean> loadedPlayers = mob.playerAgroMap; ConcurrentHashMap<Integer, Float> loadedPlayers = mob.playerAgroMap;
for (Entry playerEntry : loadedPlayers.entrySet()) { for (Entry playerEntry : loadedPlayers.entrySet()) {
@ -1364,7 +1364,7 @@ public class MobAI {
float CurrentHateValue = 0; float CurrentHateValue = 0;
if (mob.getCombatTarget() != null && mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) 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; AbstractWorldObject mostHatedTarget = null;
@ -1375,8 +1375,8 @@ public class MobAI {
if (potentialTarget.equals(mob.getCombatTarget())) if (potentialTarget.equals(mob.getCombatTarget()))
continue; continue;
if (potentialTarget != null && potentialTarget.getHateValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) { if (potentialTarget != null && mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue() > CurrentHateValue && MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
CurrentHateValue = potentialTarget.getHateValue(); CurrentHateValue = mob.playerAgroMap.get(potentialTarget.getObjectUUID()).floatValue();
mostHatedTarget = potentialTarget; mostHatedTarget = potentialTarget;
} }

24
src/engine/objects/AbstractCharacter.java

@ -117,7 +117,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
protected boolean movingUp = false; protected boolean movingUp = false;
private float desiredAltitude = 0; private float desiredAltitude = 0;
private long takeOffTime = 0; private long takeOffTime = 0;
private float hateValue = 0;
private long lastHateUpdate = 0; private long lastHateUpdate = 0;
private byte aoecntr = 0; private byte aoecntr = 0;
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); public final ConcurrentHashMap<Mob, Integer> 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; 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() { public int getInFloorID() {
return inFloorID; return inFloorID;
} }

27
src/engine/objects/Mob.java

@ -45,7 +45,7 @@ public class Mob extends AbstractIntelligenceAgent {
private static int staticID = 0; private static int staticID = 0;
//mob specific //mob specific
public final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>(); public final ConcurrentHashMap<Integer, Float> playerAgroMap = new ConcurrentHashMap<>(); //key = Player value = hate value
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
public long nextCastTime = 0; public long nextCastTime = 0;
@ -589,28 +589,6 @@ public class Mob extends AbstractIntelligenceAgent {
return skill.getModifiedAmount(); return skill.getModifiedAmount();
} }
public static void HandleAssistedAggro(PlayerCharacter source, PlayerCharacter target) {
HashSet<AbstractWorldObject> 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) { public static void submitUpgradeJob(Mob mob) {
if (mob.getUpgradeDateTime() == null) { if (mob.getUpgradeDateTime() == null) {
@ -1792,9 +1770,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (player.getObjectUUID() == this.getCombatTarget().getObjectUUID()) if (player.getObjectUUID() == this.getCombatTarget().getObjectUUID())
return; return;
if (this.getCombatTarget().getObjectType() == GameObjectType.PlayerCharacter)
if (ac.getHateValue() > ((PlayerCharacter) this.getCombatTarget()).getHateValue())
this.setCombatTarget(player);
} }
public void setRank(int newRank) { public void setRank(int newRank) {

5
src/engine/powers/poweractions/ApplyEffectPowerAction.java

@ -127,10 +127,11 @@ public class ApplyEffectPowerAction extends AbstractPowerAction {
if (this.effectID.equals("TAUNT")) { if (this.effectID.equals("TAUNT")) {
if (awo != null && awo.getObjectType() == GameObjectType.Mob) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) {
((Mob) awo).setCombatTarget(source); //((Mob) awo).setCombatTarget(source); LOL DUMB
ChatSystemMsg msg = ChatManager.CombatInfo(source, awo); ChatSystemMsg msg = ChatManager.CombatInfo(source, awo);
DispatchMessage.sendToAllInRange(source, msg); 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) { if (awo != null && awo.getObjectType() == GameObjectType.Mob) {

Loading…
Cancel
Save