|
|
|
@ -22,6 +22,7 @@ import engine.net.client.msg.PerformActionMsg;
@@ -22,6 +22,7 @@ import engine.net.client.msg.PerformActionMsg;
|
|
|
|
|
import engine.net.client.msg.PowerProjectileMsg; |
|
|
|
|
import engine.objects.*; |
|
|
|
|
import engine.powers.ActionsBase; |
|
|
|
|
import engine.powers.MobPowerEntry; |
|
|
|
|
import engine.powers.PowersBase; |
|
|
|
|
import engine.server.MBServerStatics; |
|
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
@ -321,7 +322,7 @@ public class MobAI {
@@ -321,7 +322,7 @@ public class MobAI {
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mob.mobPowers.isEmpty()) |
|
|
|
|
if (PowersManager.getPowersForMobile(mob).isEmpty()) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) { |
|
|
|
@ -346,8 +347,8 @@ public class MobAI {
@@ -346,8 +347,8 @@ public class MobAI {
|
|
|
|
|
// and casts it on the current target (or itself). Validation
|
|
|
|
|
// (including empty lists) is done previously within canCast();
|
|
|
|
|
|
|
|
|
|
ArrayList<Integer> powerTokens; |
|
|
|
|
ArrayList<Integer> purgeTokens; |
|
|
|
|
ArrayList<MobPowerEntry> powerEntries; |
|
|
|
|
ArrayList<MobPowerEntry> purgeEntries; |
|
|
|
|
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); |
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.callsForHelp) |
|
|
|
@ -355,36 +356,36 @@ public class MobAI {
@@ -355,36 +356,36 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
// Generate a list of tokens from the mob powers for this mobile.
|
|
|
|
|
|
|
|
|
|
powerTokens = new ArrayList<>(mob.mobPowers.keySet()); |
|
|
|
|
purgeTokens = new ArrayList<>(); |
|
|
|
|
powerEntries = new ArrayList<>(PowersManager.getPowersForMobile(mob)); |
|
|
|
|
purgeEntries = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// If player has this effect on them currently then remove
|
|
|
|
|
// this token from our list.
|
|
|
|
|
|
|
|
|
|
for (int powerToken : powerTokens) { |
|
|
|
|
for (MobPowerEntry mobPowerEntry : powerEntries) { |
|
|
|
|
|
|
|
|
|
PowersBase powerBase = PowersManager.getPowerByToken(powerToken); |
|
|
|
|
PowersBase powerBase = PowersManager.getPowerByToken(mobPowerEntry.token); |
|
|
|
|
|
|
|
|
|
for (ActionsBase actionBase : powerBase.getActions()) { |
|
|
|
|
|
|
|
|
|
String stackType = actionBase.stackType; |
|
|
|
|
|
|
|
|
|
if (target.getEffects() != null && target.getEffects().containsKey(stackType)) |
|
|
|
|
purgeTokens.add(powerToken); |
|
|
|
|
purgeEntries.add(mobPowerEntry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
powerTokens.removeAll(purgeTokens); |
|
|
|
|
powerEntries.removeAll(purgeEntries); |
|
|
|
|
|
|
|
|
|
// Sanity check
|
|
|
|
|
|
|
|
|
|
if (powerTokens.isEmpty()) |
|
|
|
|
if (powerEntries.isEmpty()) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
// Pick random spell from our list of powers
|
|
|
|
|
|
|
|
|
|
int powerToken = powerTokens.get(ThreadLocalRandom.current().nextInt(powerTokens.size())); |
|
|
|
|
int powerRank = mob.mobPowers.get(powerToken); |
|
|
|
|
int powerToken = powerEntries.get(ThreadLocalRandom.current().nextInt(powerEntries.size())).token; |
|
|
|
|
int powerRank = powerEntries.get(ThreadLocalRandom.current().nextInt(powerEntries.size())).rank; |
|
|
|
|
|
|
|
|
|
PowersBase mobPower = PowersManager.getPowerByToken(powerToken); |
|
|
|
|
|
|
|
|
@ -429,8 +430,8 @@ public class MobAI {
@@ -429,8 +430,8 @@ public class MobAI {
|
|
|
|
|
// and casts it on the current target (or itself). Validation
|
|
|
|
|
// (including empty lists) is done previously within canCast();
|
|
|
|
|
|
|
|
|
|
ArrayList<Integer> powerTokens; |
|
|
|
|
ArrayList<Integer> purgeTokens; |
|
|
|
|
ArrayList<MobPowerEntry> powerEntries; |
|
|
|
|
ArrayList<MobPowerEntry> purgeEntries; |
|
|
|
|
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); |
|
|
|
|
|
|
|
|
|
if (mob.behaviourType.callsForHelp) |
|
|
|
@ -438,30 +439,36 @@ public class MobAI {
@@ -438,30 +439,36 @@ public class MobAI {
|
|
|
|
|
|
|
|
|
|
// Generate a list of tokens from the mob powers for this mobile.
|
|
|
|
|
|
|
|
|
|
powerTokens = new ArrayList<>(mob.mobPowers.keySet()); |
|
|
|
|
purgeTokens = new ArrayList<>(); |
|
|
|
|
powerEntries = PowersManager.getPowersForMobile(mob); |
|
|
|
|
purgeEntries = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// If player has this effect on them currently then remove
|
|
|
|
|
// this token from our list.
|
|
|
|
|
|
|
|
|
|
for (int powerToken : powerTokens) { |
|
|
|
|
powerEntries = new ArrayList<>(PowersManager.getPowersForMobile(mob)); |
|
|
|
|
purgeEntries = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
PowersBase powerBase = PowersManager.getPowerByToken(powerToken); |
|
|
|
|
// If player has this effect on them currently then remove
|
|
|
|
|
// this token from our list.
|
|
|
|
|
|
|
|
|
|
for (MobPowerEntry mobPowerEntry : powerEntries) { |
|
|
|
|
|
|
|
|
|
PowersBase powerBase = PowersManager.getPowerByToken(mobPowerEntry.token); |
|
|
|
|
|
|
|
|
|
for (ActionsBase actionBase : powerBase.getActions()) { |
|
|
|
|
|
|
|
|
|
String stackType = actionBase.stackType; |
|
|
|
|
|
|
|
|
|
if (target.getEffects() != null && target.getEffects().containsKey(stackType)) |
|
|
|
|
purgeTokens.add(powerToken); |
|
|
|
|
purgeEntries.add(mobPowerEntry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
powerTokens.removeAll(purgeTokens); |
|
|
|
|
powerEntries.removeAll(purgeEntries); |
|
|
|
|
|
|
|
|
|
// Sanity check
|
|
|
|
|
|
|
|
|
|
if (powerTokens.isEmpty()) |
|
|
|
|
if (powerEntries.isEmpty()) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
int powerToken = 0; |
|
|
|
@ -470,11 +477,11 @@ public class MobAI {
@@ -470,11 +477,11 @@ public class MobAI {
|
|
|
|
|
if (nukeRoll < 55) { |
|
|
|
|
|
|
|
|
|
//use direct damage spell
|
|
|
|
|
powerToken = powerTokens.get(powerTokens.size() - 1); |
|
|
|
|
powerToken = powerEntries.get(powerEntries.size() - 1).token; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//use random spell
|
|
|
|
|
powerToken = powerTokens.get(ThreadLocalRandom.current().nextInt(powerTokens.size())); |
|
|
|
|
powerToken = powerEntries.get(ThreadLocalRandom.current().nextInt(powerEntries.size())).token; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int powerRank = 1; |
|
|
|
|