From 29e8cdf6991e09de136d50fe4909056d485f7513 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 2 Sep 2023 19:23:33 -0500 Subject: [PATCH 1/5] attacking guard minion will no longer be ignored --- src/engine/objects/AbstractCharacter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 84c5b784..604b112c 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -1121,7 +1121,14 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } } } + //handle minion informing his captain of the attack + if(this.getObjectType().equals(GameObjectType.Mob) && ((Mob)this).agentType.equals(AIAgentType.GUARDMINION)) + if(((Mob)this).guardCaptain.combatTarget == null) + ((Mob)this).guardCaptain.combatTarget = value; + this.combatTarget = value; + + } public final ConcurrentHashMap getTimers() { From 4318849127a413ea7c0c5bcb18fe632285dea8c5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 2 Sep 2023 19:34:08 -0500 Subject: [PATCH 2/5] minion relatiate handled inside retaliate function --- src/engine/gameManager/CombatManager.java | 52 +++++++++++++---------- src/engine/objects/AbstractCharacter.java | 4 -- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 53347204..0f90188b 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -1268,61 +1268,69 @@ public enum CombatManager { } //Called when character takes damage. - public static void handleRetaliate(AbstractCharacter tarAc, AbstractCharacter ac) { + public static void handleRetaliate(AbstractCharacter target, AbstractCharacter attacker) { - if (ac == null || tarAc == null) + if (attacker == null || target == null) return; - if (ac.equals(tarAc)) + if (attacker.equals(target)) return; - if (tarAc.isMoving() && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) + if (target.isMoving() && target.getObjectType().equals(GameObjectType.PlayerCharacter)) return; - if (!tarAc.isAlive() || !ac.isAlive()) + if (!target.isAlive() || !attacker.isAlive()) return; - boolean isCombat = tarAc.isCombat(); + boolean isCombat = target.isCombat(); //If target in combat and has no target, then attack back - AbstractWorldObject awoCombTar = tarAc.getCombatTarget(); + AbstractWorldObject awoCombTar = target.getCombatTarget(); - if ((tarAc.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || tarAc.isCombat() && NotInRange(tarAc, awoCombTar, tarAc.getRange()))) || (tarAc != null && tarAc.getObjectType() == GameObjectType.Mob && ((Mob) tarAc).isSiege())) - if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target + if ((target.isCombat() && awoCombTar == null) || (isCombat && awoCombTar != null && (!awoCombTar.isAlive() || target.isCombat() && NotInRange(target, awoCombTar, target.getRange()))) || (target != null && target.getObjectType() == GameObjectType.Mob && ((Mob) target).isSiege())) + if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { // we are in combat with no valid target - PlayerCharacter pc = (PlayerCharacter) tarAc; - tarAc.setCombatTarget(ac); - pc.setLastTarget(ac.getObjectType(), ac.getObjectUUID()); + PlayerCharacter pc = (PlayerCharacter) target; + target.setCombatTarget(attacker); + pc.setLastTarget(attacker.getObjectType(), attacker.getObjectUUID()); - if (tarAc.getTimers() != null) - if (!tarAc.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND)) - CombatManager.AttackTarget((PlayerCharacter) tarAc, tarAc.getCombatTarget()); + if (target.getTimers() != null) + if (!target.getTimers().containsKey("Attack" + MBServerStatics.SLOT_MAINHAND)) + CombatManager.AttackTarget((PlayerCharacter) target, target.getCombatTarget()); } //Handle pet retaliate if assist is on and pet doesn't have a target. - if (tarAc.getObjectType().equals(GameObjectType.PlayerCharacter)) { + if (target.getObjectType().equals(GameObjectType.PlayerCharacter)) { - Mob pet = ((PlayerCharacter) tarAc).getPet(); + Mob pet = ((PlayerCharacter) target).getPet(); if (pet != null && pet.assist && pet.getCombatTarget() == null) - pet.setCombatTarget(ac); + pet.setCombatTarget(attacker); } //Handle Mob Retaliate. - if (tarAc.getObjectType() == GameObjectType.Mob) { + if (target.getObjectType() == GameObjectType.Mob) { - Mob retaliater = (Mob) tarAc; + Mob retaliater = (Mob) target; if (retaliater.getCombatTarget() != null && !retaliater.isSiege()) return; - if (ac.getObjectType() == GameObjectType.Mob && retaliater.isSiege()) + if (attacker.getObjectType() == GameObjectType.Mob && retaliater.isSiege()) return; - retaliater.setCombatTarget(ac); + //handle minion informing his captain of the attack + if(attacker.getObjectType().equals(GameObjectType.Mob)){ + Mob mob = (Mob)attacker; + if(mob.agentType.equals(AIAgentType.GUARDMINION) && mob.guardCaptain != null && mob.guardCaptain.isAlive()) + if(mob.guardCaptain.combatTarget == null) + mob.guardCaptain.combatTarget = attacker; + } + + retaliater.setCombatTarget(attacker); } } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 604b112c..ebd2cbdf 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -1121,10 +1121,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } } } - //handle minion informing his captain of the attack - if(this.getObjectType().equals(GameObjectType.Mob) && ((Mob)this).agentType.equals(AIAgentType.GUARDMINION)) - if(((Mob)this).guardCaptain.combatTarget == null) - ((Mob)this).guardCaptain.combatTarget = value; this.combatTarget = value; From 9aff208403e43351e50228a1d5ea13ff508cdff1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 2 Sep 2023 19:43:40 -0500 Subject: [PATCH 3/5] guard captains to move tot heir first patrol point right away --- src/engine/gameManager/NPCManager.java | 2 +- src/engine/objects/Mob.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 65719d21..bce31627 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -341,7 +341,7 @@ public enum NPCManager { mob.patrolPoints.add(newPatrolPoint); if (i == 1) { - mob.loc = newPatrolPoint; + mob.setLoc(newPatrolPoint); mob.endLoc = newPatrolPoint; } } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 31ca46ce..38bfa974 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -20,6 +20,7 @@ import engine.jobs.DeferredPowerJob; import engine.jobs.UpgradeNPCJob; import engine.math.Bounds; import engine.math.Vector3fImmutable; +import engine.mobileAI.utilities.MovementUtilities; import engine.net.ByteBufferWriter; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -427,6 +428,7 @@ public class Mob extends AbstractIntelligenceAgent { else mobile.contractUUID = contract.getContractID(); + return mobile; } @@ -1678,6 +1680,16 @@ public class Mob extends AbstractIntelligenceAgent { if (this.agentType.equals(AIAgentType.MOBILE)) NPCManager.AssignPatrolPoints(this); + if (this.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) { + + Building barracks = this.building; + + if (barracks != null && barracks.patrolPoints != null && !barracks.getPatrolPoints().isEmpty()) { + this.patrolPoints = barracks.patrolPoints; + MovementUtilities.aiMove(this, this.patrolPoints.get(0), true); + } + } + this.deathTime = 0; } From 449c5c5c775b45395d50c96f593d99a6fa85976c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 2 Sep 2023 20:29:03 -0500 Subject: [PATCH 4/5] infrastructure for mob skills loading --- src/engine/gameManager/NPCManager.java | 5 +++++ src/engine/objects/Mob.java | 21 +++++++++++++++++++++ src/engine/objects/MobBaseStats.java | 10 ++++++++++ 3 files changed, 36 insertions(+) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index bce31627..bc94d359 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -14,6 +14,7 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.acos; @@ -399,4 +400,8 @@ public enum NPCManager { } } } + + public static void applyMobbaseSkills(Mob mob) { + + } } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 38bfa974..96d88b57 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1127,6 +1127,26 @@ public class Mob extends AbstractIntelligenceAgent { this.defenseRating = 0; return; } + this.atrHandOne = (short) this.mobBase.getAttackRating(); + this.minDamageHandOne = (short) this.mobBase.getMinDmg(); + this.maxDamageHandOne = (short) this.mobBase.getMaxDmg(); + this.rangeHandOne = 6.5f; + this.speedHandOne = 20; + + this.atrHandTwo = (short) this.mobBase.getAttackRating(); + this.minDamageHandTwo = (short) this.mobBase.getMinDmg(); + this.maxDamageHandTwo = (short) this.mobBase.getMaxDmg(); + this.rangeHandTwo = 6.5f; + this.speedHandTwo = 20; + + if(this.equip.get(MBServerStatics.SLOT_MAINHAND) != null){ + //has mainhand weapon to calculate + calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true); + } + if(this.equip.get(MBServerStatics.SLOT_OFFHAND) != null && !this.equip.get(MBServerStatics.SLOT_OFFHAND).getItemBase().isShield()){ + //has offhand weapon to calculate + calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_OFFHAND), false); + } try { calculateAtrDamageForWeapon(this.equip.get(MBServerStatics.SLOT_MAINHAND), true); @@ -1666,6 +1686,7 @@ public class Mob extends AbstractIntelligenceAgent { } NPCManager.applyMobbaseEffects(this); NPCManager.applyEquipmentResists(this); + NPCManager.applyMobbaseSkills(this); this.recalculateStats(); this.setHealth(this.healthMax); diff --git a/src/engine/objects/MobBaseStats.java b/src/engine/objects/MobBaseStats.java index 38a09379..7acd1e3b 100644 --- a/src/engine/objects/MobBaseStats.java +++ b/src/engine/objects/MobBaseStats.java @@ -21,6 +21,9 @@ public class MobBaseStats { private final int baseSpi; private final int baseDex; + private final int mobbaseSkill; + private final int mobbaseSkillAmount; + /** * ResultSet Constructor @@ -31,6 +34,8 @@ public class MobBaseStats { this.baseCon = rs.getInt("Constitution"); this.baseSpi = rs.getInt("Spirit"); this.baseDex = rs.getInt("Dexterity"); + this.mobbaseSkill = rs.getInt("baseSkills"); + this.mobbaseSkillAmount = rs.getInt("skillAmount"); } /** @@ -43,6 +48,8 @@ public class MobBaseStats { this.baseCon = 0; this.baseSpi = 0; this.baseDex = 0; + this.mobbaseSkill = 0; + this.mobbaseSkillAmount = 0; } public static MobBaseStats GetGenericStats() { @@ -72,5 +79,8 @@ public class MobBaseStats { return baseDex; } + public int getBaseSkill(){return mobbaseSkill;} + + public int getBaseSkillAmount(){return mobbaseSkillAmount;} } From 95c203b0ed9adc8d737b8e22405448c7ee8d0cba Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 2 Sep 2023 20:39:36 -0500 Subject: [PATCH 5/5] load and apply mobbaseSkill --- src/engine/gameManager/NPCManager.java | 7 ++++--- src/engine/objects/Mob.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index bc94d359..4ece92d9 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -14,7 +14,6 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.acos; @@ -401,7 +400,9 @@ public enum NPCManager { } } - public static void applyMobbaseSkills(Mob mob) { - + public static void applyMobbaseSkill(Mob mob) { + SkillsBase baseSkill = DbManager.SkillsBaseQueries.GET_BASE_BY_TOKEN(mob.mobBase.getMobBaseStats().getBaseSkill()); + if(baseSkill != null) + mob.getSkills().put(baseSkill.getName(),new CharacterSkill(baseSkill,mob,mob.mobBase.getMobBaseStats().getBaseSkillAmount())); } } diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 96d88b57..04059f1b 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1686,7 +1686,7 @@ public class Mob extends AbstractIntelligenceAgent { } NPCManager.applyMobbaseEffects(this); NPCManager.applyEquipmentResists(this); - NPCManager.applyMobbaseSkills(this); + NPCManager.applyMobbaseSkill(this); this.recalculateStats(); this.setHealth(this.healthMax);