Browse Source

aiAgentType enumeration defined.

master
MagicBot 1 year ago
parent
commit
bed99dce62
  1. 7
      src/engine/Enum.java
  2. 83
      src/engine/objects/AbstractIntelligenceAgent.java
  3. 11
      src/engine/objects/Mob.java
  4. 7
      src/engine/objects/NPC.java

7
src/engine/Enum.java

@ -2875,4 +2875,11 @@ public class Enum {
} }
} }
public enum AIAgentType {
MOBILE,
PET,
CHARMED,
GUARD;
}
} }

83
src/engine/objects/AbstractIntelligenceAgent.java

@ -14,9 +14,9 @@ import engine.Enum.GameObjectType;
import engine.Enum.ModType; import engine.Enum.ModType;
import engine.Enum.SourceType; import engine.Enum.SourceType;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.mobileAI.Threads.MobAIThread;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.msg.PetMsg; import engine.net.client.msg.PetMsg;
@ -30,26 +30,13 @@ import java.util.ArrayList;
public abstract class AbstractIntelligenceAgent extends AbstractCharacter { public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
protected Vector3fImmutable lastBindLoc; protected Vector3fImmutable lastBindLoc;
private boolean assist = false; private boolean assist = false;
private AbstractCharacter callForHelpAggro = null; private Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE;
private int type = 0; //Mob: 0, Pet: 1, Guard: 2
private boolean clearAggro = false;
public AbstractIntelligenceAgent(ResultSet rs) throws SQLException { public AbstractIntelligenceAgent(ResultSet rs) throws SQLException {
super(rs); 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, public AbstractIntelligenceAgent(String firstName,
String lastName, short statStrCurrent, short statDexCurrent, String lastName, short statStrCurrent, short statDexCurrent,
short statConCurrent, short statIntCurrent, short statSpiCurrent, short statConCurrent, short statIntCurrent, short statSpiCurrent,
@ -88,107 +75,84 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
if (this.getObjectType().equals(GameObjectType.Mob)) if (this.getObjectType().equals(GameObjectType.Mob))
return this.getMobBase(); return this.getMobBase();
return null;
}
public AbstractCharacter getCallForHelpAggro() {
return callForHelpAggro;
}
public void setCallForHelpAggro(AbstractCharacter ac) { return null;
this.callForHelpAggro = ac;
} }
public void setMob() { public void setMob() {
this.type = 0; this.agentType = Enum.AIAgentType.MOBILE;
} }
public void setPet(PlayerCharacter owner, boolean summoned) { public void setPet(PlayerCharacter owner, boolean summoned) {
if (summoned) if (summoned)
this.type = 1; //summoned this.agentType = Enum.AIAgentType.PET; //summoned
else else
this.type = 2; //charmed this.agentType = Enum.AIAgentType.CHARMED;
if (this.getObjectType().equals(GameObjectType.Mob)) { if (this.getObjectType().equals(GameObjectType.Mob)) {
((Mob) this).setOwner(owner); ((Mob) this).setOwner(owner);
} }
} }
public void setGuard() {
this.type = 3;
}
public boolean isMob() { public boolean isMob() {
return (this.type == 0); return (this.agentType.equals(Enum.AIAgentType.MOBILE));
} }
public boolean isPet() { 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() { public boolean isSummonedPet() {
return (this.type == 1); return (this.agentType.equals(Enum.AIAgentType.PET));
} }
public boolean isCharmedPet() { public boolean isCharmedPet() {
return (this.type == 2); return (this.agentType.equals(Enum.AIAgentType.CHARMED));
} }
public boolean isGuard() { public boolean isGuard() {
return (this.type == 3); return (this.agentType.equals(Enum.AIAgentType.GUARD));
} }
public boolean assist() { public boolean assist() {
return this.assist; return this.assist;
} }
public void setAssist(boolean value) {
this.assist = value;
}
public void toggleAssist() { public void toggleAssist() {
this.assist = (this.assist) ? false : true; this.assist = !this.assist;
} }
public int getDBID() { public int getDBID() {
if (this.getObjectType().equals(GameObjectType.Mob)) if (this.getObjectType().equals(GameObjectType.Mob))
return this.getDBID(); return this.getDBID();
return 0;
}
public boolean clearAggro() {
return clearAggro;
}
public void setClearAggro(boolean value) {
this.clearAggro = value;
}
public Vector3fImmutable getLastBindLoc() { return 0;
if (this.lastBindLoc == null)
this.lastBindLoc = this.getBindLoc();
return this.lastBindLoc;
} }
public PlayerCharacter getOwner() { public PlayerCharacter getOwner() {
if (this.getObjectType().equals(GameObjectType.Mob)) if (this.getObjectType().equals(GameObjectType.Mob))
return this.getOwner(); return this.getOwner();
return null; return null;
} }
public boolean getSafeZone() { public boolean getSafeZone() {
ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc()); ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc());
for (Zone zone : allIn) {
for (Zone zone : allIn)
if (zone.getSafeZone() == (byte) 1) if (zone.getSafeZone() == (byte) 1)
return true; return true;
}
return false; return false;
//return this.safeZone;
} }
public abstract AbstractWorldObject getFearedObject();
public float getAggroRange() { public float getAggroRange() {
float ret = MobAIThread.AI_BASE_AGGRO_RANGE; float ret = MobAIThread.AI_BASE_AGGRO_RANGE;
if (this.bonuses != null) if (this.bonuses != null)
@ -212,9 +176,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
} else { //revert charmed pet } else { //revert charmed pet
this.setMob(); this.setMob();
this.setCombatTarget(null); this.setCombatTarget(null);
// if (this.isAlive())
// WorldServer.updateObject(this);
} }
//clear owner //clear owner
PlayerCharacter owner = this.getOwner(); PlayerCharacter owner = this.getOwner();

11
src/engine/objects/Mob.java

@ -83,7 +83,6 @@ public class Mob extends AbstractIntelligenceAgent {
public City guardedCity; public City guardedCity;
protected int dbID; //the database ID protected int dbID; //the database ID
protected int loadID; protected int loadID;
protected boolean isMob;
protected float spawnRadius; protected float spawnRadius;
//used by static mobs //used by static mobs
protected int parentZoneID; protected int parentZoneID;
@ -111,7 +110,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
this.loadID = npcType; this.loadID = npcType;
this.isMob = isMob;
this.mobBase = MobBase.getMobBase(loadID); this.mobBase = MobBase.getMobBase(loadID);
this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
this.parentZone = parent; 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); 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.dbID = newUUID;
this.loadID = npcType; this.loadID = npcType;
this.isMob = isMob;
if (contractID == 0) if (contractID == 0)
this.contract = null; 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); 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.dbID = tableID;
this.loadID = mobBase.getObjectUUID(); this.loadID = mobBase.getObjectUUID();
this.isMob = true;
this.mobBase = mobBase; this.mobBase = mobBase;
this.parentZone = parent; this.parentZone = parent;
this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; 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); 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.dbID = tableID;
this.loadID = mobBase.getObjectUUID(); this.loadID = mobBase.getObjectUUID();
this.isMob = true;
this.mobBase = mobBase; this.mobBase = mobBase;
this.parentZone = parent; this.parentZone = parent;
this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0; this.parentZoneID = (parent != null) ? parent.getObjectUUID() : 0;
@ -201,7 +196,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.gridObjectType = GridObjectType.DYNAMIC; this.gridObjectType = GridObjectType.DYNAMIC;
this.spawnRadius = rs.getFloat("mob_spawnRadius"); this.spawnRadius = rs.getFloat("mob_spawnRadius");
this.spawnTime = rs.getInt("mob_spawnTime"); this.spawnTime = rs.getInt("mob_spawnTime");
this.isMob = true;
this.parentZone = null; this.parentZone = null;
this.statLat = rs.getFloat("mob_spawnX"); this.statLat = rs.getFloat("mob_spawnX");
this.statAlt = rs.getFloat("mob_spawnY"); this.statAlt = rs.getFloat("mob_spawnY");
@ -1108,11 +1102,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.ownerUID = value.getObjectUUID(); this.ownerUID = value.getObjectUUID();
} }
@Override
public AbstractWorldObject getFearedObject() {
return this.fearedObject;
}
public void setFearedObject(AbstractWorldObject awo) { public void setFearedObject(AbstractWorldObject awo) {
this.fearedObject = awo; this.fearedObject = awo;
} }

