Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f556181d77 | |||
| d48e26904e | |||
| 19232ac405 | |||
| 9ee2ccc8af | |||
| 7079bb6a63 | |||
| 0ab5827ee5 | |||
| c5443f622c | |||
| e4aa276cca | |||
| 90ff2d679e | |||
| da26c35d5a | |||
| 779e3da74e | |||
| e358c08773 | |||
| 2945fa3a47 | |||
| ab1541e741 | |||
| 3aeaa709a5 | |||
| 91e627df6b | |||
| d0795e9e1c | |||
| 0e12dd4874 | |||
| 25c0e48181 | |||
| 0d43c3620d | |||
| 2f6137f8df | |||
| 2843b86a93 | |||
| 8235de07ff | |||
| e2f9a4c7f0 | |||
| 55c6e3cf93 | |||
| 11c154e564 | |||
| 7fc0d27c3c | |||
| 1ac76cfcd8 | |||
| c8ed04aaaf |
@@ -2877,10 +2877,11 @@ public class Enum {
|
||||
|
||||
public enum AIAgentType {
|
||||
MOBILE,
|
||||
GUARDCAPTAIN,
|
||||
GUARDMINION,
|
||||
GUARDWALLARCHER,
|
||||
PET,
|
||||
CHARMED,
|
||||
|
||||
SIEGEENGINE,
|
||||
GUARD;
|
||||
SIEGEENGINE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
Mob mobile = null;
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("CALL `mob_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);")) {
|
||||
|
||||
preparedStatement.setLong(1, toAdd.parentZoneUUID);
|
||||
preparedStatement.setInt(2, toAdd.loadID);
|
||||
@@ -48,6 +48,7 @@ public class dbMobHandler extends dbHandlerBase {
|
||||
preparedStatement.setInt(11, toAdd.buildingUUID);
|
||||
preparedStatement.setInt(12, toAdd.level);
|
||||
preparedStatement.setString(13, toAdd.firstName);
|
||||
preparedStatement.setString(14, toAdd.behaviourType.toString());
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ChatManager;
|
||||
@@ -43,7 +44,7 @@ public class AddMobCmd extends AbstractDevCmd {
|
||||
MobBase mb = (MobBase) mobbaseAGO;
|
||||
int loadID = mb.getObjectUUID();
|
||||
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
|
||||
null, zone, null, null, "", 1);
|
||||
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||
if (mob != null) {
|
||||
mob.updateDatabase();
|
||||
this.setResult(String.valueOf(mob.getDBID()));
|
||||
@@ -84,7 +85,7 @@ public class AddMobCmd extends AbstractDevCmd {
|
||||
|
||||
|
||||
Mob mob = Mob.createMob(loadID, pc.getLoc(),
|
||||
null, zone, null, null, "", 1);
|
||||
null, zone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||
if (mob != null) {
|
||||
mob.updateDatabase();
|
||||
ChatManager.chatSayInfo(pc,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector3fImmutable;
|
||||
@@ -110,7 +111,7 @@ public class SplatMobCmd extends AbstractDevCmd {
|
||||
|
||||
mobile = Mob.createMob(_mobileUUID,
|
||||
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
|
||||
null, serverZone, null, null, "", 1);
|
||||
null, serverZone, null, null, "", 1, Enum.AIAgentType.MOBILE);
|
||||
|
||||
if (mobile != null) {
|
||||
mobile.updateDatabase();
|
||||
|
||||
@@ -15,6 +15,7 @@ import engine.gameManager.PowersManager;
|
||||
import engine.objects.AbstractGameObject;
|
||||
import engine.objects.Mob;
|
||||
import engine.objects.PlayerCharacter;
|
||||
import engine.powers.MobPowerEntry;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -90,8 +91,8 @@ public class aiInfoCmd extends AbstractDevCmd {
|
||||
|
||||
output += "Powers:" + newline;
|
||||
|
||||
for (int token : mob.mobPowers.keySet())
|
||||
output += PowersManager.getPowerByToken(token).getName() + newline;
|
||||
for (MobPowerEntry mobPowerEntry : PowersManager.getPowersForMobile(mob))
|
||||
output += PowersManager.getPowerByToken(mobPowerEntry.token).getName() + newline;
|
||||
|
||||
throwbackInfo(playerCharacter, output);
|
||||
}
|
||||
|
||||
@@ -530,41 +530,63 @@ public enum BuildingManager {
|
||||
else
|
||||
rank = 10;
|
||||
|
||||
Mob mob;
|
||||
Mob mobile;
|
||||
NPC npc;
|
||||
|
||||
if (NPC.ISWallArcher(contract)) {
|
||||
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
|
||||
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDWALLARCHER);
|
||||
|
||||
if (mob == null)
|
||||
if (mobile == null)
|
||||
return false;
|
||||
|
||||
mob.setLoc(mob.getLoc());
|
||||
// Configure AI and write new mobile to disk
|
||||
|
||||
mobile.behaviourType = Enum.MobBehaviourType.GuardWallArcher;
|
||||
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||
|
||||
// Spawn new mobile
|
||||
|
||||
mobile.setLoc(mobile.getLoc());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NPC.ISGuardCaptain(contract.getContractID())) {
|
||||
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
|
||||
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDCAPTAIN);
|
||||
|
||||
if (mob == null)
|
||||
if (mobile == null)
|
||||
return false;
|
||||
|
||||
mob.setLoc(mob.getLoc());
|
||||
// Configure AI and write new mobile to disk
|
||||
|
||||
mobile.behaviourType = Enum.MobBehaviourType.GuardCaptain;
|
||||
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||
|
||||
// Spawn new mobile
|
||||
|
||||
mobile.setLoc(mobile.getLoc());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (contract.getContractID() == 910) {
|
||||
|
||||
//guard dog
|
||||
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank);
|
||||
mobile = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank, Enum.AIAgentType.GUARDCAPTAIN);
|
||||
|
||||
if (mob == null)
|
||||
if (mobile == null)
|
||||
return false;
|
||||
|
||||
mob.setLoc(mob.getLoc());
|
||||
// Configure AI and write new mobile to disk
|
||||
|
||||
mobile.behaviourType = Enum.MobBehaviourType.GuardCaptain;
|
||||
mobile = DbManager.MobQueries.PERSIST(mobile);
|
||||
|
||||
// Spawn new mobile
|
||||
|
||||
mobile.setLoc(mobile.getLoc());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,84 +23,6 @@ public enum NPCManager {
|
||||
NPC_MANAGER;
|
||||
public static HashMap<Integer, ArrayList<Integer>> _runeSetMap = new HashMap<>();
|
||||
|
||||
public static void applyRuneSetEffects(Mob mob) {
|
||||
|
||||
// Early exit
|
||||
|
||||
if (mob.runeSet == 0)
|
||||
return;
|
||||
|
||||
//Apply all rune effects.
|
||||
|
||||
if (NPCManager._runeSetMap.get(mob.runeSet).contains(252623)) {
|
||||
mob.isPlayerGuard = true;
|
||||
}
|
||||
|
||||
// Only captains have contracts
|
||||
|
||||
if (mob.contract != null || mob.isPlayerGuard)
|
||||
applyEffectsForRune(mob, 252621);
|
||||
|
||||
|
||||
// Apply effects from RuneSet
|
||||
|
||||
if (mob.runeSet != 0)
|
||||
for (int runeID : _runeSetMap.get(mob.runeSet))
|
||||
applyEffectsForRune(mob, runeID);
|
||||
|
||||
// Not sure why but apply Warrior effects for some reason?
|
||||
|
||||
applyEffectsForRune(mob, 2518);
|
||||
}
|
||||
|
||||
public static void applyEffectsForRune(AbstractCharacter character, int runeID) {
|
||||
|
||||
EffectsBase effectsBase;
|
||||
RuneBase sourceRune = RuneBase.getRuneBase(runeID);
|
||||
|
||||
// Race runes are in the runeset but not in runebase for some reason
|
||||
|
||||
if (sourceRune == null)
|
||||
return;
|
||||
|
||||
for (MobBaseEffects mbe : sourceRune.getEffectsList()) {
|
||||
|
||||
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
|
||||
|
||||
if (effectsBase == null) {
|
||||
Logger.info("Mob: " + character.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
|
||||
continue;
|
||||
}
|
||||
|
||||
//check to upgrade effects if needed.
|
||||
if (character.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
|
||||
|
||||
if (mbe.getReqLvl() > (int) character.level)
|
||||
continue;
|
||||
|
||||
Effect eff = character.effects.get(Integer.toString(effectsBase.getUUID()));
|
||||
|
||||
if (eff == null)
|
||||
continue;
|
||||
|
||||
//Current effect is a higher rank, dont apply.
|
||||
if (eff.getTrains() > mbe.getRank())
|
||||
continue;
|
||||
|
||||
//new effect is of a higher rank. remove old effect and apply new one.
|
||||
eff.cancelJob();
|
||||
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) character.level)
|
||||
continue;
|
||||
|
||||
character.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void dismissNecroPet(Mob necroPet, boolean updateOwner) {
|
||||
|
||||
necroPet.setCombatTarget(null);
|
||||
@@ -424,4 +346,57 @@ public enum NPCManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyMobbaseEffects(Mob mob) {
|
||||
EffectsBase effectsBase;
|
||||
for (MobBaseEffects mbe : mob.mobBase.effectsList) {
|
||||
|
||||
effectsBase = PowersManager.getEffectByToken(mbe.getToken());
|
||||
|
||||
if (effectsBase == null) {
|
||||
Logger.info("Mob: " + mob.getObjectUUID() + " EffectsBase Null for Token " + mbe.getToken());
|
||||
continue;
|
||||
}
|
||||
|
||||
//check to upgrade effects if needed.
|
||||
if (mob.effects.containsKey(Integer.toString(effectsBase.getUUID()))) {
|
||||
|
||||
if (mbe.getReqLvl() > (int) mob.level)
|
||||
continue;
|
||||
|
||||
Effect eff = mob.effects.get(Integer.toString(effectsBase.getUUID()));
|
||||
|
||||
if (eff == null)
|
||||
continue;
|
||||
|
||||
//Current effect is a higher rank, dont apply.
|
||||
if (eff.getTrains() > mbe.getRank())
|
||||
continue;
|
||||
|
||||
//new effect is of a higher rank. remove old effect and apply new one.
|
||||
eff.cancelJob();
|
||||
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
} else {
|
||||
|
||||
if (mbe.getReqLvl() > (int) mob.level)
|
||||
continue;
|
||||
|
||||
mob.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, mbe.getRank(), true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void applyEquipmentResists(Mob mob){
|
||||
if(mob.equip != null){
|
||||
for(MobEquipment equipped : mob.equip.values()){
|
||||
ItemBase itemBase = equipped.getItemBase();
|
||||
if(itemBase.isHeavyArmor() || itemBase.isLightArmor() || itemBase.isMediumArmor()){
|
||||
mob.resists.setResist(Enum.DamageType.Crush, mob.resists.getResist(Enum.DamageType.Crush,0) + itemBase.getCrushResist());
|
||||
mob.resists.setResist(Enum.DamageType.Slash, mob.resists.getResist(Enum.DamageType.Slash,0) + itemBase.getCrushResist());
|
||||
mob.resists.setResist(Enum.DamageType.Pierce, mob.resists.getResist(Enum.DamageType.Pierce,0) + itemBase.getCrushResist());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public enum PowersManager {
|
||||
public static HashMap<Integer, AbstractPowerAction> powerActionsByID = new HashMap<>();
|
||||
public static HashMap<String, Integer> ActionTokenByIDString = new HashMap<>();
|
||||
public static HashMap<String, Integer> AnimationOverrides = new HashMap<>();
|
||||
public static HashMap<Integer, ArrayList<MobPowerEntry>> AllMobPowers;
|
||||
public static HashMap<Integer, ArrayList<MobPowerEntry>> _allMobPowers;
|
||||
private static JobScheduler js;
|
||||
|
||||
private PowersManager() {
|
||||
@@ -103,6 +103,30 @@ public enum PowersManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<MobPowerEntry> getPowersForMobile(Mob mobile) {
|
||||
|
||||
ArrayList<MobPowerEntry> mobPowers = new ArrayList<>();
|
||||
ArrayList<MobPowerEntry> powerEntries;
|
||||
|
||||
if (mobile.agentType.equals(AIAgentType.GUARDMINION))
|
||||
powerEntries = PowersManager._allMobPowers.get(mobile.guardCaptain.contractUUID);
|
||||
else
|
||||
powerEntries = PowersManager._allMobPowers.get(mobile.contractUUID);
|
||||
|
||||
if (powerEntries != null)
|
||||
mobPowers.addAll(powerEntries);
|
||||
|
||||
if (mobile.agentType.equals(AIAgentType.GUARDMINION))
|
||||
powerEntries = PowersManager._allMobPowers.get(((Mob) mobile.guardCaptain).loadID);
|
||||
else
|
||||
powerEntries = PowersManager._allMobPowers.get(mobile.loadID);
|
||||
|
||||
if (powerEntries != null)
|
||||
mobPowers.addAll(powerEntries);
|
||||
|
||||
return mobPowers;
|
||||
}
|
||||
|
||||
// This pre-loads all powers and effects
|
||||
public static void InitializePowers() {
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -165,7 +166,7 @@ public class MobAI {
|
||||
|
||||
if (playercity != null)
|
||||
for (Mob guard : playercity.getParent().zoneMobSet)
|
||||
if (guard.behaviourType != null && guard.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
|
||||
if (guard.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
||||
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
|
||||
guard.setCombatTarget(mob);
|
||||
|
||||
@@ -260,7 +261,7 @@ public class MobAI {
|
||||
|
||||
//guard captains inherit barracks patrol points dynamically
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) {
|
||||
|
||||
Building barracks = mob.building;
|
||||
|
||||
@@ -280,7 +281,7 @@ public class MobAI {
|
||||
|
||||
MovementUtilities.aiMove(mob, mob.destination, true);
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
||||
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
|
||||
|
||||
//make sure mob is out of combat stance
|
||||
@@ -308,20 +309,21 @@ public class MobAI {
|
||||
if (mob == null)
|
||||
return false;
|
||||
|
||||
if(mob.isPlayerGuard == true){
|
||||
if (mob.isPlayerGuard() == true) {
|
||||
|
||||
int contractID;
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion))
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
||||
contractID = mob.guardCaptain.contract.getContractID();
|
||||
else
|
||||
contractID = mob.contract.getContractID();
|
||||
|
||||
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
|
||||
//exception for werewolf and werebear guard captains
|
||||
if (Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false && contractID != 980111 && contractID != 980110)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mob.mobPowers.isEmpty())
|
||||
if (PowersManager.getPowersForMobile(mob).isEmpty())
|
||||
return false;
|
||||
|
||||
if (!mob.canSee((PlayerCharacter) mob.getCombatTarget())) {
|
||||
@@ -346,8 +348,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 +357,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 +431,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 +440,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 +478,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;
|
||||
@@ -606,9 +614,9 @@ public class MobAI {
|
||||
|
||||
//override for guards
|
||||
|
||||
if (mob.despawned && mob.isPlayerGuard) {
|
||||
if (mob.despawned && mob.isPlayerGuard()) {
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||
if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) {
|
||||
|
||||
//minions don't respawn while guard captain is dead
|
||||
@@ -625,7 +633,7 @@ public class MobAI {
|
||||
|
||||
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
|
||||
if (!mob.agentType.equals(Enum.AIAgentType.PET))
|
||||
CheckToSendMobHome(mob);
|
||||
|
||||
return;
|
||||
@@ -646,7 +654,7 @@ public class MobAI {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false)
|
||||
if (mob.agentType.equals(Enum.AIAgentType.PET) == false)
|
||||
CheckToSendMobHome(mob);
|
||||
|
||||
if (mob.getCombatTarget() != null) {
|
||||
@@ -901,7 +909,7 @@ public class MobAI {
|
||||
return;
|
||||
|
||||
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false &&
|
||||
mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) {
|
||||
mob.agentType.equals(Enum.AIAgentType.PET) == false) {
|
||||
|
||||
mob.setCombatTarget(null);
|
||||
return;
|
||||
@@ -920,7 +928,7 @@ public class MobAI {
|
||||
if (mob.behaviourType.isAgressive) {
|
||||
|
||||
if (mob.isPlayerGuard()) {
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN))
|
||||
CheckForPlayerGuardAggro(mob);
|
||||
} else {
|
||||
CheckForAggro(mob);
|
||||
@@ -940,7 +948,7 @@ public class MobAI {
|
||||
PowersManager.useMobPower(mob, mob, recall, 40);
|
||||
mob.setCombatTarget(null);
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) {
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN) && mob.isAlive()) {
|
||||
|
||||
//guard captain pulls his minions home with him
|
||||
|
||||
@@ -1011,17 +1019,17 @@ public class MobAI {
|
||||
|
||||
//dont scan self.
|
||||
|
||||
if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARD)) == true)
|
||||
if (mob.equals(awoMob) || (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) == true)
|
||||
continue;
|
||||
|
||||
Mob aggroMob = (Mob) awoMob;
|
||||
|
||||
//don't attack other guards
|
||||
|
||||
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD)))
|
||||
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)))
|
||||
continue;
|
||||
|
||||
if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1))
|
||||
if (aggroMob.agentType.equals(Enum.AIAgentType.PET))
|
||||
continue;
|
||||
|
||||
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
|
||||
@@ -1252,7 +1260,7 @@ public class MobAI {
|
||||
if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
|
||||
return false;
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) {
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDMINION)) {
|
||||
if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
|
||||
return true;
|
||||
}
|
||||
@@ -1337,7 +1345,7 @@ public class MobAI {
|
||||
|
||||
MovementUtilities.aiMove(mob, mob.destination, true);
|
||||
|
||||
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) {
|
||||
if (mob.agentType.equals(Enum.AIAgentType.GUARDCAPTAIN)) {
|
||||
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
|
||||
|
||||
//make sure mob is out of combat stance
|
||||
|
||||
@@ -15,9 +15,6 @@ import engine.net.client.msg.*;
|
||||
import engine.objects.*;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/*
|
||||
* @Author:
|
||||
* @Summary: Processes application protocol message which
|
||||
@@ -26,8 +23,6 @@ import java.util.HashMap;
|
||||
|
||||
public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public static HashMap<Integer, ArrayList<Integer>> _minionsByCaptain = null;
|
||||
|
||||
public MinionTrainingMsgHandler() {
|
||||
super(MinionTrainingMessage.class);
|
||||
}
|
||||
@@ -37,10 +32,11 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
MinionTrainingMessage minionMsg = (MinionTrainingMessage) baseMsg;
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) {
|
||||
|
||||
NPC npc = NPC.getFromCache(minionMsg.getNpcID());
|
||||
@@ -48,14 +44,15 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
Building b = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
Building building = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
|
||||
if (b == null)
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
//clear minion
|
||||
|
||||
if (npc.minionLock.writeLock().tryLock()) {
|
||||
|
||||
try {
|
||||
if (minionMsg.getType() == 2) {
|
||||
|
||||
@@ -86,23 +83,21 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// we Found the move to remove, lets break the for loop so it doesnt look for more.
|
||||
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, b);
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(playerCharacter, building);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(b.getObjectType().ordinal());
|
||||
mca1.setTargetID(b.getObjectUUID());
|
||||
mca1.setTargetType(building.getObjectType().ordinal());
|
||||
mca1.setTargetID(building.getObjectUUID());
|
||||
|
||||
mca1.setTargetType3(npc.getObjectType().ordinal());
|
||||
mca1.setTargetID3(npc.getObjectUUID());
|
||||
mca1.setAssetName1(b.getName());
|
||||
mca1.setAssetName1(building.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//Add Minion
|
||||
@@ -156,7 +151,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
} finally {
|
||||
@@ -199,19 +194,21 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
DbManager.removeFromCache(toRemove);
|
||||
|
||||
if (toRemove.agentType.equals(Enum.AIAgentType.SIEGEENGINE)) {
|
||||
|
||||
PlayerCharacter petOwner = (PlayerCharacter) toRemove.guardCaptain;
|
||||
PlayerCharacter trebOwner = (PlayerCharacter) toRemove.guardCaptain;
|
||||
|
||||
if (petOwner != null) {
|
||||
petOwner.setPet(null);
|
||||
if (trebOwner != null) {
|
||||
trebOwner.setPet(null);
|
||||
|
||||
toRemove.guardCaptain = null;
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
toRemove.guardCaptain = null;
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(trebOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, building);
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(playerCharacter, building);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(building.getObjectType().ordinal());
|
||||
mca1.setTargetID(building.getObjectUUID());
|
||||
@@ -221,11 +218,11 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
mca1.setAssetName1(building.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//Add Minion
|
||||
@@ -287,7 +284,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putString("A weapon suited to laying siege");
|
||||
}
|
||||
|
||||
private static void serializeGuardList(ByteBufferWriter writer, int minion) {
|
||||
private static void serializeGuardList(ByteBufferWriter writer, int minion, Mob captain) {
|
||||
|
||||
writer.putInt(1);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
writer.putInt(minion);
|
||||
writer.putInt(1);
|
||||
writer.putInt(minion);
|
||||
writer.putInt(1);
|
||||
writer.putInt(captain.getRank());//minion rank
|
||||
writer.put((byte) 0);
|
||||
|
||||
writer.putInt(600); //roll time
|
||||
@@ -669,7 +669,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
ConcurrentHashMap<Mob, Integer> siegeMinions = mobA.getSiegeMinionMap();
|
||||
|
||||
writer.putInt(siegeMinions.size() + 1);
|
||||
serializeGuardList(writer, mobA.getContract().getContractID()); //Guard
|
||||
serializeGuardList(writer, mobA.getContract().getContractID(), mobA); //Guard
|
||||
|
||||
if (siegeMinions != null && siegeMinions.size() > 0)
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
protected AtomicFloat mana = new AtomicFloat();
|
||||
protected float manaMax; // Health/Mana/Stamina
|
||||
protected AtomicBoolean isAlive = new AtomicBoolean(true);
|
||||
protected Resists resists = new Resists("Genric");
|
||||
public Resists resists = new Resists("Genric");
|
||||
protected ConcurrentHashMap<String, JobContainer> timers;
|
||||
protected ConcurrentHashMap<String, Long> timestamps;
|
||||
protected int atrHandOne;
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
|
||||
protected Vector3fImmutable lastBindLoc;
|
||||
public boolean assist = false;
|
||||
public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE;
|
||||
public boolean isPlayerGuard = false;
|
||||
|
||||
public AbstractCharacter guardCaptain;
|
||||
public EnumBitSet<Enum.MonsterType> notEnemy = EnumBitSet.noneOf(Enum.MonsterType.class);
|
||||
public EnumBitSet<Enum.MonsterType> enemy = EnumBitSet.noneOf(Enum.MonsterType.class);
|
||||
|
||||
+69
-110
@@ -25,15 +25,14 @@ import engine.net.Dispatch;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.PetMsg;
|
||||
import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.powers.MobPowerEntry;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.joda.time.DateTime;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@@ -51,7 +50,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
|
||||
public boolean despawned = false;
|
||||
public Vector3fImmutable destination = Vector3fImmutable.ZERO;
|
||||
public LinkedHashMap<Integer, Integer> mobPowers = new LinkedHashMap<>();
|
||||
public MobBase mobBase;
|
||||
public int spawnTime;
|
||||
public Zone parentZone;
|
||||
@@ -65,15 +63,13 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
public float spawnRadius;
|
||||
//used by static mobs
|
||||
public int parentZoneUUID;
|
||||
protected int dbID; //the database ID
|
||||
|
||||
private int currentID;
|
||||
|
||||
//TODO implement feared object system
|
||||
public AbstractWorldObject fearedObject = null;
|
||||
protected int dbID; //the database ID
|
||||
private int currentID;
|
||||
private long lastAttackTime = 0;
|
||||
private int lastMobPowerToken = 0;
|
||||
private HashMap<Integer, MobEquipment> equip = null;
|
||||
public HashMap<Integer, MobEquipment> equip = null;
|
||||
private DeferredPowerJob weaponPower;
|
||||
private DateTime upgradeDateTime = null;
|
||||
private boolean lootSync = false;
|
||||
@@ -105,6 +101,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.dbID = rs.getInt(1);
|
||||
this.loadID = rs.getInt("mob_mobbaseID");
|
||||
this.gridObjectType = GridObjectType.DYNAMIC;
|
||||
this.agentType = AIAgentType.MOBILE;
|
||||
|
||||
this.spawnRadius = rs.getFloat("mob_spawnRadius");
|
||||
this.spawnTime = rs.getInt("mob_spawnTime");
|
||||
@@ -153,7 +150,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
this.currentID = this.dbID;
|
||||
|
||||
this.agentType = AIAgentType.MOBILE;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e + " " + this.dbID);
|
||||
}
|
||||
@@ -183,7 +179,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
} else if (tid == 100962 || tid == 100965) { //Spydraxxx the Mighty, Denigo Tantric
|
||||
writer.putInt(2);
|
||||
serializeRune(mob, writer, 5, GameObjectType.NPCClassRuneTwo.ordinal(), 252621); //guard rune
|
||||
} else if (mob.contract != null || mob.isPlayerGuard) {
|
||||
} else if (mob.contract != null || mob.isPlayerGuard()) {
|
||||
writer.putInt(3);
|
||||
serializeRune(mob, writer, 3, GameObjectType.NPCClassRuneTwo.ordinal(), MobBase.GetClassType(mob.getMobBaseID())); //warrior class
|
||||
serializeRune(mob, writer, 5, GameObjectType.NPCClassRuneThree.ordinal(), 252621); //guard rune
|
||||
@@ -316,13 +312,13 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
writer.put((byte) 1);
|
||||
|
||||
|
||||
if ((PlayerCharacter) mob.guardCaptain != null) {
|
||||
if (mob.guardCaptain != null) {
|
||||
|
||||
|
||||
writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectType().ordinal());
|
||||
writer.putInt(mob.guardCaptain.getObjectType().ordinal());
|
||||
|
||||
|
||||
writer.putInt(((PlayerCharacter) mob.guardCaptain).getObjectUUID());
|
||||
writer.putInt(mob.guardCaptain.getObjectUUID());
|
||||
} else {
|
||||
writer.putInt(0); //ownerType
|
||||
writer.putInt(0); //ownerID
|
||||
@@ -340,7 +336,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
|
||||
if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.behaviourType.equals(MobBehaviourType.SiegeEngine) && !mob.isPlayerGuard) {
|
||||
if (!mob.isAlive() && !mob.isPet() && !mob.isNecroPet() && !mob.behaviourType.equals(MobBehaviourType.SiegeEngine) && !mob.isPlayerGuard()) {
|
||||
writer.putInt(0);
|
||||
writer.putInt(0);
|
||||
}
|
||||
@@ -401,10 +397,13 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
writer.putInt(mob.currentID);
|
||||
}
|
||||
|
||||
public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, Zone parent, Building building, Contract contract, String pirateName, int level) {
|
||||
public static Mob createMob(int loadID, Vector3fImmutable spawn, Guild guild, Zone parent, Building building, Contract contract, String pirateName, int level, AIAgentType mobType) {
|
||||
|
||||
Mob mobile = new Mob();
|
||||
mobile.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
|
||||
//mobile.agentType = AIAgentType.MOBILE; this method is only called to make guard captains and wall archers
|
||||
mobile.agentType = mobType;
|
||||
mobile.behaviourType = MobBehaviourType.None;
|
||||
mobile.loadID = loadID;
|
||||
mobile.level = (short) level;
|
||||
|
||||
@@ -428,18 +427,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
else
|
||||
mobile.contractUUID = contract.getContractID();
|
||||
|
||||
Mob mob;
|
||||
|
||||
mobile.agentType = AIAgentType.GUARD;
|
||||
try {
|
||||
mob = DbManager.MobQueries.PERSIST(mobile);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("SQLException:" + e.getMessage());
|
||||
mob = null;
|
||||
}
|
||||
|
||||
return mob;
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public static synchronized Mob createGuardMinion(Mob guardCaptain, short level, String minionName) {
|
||||
@@ -463,8 +451,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
minionMobile.guardCaptain = guardCaptain;
|
||||
minionMobile.spawnTime = (int) (-2.500 * guardCaptain.building.getRank() + 22.5) * 60;
|
||||
minionMobile.behaviourType = Enum.MobBehaviourType.GuardMinion;
|
||||
minionMobile.agentType = AIAgentType.GUARD;
|
||||
minionMobile.isPlayerGuard = true;
|
||||
minionMobile.agentType = AIAgentType.GUARDMINION;
|
||||
minionMobile.guardedCity = guardCaptain.guardedCity;
|
||||
minionMobile.patrolPoints = guardCaptain.building.patrolPoints;
|
||||
|
||||
@@ -566,6 +553,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
return petMinion;
|
||||
}
|
||||
|
||||
public static Mob getMob(int id) {
|
||||
|
||||
if (id == 0)
|
||||
@@ -708,7 +696,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
public Vector3fImmutable getBindLoc() {
|
||||
|
||||
if (this.isPet() && !this.behaviourType.equals(MobBehaviourType.SiegeEngine))
|
||||
return (PlayerCharacter) this.guardCaptain != null ? ((PlayerCharacter) this.guardCaptain).getLoc() : this.getLoc();
|
||||
return this.guardCaptain != null ? this.guardCaptain.getLoc() : this.getLoc();
|
||||
else
|
||||
return this.bindLoc;
|
||||
}
|
||||
@@ -737,8 +725,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
conVal *= (1 + this.bonuses.getFloatPercentAll(ModType.Attr, SourceType.Constitution));
|
||||
intVal *= (1 + this.bonuses.getFloatPercentAll(ModType.Attr, SourceType.Intelligence));
|
||||
spiVal *= (1 + this.bonuses.getFloatPercentAll(ModType.Attr, SourceType.Spirit));
|
||||
} else {
|
||||
// apply dex penalty for armor
|
||||
}
|
||||
|
||||
// Set current stats
|
||||
@@ -757,7 +743,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
// get rune and effect bonuses
|
||||
bonus *= (1 + this.bonuses.getFloatPercentAll(ModType.Speed, SourceType.None));
|
||||
|
||||
if (this.isPlayerGuard)
|
||||
if (this.isPlayerGuard())
|
||||
switch (this.mobBase.getLoadID()) {
|
||||
case 2111:
|
||||
if (this.isWalk())
|
||||
@@ -825,7 +811,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
Group g = GroupManager.getGroup((PlayerCharacter) attacker);
|
||||
|
||||
// Give XP, now handled inside the Experience Object
|
||||
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard)
|
||||
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard())
|
||||
Experience.doExperience((PlayerCharacter) attacker, this, g);
|
||||
} else if (attacker.getObjectType().equals(GameObjectType.Mob)) {
|
||||
Mob mobAttacker = (Mob) attacker;
|
||||
@@ -836,7 +822,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
PlayerCharacter owner = (PlayerCharacter) mobAttacker.guardCaptain;
|
||||
|
||||
if (owner != null)
|
||||
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard) {
|
||||
if (!this.isPet() && !this.isNecroPet() && !(this.agentType.equals(AIAgentType.PET)) && !this.isPlayerGuard()) {
|
||||
Group g = GroupManager.getGroup(owner);
|
||||
|
||||
// Give XP, now handled inside the Experience Object
|
||||
@@ -950,7 +936,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
|
||||
playerAgroMap.clear();
|
||||
|
||||
if (!this.isPlayerGuard && this.equip != null)
|
||||
if (!this.isPlayerGuard() && this.equip != null)
|
||||
LootManager.GenerateEquipmentDrop(this);
|
||||
|
||||
}
|
||||
@@ -987,7 +973,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.setLoc(this.lastBindLoc);
|
||||
this.stopMovement(this.lastBindLoc);
|
||||
|
||||
NPCManager.applyRuneSetEffects(this);
|
||||
NPCManager.applyMobbaseEffects(this);
|
||||
|
||||
this.recalculateStats();
|
||||
this.setHealth(this.healthMax);
|
||||
@@ -997,8 +983,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
else if (this.building != null)
|
||||
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
|
||||
|
||||
if (!this.behaviourType.equals(MobBehaviourType.SiegeEngine) && !this.isPlayerGuard && contract == null)
|
||||
loadInventory();
|
||||
this.loadInventory();
|
||||
|
||||
this.updateLocation();
|
||||
}
|
||||
@@ -1036,7 +1021,9 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
this.charItemManager.clearInventory();
|
||||
this.charItemManager.clearEquip();
|
||||
|
||||
if (isPlayerGuard)
|
||||
// Only generate loot for mobiles
|
||||
|
||||
if (!this.agentType.equals(AIAgentType.MOBILE))
|
||||
return;
|
||||
|
||||
LootManager.GenerateMobLoot(this);
|
||||
@@ -1529,49 +1516,33 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
@Override
|
||||
public void runAfterLoad() {
|
||||
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks());
|
||||
|
||||
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
|
||||
return;
|
||||
|
||||
this.mobBase = MobBase.getMobBase(loadID);
|
||||
this.charItemManager = new CharacterItemManager(this);
|
||||
|
||||
this.setObjectTypeMask(MBServerStatics.MASK_MOB | this.getTypeMasks());
|
||||
this.mobBase = MobBase.getMobBase(loadID);
|
||||
|
||||
this.building = BuildingManager.getBuilding(this.buildingUUID);
|
||||
|
||||
if (this.contractUUID == 0)
|
||||
this.contract = null;
|
||||
else
|
||||
this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID);
|
||||
// Configure AI related values
|
||||
|
||||
// Setup mobile AI and equipset for contract
|
||||
|
||||
if (this.contract != null) {
|
||||
|
||||
this.equipmentSetID = this.contract.getEquipmentSet();
|
||||
|
||||
// Load AI for guard captains
|
||||
|
||||
if (NPC.ISGuardCaptain(contract.getContractID()) || this.contract.getContractID() == 910) { // Guard Dog
|
||||
this.behaviourType = MobBehaviourType.GuardCaptain;
|
||||
this.spawnTime = 60 * 15;
|
||||
this.isPlayerGuard = true;
|
||||
switch (this.behaviourType) {
|
||||
case GuardCaptain:
|
||||
this.agentType = AIAgentType.GUARDCAPTAIN;
|
||||
this.spawnTime = 600;
|
||||
this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc());
|
||||
}
|
||||
|
||||
// Load AI for wall archers
|
||||
|
||||
if (NPC.ISWallArcher(this.contract)) {
|
||||
this.gridObjectType = GridObjectType.DYNAMIC;
|
||||
this.behaviourType = MobBehaviourType.GuardWallArcher;
|
||||
this.isPlayerGuard = true;
|
||||
break;
|
||||
case GuardWallArcher:
|
||||
this.agentType = AIAgentType.GUARDWALLARCHER;
|
||||
this.spawnTime = 450;
|
||||
this.guardedCity = ZoneManager.getCityAtLocation(this.building.getLoc());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Default to the mobbase for AI if nothing is hte mob field to override.
|
||||
// Default to the mobbase for AI if nothing is in mob field to override.
|
||||
|
||||
if (this.behaviourType == null || this.behaviourType.equals(MobBehaviourType.None))
|
||||
this.behaviourType = this.getMobBase().fsm;
|
||||
@@ -1579,6 +1550,18 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (this.behaviourType == null)
|
||||
this.behaviourType = MobBehaviourType.None;
|
||||
|
||||
if (this.contractUUID == 0)
|
||||
this.contract = null;
|
||||
else
|
||||
this.contract = DbManager.ContractQueries.GET_CONTRACT(this.contractUUID);
|
||||
|
||||
// Setup equipset for contract
|
||||
|
||||
if (this.contract != null)
|
||||
this.equipmentSetID = this.contract.getEquipmentSet();
|
||||
|
||||
// Mobiles default to the building guild.
|
||||
|
||||
if (this.building != null)
|
||||
this.guild = this.building.getGuild();
|
||||
else
|
||||
@@ -1604,7 +1587,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
// Don't override level for guard minions or pets
|
||||
|
||||
if (this.contract == null)
|
||||
if (!this.agentType.equals(AIAgentType.GUARD) && !this.agentType.equals(AIAgentType.PET))
|
||||
if (!this.agentType.equals(AIAgentType.GUARDMINION) && !this.agentType.equals(AIAgentType.PET))
|
||||
this.level = (short) this.mobBase.getLevel();
|
||||
|
||||
//set bonuses
|
||||
@@ -1614,8 +1597,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
//TODO set these correctly later
|
||||
this.rangeHandOne = this.mobBase.getAttackRange();
|
||||
this.rangeHandTwo = -1;
|
||||
this.minDamageHandOne = (int)this.mobBase.getMinDmg();
|
||||
this.maxDamageHandOne = (int)this.mobBase.getMaxDmg();
|
||||
this.minDamageHandOne = (int) this.mobBase.getMinDmg();
|
||||
this.maxDamageHandOne = (int) this.mobBase.getMaxDmg();
|
||||
this.minDamageHandTwo = 0;
|
||||
this.maxDamageHandTwo = 0;
|
||||
this.atrHandOne = this.mobBase.getAtr();
|
||||
@@ -1664,18 +1647,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
else
|
||||
this.equip = new HashMap<>();
|
||||
|
||||
// Powers from mobbase
|
||||
|
||||
if (PowersManager.AllMobPowers.containsKey(this.getMobBaseID()))
|
||||
for (MobPowerEntry mobPowerEntry : PowersManager.AllMobPowers.get(this.getMobBaseID()))
|
||||
mobPowers.put(mobPowerEntry.token, mobPowerEntry.rank);
|
||||
|
||||
// Powers from contract
|
||||
|
||||
if (this.contract != null && PowersManager.AllMobPowers.containsKey(this.contract.getContractID()))
|
||||
for (MobPowerEntry mobPowerEntry : PowersManager.AllMobPowers.get(this.contract.getContractID()))
|
||||
mobPowers.put(mobPowerEntry.token, mobPowerEntry.rank);
|
||||
|
||||
if (this.equip == null) {
|
||||
Logger.error("Null equipset returned for uuid " + currentID);
|
||||
this.equip = new HashMap<>(0);
|
||||
@@ -1691,29 +1662,24 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (this.getMobBase().enemy.size() > 0)
|
||||
this.enemy.addAll(this.getMobBase().enemy);
|
||||
}
|
||||
NPCManager.applyMobbaseEffects(this);
|
||||
NPCManager.applyEquipmentResists(this);
|
||||
this.recalculateStats();
|
||||
this.setHealth(this.healthMax);
|
||||
|
||||
try {
|
||||
NPCManager.applyRuneSetEffects(this);
|
||||
recalculateStats();
|
||||
this.setHealth(this.healthMax);
|
||||
// Set bounds for this mobile
|
||||
|
||||
// Set bounds for this mobile
|
||||
Bounds mobBounds = Bounds.borrow();
|
||||
mobBounds.setBounds(this.getLoc());
|
||||
this.setBounds(mobBounds);
|
||||
|
||||
Bounds mobBounds = Bounds.borrow();
|
||||
mobBounds.setBounds(this.getLoc());
|
||||
this.setBounds(mobBounds);
|
||||
//assign 5 random patrol points for regular mobs
|
||||
|
||||
//assign 5 random patrol points for regular mobs
|
||||
if (this.agentType.equals(AIAgentType.MOBILE))
|
||||
NPCManager.AssignPatrolPoints(this);
|
||||
|
||||
if (this.agentType.equals(AIAgentType.MOBILE)) {
|
||||
this.deathTime = 0;
|
||||
|
||||
NPCManager.AssignPatrolPoints(this);
|
||||
}
|
||||
|
||||
this.deathTime = 0;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1750,16 +1716,9 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
if (!ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||
return;
|
||||
|
||||
PlayerCharacter player = (PlayerCharacter) ac;
|
||||
|
||||
if (this.getCombatTarget() == null) {
|
||||
this.setCombatTarget(ac);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getObjectUUID() == this.getCombatTarget().getObjectUUID())
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public void setRank(int newRank) {
|
||||
@@ -1822,7 +1781,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
}
|
||||
|
||||
public boolean isPlayerGuard() {
|
||||
return isPlayerGuard;
|
||||
|
||||
return EnumSet.of(AIAgentType.GUARDCAPTAIN, AIAgentType.GUARDMINION, AIAgentType.GUARDWALLARCHER).contains(this.agentType);
|
||||
}
|
||||
|
||||
public int getLastMobPowerToken() {
|
||||
@@ -1902,5 +1862,4 @@ public class Mob extends AbstractIntelligenceAgent {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class MobBase extends AbstractGameObject {
|
||||
private final String firstName;
|
||||
private final byte level;
|
||||
private final float scale;
|
||||
public final ArrayList<MobBaseEffects> effectsList;
|
||||
public int bootySet;
|
||||
public Enum.MobBehaviourType fsm;
|
||||
public EnumBitSet<Enum.MonsterType> notEnemy;
|
||||
@@ -108,6 +109,8 @@ public class MobBase extends AbstractGameObject {
|
||||
|
||||
this.mobBaseStats = DbManager.MobBaseQueries.LOAD_STATS(this.loadID);
|
||||
DbManager.MobBaseQueries.LOAD_ALL_MOBBASE_SPEEDS(this);
|
||||
//load effects for mobbase
|
||||
this.effectsList = DbManager.MobBaseQueries.GET_RUNEBASE_EFFECTS(this.loadID);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ public class WorldServer {
|
||||
DbManager.MobBaseQueries.GET_ALL_MOBBASES();
|
||||
|
||||
Logger.info("Loading Mob Powers");
|
||||
PowersManager.AllMobPowers = dbPowerHandler.LOAD_MOB_POWERS();
|
||||
PowersManager._allMobPowers = dbPowerHandler.LOAD_MOB_POWERS();
|
||||
|
||||
Logger.info("Loading item enchants");
|
||||
DbManager.LootQueries.LOAD_ENCHANT_VALUES();
|
||||
|
||||
Reference in New Issue
Block a user