Compare commits

...

8 Commits

Author SHA1 Message Date
byronhb 221ae0a58b Fixes for /mob, /npc, and /equipset commands. 2025-11-10 21:14:28 -06:00
MagicBot 3649c629b7 Revert "DamageType defined as in JSON"
This reverts commit 1c31070fc8.
2024-04-01 12:04:12 -04:00
MagicBot 1c31070fc8 DamageType defined as in JSON 2024-04-01 12:01:59 -04:00
MagicBot bff41967db Revert "Out of combat mode when patrolling."
This reverts commit d3692d0fb7.
2023-09-08 13:07:15 -04:00
MagicBot d3692d0fb7 Out of combat mode when patrolling. 2023-09-08 13:04:29 -04:00
FatBoy 074a799d01 added health recovery to mobs 2023-08-22 20:58:52 -05:00
FatBoy 36ffd08a72 guard minions logic work 2023-08-22 20:52:45 -05:00
FatBoy 58f828b3cd items removed properly from inventory, NPCs nop longer stock base items 2023-08-22 20:52:26 -05:00
4 changed files with 45 additions and 41 deletions
+6 -2
View File
@@ -243,8 +243,12 @@ public class dbNPCHandler extends dbHandlerBase {
public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) { public boolean UPDATE_EQUIPSET(NPC npc, int equipSetID) {
// Column name must match what NPC/Mob loaders read ("equipmentSet").
// Using the wrong column here causes the update to fail silently and
// dev command to report "Unable to find Equipset" despite a valid ID.
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipsetID`=? WHERE `UID`=?")) { PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `obj_npc` SET `equipmentSet`=? WHERE `UID`=?")) {
preparedStatement.setInt(1, equipSetID); preparedStatement.setInt(1, equipSetID);
preparedStatement.setLong(2, npc.getObjectUUID()); preparedStatement.setLong(2, npc.getObjectUUID());
@@ -467,4 +471,4 @@ public class dbNPCHandler extends dbHandlerBase {
return false; return false;
} }
} }
} }
+25 -36
View File
@@ -693,6 +693,8 @@ public class MobAI {
DefaultLogic(mob); DefaultLogic(mob);
break; break;
} }
if(mob.isAlive())
RecoverHealth(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
} }
@@ -808,7 +810,7 @@ public class MobAI {
chaseTarget(mob); chaseTarget(mob);
break; break;
case GuardMinion: case GuardMinion:
if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned) if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null)
randomGuardPatrolPoint(mob); randomGuardPatrolPoint(mob);
else { else {
if (mob.getCombatTarget() != null) { if (mob.getCombatTarget() != null) {
@@ -827,6 +829,7 @@ public class MobAI {
chaseTarget(mob); chaseTarget(mob);
} }
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
@@ -1043,7 +1046,6 @@ public class MobAI {
mob.setCombatTarget(newTarget); mob.setCombatTarget(newTarget);
} }
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
@@ -1054,24 +1056,9 @@ public class MobAI {
public static void GuardMinionLogic(Mob mob) { public static void GuardMinionLogic(Mob mob) {
try { try {
if (!mob.npcOwner.isAlive()) { boolean isComanded = mob.npcOwner.isAlive();
if (!isComanded) {
if (mob.getCombatTarget() == null) { GuardCaptainLogic(mob);
CheckForPlayerGuardAggro(mob);
} else {
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
if (newTarget != null) {
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
mob.setCombatTarget(newTarget);
} else
mob.setCombatTarget(newTarget);
}
}
}else { }else {
if (mob.npcOwner.getCombatTarget() != null) if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.npcOwner.getCombatTarget()); mob.setCombatTarget(mob.npcOwner.getCombatTarget());
@@ -1110,22 +1097,6 @@ public class MobAI {
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
//recover health
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
} }
@@ -1379,4 +1350,22 @@ public class MobAI {
} }
return null; return null;
} }
public static void RecoverHealth(Mob mob){
//recover health
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
}
} }
+11 -1
View File
@@ -541,8 +541,18 @@ public class Mob extends AbstractIntelligenceAgent {
mobWithoutID.parentZone = parent; mobWithoutID.parentZone = parent;
mobWithoutID.parentZoneID = parent.getObjectUUID(); mobWithoutID.parentZoneID = parent.getObjectUUID();
// NPC in a Building derives position from slot // Ensure spawn coordinates are persisted for DB insert
// statLat/statAlt/statLon represent local (zone-relative) spawn
// coordinates used by the DB handler when creating the mob row.
if (spawn != null && parent != null) {
// Convert world coordinates to zone-local spawn coordinates
Vector3fImmutable localSpawn = spawn.subtract(parent.getLoc());
mobWithoutID.statLat = localSpawn.x;
mobWithoutID.statAlt = localSpawn.y;
mobWithoutID.statLon = localSpawn.z;
}
// NPC in a Building derives position from slot
if (mobWithoutID.building != null) if (mobWithoutID.building != null)
mobWithoutID.bindLoc = Vector3fImmutable.ZERO; mobWithoutID.bindLoc = Vector3fImmutable.ZERO;
+3 -2
View File
@@ -470,7 +470,8 @@ public class NPC extends AbstractCharacter {
newNPC.bindLoc = Vector3fImmutable.ZERO; newNPC.bindLoc = Vector3fImmutable.ZERO;
newNPC.parentZoneUUID = parent.getObjectUUID(); newNPC.parentZoneUUID = parent.getObjectUUID();
newNPC.guildUUID = guild.getObjectUUID(); // guild may be null when spawning via ./npc; default to 0
newNPC.guildUUID = (guild != null) ? guild.getObjectUUID() : 0;
if (building == null) if (building == null)
newNPC.buildingUUID = 0; newNPC.buildingUUID = 0;
@@ -1347,4 +1348,4 @@ public class NPC extends AbstractCharacter {
} }
} }
} }