|
|
|
@ -58,15 +58,11 @@ public class MobAI {
@@ -58,15 +58,11 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) { |
|
|
|
|
|
|
|
|
|
if (mob.isPlayerGuard() == false && MobCast(mob)) { |
|
|
|
|
if (MobCast(mob)) { |
|
|
|
|
mob.updateLocation(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mob.isPlayerGuard() == true && GuardCast(mob)) { |
|
|
|
|
mob.updateLocation(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!CombatUtilities.inRangeToAttack(mob, target)) |
|
|
|
@ -412,10 +408,13 @@ public class MobAI {
@@ -412,10 +408,13 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
// Pick random spell from our list of powers
|
|
|
|
|
|
|
|
|
|
int powerToken = powerEntries.get(ThreadLocalRandom.current().nextInt(powerEntries.size())).token; |
|
|
|
|
int powerRank = powerEntries.get(ThreadLocalRandom.current().nextInt(powerEntries.size())).rank; |
|
|
|
|
RunePowerEntry runePowerEntry = powerEntries.get(ThreadLocalRandom.current().nextInt(powerEntries.size())); |
|
|
|
|
|
|
|
|
|
PowersBase mobPower = PowersManager.getPowerByToken(runePowerEntry.token); |
|
|
|
|
int powerRank = runePowerEntry.rank; |
|
|
|
|
|
|
|
|
|
PowersBase mobPower = PowersManager.getPowerByToken(powerToken); |
|
|
|
|
if (mob.isPlayerGuard()) |
|
|
|
|
powerRank = getGuardPowerRank(mob); |
|
|
|
|
|
|
|
|
|
//check for hit-roll
|
|
|
|
|
|
|
|
|
@ -451,72 +450,7 @@ public class MobAI {
@@ -451,72 +450,7 @@ public class MobAI {
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean GuardCast(Mob mob) { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// Method picks a random spell from a mobile's list of powers
|
|
|
|
|
// and casts it on the current target (or itself). Validation
|
|
|
|
|
// (including empty lists) is done previously within canCast();
|
|
|
|
|
|
|
|
|
|
ArrayList<RunePowerEntry> powerEntries; |
|
|
|
|
ArrayList<RunePowerEntry> purgeEntries; |
|
|
|
|
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); |
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.callsForHelp) |
|
|
|
|
MobCallForHelp(mob); |
|
|
|
|
|
|
|
|
|
// If player has this effect on them currently then remove
|
|
|
|
|
// this token from our list.
|
|
|
|
|
|
|
|
|
|
powerEntries = new ArrayList<>(PowersManager.getPowersForRune(mob.getMobBaseID())); |
|
|
|
|
purgeEntries = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// Additional powers may come from the contract ID. This is to support
|
|
|
|
|
// powers for player guards irrespective of the mobbase used.
|
|
|
|
|
|
|
|
|
|
if (mob.isPlayerGuard()) { |
|
|
|
|
|
|
|
|
|
ArrayList<RunePowerEntry> contractEntries = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
if (mob.contract != null) |
|
|
|
|
contractEntries = PowersManager.getPowersForRune(mob.contractUUID); |
|
|
|
|
|
|
|
|
|
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION)) |
|
|
|
|
contractEntries = PowersManager.getPowersForRune(mob.guardCaptain.contractUUID); |
|
|
|
|
|
|
|
|
|
powerEntries.addAll(contractEntries); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// If player has this effect on them currently then remove
|
|
|
|
|
// this token from our list.
|
|
|
|
|
|
|
|
|
|
for (RunePowerEntry runePowerEntry : powerEntries) { |
|
|
|
|
|
|
|
|
|
PowersBase powerBase = PowersManager.getPowerByToken(runePowerEntry.token); |
|
|
|
|
|
|
|
|
|
for (ActionsBase actionBase : powerBase.getActions()) { |
|
|
|
|
|
|
|
|
|
String stackType = actionBase.stackType; |
|
|
|
|
|
|
|
|
|
if (target.getEffects() != null && target.getEffects().containsKey(stackType)) |
|
|
|
|
purgeEntries.add(runePowerEntry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
powerEntries.removeAll(purgeEntries); |
|
|
|
|
|
|
|
|
|
// Sanity check
|
|
|
|
|
|
|
|
|
|
if (powerEntries.isEmpty()) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
int powerToken = 0; |
|
|
|
|
|
|
|
|
|
// Choose a random spell.
|
|
|
|
|
|
|
|
|
|
powerToken = powerEntries.get(ThreadLocalRandom.current().nextInt(powerEntries.size())).token; |
|
|
|
|
|
|
|
|
|
private static int getGuardPowerRank(Mob mob) { |
|
|
|
|
int powerRank = 1; |
|
|
|
|
|
|
|
|
|
switch (mob.getRank()) { |
|
|
|
@ -542,47 +476,7 @@ public class MobAI {
@@ -542,47 +476,7 @@ public class MobAI {
|
|
|
|
|
powerRank = 40; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PowersBase mobPower = PowersManager.getPowerByToken(powerToken); |
|
|
|
|
|
|
|
|
|
//check for hit-roll
|
|
|
|
|
|
|
|
|
|
if (mobPower.requiresHitRoll) |
|
|
|
|
if (CombatUtilities.triggerDefense(mob, mob.getCombatTarget())) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
// Cast the spell
|
|
|
|
|
|
|
|
|
|
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mobPower.getRange())) { |
|
|
|
|
|
|
|
|
|
PerformActionMsg msg; |
|
|
|
|
|
|
|
|
|
if (!mobPower.isHarmful() || mobPower.targetSelf) { |
|
|
|
|
|
|
|
|
|
if (mobPower.category.equals("DISPEL")) { |
|
|
|
|
PowersManager.useMobPower(mob, target, mobPower, powerRank); |
|
|
|
|
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target); |
|
|
|
|
} else { |
|
|
|
|
PowersManager.useMobPower(mob, mob, mobPower, powerRank); |
|
|
|
|
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, mob); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
PowersManager.useMobPower(mob, target, mobPower, powerRank); |
|
|
|
|
msg = PowersManager.createPowerMsg(mobPower, powerRank, mob, target); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
msg.setUnknown04(2); |
|
|
|
|
|
|
|
|
|
PowersManager.finishUseMobPower(msg, mob, 0, 0); |
|
|
|
|
|
|
|
|
|
long randomCooldown = (long)((ThreadLocalRandom.current().nextInt(10,15) * 1000) * MobAIThread.AI_CAST_FREQUENCY); |
|
|
|
|
mob.nextCastTime = System.currentTimeMillis() + randomCooldown; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: MobCast" + " " + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
return powerRank; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void MobCallForHelp(Mob mob) { |
|
|
|
|