7
src/engine/objects/NPC.java

@ -54,7 +54,6 @@ public class NPC extends AbstractCharacter {
public int runeSetID = 0; public int runeSetID = 0;
public int extraRune2 = 0; public int extraRune2 = 0;
protected int loadID; protected int loadID;
protected boolean isMob;
protected MobBase mobBase; protected MobBase mobBase;
protected String name; protected String name;
protected int dbID; protected int dbID;
@ -91,7 +90,6 @@ public class NPC extends AbstractCharacter {
super(name, "", statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp, super(name, "", statStrCurrent, statDexCurrent, statConCurrent, statIntCurrent, statSpiCurrent, level, exp,
bindLoc, currentLoc, faceDir, guild, runningTrains); bindLoc, currentLoc, faceDir, guild, runningTrains);
this.loadID = npcType; this.loadID = npcType;
this.isMob = isMob;
this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
if (this.contract != null) if (this.contract != null)
@ -133,7 +131,6 @@ public class NPC extends AbstractCharacter {
this.loadID = rs.getInt("npc_raceID"); this.loadID = rs.getInt("npc_raceID");
this.level = rs.getByte("npc_level"); this.level = rs.getByte("npc_level");
this.isMob = false;
buildingUUID = rs.getInt("npc_buildingID"); buildingUUID = rs.getInt("npc_buildingID");
@ -747,10 +744,6 @@ public class NPC extends AbstractCharacter {
this.charItemManager.load(); this.charItemManager.load();
} }
public boolean isMob() {
return this.isMob;
}
public MobBase getMobBase() { public MobBase getMobBase() {
return this.mobBase; return this.mobBase;
} }

Loading…
Cancel
Save