From 525facf7b52b01623417820d97f9e037807cc2b2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 13:27:35 -0500 Subject: [PATCH 01/10] remote commit --- src/engine/ai/MobileFSM.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 588b8bd4..2b8e6136 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -496,7 +496,7 @@ public class MobileFSM { } } } - } else if (System.currentTimeMillis() > aiAgent.deathTime + (aiAgent.spawnTime * 1000)) { + } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { aiAgent.respawn(); } } From 18bcd79733de71d681cd05b6328fc9d9ddf79d79 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 14:08:44 -0500 Subject: [PATCH 02/10] pets now spawn at owners location --- src/engine/powers/poweractions/CreateMobPowerAction.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index e9823ffd..34197fe4 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -11,7 +11,9 @@ package engine.powers.poweractions; import engine.Enum; import engine.InterestManagement.WorldGrid; +import engine.ai.utilities.MovementUtilities; import engine.gameManager.DbManager; +import engine.gameManager.MovementManager; import engine.gameManager.NPCManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; @@ -153,6 +155,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { // if (mobID == 12021 || mobID == 12022) //Necro Pets // pet.setPet(owner, true); owner.setPet(pet); + MovementManager.translocate(pet,owner.getLoc(),owner.region); PetMsg pm = new PetMsg(5, pet); Dispatch dispatch = Dispatch.borrow(owner, pm); DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); From e0929a4cbd6c5b2530abb92cc6e7bbb5ada4a2b3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 14:20:50 -0500 Subject: [PATCH 03/10] pets added to seafloor mob set --- src/engine/objects/Mob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index f3091d86..e70778b9 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -590,7 +590,7 @@ public class Mob extends AbstractIntelligenceAgent { } finally { createLock.writeLock().unlock(); } - + parent.zoneMobSet.add(mob); return mob; } From 7dc6fece7d80a124ffab3099e52246fcd5a94fd7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 15:27:22 -0500 Subject: [PATCH 04/10] work on pet AI --- src/engine/ai/MobileFSM.java | 19 +++++++++++++------ .../poweractions/CreateMobPowerAction.java | 4 +++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 2b8e6136..f43d8d66 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -332,6 +332,11 @@ public class MobileFSM { public static void DetermineAction(Mob mob) { if (mob == null) return; + //pet cleanup for errant pets + if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.Pet1.ordinal() && mob.getOwner() == null && mob.isSiege() == false){ + mob.despawn(); + WorldGrid.removeObject(mob); + } if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { //trebuchet spawn handler CheckForRespawn(mob); @@ -358,7 +363,7 @@ public class MobileFSM { CheckForRespawn(mob); return; } - if (mob.playerAgroMap.isEmpty() && mob.isPlayerGuard == false) + if (mob.playerAgroMap.isEmpty() && mob.isPlayerGuard == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) //no players loaded, no need to proceed return; if (mob.isCombat() && mob.getCombatTarget() == null) { @@ -368,7 +373,9 @@ public class MobileFSM { DispatchMessage.sendToAllInRange(mob, rwss); } mob.updateLocation(); - CheckToSendMobHome(mob); + if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) { + CheckToSendMobHome(mob); + } if (mob.combatTarget != null && mob.combatTarget.isAlive() == false) { mob.setCombatTarget(null); } @@ -568,10 +575,10 @@ public class MobileFSM { private static void chaseTarget(Mob mob) { mob.updateMovementState(); - if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) { - mob.setCombatTarget(null); - return; - } + //if (mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) { + // mob.setCombatTarget(null); + // return; + //} if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { if (mob.getRange() > 15) { mob.destination = mob.getCombatTarget().getLoc(); diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index 34197fe4..969e2927 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -155,7 +155,9 @@ public class CreateMobPowerAction extends AbstractPowerAction { // if (mobID == 12021 || mobID == 12022) //Necro Pets // pet.setPet(owner, true); owner.setPet(pet); - MovementManager.translocate(pet,owner.getLoc(),owner.region); + if(pet.isSiege() == false) { + MovementManager.translocate(pet, owner.getLoc(), owner.region); + } PetMsg pm = new PetMsg(5, pet); Dispatch dispatch = Dispatch.borrow(owner, pm); DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); From 8c1b23772027068455edde9bd7e98958fa2eaf34 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 15:39:57 -0500 Subject: [PATCH 05/10] dead pets removed form seafloor zonemobset --- src/engine/ai/MobileFSM.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index f43d8d66..9eec4af8 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -335,7 +335,10 @@ public class MobileFSM { //pet cleanup for errant pets if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.Pet1.ordinal() && mob.getOwner() == null && mob.isSiege() == false){ mob.despawn(); + DbManager.removeFromCache(mob); WorldGrid.removeObject(mob); + ZoneManager.getSeaFloor().zoneMobSet.remove(mob); + return; } if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { //trebuchet spawn handler From 06c4b7ca3c62b86d883c571c9fbee0e94e2cb3d1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 15:48:11 -0500 Subject: [PATCH 06/10] ghost mob fix --- src/engine/ai/MobileFSM.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 9eec4af8..df11c008 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -489,6 +489,7 @@ public class MobileFSM { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) { aiAgent.despawn(); aiAgent.deathTime = System.currentTimeMillis(); + return; } //No items in inventory. } else { @@ -497,17 +498,20 @@ public class MobileFSM { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) { aiAgent.despawn(); aiAgent.deathTime = System.currentTimeMillis(); + return; } //Mob never had Loot. } else { if (System.currentTimeMillis() > aiAgent.deathTime + MBServerStatics.DESPAWN_TIMER) { aiAgent.despawn(); aiAgent.deathTime = System.currentTimeMillis(); + return; } } } } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { aiAgent.respawn(); + return; } } From 9ea02c888fa39ef50dcd38c648dcdcac52506d26 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 18:38:46 -0500 Subject: [PATCH 07/10] pet troubles resolved --- src/engine/ai/MobileFSM.java | 21 +++++++++++-------- src/engine/objects/Mob.java | 9 ++++---- .../poweractions/CreateMobPowerAction.java | 10 ++++----- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index df11c008..57889e36 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -332,14 +332,6 @@ public class MobileFSM { public static void DetermineAction(Mob mob) { if (mob == null) return; - //pet cleanup for errant pets - if(mob.BehaviourType.ordinal() == Enum.MobBehaviourType.Pet1.ordinal() && mob.getOwner() == null && mob.isSiege() == false){ - mob.despawn(); - DbManager.removeFromCache(mob); - WorldGrid.removeObject(mob); - ZoneManager.getSeaFloor().zoneMobSet.remove(mob); - return; - } if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { //trebuchet spawn handler CheckForRespawn(mob); @@ -358,7 +350,9 @@ public class MobileFSM { } CheckForRespawn(mob); //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting - CheckToSendMobHome(mob); + if(mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()){ + CheckToSendMobHome(mob); + } return; } if (!mob.isAlive()) { @@ -382,6 +376,7 @@ public class MobileFSM { if (mob.combatTarget != null && mob.combatTarget.isAlive() == false) { mob.setCombatTarget(null); } + mob.updateLocation(); switch (mob.BehaviourType) { case GuardCaptain: GuardCaptainLogic(mob); @@ -440,6 +435,9 @@ public class MobileFSM { return; switch (mob.BehaviourType) { case Pet1: + if(mob.getOwner() == null){ + return; + } if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { //mob no longer has its owner loaded, translocate pet to owner MovementManager.translocate(mob, mob.getOwner().getLoc(), null); @@ -640,6 +638,11 @@ public class MobileFSM { } private static void PetLogic(Mob mob) { + if(mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false){ + if(ZoneManager.getSeaFloor().zoneMobSet.contains(mob)){ + mob.killCharacter("no owner"); + } + } if (mob.getCombatTarget() != null && !mob.getCombatTarget().isAlive()) mob.setCombatTarget(null); if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index e70778b9..d8344e6b 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1331,9 +1331,11 @@ public class Mob extends AbstractIntelligenceAgent { this.combatTarget = null; this.hasLoot = false; - if (this.parentZone != null) - this.parentZone.zoneMobSet.remove(this); - + //if (this.parentZone != null) + //this.parentZone.zoneMobSet.remove(this); + if(ZoneManager.getSeaFloor().zoneMobSet.contains(this)) { + ZoneManager.getSeaFloor().zoneMobSet.remove(this); + } try { this.clearEffects(); } catch (Exception e) { @@ -1372,7 +1374,6 @@ public class Mob extends AbstractIntelligenceAgent { this.combatTarget = null; this.hasLoot = this.charItemManager.getInventoryCount() > 0; - } catch (Exception e) { Logger.error(e); } diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index 969e2927..c13bcd5a 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -85,9 +85,9 @@ public class CreateMobPowerAction extends AbstractPowerAction { WorldGrid.RemoveWorldObject(currentPet); currentPet.setCombatTarget(null); - if (currentPet.getParentZone() != null) - currentPet.getParentZone().zoneMobSet.remove(currentPet); - + //if (currentPet.getParentZone() != null) + //currentPet.getParentZone().zoneMobSet.remove(currentPet); + seaFloor.zoneMobSet.remove(currentPet); currentPet.playerAgroMap.clear(); try { @@ -118,8 +118,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { currentPet.setOwner(null); WorldGrid.RemoveWorldObject(currentPet); - - currentPet.getParentZone().zoneMobSet.remove(currentPet); + //currentPet.getParentZone().zoneMobSet.remove(currentPet); + seaFloor.zoneMobSet.remove(currentPet); currentPet.playerAgroMap.clear(); currentPet.clearEffects(); //currentPet.disableIntelligence(); From 9db568206dab7e860033ef12ae0d8727ee209e18 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 21:57:27 -0500 Subject: [PATCH 08/10] pet stats added again --- src/engine/ai/utilities/CombatUtilities.java | 3 +-- src/engine/objects/Mob.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/engine/ai/utilities/CombatUtilities.java b/src/engine/ai/utilities/CombatUtilities.java index abc35db2..3fb076a1 100644 --- a/src/engine/ai/utilities/CombatUtilities.java +++ b/src/engine/ai/utilities/CombatUtilities.java @@ -363,11 +363,10 @@ public class CombatUtilities { float damage; float min = 40; float max = 60; - AbstractWorldObject target = agent.getCombatTarget(); float dmgMultiplier = 1 + agent.getBonuses().getFloatPercentAll(ModType.MeleeDamageModifier, SourceType.None); double minDmg = getMinDmg(min, agent, null); double maxDmg = getMaxDmg(max, agent, null); - dmgMultiplier += agent.getLevel() / 10; + dmgMultiplier += agent.getLevel() * 0.1f; range = (float) (maxDmg - minDmg); damage = min + ((ThreadLocalRandom.current().nextFloat() * range) + (ThreadLocalRandom.current().nextFloat() * range)) / 2; return (int) (damage * dmgMultiplier); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d8344e6b..5fc298ad 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -591,6 +591,9 @@ public class Mob extends AbstractIntelligenceAgent { createLock.writeLock().unlock(); } parent.zoneMobSet.add(mob); + mob.level = level; + mob.healthMax = mob.getMobBase().getHealthMax() * (mob.level * 0.5f); + mob.health.set(mob.healthMax); return mob; } @@ -1952,12 +1955,14 @@ public class Mob extends AbstractIntelligenceAgent { this.equip = new HashMap<>(0); } // Combine mobbase and mob aggro arrays into one bitvector - if (this.getMobBase().notEnemy.size() > 0) - this.notEnemy.addAll(this.getMobBase().notEnemy); - - if (this.getMobBase().enemy.size() > 0) - this.enemy.addAll(this.getMobBase().enemy); + //skip for pets + if(this.isPet() == false && this.isSummonedPet() == false && this.isNecroPet() == false) { + if (this.getMobBase().notEnemy.size() > 0) + this.notEnemy.addAll(this.getMobBase().notEnemy); + if (this.getMobBase().enemy.size() > 0) + this.enemy.addAll(this.getMobBase().enemy); + } try { NPCManager.applyRuneSetEffects(this); recalculateStats(); From c72cda1b73dc2027241602a868ca5911fcd8cf94 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 15 Jul 2023 22:34:09 -0500 Subject: [PATCH 09/10] pets attack buildings --- src/engine/ai/MobileFSM.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 57889e36..d856b162 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -13,6 +13,7 @@ import engine.InterestManagement.WorldGrid; import engine.ai.utilities.CombatUtilities; import engine.ai.utilities.MovementUtilities; import engine.gameManager.*; +import engine.math.Vector2f; import engine.math.Vector3f; import engine.math.Vector3fImmutable; import engine.net.DispatchMessage; @@ -589,8 +590,19 @@ public class MobileFSM { mob.destination = mob.getCombatTarget().getLoc(); MovementUtilities.moveToLocation(mob, mob.destination, 0); } else { - mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget()); - MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange()); + //check if building + switch (mob.getCombatTarget().getObjectType()) { + case PlayerCharacter: + case Mob: + mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget()); + MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange()); + break; + case Building: + mob.destination = mob.getCombatTarget().getLoc(); + MovementUtilities.moveToLocation(mob,mob.getCombatTarget().getLoc(),0); + break; + } + } } } From c04a3428902d45a484e418f95d3e3bc463507220 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 16 Jul 2023 07:52:10 -0400 Subject: [PATCH 10/10] Update to sql for better default mysql.cnf compatibility. --- src/engine/db/handlers/dbBuildingLocationHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbBuildingLocationHandler.java b/src/engine/db/handlers/dbBuildingLocationHandler.java index b92f2002..7a3bbd9e 100644 --- a/src/engine/db/handlers/dbBuildingLocationHandler.java +++ b/src/engine/db/handlers/dbBuildingLocationHandler.java @@ -31,7 +31,7 @@ public class dbBuildingLocationHandler extends dbHandlerBase { ArrayList buildingLocations = new ArrayList<>(); try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("select * from static_building_location " + + PreparedStatement preparedStatement = connection.prepareStatement("select `ID`, `BuildingID`, `type`, `slot`, `unknown`, `locX`, `locY`, `locZ`, `w`, `rotX`, `rotY`, `rotZ` from static_building_location " + "where type = 6 or type = 8 " + "GROUP BY buildingID, slot " + "ORDER BY buildingID, slot ASC;")) {