Browse Source

Cleanup of bind/loc logic.

combat-2
MagicBot 1 year ago
parent
commit
c39ed6120f
  1. 1
      src/engine/Enum.java
  2. 69
      src/engine/objects/Mob.java

1
src/engine/Enum.java

@ -2822,7 +2822,6 @@ public class Enum {
public enum MobBehaviourType { public enum MobBehaviourType {
None(null, false, false, false, false, false), None(null, false, false, false, false, false),
//Power
Power(null, false, true, true, true, false), Power(null, false, true, true, true, false),
PowerHelpee(Power, false, true, true, false, true), PowerHelpee(Power, false, true, true, false, true),
PowerHelpeeWimpy(Power, true, false, true, false, false), PowerHelpeeWimpy(Power, true, false, true, false, false),

69
src/engine/objects/Mob.java

@ -682,7 +682,7 @@ public class Mob extends AbstractIntelligenceAgent {
DbManager.addToCache(minionMobile); DbManager.addToCache(minionMobile);
minionMobile.setLoc(minionMobile.bindLoc); minionMobile.setLoc(minionMobile.bindLoc);
// minionMobile.despawn(); minionMobile.despawn();
int slot = guardCaptain.siegeMinionMap.size() + 1; int slot = guardCaptain.siegeMinionMap.size() + 1;
guardCaptain.siegeMinionMap.put(minionMobile, slot); guardCaptain.siegeMinionMap.put(minionMobile, slot);
@ -1680,12 +1680,9 @@ public class Mob extends AbstractIntelligenceAgent {
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return; return;
try { this.gridObjectType = GridObjectType.DYNAMIC;
this.building = BuildingManager.getBuilding(this.buildingUUID); this.mobBase = MobBase.getMobBase(loadID);
} catch (Exception e) { this.building = BuildingManager.getBuilding(this.buildingUUID);
this.building = null;
Logger.error(e.getMessage());
}
if (this.contractUUID == 0) if (this.contractUUID == 0)
this.contract = null; this.contract = null;
@ -1719,6 +1716,11 @@ public class Mob extends AbstractIntelligenceAgent {
} }
} }
// Default to the mobbase for AI if nothing is hte mob field to override.
if (this.behaviourType == null || this.behaviourType.equals(MobBehaviourType.None))
this.behaviourType = this.getMobBase().fsm;
if (this.building != null) if (this.building != null)
this.guild = this.building.getGuild(); this.guild = this.building.getGuild();
else else
@ -1727,8 +1729,6 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.guild == null) if (this.guild == null)
this.guild = Guild.getErrantGuild(); this.guild = Guild.getErrantGuild();
this.mobBase = MobBase.getMobBase(loadID);
this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks()); this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks());
if (this.firstName.isEmpty()) if (this.firstName.isEmpty())
@ -1742,7 +1742,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.lastName = this.getContract().getName(); this.lastName = this.getContract().getName();
} }
this.gridObjectType = GridObjectType.DYNAMIC;
this.healthMax = this.mobBase.getHealthMax(); this.healthMax = this.mobBase.getHealthMax();
this.manaMax = 0; this.manaMax = 0;
this.staminaMax = 0; this.staminaMax = 0;
@ -1778,39 +1777,36 @@ public class Mob extends AbstractIntelligenceAgent {
this.parentZone.zoneMobSet.remove(this); this.parentZone.zoneMobSet.remove(this);
this.parentZone.zoneMobSet.add(this); this.parentZone.zoneMobSet.add(this);
// Setup location for this Mobile
this.bindLoc = this.parentZone.getLoc().add(this.bindLoc);
this.loc = new Vector3fImmutable(bindLoc);
this.endLoc = new Vector3fImmutable(bindLoc);
// Handle Mobiles within buildings // Handle Mobiles within buildings
if (this.building != null) { if (this.building == null)
this.bindLoc = this.parentZone.getLoc().add(this.bindLoc);
else {
// Mobiles inside buildings are offset from it not the zone // Mobiles inside buildings are offset from it not the zone
// with the exceptions being mobiles
this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); // with a contract.
this.bindLoc = this.building.getLoc().add(this.bindLoc);
if (this.contract != null || this.isSiege) if (this.contract != null || this.isSiege)
NPCManager.slotCharacterInBuilding(this); NPCManager.slotCharacterInBuilding(this);
else
this.bindLoc = building.getLoc();
} }
// Setup location for this Mobile
this.loc = new Vector3fImmutable(bindLoc);
this.endLoc = new Vector3fImmutable(bindLoc);
// Initialize inventory // Initialize inventory
this.charItemManager.load(); this.charItemManager.load();
this.loadInventory(); this.loadInventory();
try { if (this.equipmentSetID != 0)
if (this.equipmentSetID != 0) this.equip = MobBase.loadEquipmentSet(this.equipmentSetID);
this.equip = MobBase.loadEquipmentSet(this.equipmentSetID); else
else this.equip = new HashMap<>();
this.equip = new HashMap<>();
} catch (Exception e) {
Logger.error(e.getMessage());
}
// Powers from mobbase // Powers from mobbase
@ -1832,7 +1828,7 @@ public class Mob extends AbstractIntelligenceAgent {
// Combine mobbase and mob aggro arrays into one bitvector // Combine mobbase and mob aggro arrays into one bitvector
//skip for pets //skip for pets
if (this.isPet() == false && (this.agentType.equals(AIAgentType.PET)) == false && this.isNecroPet() == false) { if (this.isPet() == false && this.isNecroPet() == false) {
if (this.getMobBase().notEnemy.size() > 0) if (this.getMobBase().notEnemy.size() > 0)
this.notEnemy.addAll(this.getMobBase().notEnemy); this.notEnemy.addAll(this.getMobBase().notEnemy);
@ -1873,19 +1869,6 @@ public class Mob extends AbstractIntelligenceAgent {
} }
} }
if (this.behaviourType == null)
this.behaviourType = this.getMobBase().fsm;
if (this.isPlayerGuard() && this.contract != null)
if (NPC.ISWallArcher(this.getContract())) {
this.behaviourType = MobBehaviourType.GuardWallArcher;
this.spawnTime = 450;
} else {
this.behaviourType = MobBehaviourType.GuardCaptain;
this.spawnTime = 900;
this.guardedCity = ZoneManager.getCityAtLocation(this.bindLoc);
}
this.deathTime = 0; this.deathTime = 0;
} catch (Exception e) { } catch (Exception e) {
Logger.error(e.getMessage()); Logger.error(e.getMessage());

Loading…
Cancel
Save