forked from MagicBane/Server
More siege engine work.
This commit is contained in:
@@ -2846,7 +2846,7 @@ public class Enum {
|
|||||||
//Independent Types
|
//Independent Types
|
||||||
SimpleStandingGuard(null, false, false, false, false, false),
|
SimpleStandingGuard(null, false, false, false, false, false),
|
||||||
Pet1(null, false, false, true, false, false),
|
Pet1(null, false, false, true, false, false),
|
||||||
SiegeEngine(null, false, false, true, false, false),
|
SiegeEngine(null, false, false, false, false, false),
|
||||||
Simple(null, false, false, true, false, false),
|
Simple(null, false, false, true, false, false),
|
||||||
Helpee(null, false, true, true, false, true),
|
Helpee(null, false, true, true, false, true),
|
||||||
HelpeeWimpy(null, true, false, true, false, false),
|
HelpeeWimpy(null, true, false, true, false, false),
|
||||||
@@ -2857,13 +2857,12 @@ public class Enum {
|
|||||||
HamletGuard(null, false, true, false, false, false),
|
HamletGuard(null, false, true, false, false, false),
|
||||||
AggroWanderer(null, false, false, true, false, false);
|
AggroWanderer(null, false, false, true, false, false);
|
||||||
|
|
||||||
private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>();
|
public final MobBehaviourType BehaviourHelperType;
|
||||||
public MobBehaviourType BehaviourHelperType;
|
public final boolean isWimpy;
|
||||||
public boolean isWimpy;
|
public final boolean isAgressive;
|
||||||
public boolean isAgressive;
|
public final boolean canRoam;
|
||||||
public boolean canRoam;
|
public final boolean callsForHelp;
|
||||||
public boolean callsForHelp;
|
public final boolean respondsToCallForHelp;
|
||||||
public boolean respondsToCallForHelp;
|
|
||||||
|
|
||||||
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
|
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
|
||||||
this.BehaviourHelperType = helpeebehaviourType;
|
this.BehaviourHelperType = helpeebehaviourType;
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ public class MobAI {
|
|||||||
int contractID;
|
int contractID;
|
||||||
|
|
||||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion))
|
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion))
|
||||||
contractID = mob.npcOwner.contract.getContractID();
|
contractID = mob.guardCaptain.contract.getContractID();
|
||||||
else
|
else
|
||||||
contractID = mob.contract.getContractID();
|
contractID = mob.contract.getContractID();
|
||||||
|
|
||||||
@@ -609,7 +609,7 @@ public class MobAI {
|
|||||||
if (mob.despawned && mob.isPlayerGuard) {
|
if (mob.despawned && mob.isPlayerGuard) {
|
||||||
|
|
||||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
||||||
if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) {
|
if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) {
|
||||||
|
|
||||||
//minions don't respawn while guard captain is dead
|
//minions don't respawn while guard captain is dead
|
||||||
|
|
||||||
@@ -808,7 +808,7 @@ public class MobAI {
|
|||||||
chaseTarget(mob);
|
chaseTarget(mob);
|
||||||
break;
|
break;
|
||||||
case GuardMinion:
|
case GuardMinion:
|
||||||
if (!mob.npcOwner.isAlive() || ((Mob) mob.npcOwner).despawned)
|
if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned)
|
||||||
randomGuardPatrolPoint(mob);
|
randomGuardPatrolPoint(mob);
|
||||||
else {
|
else {
|
||||||
if (mob.getCombatTarget() != null) {
|
if (mob.getCombatTarget() != null) {
|
||||||
@@ -1055,7 +1055,7 @@ public class MobAI {
|
|||||||
public static void GuardMinionLogic(Mob mob) {
|
public static void GuardMinionLogic(Mob mob) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!mob.npcOwner.isAlive()) {
|
if (!mob.guardCaptain.isAlive()) {
|
||||||
|
|
||||||
if (mob.getCombatTarget() == null) {
|
if (mob.getCombatTarget() == null) {
|
||||||
CheckForPlayerGuardAggro(mob);
|
CheckForPlayerGuardAggro(mob);
|
||||||
@@ -1074,11 +1074,10 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if (mob.npcOwner.getCombatTarget() != null)
|
if (mob.guardCaptain.getCombatTarget() != null)
|
||||||
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
|
mob.setCombatTarget(mob.guardCaptain.getCombatTarget());
|
||||||
else
|
else if (mob.getCombatTarget() != null)
|
||||||
if (mob.getCombatTarget() != null)
|
mob.setCombatTarget(null);
|
||||||
mob.setCombatTarget(null);
|
|
||||||
}
|
}
|
||||||
CheckMobMovement(mob);
|
CheckMobMovement(mob);
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
@@ -1246,7 +1245,7 @@ public class MobAI {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
||||||
if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
|
if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
|
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import engine.Enum;
|
|||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.Enum.ModType;
|
import engine.Enum.ModType;
|
||||||
import engine.Enum.SourceType;
|
import engine.Enum.SourceType;
|
||||||
import engine.mobileAI.Threads.MobAIThread;
|
|
||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.MovementManager;
|
import engine.gameManager.MovementManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
|
import engine.mobileAI.Threads.MobAIThread;
|
||||||
import engine.net.client.msg.MoveToPointMsg;
|
import engine.net.client.msg.MoveToPointMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
@@ -38,7 +38,7 @@ public class MovementUtilities {
|
|||||||
if (agent.getContract() != null)
|
if (agent.getContract() != null)
|
||||||
guardCaptain = agent;
|
guardCaptain = agent;
|
||||||
else
|
else
|
||||||
guardCaptain = (Mob) agent.npcOwner;
|
guardCaptain = (Mob) agent.guardCaptain;
|
||||||
|
|
||||||
if (guardCaptain != null) {
|
if (guardCaptain != null) {
|
||||||
Building barracks = guardCaptain.building;
|
Building barracks = guardCaptain.building;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER))
|
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER))
|
||||||
slot = 2;
|
slot = 2;
|
||||||
else
|
else
|
||||||
slot = ((NPC) siegeMob.npcOwner).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain
|
slot = ((NPC) siegeMob.guardCaptain).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain
|
||||||
|
|
||||||
BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
|
BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
|
||||||
siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation());
|
siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation());
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
|||||||
long timeLife = upgradeTime - curTime;
|
long timeLife = upgradeTime - curTime;
|
||||||
|
|
||||||
if (upgradeTime * 1000 > System.currentTimeMillis()) {
|
if (upgradeTime * 1000 > System.currentTimeMillis()) {
|
||||||
if (mob.npcOwner.isAlive()) {
|
if (mob.guardCaptain.isAlive()) {
|
||||||
writer.put((byte) 0);//shows respawning timer
|
writer.put((byte) 0);//shows respawning timer
|
||||||
writer.putInt(mob.spawnTime);
|
writer.putInt(mob.spawnTime);
|
||||||
writer.putInt(mob.spawnTime);
|
writer.putInt(mob.spawnTime);
|
||||||
@@ -689,7 +689,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
|||||||
long timeLife = upgradeTime - curTime;
|
long timeLife = upgradeTime - curTime;
|
||||||
|
|
||||||
if (upgradeTime * 1000 > System.currentTimeMillis()) {
|
if (upgradeTime * 1000 > System.currentTimeMillis()) {
|
||||||
if (mob.npcOwner.isAlive()) {
|
if (mob.guardCaptain.isAlive()) {
|
||||||
writer.put((byte) 0);//shows respawning timer
|
writer.put((byte) 0);//shows respawning timer
|
||||||
writer.putInt(mob.spawnTime);
|
writer.putInt(mob.spawnTime);
|
||||||
writer.putInt(mob.spawnTime);
|
writer.putInt(mob.spawnTime);
|
||||||
|
|||||||
+32
-34
@@ -61,13 +61,14 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
public Zone parentZone;
|
public Zone parentZone;
|
||||||
public boolean hasLoot = false;
|
public boolean hasLoot = false;
|
||||||
public boolean isPlayerGuard = false;
|
public boolean isPlayerGuard = false;
|
||||||
public AbstractCharacter npcOwner;
|
public AbstractCharacter guardCaptain;
|
||||||
public long deathTime = 0;
|
public long deathTime = 0;
|
||||||
public int equipmentSetID = 0;
|
public int equipmentSetID = 0;
|
||||||
public int runeSet = 0;
|
public int runeSet = 0;
|
||||||
public int bootySet = 0;
|
public int bootySet = 0;
|
||||||
public EnumBitSet<MonsterType> notEnemy;
|
public EnumBitSet<MonsterType> notEnemy = EnumBitSet.noneOf(MonsterType.class);
|
||||||
public EnumBitSet<Enum.MonsterType> enemy;
|
public EnumBitSet<Enum.MonsterType> enemy = EnumBitSet.noneOf(MonsterType.class);
|
||||||
|
;
|
||||||
public MobBehaviourType behaviourType;
|
public MobBehaviourType behaviourType;
|
||||||
public ArrayList<Vector3fImmutable> patrolPoints;
|
public ArrayList<Vector3fImmutable> patrolPoints;
|
||||||
public int lastPatrolPointIndex = 0;
|
public int lastPatrolPointIndex = 0;
|
||||||
@@ -323,7 +324,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
writer.putInt(0); // NPC menu options
|
writer.putInt(0); // NPC menu options
|
||||||
|
|
||||||
if (mob.contract != null && mob.npcOwner == null) {
|
if (mob.contract != null && mob.guardCaptain == null) {
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
writer.putLong(0);
|
writer.putLong(0);
|
||||||
writer.putLong(0);
|
writer.putLong(0);
|
||||||
@@ -336,12 +337,12 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
} else
|
} else
|
||||||
writer.put((byte) 0);
|
writer.put((byte) 0);
|
||||||
|
|
||||||
if (mob.npcOwner != null) {
|
if (mob.guardCaptain != null) {
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||||
writer.putInt(131117009);
|
writer.putInt(131117009);
|
||||||
writer.putInt(mob.npcOwner.getObjectType().ordinal());
|
writer.putInt(mob.guardCaptain.getObjectType().ordinal());
|
||||||
writer.putInt(mob.npcOwner.getObjectUUID());
|
writer.putInt(mob.guardCaptain.getObjectUUID());
|
||||||
writer.putInt(8);
|
writer.putInt(8);
|
||||||
} else
|
} else
|
||||||
writer.put((byte) 0);
|
writer.put((byte) 0);
|
||||||
@@ -618,7 +619,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
minionMobile.notEnemy = guardCaptain.notEnemy;
|
minionMobile.notEnemy = guardCaptain.notEnemy;
|
||||||
|
|
||||||
minionMobile.deathTime = System.currentTimeMillis();
|
minionMobile.deathTime = System.currentTimeMillis();
|
||||||
minionMobile.npcOwner = guardCaptain;
|
minionMobile.guardCaptain = guardCaptain;
|
||||||
minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60;
|
minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60;
|
||||||
minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion;
|
minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion;
|
||||||
minionMobile.isPlayerGuard = true;
|
minionMobile.isPlayerGuard = true;
|
||||||
@@ -651,7 +652,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
// Configure and spawn minion
|
// Configure and spawn minion
|
||||||
|
|
||||||
minionMobile.runAfterLoad();
|
minionMobile.runAfterLoad();
|
||||||
minionMobile.despawned = false;
|
|
||||||
DbManager.addToCache(minionMobile);
|
DbManager.addToCache(minionMobile);
|
||||||
|
|
||||||
minionMobile.setLoc(minionMobile.bindLoc);
|
minionMobile.setLoc(minionMobile.bindLoc);
|
||||||
@@ -665,26 +665,22 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) {
|
public static synchronized Mob createSiegeMob(NPC owner, int loadID, Guild guild, Zone parent, Vector3fImmutable loc, short level) {
|
||||||
|
|
||||||
MobBase minionMobBase;
|
Mob siegeMinion;
|
||||||
Mob mob;
|
|
||||||
|
|
||||||
if (owner.getSiegeMinionMap().size() == 3)
|
if (owner.getSiegeMinionMap().size() == 3)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
minionMobBase = MobBase.getMobBase(loadID);
|
siegeMinion = new Mob();
|
||||||
|
|
||||||
if (minionMobBase == null)
|
siegeMinion.level = 1;
|
||||||
return null;
|
siegeMinion.loadID = loadID;
|
||||||
|
siegeMinion.guildUUID = guild.getObjectUUID();
|
||||||
mob = new Mob(minionMobBase, guild, parent, level, new Vector3fImmutable(1, 1, 1), 0, false);
|
siegeMinion.equipmentSetID = 0;
|
||||||
//mob.runAfterLoad();
|
siegeMinion.buildingUUID = owner.buildingUUID;
|
||||||
mob.despawned = true;
|
siegeMinion.guardCaptain = owner;
|
||||||
DbManager.addToCache(mob);
|
siegeMinion.parentZoneUUID = parent.getObjectUUID();
|
||||||
|
siegeMinion.behaviourType = MobBehaviourType.SiegeEngine;
|
||||||
mob.setObjectTypeMask(MBServerStatics.MASK_MOB | mob.getTypeMasks());
|
siegeMinion.bindLoc = Vector3fImmutable.ZERO;
|
||||||
|
|
||||||
//mob.setMob();
|
|
||||||
// mob.setSiege(true);
|
|
||||||
|
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
|
|
||||||
@@ -693,12 +689,14 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
else if (!owner.getSiegeMinionMap().containsValue(2))
|
else if (!owner.getSiegeMinionMap().containsValue(2))
|
||||||
slot = 2;
|
slot = 2;
|
||||||
|
|
||||||
owner.getSiegeMinionMap().put(mob, slot);
|
owner.getSiegeMinionMap().put(siegeMinion, slot);
|
||||||
|
|
||||||
mob.setNpcOwner(owner);
|
siegeMinion.runAfterLoad();
|
||||||
mob.behaviourType = MobBehaviourType.Pet1;
|
siegeMinion.despawned = true;
|
||||||
mob.behaviourType.canRoam = false;
|
DbManager.addToCache(siegeMinion);
|
||||||
return mob;
|
siegeMinion.setLoc(siegeMinion.bindLoc);
|
||||||
|
|
||||||
|
return siegeMinion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -995,7 +993,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
this.playerAgroMap.clear();
|
this.playerAgroMap.clear();
|
||||||
|
|
||||||
if (this.behaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal())
|
if (this.behaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal())
|
||||||
this.spawnTime = (int) (-2.500 * this.npcOwner.building.getRank() + 22.5) * 60;
|
this.spawnTime = (int) (-2.500 * this.guardCaptain.building.getRank() + 22.5) * 60;
|
||||||
|
|
||||||
if (this.isPet()) {
|
if (this.isPet()) {
|
||||||
|
|
||||||
@@ -1084,8 +1082,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
this.recalculateStats();
|
this.recalculateStats();
|
||||||
this.setHealth(this.healthMax);
|
this.setHealth(this.healthMax);
|
||||||
|
|
||||||
if (this.building == null && this.npcOwner != null && ((Mob) this.npcOwner).behaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal())
|
if (this.building == null && this.guardCaptain != null && ((Mob) this.guardCaptain).behaviourType.ordinal() == MobBehaviourType.GuardCaptain.ordinal())
|
||||||
this.building = this.npcOwner.building;
|
this.building = this.guardCaptain.building;
|
||||||
else if (this.building != null)
|
else if (this.building != null)
|
||||||
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
|
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
|
||||||
|
|
||||||
@@ -1843,8 +1841,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
return this.behaviourType.equals(MobBehaviourType.SiegeEngine);
|
return this.behaviourType.equals(MobBehaviourType.SiegeEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNpcOwner(AbstractCharacter npcOwner) {
|
public void setGuardCaptain(AbstractCharacter guardCaptain) {
|
||||||
this.npcOwner = npcOwner;
|
this.guardCaptain = guardCaptain;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNecroPet() {
|
public boolean isNecroPet() {
|
||||||
|
|||||||
Reference in New Issue
Block a user