From 3c610a85647ad3700dd3830ffab7cf646784f238 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 6 Jun 2022 19:21:39 -0500 Subject: [PATCH 1/8] Fix to mob/guard static power lookup --- src/engine/ai/MobileFSM.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 4861fa4e..78b4dccd 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -16,10 +16,7 @@ import engine.Enum.GameObjectType; import engine.InterestManagement.WorldGrid; import engine.ai.utilities.CombatUtilities; import engine.ai.utilities.MovementUtilities; -import engine.gameManager.BuildingManager; -import engine.gameManager.CombatManager; -import engine.gameManager.MovementManager; -import engine.gameManager.PowersManager; +import engine.gameManager.*; import engine.math.Vector3fImmutable; import engine.net.DispatchMessage; import engine.net.client.msg.PerformActionMsg; @@ -1129,8 +1126,8 @@ public class MobileFSM { return; } - HashMap staticPowers = aiAgent.getMobBase().getStaticPowers(); - + //HashMap staticPowers = aiAgent.getMobBase().getStaticPowers(); + HashMap staticPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(aiAgent.getMobBaseID()); if (staticPowers != null && !staticPowers.isEmpty()) { int chance = ThreadLocalRandom.current().nextInt(100); From 69c78fa5a63306a47ef1864373d9d67be3fc5618 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 7 Jun 2022 20:24:11 -0500 Subject: [PATCH 2/8] added power casting for pets who have DB entires --- src/engine/ai/MobileFSM.java | 3 +- src/engine/ai/utilities/CombatUtilities.java | 40 +++++++++++++++++++- src/engine/objects/Mob.java | 12 +++--- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 78b4dccd..97e256e2 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -1126,8 +1126,7 @@ public class MobileFSM { return; } - //HashMap staticPowers = aiAgent.getMobBase().getStaticPowers(); - HashMap staticPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(aiAgent.getMobBaseID()); + HashMap staticPowers = aiAgent.getMobBase().getStaticPowers(); if (staticPowers != null && !staticPowers.isEmpty()) { int chance = ThreadLocalRandom.current().nextInt(100); diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index 60b538b9..f6c36e8a 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -15,13 +15,17 @@ import engine.Enum.*; import engine.ai.MobileFSM.STATE; import engine.gameManager.ChatManager; import engine.gameManager.CombatManager; +import engine.gameManager.PowersManager; import engine.math.Vector3fImmutable; import engine.net.DispatchMessage; import engine.net.client.msg.TargetedActionMsg; import engine.objects.*; +import engine.powers.ActionsBase; +import engine.powers.PowersBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.util.Random; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; @@ -381,10 +385,42 @@ public class CombatUtilities { float min = (mainHand) ? agent.getMinDamageHandOne() : agent.getMinDamageHandTwo(); float max = (mainHand) ? agent.getMaxDamageHandOne() : agent.getMaxDamageHandTwo();; - + if(agent.isSummonedPet() == true) + { + //check if we have powers to cast + if(agent.mobPowers.isEmpty() == false) { + //check for power usage + Random random = new Random(); + int value = random.nextInt(0 + (agent.mobPowers.size() + (agent.mobPowers.size() * 5))) + 0; + if (value <= agent.mobPowers.size()) + { + //do power + int powerId = agent.mobPowers.get(value); + PowersManager.runPowerAction(agent,target,target.getLoc(),new ActionsBase(),40, PowersManager.getPowerByToken(powerId)); + } + else + { + //do mele damage + float range = max - min; + float damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; + if (AbstractWorldObject.IsAbstractCharacter(target)) + if (((AbstractCharacter) target).isSit()) + damage *= 2.5f; //increase damage if sitting + + if (AbstractWorldObject.IsAbstractCharacter(target)) + return ((AbstractCharacter) target).getResists().getResistedDamage(agent, (AbstractCharacter) target, dt, damage, 0); + + if (target.getObjectType() == GameObjectType.Building) { + Building building = (Building) target; + Resists resists = building.getResists(); + return damage * (1 - (resists.getResist(dt, 0) / 100)); + } + } + } + } float range = max - min; float damage = min + ((ThreadLocalRandom.current().nextFloat()*range)+(ThreadLocalRandom.current().nextFloat()*range))/2; - +//DAMAGE FORMULA FOR PET if (AbstractWorldObject.IsAbstractCharacter(target)) if (((AbstractCharacter)target).isSit()) damage *= 2.5f; //increase damage if sitting diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index dfd30590..d1aa7b31 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -32,6 +32,7 @@ import engine.net.client.msg.ManageCityAssetsMsg; import engine.net.client.msg.PetMsg; import engine.net.client.msg.PlaceAssetMsg; import engine.powers.EffectsBase; +import engine.powers.PowersBase; import engine.server.MBServerStatics; import engine.server.world.WorldServer; import org.joda.time.DateTime; @@ -111,7 +112,7 @@ public class Mob extends AbstractIntelligenceAgent { public boolean despawned = false; public Vector3fImmutable destination = Vector3fImmutable.ZERO; public Vector3fImmutable localLoc = Vector3fImmutable.ZERO; - + public HashMap mobPowers; /** * No Id Constructor */ @@ -365,6 +366,7 @@ public class Mob extends AbstractIntelligenceAgent { this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks()); if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) this.setLoc(this.getLoc()); + mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID()); } if (!isPet && this.contract == null) { this.level = (short) this.mobBase.getLevel(); @@ -393,10 +395,10 @@ public class Mob extends AbstractIntelligenceAgent { //TODO set these correctly later this.rangeHandOne = 8; this.rangeHandTwo = -1; - this.minDamageHandOne = 0; - this.maxDamageHandOne = 0; - this.minDamageHandTwo = 1; - this.maxDamageHandTwo = 4; + this.minDamageHandOne = 0; + this.maxDamageHandOne = 0; + this.minDamageHandTwo = 1; + this.maxDamageHandTwo = 4; this.atrHandOne = 300; this.atrHandOne = 300; this.defenseRating = (short) this.mobBase.getDefenseRating(); From 65840e89b65ac9ab6dc9b59f1bc6df149d0fb315 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 7 Jun 2022 20:27:45 -0500 Subject: [PATCH 3/8] scaled damage range for pets to be based on level --- src/engine/ai/utilities/CombatUtilities.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index f6c36e8a..af0e3b28 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -387,6 +387,8 @@ public class CombatUtilities { float max = (mainHand) ? agent.getMaxDamageHandOne() : agent.getMaxDamageHandTwo();; if(agent.isSummonedPet() == true) { + min = 40 * (1 + (agent.getLevel()/10)); + max = 60 * (1 + (agent.getLevel()/10)); //check if we have powers to cast if(agent.mobPowers.isEmpty() == false) { //check for power usage From 56ad9d7907a13bd2c7a1fa70d68c1f374c9af6b8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 7 Jun 2022 20:30:02 -0500 Subject: [PATCH 4/8] changed max pet damage scale --- src/engine/ai/utilities/CombatUtilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index af0e3b28..2d3f92ed 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -388,7 +388,7 @@ public class CombatUtilities { if(agent.isSummonedPet() == true) { min = 40 * (1 + (agent.getLevel()/10)); - max = 60 * (1 + (agent.getLevel()/10)); + max = 60 * (1 + (agent.getLevel()/8)); //check if we have powers to cast if(agent.mobPowers.isEmpty() == false) { //check for power usage From 2e5c05d932431abc12667cc500619f571a194d98 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 8 Jun 2022 19:56:09 -0500 Subject: [PATCH 5/8] work on mob casting --- src/engine/ai/utilities/CombatUtilities.java | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index 2d3f92ed..b44f4867 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -15,6 +15,7 @@ import engine.Enum.*; import engine.ai.MobileFSM.STATE; import engine.gameManager.ChatManager; import engine.gameManager.CombatManager; +import engine.gameManager.DbManager; import engine.gameManager.PowersManager; import engine.math.Vector3fImmutable; import engine.net.DispatchMessage; @@ -25,6 +26,7 @@ import engine.powers.PowersBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.util.HashMap; import java.util.Random; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; @@ -241,7 +243,6 @@ public class CombatUtilities { speed = agent.getSpeedHandOne(); else speed = agent.getSpeedHandTwo(); - DamageType dt = DamageType.Crush; if (agent.isSiege()) dt = DamageType.Siege; @@ -284,6 +285,26 @@ public class CombatUtilities { else if(triggerBlock(agent,target)) swingIsBlock(agent,target, passiveAnim); else + //check for a cast here? + if(agent.isCasting() == true) + { + //force stop if they are already casting + return; + } + if(agent.mobPowers.size() > 0) + { + //get cast chance + int random = ThreadLocalRandom.current().nextInt(agent.mobPowers.size() * 3); + //allow casting of spell + if(random <= agent.mobPowers.size()) + { + //cast a spell + ActionsBase ab = new ActionsBase(); + + return; + } + } + //finished with casting check swingIsDamage(agent,target, determineDamage(agent,target, mainHand, speed, dt), anim); if (agent.getWeaponPower() != null) @@ -419,6 +440,7 @@ public class CombatUtilities { } } } + } float range = max - min; float damage = min + ((ThreadLocalRandom.current().nextFloat()*range)+(ThreadLocalRandom.current().nextFloat()*range))/2; From 9ce7e1c5ca937e2a9d74e37a85002b0dbab183c7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 8 Jun 2022 21:09:59 -0500 Subject: [PATCH 6/8] mobs and guards can cast their power sets --- src/engine/ai/utilities/CombatUtilities.java | 33 ++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index b44f4867..8191f250 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -12,6 +12,7 @@ package engine.ai.utilities; import engine.Enum; import engine.Enum.*; +import engine.ai.MobileFSM; import engine.ai.MobileFSM.STATE; import engine.gameManager.ChatManager; import engine.gameManager.CombatManager; @@ -25,8 +26,11 @@ import engine.powers.ActionsBase; import engine.powers.PowersBase; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import sun.security.util.Debug; +import java.security.KeyStore; import java.util.HashMap; +import java.util.Map; import java.util.Random; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; @@ -286,21 +290,32 @@ public class CombatUtilities { swingIsBlock(agent,target, passiveAnim); else //check for a cast here? - if(agent.isCasting() == true) - { - //force stop if they are already casting - return; - } - if(agent.mobPowers.size() > 0) + + agent.mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(agent.getMobBaseID()); + + if(agent.mobPowers.size() > 0 && agent.mobPowers != null) { - //get cast chance + //get cast chance 33% cast 67% mele int random = ThreadLocalRandom.current().nextInt(agent.mobPowers.size() * 3); //allow casting of spell if(random <= agent.mobPowers.size()) { + int powerToken; + int powerRank; //cast a spell - ActionsBase ab = new ActionsBase(); - + Map entries = agent.mobPowers; + int count = 0; + for(Map.Entry entry : entries.entrySet()) + { + count += 1; + if(count == random) + { + powerToken = entry.getKey(); + powerRank = entry.getValue(); + System.out.println(agent.getMobBase().getFirstName() + " is casting: " + PowersManager.getPowerByToken(powerToken).skillName); + PowersManager.applyPower(agent,target,target.getLoc(),powerToken,powerRank, false); + } + } return; } } From f8a9262fc576caaf4da7f4bd3dbb247516d3969d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 9 Jun 2022 18:22:30 -0500 Subject: [PATCH 7/8] changed location of mob power lookup --- src/engine/ai/utilities/CombatUtilities.java | 2 +- src/engine/objects/Mob.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index 8191f250..2c092188 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -291,7 +291,7 @@ public class CombatUtilities { else //check for a cast here? - agent.mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(agent.getMobBaseID()); + //agent.mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(agent.getMobBaseID()); if(agent.mobPowers.size() > 0 && agent.mobPowers != null) { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d1aa7b31..c5856358 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -2203,7 +2203,7 @@ public class Mob extends AbstractIntelligenceAgent { } catch(Exception e){ Logger.error( e.getMessage()); } - + mobPowers = DbManager.MobBaseQueries.LOAD_STATIC_POWERS(this.getMobBaseID()); if (this.equip == null) { Logger.error("Null equipset returned for uuid " + currentID); this.equip = new HashMap<>(0); From 3189ac0d56a31f61d38efaa4aae82914aebd6fe8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 9 Jun 2022 18:55:16 -0500 Subject: [PATCH 8/8] mob powers now scale based on their level --- src/engine/ai/utilities/CombatUtilities.java | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index 2c092188..c29d6fe0 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -311,7 +311,34 @@ public class CombatUtilities { if(count == random) { powerToken = entry.getKey(); - powerRank = entry.getValue(); + //powerRank = entry.getValue(); + switch(agent.getLevel()) + { + default: + powerRank = 1; + break; + case 10: + powerRank = 5; + break; + case 20: + powerRank = 10; + break; + case 30: + powerRank = 15; + break; + case 40: + powerRank = 25; + break; + case 50: + powerRank = 30; + break; + case 60: + powerRank = 35; + break; + case 70: + powerRank = 40; + break; + } System.out.println(agent.getMobBase().getFirstName() + " is casting: " + PowersManager.getPowerByToken(powerToken).skillName); PowersManager.applyPower(agent,target,target.getLoc(),powerToken,powerRank, false); }