From df3964110a3d66fe5cd604a35c852ad2ca8169bb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 9 Sep 2023 19:23:46 -0500 Subject: [PATCH] stances for guards --- src/engine/gameManager/NPCManager.java | 88 +++++++++++++++++ src/engine/mobileAI/MobAI.java | 2 +- src/engine/objects/AbstractCharacter.java | 12 +-- src/engine/objects/Mob.java | 109 ++++++++++++---------- 4 files changed, 153 insertions(+), 58 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 7b1241fb..fd6d4bcb 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -5,14 +5,17 @@ import engine.InterestManagement.WorldGrid; import engine.math.Quaternion; import engine.math.Vector3f; import engine.math.Vector3fImmutable; +import engine.mobileAI.MobAI; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; import engine.objects.*; import engine.powers.EffectsBase; +import engine.powers.PowersBase; import engine.powers.RuneSkillAdjustEntry; import org.pmw.tinylog.Logger; +import javax.smartcardio.ATR; import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.ThreadLocalRandom; @@ -274,6 +277,91 @@ public enum NPCManager { } } + public static void setDamageAndSpeedForGuard(Mob guard){ + + //handle stance for guard mob + String stancePowerName = ""; + if(guard.agentType.equals(Enum.AIAgentType.GUARDWALLARCHER)){ + //apply rogue offensive stance + stancePowerName = "STC-R-O"; + }else { + Integer contractID; + if (guard.agentType.equals(Enum.AIAgentType.GUARDMINION)) { + contractID = guard.guardCaptain.contract.getContractID(); + } else{ + contractID = guard.contract.getContractID(); + } + if (Enum.MinionType.ContractToMinionMap.get(contractID) != null && Enum.MinionType.ContractToMinionMap.get(contractID).isMage()){ + //apply mage offensive Stance + stancePowerName = "STC-M-O"; + } else{ + //apply fighter offensive stance + stancePowerName = "STC-F-O"; + } + } + + int stancePowerRank = MobAI.getGuardPowerRank(guard); + PowersBase stancePower = PowersManager.getPowerByIDString(stancePowerName); + PowersManager.useMobPower(guard,guard,stancePower,stancePowerRank); + + if(guard.equip == null) { + guard.minDamageHandOne = (int)(guard.mobBase.getDamageMin()); + guard.maxDamageHandOne = (int)(guard.mobBase.getDamageMax()); + guard.speedHandOne = 30.0f; + }else{ + if(guard.equip.containsKey(1)){ + //has main hand weapon + ItemBase weapon = guard.equip.get(1).getItemBase(); + guard.minDamageHandOne = (int)(guard.mobBase.getDamageMin() + weapon.getMinDamage()); + guard.maxDamageHandOne = (int)(guard.mobBase.getDamageMax() + weapon.getMaxDamage()); + guard.speedHandOne = weapon.getSpeed(); + } else if(guard.equip.containsKey(2) && !guard.equip.get(2).getItemBase().isShield()){ + //has off hand weapon + ItemBase weapon = guard.equip.get(2).getItemBase(); + guard.minDamageHandTwo = (int)(guard.mobBase.getDamageMin() + weapon.getMinDamage()); + guard.maxDamageHandTwo = (int)(guard.mobBase.getDamageMax() + weapon.getMaxDamage()); + guard.speedHandTwo = weapon.getSpeed(); + } else { + guard.minDamageHandOne = (int)(guard.mobBase.getDamageMin()); + guard.maxDamageHandOne = (int)(guard.mobBase.getDamageMax()); + guard.speedHandOne = 30.0f; + } + } + } + public static void setDefenseForGuard(Mob guard){ + + } + + public static void setAttackRatingForGuard(Mob guard){ + + } + + public static void setMaxHealthForGuard(Mob guard){ + //values derived fom reading memory address for health on client when selecting player guards + switch(guard.getRank()){ + default: + guard.healthMax = 750; //rank 1 + break; + case 2: + guard.healthMax = 2082; + break; + case 3: + guard.healthMax = 2740; + break; + case 4: + guard.healthMax = 3414; + break; + case 5: + guard.healthMax = 4080; + break; + case 6: + guard.healthMax = 4746; + break; + case 7: + guard.healthMax = 5412; + break; + } + } public static void applyMobbaseEffects(Mob mob) { EffectsBase effectsBase; for (MobBaseEffects mbe : mob.mobBase.effectsList) { diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index c1f883a8..a997f3f2 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -456,7 +456,7 @@ public class MobAI { return false; } - private static int getGuardPowerRank(Mob mob) { + public static int getGuardPowerRank(Mob mob) { int powerRank = 1; switch (mob.getRank()) { diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 15a6f987..f75ecac0 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -94,14 +94,14 @@ public abstract class AbstractCharacter extends AbstractWorldObject { protected ConcurrentHashMap timestamps; protected int atrHandOne; protected int atrHandTwo; - protected int minDamageHandOne; - protected int maxDamageHandOne; - protected int minDamageHandTwo; - protected int maxDamageHandTwo; + public int minDamageHandOne; + public int maxDamageHandOne; + public int minDamageHandTwo; + public int maxDamageHandTwo; protected float rangeHandOne; protected float rangeHandTwo; - protected float speedHandOne; - protected float speedHandTwo; + public float speedHandOne; + public float speedHandTwo; protected int defenseRating; protected boolean isActive; // <-Do not use this for deleting character! protected float altitude = 0; // 0=on terrain, 1=tier 1, 2=tier 2, etc. diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 54ef4633..7134b7f8 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1030,80 +1030,87 @@ public class Mob extends AbstractIntelligenceAgent { } public void recalculateStats() { + if(this.isPlayerGuard()){ + NPCManager.setMaxHealthForGuard(this); + NPCManager.setAttackRatingForGuard(this); + NPCManager.setDefenseForGuard(this); + NPCManager.setDamageAndSpeedForGuard(this); + }else { - try { - calculateModifiedStats(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - - try { - calculateAtrDefenseDamage(); - } catch (Exception e) { - Logger.error(this.getMobBaseID() + " /" + e.getMessage()); + try { + calculateAtrDefenseDamage(); + } catch (Exception e) { + Logger.error(this.getMobBaseID() + " /" + e.getMessage()); + } + try { + calculateMaxHealthManaStamina(); + } catch (Exception e) { + Logger.error(e.getMessage()); + } } try { - calculateMaxHealthManaStamina(); + calculateModifiedStats(); } catch (Exception e) { Logger.error(e.getMessage()); } - + if(this.isSiege()) + this.healthMax = 10000; Resists.calculateResists(this); } public void calculateMaxHealthManaStamina() { - float h; - float m; - float s; + float h; + float m; + float s; - h = this.mobBase.getHealthMax(); - if (this.isPet()) { - h = this.level * 0.5f * 120; - } - m = this.statSpiCurrent; - s = this.statConCurrent; + h = this.mobBase.getHealthMax(); + if (this.isPet()) { + h = this.level * 0.5f * 120; + } + m = this.statSpiCurrent; + s = this.statConCurrent; - // Apply any bonuses from runes and effects + // Apply any bonuses from runes and effects - if (this.bonuses != null) { - h += this.bonuses.getFloat(ModType.HealthFull, SourceType.None); - m += this.bonuses.getFloat(ModType.ManaFull, SourceType.None); - s += this.bonuses.getFloat(ModType.StaminaFull, SourceType.None); + if (this.bonuses != null) { + h += this.bonuses.getFloat(ModType.HealthFull, SourceType.None); + m += this.bonuses.getFloat(ModType.ManaFull, SourceType.None); + s += this.bonuses.getFloat(ModType.StaminaFull, SourceType.None); - //apply effects percent modifiers. DO THIS LAST! + //apply effects percent modifiers. DO THIS LAST! - h *= (1 + this.bonuses.getFloatPercentAll(ModType.HealthFull, SourceType.None)); - m *= (1 + this.bonuses.getFloatPercentAll(ModType.ManaFull, SourceType.None)); - s *= (1 + this.bonuses.getFloatPercentAll(ModType.StaminaFull, SourceType.None)); - } + h *= (1 + this.bonuses.getFloatPercentAll(ModType.HealthFull, SourceType.None)); + m *= (1 + this.bonuses.getFloatPercentAll(ModType.ManaFull, SourceType.None)); + s *= (1 + this.bonuses.getFloatPercentAll(ModType.StaminaFull, SourceType.None)); + } - // Set max health, mana and stamina + // Set max health, mana and stamina - if (h > 0) - this.healthMax = h; - else - this.healthMax = 1; + if (h > 0) + this.healthMax = h; + else + this.healthMax = 1; - if (m > -1) - this.manaMax = m; - else - this.manaMax = 0; + if (m > -1) + this.manaMax = m; + else + this.manaMax = 0; - if (s > -1) - this.staminaMax = s; - else - this.staminaMax = 0; + if (s > -1) + this.staminaMax = s; + else + this.staminaMax = 0; - // Update health, mana and stamina if needed + // Update health, mana and stamina if needed - if (this.getHealth() > this.healthMax) - this.setHealth(this.healthMax); + if (this.getHealth() > this.healthMax) + this.setHealth(this.healthMax); - if (this.mana.get() > this.manaMax) - this.mana.set(this.manaMax); + if (this.mana.get() > this.manaMax) + this.mana.set(this.manaMax); - if (this.stamina.get() > this.staminaMax) - this.stamina.set(staminaMax); + if (this.stamina.get() > this.staminaMax) + this.stamina.set(staminaMax); }