Compare commits
17 Commits
5eb6302d2a
...
bdf6500260
| Author | SHA1 | Date | |
|---|---|---|---|
| bdf6500260 | |||
| db4eb0579e | |||
| 76f33534d4 | |||
| 39fea5bc2f | |||
| 660d5c1270 | |||
| 781e2fc9b2 | |||
| c2a2464fe8 | |||
| beb3c15eb3 | |||
| 553010bb7b | |||
| 8d12bbf453 | |||
| fa7588826a | |||
| 332f191e19 | |||
| 8151382a6b | |||
| ae44a21be1 | |||
| b0ff0995de | |||
| e711095ecd | |||
| 08de97a2a8 |
@@ -144,7 +144,7 @@ public enum CombatManager {
|
|||||||
|
|
||||||
City playerCity = ZoneManager.getCityAtLocation(playerCharacter.getLoc());
|
City playerCity = ZoneManager.getCityAtLocation(playerCharacter.getLoc());
|
||||||
|
|
||||||
if (playerCity != null && playerCity.getGuild().getNation().equals(playerCharacter.getGuild().getNation()) == false && playerCity.cityOutlaws.contains(playerCharacter.getObjectUUID()) == false)
|
if (playerCity != null && playerCity.cityOutlaws.contains(playerCharacter.getObjectUUID()) == false)
|
||||||
playerCity.cityOutlaws.add(playerCharacter.getObjectUUID());
|
playerCity.cityOutlaws.add(playerCharacter.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -252,18 +252,21 @@ public class MobAI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
//make sure mob is out of combat stance
|
|
||||||
|
|
||||||
int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobAIThread.AI_PATROL_DIVISOR * 0.5f), MobAIThread.AI_PATROL_DIVISOR) + MobAIThread.AI_PATROL_DIVISOR;
|
int patrolDelay = ThreadLocalRandom.current().nextInt((int) (MobAIThread.AI_PATROL_DIVISOR * 0.5f), MobAIThread.AI_PATROL_DIVISOR) + MobAIThread.AI_PATROL_DIVISOR;
|
||||||
|
|
||||||
//early exit while waiting to patrol again
|
// early exit while waiting to patrol again.
|
||||||
|
// Minions are force marched if captain is alive
|
||||||
|
|
||||||
|
boolean forced = mob.agentType.equals(Enum.AIAgentType.GUARDMINION) &&
|
||||||
|
mob.guardCaptain.isAlive();
|
||||||
|
|
||||||
if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis())
|
if (mob.stopPatrolTime + (patrolDelay * 1000) > System.currentTimeMillis())
|
||||||
return;
|
if (!forced)
|
||||||
|
return;
|
||||||
|
|
||||||
//guard captains inherit barracks patrol points dynamically
|
//guards inherit barracks patrol points dynamically
|
||||||
|
|
||||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) {
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN) || mob.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||||
|
|
||||||
Building barracks = mob.building;
|
Building barracks = mob.building;
|
||||||
|
|
||||||
@@ -278,28 +281,28 @@ public class MobAI {
|
|||||||
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1)
|
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1)
|
||||||
mob.lastPatrolPointIndex = 0;
|
mob.lastPatrolPointIndex = 0;
|
||||||
|
|
||||||
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
|
// Minions are given marching orders by the captain if he is alive
|
||||||
mob.lastPatrolPointIndex += 1;
|
|
||||||
|
|
||||||
MovementUtilities.aiMove(mob, mob.destination, true);
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION) && mob.guardCaptain.isAlive()) {
|
||||||
|
Mob captain = (Mob) mob.guardCaptain;
|
||||||
|
mob.destination = captain.destination.add(Formation.getOffset(2, mob.guardCaptain.minions.indexOf(mob.getObjectUUID()) + 3));
|
||||||
|
mob.lastPatrolPointIndex = captain.lastPatrolPointIndex;
|
||||||
|
} else {
|
||||||
|
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
|
||||||
|
mob.lastPatrolPointIndex += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Captain orders minions to patrol
|
||||||
|
|
||||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
||||||
for (Integer minionUUUD : mob.minions) {
|
for (Integer minionUUID : mob.minions) {
|
||||||
|
Mob minion = Mob.getMob(minionUUID);
|
||||||
Mob minion = Mob.getMob(minionUUUD);
|
if (minion.isAlive() && minion.combatTarget == null)
|
||||||
|
MobAI.Patrol(minion);
|
||||||
//make sure mob is out of combat stance
|
|
||||||
|
|
||||||
if (minion.despawned == false) {
|
|
||||||
if (MovementUtilities.canMove(minion)) {
|
|
||||||
Vector3f minionOffset = Formation.getOffset(2, mob.minions.indexOf(minionUUUD) + 3);
|
|
||||||
minion.updateLocation();
|
|
||||||
Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z);
|
|
||||||
MovementUtilities.aiMove(minion, formationPatrolPoint, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MovementUtilities.aiMove(mob, mob.destination, true);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackTarget" + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -609,10 +612,8 @@ public class MobAI {
|
|||||||
|
|
||||||
switch (mob.behaviourType) {
|
switch (mob.behaviourType) {
|
||||||
case GuardCaptain:
|
case GuardCaptain:
|
||||||
GuardCaptainLogic(mob);
|
|
||||||
break;
|
|
||||||
case GuardMinion:
|
case GuardMinion:
|
||||||
GuardMinionLogic(mob);
|
GuardLogic(mob);
|
||||||
break;
|
break;
|
||||||
case GuardWallArcher:
|
case GuardWallArcher:
|
||||||
GuardWallArcherLogic(mob);
|
GuardWallArcherLogic(mob);
|
||||||
@@ -682,7 +683,6 @@ public class MobAI {
|
|||||||
aiAgent.setCombatTarget(loadedPlayer);
|
aiAgent.setCombatTarget(loadedPlayer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aiAgent.getCombatTarget() == null) {
|
if (aiAgent.getCombatTarget() == null) {
|
||||||
@@ -721,49 +721,41 @@ public class MobAI {
|
|||||||
|
|
||||||
case Pet1:
|
case Pet1:
|
||||||
|
|
||||||
|
|
||||||
if (mob.guardCaptain == null)
|
if (mob.guardCaptain == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//mob no longer has its owner loaded, translate pet to owner
|
||||||
|
|
||||||
if (!mob.playerAgroMap.containsKey(mob.guardCaptain.getObjectUUID())) {
|
if (!mob.playerAgroMap.containsKey(mob.guardCaptain.getObjectUUID())) {
|
||||||
|
|
||||||
//mob no longer has its owner loaded, translocate pet to owner
|
|
||||||
|
|
||||||
|
|
||||||
MovementManager.translocate(mob, mob.guardCaptain.getLoc(), null);
|
MovementManager.translocate(mob, mob.guardCaptain.getLoc(), null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mob.getCombatTarget() == null) {
|
if (mob.getCombatTarget() == null) {
|
||||||
|
|
||||||
//move back to owner
|
//move back to owner
|
||||||
|
|
||||||
|
|
||||||
if (CombatUtilities.inRange2D(mob, mob.guardCaptain, 6))
|
if (CombatUtilities.inRange2D(mob, mob.guardCaptain, 6))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
mob.destination = mob.guardCaptain.getLoc();
|
mob.destination = mob.guardCaptain.getLoc();
|
||||||
MovementUtilities.moveToLocation(mob, mob.destination, 5);
|
MovementUtilities.moveToLocation(mob, mob.destination, 5);
|
||||||
} else
|
} else
|
||||||
chaseTarget(mob);
|
chaseTarget(mob);
|
||||||
break;
|
break;
|
||||||
case GuardMinion:
|
|
||||||
if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned)
|
|
||||||
randomGuardPatrolPoint(mob);
|
|
||||||
else {
|
|
||||||
if (mob.getCombatTarget() != null) {
|
|
||||||
chaseTarget(mob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
if (mob.getCombatTarget() == null) {
|
if (mob.getCombatTarget() == null) {
|
||||||
if (!mob.isMoving())
|
|
||||||
Patrol(mob);
|
if (!mob.isMoving()) {
|
||||||
else {
|
|
||||||
|
// Minions only patrol on their own if captain is dead.
|
||||||
|
|
||||||
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION) == false)
|
||||||
|
Patrol(mob);
|
||||||
|
else if (mob.guardCaptain.isAlive() == false)
|
||||||
|
Patrol(mob);
|
||||||
|
} else
|
||||||
mob.stopPatrolTime = System.currentTimeMillis();
|
mob.stopPatrolTime = System.currentTimeMillis();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
chaseTarget(mob);
|
chaseTarget(mob);
|
||||||
}
|
}
|
||||||
@@ -851,15 +843,6 @@ public class MobAI {
|
|||||||
private static void CheckToSendMobHome(Mob mob) {
|
private static void CheckToSendMobHome(Mob mob) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mob.behaviourType.isAgressive) {
|
|
||||||
|
|
||||||
if (mob.isPlayerGuard()) {
|
|
||||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
|
||||||
CheckForPlayerGuardAggro(mob);
|
|
||||||
} else {
|
|
||||||
CheckForAggro(mob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f))
|
if (mob.getCombatTarget() != null && CombatUtilities.inRange2D(mob, mob.getCombatTarget(), MobAIThread.AI_BASE_AGGRO_RANGE * 0.5f))
|
||||||
return;
|
return;
|
||||||
@@ -904,13 +887,7 @@ public class MobAI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
float rangeSquared = mob.getRange() * mob.getRange();
|
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
|
||||||
float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc());
|
|
||||||
|
|
||||||
if (mob.isMoving() == true && distanceSquared < rangeSquared - 50) {
|
|
||||||
mob.destination = mob.getLoc();
|
|
||||||
MovementUtilities.moveToLocation(mob, mob.destination, 0);
|
|
||||||
} else if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
|
|
||||||
if (mob.getRange() > 15) {
|
if (mob.getRange() > 15) {
|
||||||
mob.destination = mob.getCombatTarget().getLoc();
|
mob.destination = mob.getCombatTarget().getLoc();
|
||||||
MovementUtilities.moveToLocation(mob, mob.destination, 0);
|
MovementUtilities.moveToLocation(mob, mob.destination, 0);
|
||||||
@@ -970,7 +947,7 @@ public class MobAI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GuardCaptainLogic(Mob mob) {
|
public static void GuardLogic(Mob mob) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mob.getCombatTarget() == null)
|
if (mob.getCombatTarget() == null)
|
||||||
@@ -991,33 +968,7 @@ public class MobAI {
|
|||||||
CheckMobMovement(mob);
|
CheckMobMovement(mob);
|
||||||
CheckForAttack(mob);
|
CheckForAttack(mob);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage());
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void GuardMinionLogic(Mob mob) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (mob.getCombatTarget() == null)
|
|
||||||
CheckForPlayerGuardAggro(mob);
|
|
||||||
|
|
||||||
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
|
|
||||||
|
|
||||||
if (newTarget != null) {
|
|
||||||
|
|
||||||
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
|
||||||
if (GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
|
||||||
mob.setCombatTarget(newTarget);
|
|
||||||
} else
|
|
||||||
mob.setCombatTarget(newTarget);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckMobMovement(mob);
|
|
||||||
CheckForAttack(mob);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1037,7 +988,6 @@ public class MobAI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false)
|
if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false)
|
||||||
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
|
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
|
||||||
mob.killCharacter("no owner");
|
mob.killCharacter("no owner");
|
||||||
@@ -1186,12 +1136,12 @@ public class MobAI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mob.guardedCity.cityOutlaws.contains(target.getObjectUUID()) == true)
|
if (mob.guardedCity.cityOutlaws.contains(target.getObjectUUID()) == true)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
|
||||||
|
return false;
|
||||||
|
|
||||||
//first check condemn list for aggro allowed (allies button is checked)
|
//first check condemn list for aggro allowed (allies button is checked)
|
||||||
|
|
||||||
if (ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().reverseKOS) {
|
if (ZoneManager.getCityAtLocation(mob.getLoc()).getTOL().reverseKOS) {
|
||||||
|
|||||||
@@ -163,7 +163,9 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
|||||||
this.setCombatTarget(null);
|
this.setCombatTarget(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//clear owner
|
// clear owner and set not alive
|
||||||
|
|
||||||
|
this.isAlive.set(false);
|
||||||
|
|
||||||
PlayerCharacter owner = (PlayerCharacter) this.guardCaptain;
|
PlayerCharacter owner = (PlayerCharacter) this.guardCaptain;
|
||||||
|
|
||||||
@@ -181,7 +183,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
|||||||
owner.setPet(null);
|
owner.setPet(null);
|
||||||
|
|
||||||
if (this.getObjectType().equals(GameObjectType.Mob))
|
if (this.getObjectType().equals(GameObjectType.Mob))
|
||||||
((Mob) this).guardCaptain = null;
|
this.guardCaptain = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user