From bed99dce6293b110ddad6089cf26017c0c61a948 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 20 Aug 2023 15:10:31 -0400 Subject: [PATCH] aiAgentType enumeration defined. --- src/engine/Enum.java | 7 ++ .../objects/AbstractIntelligenceAgent.java | 83 +++++-------------- src/engine/objects/Mob.java | 11 --- src/engine/objects/NPC.java | 7 -- 4 files changed, 30 insertions(+), 78 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 6830dfa7..e98fcabc 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2875,4 +2875,11 @@ public class Enum { } } + + public enum AIAgentType { + MOBILE, + PET, + CHARMED, + GUARD; + } } diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index 525090fe..e73b8386 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -14,9 +14,9 @@ import engine.Enum.GameObjectType; import engine.Enum.ModType; import engine.Enum.SourceType; import engine.InterestManagement.WorldGrid; -import engine.mobileAI.Threads.MobAIThread; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; +import engine.mobileAI.Threads.MobAIThread; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.msg.PetMsg; @@ -30,26 +30,13 @@ import java.util.ArrayList; public abstract class AbstractIntelligenceAgent extends AbstractCharacter { protected Vector3fImmutable lastBindLoc; private boolean assist = false; - private AbstractCharacter callForHelpAggro = null; - private int type = 0; //Mob: 0, Pet: 1, Guard: 2 - private boolean clearAggro = false; + private Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE; public AbstractIntelligenceAgent(ResultSet rs) throws SQLException { super(rs); } - public AbstractIntelligenceAgent(ResultSet rs, boolean isPlayer) - throws SQLException { - super(rs, isPlayer); - } - - - public AbstractIntelligenceAgent(ResultSet rs, - int UUID) throws SQLException { - super(rs, UUID); - } - public AbstractIntelligenceAgent(String firstName, String lastName, short statStrCurrent, short statDexCurrent, short statConCurrent, short statIntCurrent, short statSpiCurrent, @@ -88,107 +75,84 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { if (this.getObjectType().equals(GameObjectType.Mob)) return this.getMobBase(); - return null; - } - - public AbstractCharacter getCallForHelpAggro() { - return callForHelpAggro; - } - public void setCallForHelpAggro(AbstractCharacter ac) { - this.callForHelpAggro = ac; + return null; } public void setMob() { - this.type = 0; + this.agentType = Enum.AIAgentType.MOBILE; } public void setPet(PlayerCharacter owner, boolean summoned) { + if (summoned) - this.type = 1; //summoned + this.agentType = Enum.AIAgentType.PET; //summoned else - this.type = 2; //charmed + this.agentType = Enum.AIAgentType.CHARMED; + if (this.getObjectType().equals(GameObjectType.Mob)) { ((Mob) this).setOwner(owner); } } - public void setGuard() { - this.type = 3; - } public boolean isMob() { - return (this.type == 0); + return (this.agentType.equals(Enum.AIAgentType.MOBILE)); } public boolean isPet() { - return (this.type == 1 || this.type == 2); + + return (this.agentType.equals(Enum.AIAgentType.PET) || + this.agentType.equals(Enum.AIAgentType.CHARMED)); } public boolean isSummonedPet() { - return (this.type == 1); + return (this.agentType.equals(Enum.AIAgentType.PET)); } public boolean isCharmedPet() { - return (this.type == 2); + return (this.agentType.equals(Enum.AIAgentType.CHARMED)); } public boolean isGuard() { - return (this.type == 3); + return (this.agentType.equals(Enum.AIAgentType.GUARD)); } public boolean assist() { return this.assist; } - public void setAssist(boolean value) { - this.assist = value; - } - public void toggleAssist() { - this.assist = (this.assist) ? false : true; + this.assist = !this.assist; } public int getDBID() { if (this.getObjectType().equals(GameObjectType.Mob)) return this.getDBID(); - return 0; - } - - public boolean clearAggro() { - return clearAggro; - } - - public void setClearAggro(boolean value) { - this.clearAggro = value; - } - public Vector3fImmutable getLastBindLoc() { - if (this.lastBindLoc == null) - this.lastBindLoc = this.getBindLoc(); - return this.lastBindLoc; + return 0; } public PlayerCharacter getOwner() { if (this.getObjectType().equals(GameObjectType.Mob)) return this.getOwner(); + return null; } public boolean getSafeZone() { + ArrayList allIn = ZoneManager.getAllZonesIn(this.getLoc()); - for (Zone zone : allIn) { + + for (Zone zone : allIn) if (zone.getSafeZone() == (byte) 1) return true; - } + return false; - //return this.safeZone; } - public abstract AbstractWorldObject getFearedObject(); - public float getAggroRange() { float ret = MobAIThread.AI_BASE_AGGRO_RANGE; if (this.bonuses != null) @@ -212,9 +176,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { } else { //revert charmed pet this.setMob(); this.setCombatTarget(null); - // if (this.isAlive()) - // WorldServer.updateObject(this); } + //clear owner PlayerCharacter owner = this.getOwner(); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index f6b17f21..7b629df3 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -83,7 +83,6 @@ public class Mob extends AbstractIntelligenceAgent { public City guardedCity; protected int dbID; //the database ID protected int loadID; - protected boolean isMob; protected float spawnRadius; //used by static mobs protected int parentZoneID; @@ -111,7 +110,6 @@ public class Mob extends AbstractIntelligenceAgent { this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.loadID = npcType; - this.isMob = isMob; this.mobBase = MobBase.getMobBase(loadID); this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.parentZone = parent; @@ -140,7 +138,6 @@ public class Mob extends AbstractIntelligenceAgent { super(firstName, lastName, statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp, sit, walk, combat, bindLoc, currentLoc, faceDir, healthCurrent, manaCurrent, stamCurrent, guild, runningTrains, newUUID); this.dbID = newUUID; this.loadID = npcType; - this.isMob = isMob; if (contractID == 0) this.contract = null; @@ -162,7 +159,6 @@ public class Mob extends AbstractIntelligenceAgent { super(mobBase.getFirstName(), "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, level, 0, false, true, false, owner.getLoc(), owner.getLoc(), owner.getFaceDir(), (short) mobBase.getHealthMax(), (short) 0, (short) 0, guild, (byte) 0, tableID); this.dbID = tableID; this.loadID = mobBase.getObjectUUID(); - this.isMob = true; this.mobBase = mobBase; this.parentZone = parent; this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; @@ -177,7 +173,6 @@ public class Mob extends AbstractIntelligenceAgent { super(mobBase.getFirstName(), "", (short) 0, (short) 0, (short) 0, (short) 0, (short) 0, level, 0, false, true, false, loc, loc, Vector3fImmutable.ZERO, (short) mobBase.getHealthMax(), (short) 0, (short) 0, guild, (byte) 0, tableID); this.dbID = tableID; this.loadID = mobBase.getObjectUUID(); - this.isMob = true; this.mobBase = mobBase; this.parentZone = parent; this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; @@ -201,7 +196,6 @@ public class Mob extends AbstractIntelligenceAgent { this.gridObjectType = GridObjectType.DYNAMIC; this.spawnRadius = rs.getFloat("mob_spawnRadius"); this.spawnTime = rs.getInt("mob_spawnTime"); - this.isMob = true; this.parentZone = null; this.statLat = rs.getFloat("mob_spawnX"); this.statAlt = rs.getFloat("mob_spawnY"); @@ -1108,11 +1102,6 @@ public class Mob extends AbstractIntelligenceAgent { this.ownerUID = value.getObjectUUID(); } - @Override - public AbstractWorldObject getFearedObject() { - return this.fearedObject; - } - public void setFearedObject(AbstractWorldObject awo) { this.fearedObject = awo; } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 652631c7..8618e10e 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -54,7 +54,6 @@ public class NPC extends AbstractCharacter { public int runeSetID = 0; public int extraRune2 = 0; protected int loadID; - protected boolean isMob; protected MobBase mobBase; protected String name; protected int dbID; @@ -91,7 +90,6 @@ public class NPC extends AbstractCharacter { super(name, "", statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp, bindLoc, currentLoc, faceDir, guild, runningTrains); this.loadID = npcType; - this.isMob = isMob; this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); if (this.contract != null) @@ -133,7 +131,6 @@ public class NPC extends AbstractCharacter { this.loadID = rs.getInt("npc_raceID"); this.level = rs.getByte("npc_level"); - this.isMob = false; buildingUUID = rs.getInt("npc_buildingID"); @@ -747,10 +744,6 @@ public class NPC extends AbstractCharacter { this.charItemManager.load(); } - public boolean isMob() { - return this.isMob; - } - public MobBase getMobBase() { return this.mobBase; }