Browse Source

refactored mob get/set owner

combat-2
FatBoy-DOTC 1 year ago
parent
commit
d573b238de
  1. 4
      src/engine/devcmd/cmds/InfoCmd.java
  2. 12
      src/engine/gameManager/NPCManager.java
  3. 19
      src/engine/mobileAI/MobAI.java
  4. 14
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java
  5. 5
      src/engine/objects/AbstractIntelligenceAgent.java
  6. 4
      src/engine/objects/AbstractWorldObject.java
  7. 44
      src/engine/objects/Mob.java
  8. 6
      src/engine/objects/NPC.java
  9. 3
      src/engine/objects/PlayerCharacter.java
  10. 8
      src/engine/powers/poweractions/CreateMobPowerAction.java

4
src/engine/devcmd/cmds/InfoCmd.java

@ -440,7 +440,9 @@ public class InfoCmd extends AbstractDevCmd { @@ -440,7 +440,9 @@ public class InfoCmd extends AbstractDevCmd {
output += "isSummonedPet: true";
else
output += "isSummonedPet: false";
PlayerCharacter owner = targetMob.getOwner();
PlayerCharacter owner = (PlayerCharacter) targetMob.guardCaptain;
if (owner != null)
output += " owner: " + owner.getObjectUUID();
output += newline;

12
src/engine/gameManager/NPCManager.java

@ -127,10 +127,12 @@ public enum NPCManager { @@ -127,10 +127,12 @@ public enum NPCManager {
DbManager.removeFromCache(necroPet);
PlayerCharacter petOwner = necroPet.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) necroPet.guardCaptain;
if (petOwner != null) {
necroPet.setOwner(null);
necroPet.guardCaptain = null;
petOwner.setPet(null);
if (updateOwner == false)
@ -228,12 +230,14 @@ public enum NPCManager { @@ -228,12 +230,14 @@ public enum NPCManager {
WorldGrid.removeObject(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);

19
src/engine/mobileAI/MobAI.java

@ -786,24 +786,30 @@ public class MobAI { @@ -786,24 +786,30 @@ public class MobAI {
switch (mob.behaviourType) {
case Pet1:
if (mob.getOwner() == null)
if ((PlayerCharacter) mob.guardCaptain == null)
return;
if (!mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID())) {
if (!mob.playerAgroMap.containsKey(((PlayerCharacter) mob.guardCaptain).getObjectUUID())) {
//mob no longer has its owner loaded, translocate pet to owner
MovementManager.translocate(mob, mob.getOwner().getLoc(), null);
MovementManager.translocate(mob, ((PlayerCharacter) mob.guardCaptain).getLoc(), null);
return;
}
if (mob.getCombatTarget() == null) {
//move back to owner
if (CombatUtilities.inRange2D(mob, mob.getOwner(), 6))
if (CombatUtilities.inRange2D(mob, (PlayerCharacter) mob.guardCaptain, 6))
return;
mob.destination = mob.getOwner().getLoc();
mob.destination = ((PlayerCharacter) mob.guardCaptain).getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 5);
} else
chaseTarget(mob);
@ -1103,7 +1109,8 @@ public class MobAI { @@ -1103,7 +1109,8 @@ public class MobAI {
try {
if (mob.getOwner() == null && mob.isNecroPet() == false && mob.isSiege() == false)
if ((PlayerCharacter) mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false)
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner");

14
src/engine/net/client/handlers/MinionTrainingMsgHandler.java

@ -73,11 +73,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -73,11 +73,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
@ -195,11 +198,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { @@ -195,11 +198,14 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
toRemove.getParentZone().zoneMobSet.remove(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);

5
src/engine/objects/AbstractIntelligenceAgent.java

@ -101,7 +101,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { @@ -101,7 +101,8 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
this.agentType = Enum.AIAgentType.CHARMED;
if (this.getObjectType().equals(GameObjectType.Mob)) {
((Mob) this).setOwner(owner);
((Mob) this).guardCaptain = owner;
}
}
@ -180,7 +181,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { @@ -180,7 +181,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
owner.setPet(null);
if (this.getObjectType().equals(GameObjectType.Mob))
((Mob) this).setOwner(null);
((Mob) this).guardCaptain = null;
}

4
src/engine/objects/AbstractWorldObject.java

@ -357,7 +357,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject { @@ -357,7 +357,9 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
Mob mob = (Mob) this;
if (mob.isSiege()) {
if (mob.isPet()) {
PlayerCharacter petOwner = mob.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) mob.guardCaptain;
if (petOwner != null && source.equals(EffectSourceType.Effect)) {
petOwner.dismissPet();
return;

44
src/engine/objects/Mob.java

@ -316,9 +316,14 @@ public class Mob extends AbstractIntelligenceAgent { @@ -316,9 +316,14 @@ public class Mob extends AbstractIntelligenceAgent {
writer.put((byte) 1);
if (mob.getOwner() != null) {
writer.putInt(mob.getOwner().getObjectType().ordinal());
writer.putInt(mob.getOwner().getObjectUUID());
if ((PlayerCharacter) mob.guardCaptain != null) {
writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectType().ordinal());
writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectUUID());
} else {
writer.putInt(0); //ownerType
writer.putInt(0); //ownerID
@ -732,17 +737,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -732,17 +737,6 @@ public class Mob extends AbstractIntelligenceAgent {
return this.guild.getObjectUUID();
}
public PlayerCharacter getOwner() {
return (PlayerCharacter) this.guardCaptain;
}
public void setOwner(PlayerCharacter value) {
this.guardCaptain = value;
}
public void setFearedObject(AbstractWorldObject awo) {
this.fearedObject = awo;
}
@ -751,7 +745,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -751,7 +745,7 @@ public class Mob extends AbstractIntelligenceAgent {
public Vector3fImmutable getBindLoc() {
if (this.isPet() && !this.behaviourType.equals(MobBehaviourType.SiegeEngine))
return this.getOwner() != null ? this.getOwner().getLoc() : this.getLoc();
return (PlayerCharacter) this.guardCaptain != null ? ((PlayerCharacter) this.guardCaptain).getLoc() : this.getLoc();
else
return this.bindLoc;
}
@ -875,7 +869,8 @@ public class Mob extends AbstractIntelligenceAgent { @@ -875,7 +869,8 @@ public class Mob extends AbstractIntelligenceAgent {
if (mobAttacker.isPet()) {
PlayerCharacter owner = mobAttacker.getOwner();
PlayerCharacter owner = (PlayerCharacter) mobAttacker.guardCaptain;
if (owner != null)
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard) {
@ -945,13 +940,17 @@ public class Mob extends AbstractIntelligenceAgent { @@ -945,13 +940,17 @@ public class Mob extends AbstractIntelligenceAgent {
if (this.isPet()) {
PlayerCharacter petOwner = this.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain;
if (petOwner != null) {
this.setOwner(null);
this.guardCaptain = null;
petOwner.setPet(null);
PetMsg petMsg = new PetMsg(5, null);
dispatch = Dispatch.borrow(this.getOwner(), petMsg);
dispatch = Dispatch.borrow((PlayerCharacter) this.guardCaptain, petMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
}
}
@ -974,10 +973,13 @@ public class Mob extends AbstractIntelligenceAgent { @@ -974,10 +973,13 @@ public class Mob extends AbstractIntelligenceAgent {
WorldGrid.RemoveWorldObject(this);
DbManager.removeFromCache(this);
PlayerCharacter petOwner = this.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) this.guardCaptain;
if (petOwner != null) {
this.setOwner(null);
this.guardCaptain = null;
petOwner.setPet(null);
PetMsg petMsg = new PetMsg(5, null);
dispatch = Dispatch.borrow(petOwner, petMsg);

6
src/engine/objects/NPC.java

@ -655,12 +655,14 @@ public class NPC extends AbstractCharacter { @@ -655,12 +655,14 @@ public class NPC extends AbstractCharacter {
WorldGrid.RemoveWorldObject(toRemove);
DbManager.removeFromCache(toRemove);
PlayerCharacter petOwner = toRemove.getOwner();
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
if (petOwner != null) {
petOwner.setPet(null);
toRemove.setOwner(null);
toRemove.guardCaptain = null;
PetMsg petMsg = new PetMsg(5, null);
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);

3
src/engine/objects/PlayerCharacter.java

@ -4690,7 +4690,8 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4690,7 +4690,8 @@ public class PlayerCharacter extends AbstractCharacter {
} else if (currentPet.isSiege()) {
currentPet.agentType = AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
WorldGrid.updateObject(currentPet);

8
src/engine/powers/poweractions/CreateMobPowerAction.java

@ -94,7 +94,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -94,7 +94,8 @@ public class CreateMobPowerAction extends AbstractPowerAction {
} else if (currentPet != null && currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())
@ -110,7 +111,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -110,7 +111,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
DbManager.removeFromCache(currentPet);
currentPet.setCombatTarget(null);
currentPet.setOwner(null);
currentPet.guardCaptain = null;
WorldGrid.RemoveWorldObject(currentPet);
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet);
@ -120,7 +121,8 @@ public class CreateMobPowerAction extends AbstractPowerAction { @@ -120,7 +121,8 @@ public class CreateMobPowerAction extends AbstractPowerAction {
} else {
if (currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.setOwner(null);
currentPet.guardCaptain = null;
currentPet.setCombatTarget(null);
if (currentPet.isAlive())

Loading…
Cancel
Save