forked from MagicBane/Server
147 lines
5.1 KiB
Java
147 lines
5.1 KiB
Java
|
|
package engine.mobileAI.MobBehaviours;
|
||
|
|
|
||
|
|
import engine.Enum;
|
||
|
|
import engine.objects.AbstractWorldObject;
|
||
|
|
import engine.objects.Mob;
|
||
|
|
import engine.objects.PlayerCharacter;
|
||
|
|
import org.pmw.tinylog.Logger;
|
||
|
|
|
||
|
|
public class PlayerGuard {
|
||
|
|
|
||
|
|
public static void run(Mob guard) {
|
||
|
|
|
||
|
|
if(StaticBehaviours.EarlyExit(guard))
|
||
|
|
return;
|
||
|
|
|
||
|
|
if (guard.mobPowers.isEmpty()) {
|
||
|
|
//mele
|
||
|
|
if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardWallArcher)) {
|
||
|
|
GuardWallArcherLogic(guard);
|
||
|
|
} else {
|
||
|
|
if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
|
||
|
|
GuardCaptainLogic(guard);
|
||
|
|
} else if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
||
|
|
GuardMinionLogic(guard);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
//caster
|
||
|
|
if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
|
||
|
|
MagisterCaptainLogic(guard);
|
||
|
|
} else if (guard.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
||
|
|
MagisterMinionLogic(guard);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void GuardCaptainLogic(Mob mob) {
|
||
|
|
|
||
|
|
try {
|
||
|
|
StaticBehaviours.checkToDropGuardAggro(mob);
|
||
|
|
if (mob.getCombatTarget() == null)
|
||
|
|
StaticBehaviours.CheckForPlayerGuardAggro(mob);
|
||
|
|
|
||
|
|
AbstractWorldObject newTarget = StaticBehaviours.ChangeTargetFromHateValue(mob);
|
||
|
|
|
||
|
|
if (newTarget != null) {
|
||
|
|
|
||
|
|
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||
|
|
if (StaticBehaviours.GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
||
|
|
mob.setCombatTarget(newTarget);
|
||
|
|
} else
|
||
|
|
mob.setCombatTarget(newTarget);
|
||
|
|
|
||
|
|
}
|
||
|
|
StaticBehaviours.CheckMobMovement(mob);
|
||
|
|
StaticBehaviours.CheckForAttack(mob);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void GuardMinionLogic(Mob mob) {
|
||
|
|
|
||
|
|
try {
|
||
|
|
StaticBehaviours.checkToDropGuardAggro(mob);
|
||
|
|
|
||
|
|
boolean isComanded = mob.npcOwner.isAlive();
|
||
|
|
if (!isComanded) {
|
||
|
|
GuardCaptainLogic(mob);
|
||
|
|
}else {
|
||
|
|
if (mob.npcOwner.getCombatTarget() != null)
|
||
|
|
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
|
||
|
|
else
|
||
|
|
if (mob.getCombatTarget() != null)
|
||
|
|
mob.setCombatTarget(null);
|
||
|
|
}
|
||
|
|
StaticBehaviours.CheckMobMovement(mob);
|
||
|
|
StaticBehaviours.CheckForAttack(mob);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void GuardWallArcherLogic(Mob mob) {
|
||
|
|
|
||
|
|
try {
|
||
|
|
StaticBehaviours.checkToDropGuardAggro(mob);
|
||
|
|
|
||
|
|
if (mob.getCombatTarget() == null)
|
||
|
|
StaticBehaviours.CheckForPlayerGuardAggro(mob);
|
||
|
|
else
|
||
|
|
StaticBehaviours.CheckForAttack(mob);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardWallArcherLogic" + " " + e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void MagisterCaptainLogic(Mob mob){
|
||
|
|
try {
|
||
|
|
StaticBehaviours.checkToDropGuardAggro(mob);
|
||
|
|
if (mob.getCombatTarget() == null)
|
||
|
|
StaticBehaviours.CheckForPlayerGuardAggro(mob);
|
||
|
|
|
||
|
|
AbstractWorldObject newTarget = StaticBehaviours.ChangeTargetFromHateValue(mob);
|
||
|
|
|
||
|
|
if (newTarget != null) {
|
||
|
|
|
||
|
|
if (newTarget.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||
|
|
if (StaticBehaviours.GuardCanAggro(mob, (PlayerCharacter) newTarget))
|
||
|
|
mob.setCombatTarget(newTarget);
|
||
|
|
} else
|
||
|
|
mob.setCombatTarget(newTarget);
|
||
|
|
|
||
|
|
}
|
||
|
|
StaticBehaviours.CheckMobMovement(mob);
|
||
|
|
CheckForCast(mob);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardCaptainLogic" + " " + e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void MagisterMinionLogic(Mob mob){
|
||
|
|
try {
|
||
|
|
StaticBehaviours.checkToDropGuardAggro(mob);
|
||
|
|
|
||
|
|
boolean isComanded = mob.npcOwner.isAlive();
|
||
|
|
if (!isComanded) {
|
||
|
|
MagisterCaptainLogic(mob);
|
||
|
|
}else {
|
||
|
|
if (mob.npcOwner.getCombatTarget() != null)
|
||
|
|
mob.setCombatTarget(mob.npcOwner.getCombatTarget());
|
||
|
|
else
|
||
|
|
if (mob.getCombatTarget() != null)
|
||
|
|
mob.setCombatTarget(null);
|
||
|
|
}
|
||
|
|
StaticBehaviours.CheckMobMovement(mob);
|
||
|
|
CheckForCast(mob);
|
||
|
|
} catch (Exception e) {
|
||
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardMinionLogic" + " " + e.getMessage());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void CheckForCast(Mob mob){
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|