Browse Source

Merge remote-tracking branch 'origin/char-init-mobwork' into char-init-cleanup

master
MagicBot 2 years ago
parent
commit
611e34add2
  1. 5
      src/engine/Enum.java
  2. 23
      src/engine/ai/MobileFSM.java
  3. 6
      src/engine/gameManager/BuildingManager.java
  4. 46
      src/engine/objects/Mob.java
  5. 28
      src/engine/objects/NPC.java

5
src/engine/Enum.java

@ -2636,8 +2636,9 @@ public class Enum {
TEMPLEGUARD(1575,1652, MinionClass.MELEE,"Guard","Temple"), TEMPLEGUARD(1575,1652, MinionClass.MELEE,"Guard","Temple"),
TEMPLEMAGE(1577, 1656, MinionClass.MAGE,"Confessor","Temple"), TEMPLEMAGE(1577, 1656, MinionClass.MAGE,"Confessor","Temple"),
UNDEADGUARD(980100,1674,MinionClass.MELEE,"Guard","Undead"), UNDEADGUARD(980100,1674,MinionClass.MELEE,"Guard","Undead"),
UNDEADMAGE(980102,1675,MinionClass.MAGE,"Adept","Undead"); UNDEADMAGE(980102,1675,MinionClass.MAGE,"Adept","Undead"),
WEREWOLFGUARD(980104,0,MinionClass.MELEE,"Guard","Werewolf"),
WEREBEARGUARD(980103,0,MinionClass.MELEE,"Guard","Werebear");
private final int captainContractID; private final int captainContractID;
private final int equipSetID; private final int equipSetID;
private final MinionClass minionClass; private final MinionClass minionClass;

23
src/engine/ai/MobileFSM.java

@ -199,7 +199,7 @@ public class MobileFSM {
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex); mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
mob.lastPatrolPointIndex += 1; mob.lastPatrolPointIndex += 1;
if (mob.isPlayerGuard()) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) { for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance //make sure mob is out of combat stance
if (minion.getKey().isCombat() && minion.getKey().getCombatTarget() == null) { if (minion.getKey().isCombat() && minion.getKey().getCombatTarget() == null) {
@ -320,6 +320,12 @@ public class MobileFSM {
if (mob.playerAgroMap.isEmpty()) if (mob.playerAgroMap.isEmpty())
//no players loaded, no need to proceed //no players loaded, no need to proceed
return; return;
if (mob.isCombat() && mob.getCombatTarget() == null) {
mob.setCombat(false);
UpdateStateMsg rwss = new UpdateStateMsg();
rwss.setPlayer(mob);
DispatchMessage.sendToAllInRange(mob, rwss);
}
CheckToSendMobHome(mob); CheckToSendMobHome(mob);
mob.updateLocation(); mob.updateLocation();
switch (mob.BehaviourType) { switch (mob.BehaviourType) {
@ -378,10 +384,16 @@ public class MobileFSM {
return; return;
mob.updateLocation(); mob.updateLocation();
if (mob.BehaviourType != Enum.MobBehaviourType.Pet1) { if (mob.BehaviourType != Enum.MobBehaviourType.Pet1) {
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null) {
if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (mob.npcOwner.isAlive() == true) {
return;
}
}
Patrol(mob); Patrol(mob);
else }else {
chaseTarget(mob); chaseTarget(mob);
}
} else { } else {
//pet logic //pet logic
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) { if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
@ -505,11 +517,6 @@ public class MobileFSM {
CheckForAttack(mob); CheckForAttack(mob);
} }
public static void GuardMinionLogic(Mob mob) { public static void GuardMinionLogic(Mob mob) {
if (mob.despawned || !mob.isAlive()) {
if (System.currentTimeMillis() > mob.deathTime + (mob.spawnTime * 1000))
mob.respawn();
return;
}
if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) { if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null) {
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
return; return;

6
src/engine/gameManager/BuildingManager.java

@ -297,7 +297,7 @@ public enum BuildingManager {
for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) { for (AbstractCharacter slottedNPC : building.getHirelings().keySet()) {
if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC) if (slottedNPC.getObjectType() == Enum.GameObjectType.NPC)
((NPC) slottedNPC).remove(); ((NPC)slottedNPC).remove();
else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob) else if (slottedNPC.getObjectType() == Enum.GameObjectType.Mob)
NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building); NPCManager.removeMobileFromBuilding(((Mob) slottedNPC), building);
} }
@ -475,7 +475,7 @@ public enum BuildingManager {
NPC npc = null; NPC npc = null;
npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, false, zone, (short) rank, building); npc = NPC.createNPC(pirateName, NpcID.getObjectUUID(), NpcLoc, null, false, zone, (short)rank, building);
if (npc == null) if (npc == null)
return false; return false;
@ -508,7 +508,7 @@ public enum BuildingManager {
if (NPC.ISWallArcher(contract)) { if (NPC.ISWallArcher(contract)) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank * 10); mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;

46
src/engine/objects/Mob.java

@ -67,7 +67,6 @@ public class Mob extends AbstractIntelligenceAgent {
public boolean isPlayerGuard = false; public boolean isPlayerGuard = false;
public AbstractCharacter npcOwner; public AbstractCharacter npcOwner;
public long deathTime = 0; public long deathTime = 0;
public String nameOverride = "";
public int equipmentSetID = 0; public int equipmentSetID = 0;
public int runeSet = 0; public int runeSet = 0;
public int bootySet = 0; public int bootySet = 0;
@ -120,7 +119,9 @@ public class Mob extends AbstractIntelligenceAgent {
if (contractID == 0) this.contract = null; if (contractID == 0) this.contract = null;
else this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID); else this.contract = DbManager.ContractQueries.GET_CONTRACT(contractID);
if(building != null && building.getOwner()!= null){
this.lastName = "the " + contract.getName();
}
clearStatic(); clearStatic();
} }
@ -253,13 +254,16 @@ public class Mob extends AbstractIntelligenceAgent {
this.notEnemy = EnumBitSet.asEnumBitSet(rs.getLong("notEnemy"), Enum.MonsterType.class); this.notEnemy = EnumBitSet.asEnumBitSet(rs.getLong("notEnemy"), Enum.MonsterType.class);
this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class); this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class);
this.firstName = rs.getString("mob_name");
if(this.firstName.isEmpty()){
this.firstName = this.mobBase.getFirstName();
}
if (this.contract != null) { if (this.contract != null) {
this.equipmentSetID = this.contract.getEquipmentSet(); this.equipmentSetID = this.contract.getEquipmentSet();
this.nameOverride = this.getContract().getName(); this.lastName = this.getContract().getName();
} else { } else {
this.equipmentSetID = rs.getInt("equipmentSet"); this.equipmentSetID = rs.getInt("equipmentSet");
this.nameOverride = rs.getString("mob_name");
} }
if (rs.getString("fsm").length() > 1) this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm")); if (rs.getString("fsm").length() > 1) this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm"));
@ -328,14 +332,11 @@ public class Mob extends AbstractIntelligenceAgent {
writer.putInt(0xFF665EC3); //Spi writer.putInt(0xFF665EC3); //Spi
writer.putInt(0); writer.putInt(0);
if (!mob.nameOverride.isEmpty()) {
writer.putString(mob.nameOverride);
writer.putInt(0);
} else {
writer.putString(mob.firstName); writer.putString(mob.firstName);
writer.putString(mob.lastName); writer.putString(mob.lastName);
}
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
@ -706,10 +707,8 @@ public class Mob extends AbstractIntelligenceAgent {
else if (guardCaptain.getRank() == 6) rank = MBServerStatics.VETERAN; else if (guardCaptain.getRank() == 6) rank = MBServerStatics.VETERAN;
else rank = MBServerStatics.ELITE; else rank = MBServerStatics.ELITE;
if (rank.isEmpty()) mob.firstName = NPC.getPirateName(mob.getMobBaseID());
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + minionType.getName(); mob.lastName = rank + " " + minionType.getRace() + " " + minionType.getName();
else
mob.nameOverride = pirateName + " " + minionType.getRace() + " " + rank + " " + minionType.getName();
} }
} }
@ -717,6 +716,7 @@ public class Mob extends AbstractIntelligenceAgent {
// mob.setMob(); // mob.setMob();
mob.isPlayerGuard = true; mob.isPlayerGuard = true;
DbManager.addToCache(mob); DbManager.addToCache(mob);
RuneBase guardRune = RuneBase.getRuneBase(252621); RuneBase guardRune = RuneBase.getRuneBase(252621);
@ -762,7 +762,8 @@ public class Mob extends AbstractIntelligenceAgent {
mob.spawnTime = 900; mob.spawnTime = 900;
mob.npcOwner = guardCaptain; mob.npcOwner = guardCaptain;
mob.BehaviourType = Enum.MobBehaviourType.GuardMinion; mob.BehaviourType = Enum.MobBehaviourType.GuardMinion;
//add mob to zone set of captain
guardCaptain.getParentZone().zoneMobSet.add(mob);
return mob; return mob;
} }
@ -887,11 +888,6 @@ public class Mob extends AbstractIntelligenceAgent {
this.mana.set(this.manaMax); this.mana.set(this.manaMax);
this.stamina.set(this.staminaMax); this.stamina.set(this.staminaMax);
if (!this.nameOverride.isEmpty())
this.firstName = this.nameOverride;
else
this.firstName = this.mobBase.getFirstName();
if (isPet) if (isPet)
this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks()); this.setObjectTypeMask(MBServerStatics.MASK_PET | this.getTypeMasks());
@ -916,7 +912,10 @@ public class Mob extends AbstractIntelligenceAgent {
this.charItemManager.load(); this.charItemManager.load();
//load AI for general mobs. //load AI for general mobs.
if(this.contract != null && NPC.ISWallArcher(this.contract)){
this.BehaviourType = MobBehaviourType.GuardWallArcher;
this.isPlayerGuard = true;
}
if (isPet || isSiege || (isGuard && this.contract == null)) this.currentID = (--Mob.staticID); if (isPet || isSiege || (isGuard && this.contract == null)) this.currentID = (--Mob.staticID);
else this.currentID = this.dbID; else this.currentID = this.dbID;
@ -1281,7 +1280,6 @@ public class Mob extends AbstractIntelligenceAgent {
public void respawn() { public void respawn() {
//Commenting out Mob ID rotation. //Commenting out Mob ID rotation.
this.despawned = false; this.despawned = false;
this.playerAgroMap.clear(); this.playerAgroMap.clear();
this.setCombatTarget(null); this.setCombatTarget(null);
@ -1300,7 +1298,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.recalculateStats(); this.recalculateStats();
this.setHealth(this.healthMax); this.setHealth(this.healthMax);
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
if (!this.isSiege && !this.isPlayerGuard && contract == null) loadInventory(); if (!this.isSiege && !this.isPlayerGuard && contract == null) loadInventory();
} }
@ -1987,7 +1985,7 @@ public class Mob extends AbstractIntelligenceAgent {
} }
public String getNameOverride() { public String getNameOverride() {
return nameOverride; return firstName + " " + lastName;
} }
public void processUpgradeMob(PlayerCharacter player) { public void processUpgradeMob(PlayerCharacter player) {

28
src/engine/objects/NPC.java

@ -87,7 +87,6 @@ public class NPC extends AbstractCharacter {
public ArrayList<ProducedItem> forgedItems = new ArrayList<>(); public ArrayList<ProducedItem> forgedItems = new ArrayList<>();
public HashMap<Integer, MobEquipment> equip = null; public HashMap<Integer, MobEquipment> equip = null;
private String nameOverride = "";
private int equipmentSetID = 0; private int equipmentSetID = 0;
public int runeSetID = 0; public int runeSetID = 0;
@ -240,8 +239,10 @@ public class NPC extends AbstractCharacter {
if (this.upgradeDateTime != null) if (this.upgradeDateTime != null)
submitUpgradeJob(); submitUpgradeJob();
this.name = this.contract.getName(); this.name = rs.getString("npc_name");
this.nameOverride = rs.getString("npc_name"); if(this.building != null && this.building.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)){
this.name += " the " + this.contract.getName();
}
}catch(Exception e){ }catch(Exception e){
Logger.error(e); Logger.error(e);
@ -620,23 +621,8 @@ public class NPC extends AbstractCharacter {
writer.putInt(0xFF665EC3); //Spi writer.putInt(0xFF665EC3); //Spi
writer.putInt(0); writer.putInt(0);
if (!npc.nameOverride.isEmpty()){ writer.putString(npc.name);
writer.putString(npc.nameOverride); writer.putString("");
writer.putInt(0);
}else
if (npc.contract != null) {
if (npc.contract.isTrainer()) {
writer.putString(npc.name + ", " + npc.contract.getName());
writer.putString("");
} else {
writer.putString(npc.name);
writer.putString(npc.contract.getName());
}
} else {
writer.putString(npc.name);
writer.putString("");
}
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
@ -1473,7 +1459,7 @@ public class NPC extends AbstractCharacter {
} }
public String getNameOverride() { public String getNameOverride() {
return nameOverride; return name;
} }
public static NPCProfits GetNPCProfits(NPC npc){ public static NPCProfits GetNPCProfits(NPC npc){

Loading…
Cancel
Save