Compare commits

..

13 Commits

31 changed files with 1060 additions and 690 deletions
+2
View File
@@ -24,3 +24,5 @@
hs_err_pid* hs_err_pid*
replay_pid* replay_pid*
.idea/
*.iml
+8 -7
View File
@@ -2822,6 +2822,7 @@ public class Enum {
public enum MobBehaviourType { public enum MobBehaviourType {
None(null, false, false, false, false, false), None(null, false, false, false, false, false),
//Power
Power(null, false, true, true, true, false), Power(null, false, true, true, true, false),
PowerHelpee(Power, false, true, true, false, true), PowerHelpee(Power, false, true, true, false, true),
PowerHelpeeWimpy(Power, true, false, true, false, false), PowerHelpeeWimpy(Power, true, false, true, false, false),
@@ -2846,7 +2847,6 @@ public class Enum {
//Independent Types //Independent Types
SimpleStandingGuard(null, false, false, false, false, false), SimpleStandingGuard(null, false, false, false, false, false),
Pet1(null, false, false, true, false, false), Pet1(null, false, false, true, false, false),
SiegeEngine(null, false, false, false, false, false),
Simple(null, false, false, true, false, false), Simple(null, false, false, true, false, false),
Helpee(null, false, true, true, false, true), Helpee(null, false, true, true, false, true),
HelpeeWimpy(null, true, false, true, false, false), HelpeeWimpy(null, true, false, true, false, false),
@@ -2857,12 +2857,13 @@ public class Enum {
HamletGuard(null, false, true, false, false, false), HamletGuard(null, false, true, false, false, false),
AggroWanderer(null, false, false, true, false, false); AggroWanderer(null, false, false, true, false, false);
public final MobBehaviourType BehaviourHelperType; private static HashMap<Integer, MobBehaviourType> _behaviourTypes = new HashMap<>();
public final boolean isWimpy; public MobBehaviourType BehaviourHelperType;
public final boolean isAgressive; public boolean isWimpy;
public final boolean canRoam; public boolean isAgressive;
public final boolean callsForHelp; public boolean canRoam;
public final boolean respondsToCallForHelp; public boolean callsForHelp;
public boolean respondsToCallForHelp;
MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) { MobBehaviourType(MobBehaviourType helpeebehaviourType, boolean wimpy, boolean agressive, boolean canroam, boolean callsforhelp, boolean respondstocallforhelp) {
this.BehaviourHelperType = helpeebehaviourType; this.BehaviourHelperType = helpeebehaviourType;
+22 -17
View File
@@ -28,26 +28,31 @@ public class dbMobHandler extends dbHandlerBase {
this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); this.localObjectType = engine.Enum.GameObjectType.valueOf(this.localClass.getSimpleName());
} }
public Mob PERSIST(Mob toAdd) { public Mob ADD_MOB(Mob toAdd) {
Mob mobile = null; Mob mobile = null;
try (Connection connection = DbManager.getConnection(); 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.setLong(1, toAdd.getParentZoneID());
preparedStatement.setInt(2, toAdd.loadID); preparedStatement.setInt(2, toAdd.getMobBaseID());
preparedStatement.setInt(3, toAdd.guildUUID); preparedStatement.setInt(3, toAdd.getGuildUUID());
preparedStatement.setFloat(4, toAdd.bindLoc.x); preparedStatement.setFloat(4, toAdd.getSpawnX());
preparedStatement.setFloat(5, toAdd.bindLoc.y); preparedStatement.setFloat(5, toAdd.getSpawnY());
preparedStatement.setFloat(6, toAdd.bindLoc.z); preparedStatement.setFloat(6, toAdd.getSpawnZ());
preparedStatement.setInt(7, 0); preparedStatement.setInt(7, 0);
preparedStatement.setFloat(8, toAdd.spawnRadius); preparedStatement.setFloat(8, toAdd.getSpawnRadius());
preparedStatement.setInt(9, toAdd.spawnTime); preparedStatement.setInt(9, toAdd.getTrueSpawnTime());
preparedStatement.setInt(10, toAdd.contractUUID);
preparedStatement.setInt(11, toAdd.buildingUUID); if (toAdd.getContract() != null)
preparedStatement.setInt(12, toAdd.level); preparedStatement.setInt(10, toAdd.getContract().getContractID());
preparedStatement.setString(13, toAdd.firstName); else
preparedStatement.setInt(10, 0);
preparedStatement.setInt(11, toAdd.getBuildingID());
preparedStatement.setInt(12, toAdd.getLevel());
preparedStatement.setString(13, toAdd.getFirstName());
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
@@ -101,17 +106,17 @@ public class dbMobHandler extends dbHandlerBase {
return row_count; return row_count;
} }
public void LOAD_GUARD_MINIONS(Mob guardCaptain) { public void LOAD_PATROL_POINTS(Mob captain) {
try (Connection connection = DbManager.getConnection(); try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) { PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_guards` WHERE `captainUID` = ?")) {
preparedStatement.setInt(1, guardCaptain.getObjectUUID()); preparedStatement.setInt(1, captain.getObjectUUID());
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) { while (rs.next()) {
String minionName = rs.getString("name"); String name = rs.getString("name");
Mob toCreate = Mob.createGuardMinion(guardCaptain, guardCaptain.getLevel(), minionName); Mob toCreate = Mob.createGuardMob(captain, captain.getGuild(), captain.getParentZone(), captain.building.getLoc(), captain.getLevel(), name);
if (toCreate == null) if (toCreate == null)
return; return;
+4 -3
View File
@@ -14,6 +14,7 @@ import engine.gameManager.ChatManager;
import engine.objects.AbstractGameObject; import engine.objects.AbstractGameObject;
import engine.objects.Item; import engine.objects.Item;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
/** /**
* @author Eighty * @author Eighty
@@ -46,10 +47,10 @@ public class AddGoldCmd extends AbstractDevCmd {
throwbackError(pc, "Quantity must be a number, " + words[0] + " is invalid"); throwbackError(pc, "Quantity must be a number, " + words[0] + " is invalid");
return; return;
} }
if (amt < 1 || amt > 10000000) { if (amt < 1 || amt > MBServerStatics.PLAYER_GOLD_LIMIT) {
throwbackError(pc, "Quantity must be between 1 and 10000000 (10 million)"); throwbackError(pc, "Quantity must be between 1 and " + MBServerStatics.PLAYER_GOLD_LIMIT);
return; return;
} else if ((curAmt + amt) > 10000000) { } else if ((curAmt + amt) > MBServerStatics.PLAYER_GOLD_LIMIT) {
throwbackError(pc, "This would place your inventory over 10,000,000 gold."); throwbackError(pc, "This would place your inventory over 10,000,000 gold.");
return; return;
} }
+2 -2
View File
@@ -43,7 +43,7 @@ public class AddMobCmd extends AbstractDevCmd {
MobBase mb = (MobBase) mobbaseAGO; MobBase mb = (MobBase) mobbaseAGO;
int loadID = mb.getObjectUUID(); int loadID = mb.getObjectUUID();
Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100), Mob mob = Mob.createMob(loadID, Vector3fImmutable.getRandomPointInCircle(pc.getLoc(), 100),
null, zone, null, null, "", 1); null, true, zone, null, 0, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
this.setResult(String.valueOf(mob.getDBID())); this.setResult(String.valueOf(mob.getDBID()));
@@ -84,7 +84,7 @@ public class AddMobCmd extends AbstractDevCmd {
Mob mob = Mob.createMob(loadID, pc.getLoc(), Mob mob = Mob.createMob(loadID, pc.getLoc(),
null, zone, null, null, "", 1); null, true, zone, null, 0, "", 1);
if (mob != null) { if (mob != null) {
mob.updateDatabase(); mob.updateDatabase();
ChatManager.chatSayInfo(pc, ChatManager.chatSayInfo(pc,
+53 -17
View File
@@ -16,6 +16,7 @@ import engine.devcmd.AbstractDevCmd;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.objects.*; import engine.objects.*;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.server.MBServerStatics;
import java.util.ArrayList; import java.util.ArrayList;
@@ -31,47 +32,82 @@ public class MakeItemCmd extends AbstractDevCmd {
@Override @Override
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
if (words[0].equals("resources")) { if (words[0].equals("resources")) {
int resourceAmount = 1000;
if (words.length > 1) {
try {
resourceAmount = Integer.parseInt(words[1]);
} catch (NumberFormatException e) {
throwbackError(pc, "Resource amount must be a number.");
return;
}
}
if (resourceAmount < 1)
resourceAmount = 1;
resourceAmount = Math.min(
resourceAmount,
MBServerStatics.RESOURCE_STACK_LIMIT
);
for (int ibID : Warehouse.getMaxResources().keySet()) { for (int ibID : Warehouse.getMaxResources().keySet()) {
if (ibID == 7) if (ibID == 7)
continue; continue;
ItemBase ib = ItemBase.getItemBase(ibID); ItemBase ib = ItemBase.getItemBase(ibID);
short weight = ib.getWeight(); if (ib == null)
if (!pc.getCharItemManager().hasRoomInventory(weight)) { continue;
throwbackError(pc, "Not enough room in inventory for any more of this item");
short weight = ib.getWeight();
if (!pc.getCharItemManager().hasRoomInventory(weight)) {
throwbackError(pc, "Not enough room in inventory for any more resources.");
pc.getCharItemManager().updateInventory(); pc.getCharItemManager().updateInventory();
return; return;
} }
boolean worked = false; Item item = new Item(
Item item = new Item(ib, pc.getObjectUUID(), ib,
OwnerType.PlayerCharacter, (byte) 0, (byte) 0, (short) ib.getDurability(), (short) ib.getDurability(), pc.getObjectUUID(),
true, false, ItemContainerType.INVENTORY, (byte) 0, OwnerType.PlayerCharacter,
new ArrayList<>(), ""); (byte) 0,
(byte) 0,
(short) ib.getDurability(),
(short) ib.getDurability(),
true,
false,
ItemContainerType.INVENTORY,
(byte) 0,
new ArrayList<>(),
""
);
item.setNumOfItems(Warehouse.getMaxResources().get(ibID)); item.setNumOfItems(resourceAmount);
try { try {
item = DbManager.ItemQueries.ADD_ITEM(item); item = DbManager.ItemQueries.ADD_ITEM(item);
worked = true;
} catch (Exception e) { } catch (Exception e) {
throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage()); throwbackError(
pc,
"Unable to create resource " + ib.getName() + ": " + e.getMessage()
);
return; return;
} }
if (item == null || !worked) { if (item == null) {
throwbackError(pc, "DB error 2: Unable to create item."); throwbackError(pc, "Unable to create resource " + ib.getName() + ".");
return; return;
} }
//add item to inventory
pc.getCharItemManager().addItemToInventory(item); pc.getCharItemManager().addItemToInventory(item);
} }
pc.getCharItemManager().updateInventory();
return; return;
} }
if (words.length < 3 || words.length > 5) { if (words.length < 3 || words.length > 5) {
@@ -100,7 +136,7 @@ public class MakeItemCmd extends AbstractDevCmd {
return; return;
} }
numItems = (numItems < 1) ? 1 : numItems; numItems = (numItems < 1) ? 1 : numItems;
numItems = (numItems > 5000) ? 5000 : numItems; numItems = Math.min(numItems, MBServerStatics.RESOURCE_STACK_LIMIT);
} }
int itembaseID; int itembaseID;
+7
View File
@@ -39,6 +39,13 @@ public class SlotTestCmd extends AbstractDevCmd {
Building building = (Building) target; Building building = (Building) target;
outString += "Rank: " + building.getRank() + "\r\n";
outString += "MaxSlots: " + building.getBlueprint().getMaxSlots() + "\r\n";
outString += "SlotsForRank: "
+ building.getBlueprint().getSlotsForRank(building.getRank())
+ "\r\n";
outString += "Hireling Count: " + building.getHirelings().size() + "\r\n\r\n";
buildingLocations = BuildingManager._slotLocations.get(building.meshUUID); buildingLocations = BuildingManager._slotLocations.get(building.meshUUID);
if (buildingLocations == null) { if (buildingLocations == null) {
+1 -1
View File
@@ -110,7 +110,7 @@ public class SplatMobCmd extends AbstractDevCmd {
mobile = Mob.createMob(_mobileUUID, mobile = Mob.createMob(_mobileUUID,
Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange), Vector3fImmutable.getRandomPointInCircle(_currentLocation, _targetRange),
null, serverZone, null, null, "", 1); null, true, serverZone, null, 0, "", 1);
if (mobile != null) { if (mobile != null) {
mobile.updateDatabase(); mobile.updateDatabase();
+13 -19
View File
@@ -11,7 +11,6 @@ package engine.devcmd.cmds;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.gameManager.PowersManager;
import engine.objects.AbstractGameObject; import engine.objects.AbstractGameObject;
import engine.objects.Mob; import engine.objects.Mob;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
@@ -57,20 +56,20 @@ public class aiInfoCmd extends AbstractDevCmd {
Mob mob = (Mob) target; Mob mob = (Mob) target;
output = "Mob AI Information:" + newline; output = "Mob AI Information:" + newline;
output += mob.getName() + newline; output += mob.getName() + newline;
if (mob.behaviourType != null) { if (mob.BehaviourType != null) {
output += "BehaviourType: " + mob.behaviourType.toString() + newline; output += "BehaviourType: " + mob.BehaviourType.toString() + newline;
if (mob.behaviourType.BehaviourHelperType != null) { if (mob.BehaviourType.BehaviourHelperType != null) {
output += "Behaviour Helper Type: " + mob.behaviourType.BehaviourHelperType.toString() + newline; output += "Behaviour Helper Type: " + mob.BehaviourType.BehaviourHelperType.toString() + newline;
} else { } else {
output += "Behaviour Helper Type: NULL" + newline; output += "Behaviour Helper Type: NULL" + newline;
} }
output += "Wimpy: " + mob.behaviourType.isWimpy + newline; output += "Wimpy: " + mob.BehaviourType.isWimpy + newline;
output += "Agressive: " + mob.behaviourType.isAgressive + newline; output += "Agressive: " + mob.BehaviourType.isAgressive + newline;
output += "Can Roam: " + mob.behaviourType.canRoam + newline; output += "Can Roam: " + mob.BehaviourType.canRoam + newline;
output += "Calls For Help: " + mob.behaviourType.callsForHelp + newline; output += "Calls For Help: " + mob.BehaviourType.callsForHelp + newline;
output += "Responds To Call For Help: " + mob.behaviourType.respondsToCallForHelp + newline; output += "Responds To Call For Help: " + mob.BehaviourType.respondsToCallForHelp + newline;
} else { } else {
output += "BehaviourType: NULL" + newline; output += "BehaviourType: NULL" + newline;
} }
output += "Aggro Range: " + mob.getAggroRange() + newline; output += "Aggro Range: " + mob.getAggroRange() + newline;
output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline; output += "Player Aggro Map Size: " + mob.playerAgroMap.size() + newline;
@@ -85,13 +84,8 @@ public class aiInfoCmd extends AbstractDevCmd {
else else
output += "Current Target: NULL" + newline; output += "Current Target: NULL" + newline;
if (mob.guardedCity != null)
output += "Patrolling: " + mob.guardedCity.getCityName() + newline;
output += "Powers:" + newline;
for (int token : mob.mobPowers.keySet()) for (int token : mob.mobPowers.keySet())
output += PowersManager.getPowerByToken(token).getName() + newline; output += token + newline;
throwbackInfo(playerCharacter, output); throwbackInfo(playerCharacter, output);
} }
+31 -3
View File
@@ -289,6 +289,34 @@ public enum BuildingManager {
// Method transfers ownership of all hirelings in a building // Method transfers ownership of all hirelings in a building
public static void reslotHirelings(Building building) {
if (building == null)
return;
ArrayList<AbstractCharacter> hirelings =
new ArrayList<>(building.getHirelings().keySet());
building.getHirelings().clear();
for (AbstractCharacter hireling : hirelings) {
int newSlot = NPCManager.slotCharacterInBuilding(hireling);
if (newSlot == -1) {
Logger.error("Unable to re-slot hireling "
+ hireling.getObjectUUID()
+ " for building "
+ building.getObjectUUID());
continue;
}
hireling.setLoc(hireling.getBindLoc());
WorldGrid.updateObject(hireling);
InterestManager.setObjectDirty(hireling);
}
}
public static void refreshHirelings(Building building) { public static void refreshHirelings(Building building) {
if (building == null) if (building == null)
@@ -535,7 +563,7 @@ public enum BuildingManager {
if (NPC.ISWallArcher(contract)) { if (NPC.ISWallArcher(contract)) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;
@@ -547,7 +575,7 @@ public enum BuildingManager {
if (NPC.ISGuardCaptain(contract.getContractID())) { if (NPC.ISGuardCaptain(contract.getContractID())) {
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;
@@ -559,7 +587,7 @@ public enum BuildingManager {
if (contract.getContractID() == 910) { if (contract.getContractID() == 910) {
//guard dog //guard dog
mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), zone, building, contract, pirateName, rank); mob = Mob.createMob(contract.getMobbaseID(), Vector3fImmutable.ZERO, contractOwner.getGuild(), true, zone, building, contract.getContractID(), pirateName, rank);
if (mob == null) if (mob == null)
return false; return false;
+1 -40
View File
@@ -343,18 +343,7 @@ public enum NPCManager {
if (buildingSlot == -1) if (buildingSlot == -1)
Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID()); Logger.error("No available slot for NPC: " + abstractCharacter.getObjectUUID());
// Pets are regular mobiles not hirelings (Siege engines) abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
if (!abstractCharacter.getObjectType().equals(Enum.GameObjectType.Mob))
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
else {
Mob mobile = (Mob) abstractCharacter;
// Siege engines are not hirelings but minions of said hireling.
if (!mobile.behaviourType.equals(Enum.MobBehaviourType.SiegeEngine))
abstractCharacter.building.getHirelings().put(abstractCharacter, buildingSlot);
}
// Override bind and location for this npc derived // Override bind and location for this npc derived
// from BuildingManager slot location data. // from BuildingManager slot location data.
@@ -381,32 +370,4 @@ public enum NPCManager {
return buildingSlot; return buildingSlot;
} }
public static int getMaxMinions(Mob guardCaptain) {
int maxSlots;
switch (guardCaptain.getRank()) {
case 3:
maxSlots = 2;
break;
case 4:
case 5:
maxSlots = 3;
break;
case 6:
maxSlots = 4;
break;
case 7:
maxSlots = 5;
break;
case 1:
case 2:
default:
maxSlots = 1;
}
return maxSlots;
}
} }
+59 -71
View File
@@ -96,7 +96,7 @@ public class MobAI {
return; return;
} }
if (mob.behaviourType.callsForHelp) if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
if (!MovementUtilities.inRangeDropAggro(mob, target)) { if (!MovementUtilities.inRangeDropAggro(mob, target)) {
@@ -165,7 +165,7 @@ public class MobAI {
if (playercity != null) if (playercity != null)
for (Mob guard : playercity.getParent().zoneMobSet) for (Mob guard : playercity.getParent().zoneMobSet)
if (guard.behaviourType != null && guard.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (guard.BehaviourType != null && guard.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild())) if (guard.getCombatTarget() == null && !guard.getGuild().equals(mob.getGuild()))
guard.setCombatTarget(mob); guard.setCombatTarget(mob);
@@ -260,7 +260,7 @@ public class MobAI {
//guard captains inherit barracks patrol points dynamically //guard captains inherit barracks patrol points dynamically
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
Building barracks = mob.building; Building barracks = mob.building;
@@ -280,7 +280,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (mob.BehaviourType.equals(Enum.MobBehaviourType.GuardCaptain))
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet())
//make sure mob is out of combat stance //make sure mob is out of combat stance
@@ -312,9 +312,9 @@ public class MobAI {
int contractID; int contractID;
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) if(mob.BehaviourType.equals(Enum.MobBehaviourType.GuardMinion))
contractID = mob.guardCaptain.contract.getContractID(); contractID = mob.npcOwner.contract.getContractID();
else else
contractID = mob.contract.getContractID(); contractID = mob.contract.getContractID();
if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false) if(Enum.MinionType.ContractToMinionMap.get(contractID).isMage() == false)
@@ -350,7 +350,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens; ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.behaviourType.callsForHelp) if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile. // Generate a list of tokens from the mob powers for this mobile.
@@ -433,7 +433,7 @@ public class MobAI {
ArrayList<Integer> purgeTokens; ArrayList<Integer> purgeTokens;
AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget();
if (mob.behaviourType.callsForHelp) if (mob.BehaviourType.callsForHelp)
MobCallForHelp(mob); MobCallForHelp(mob);
// Generate a list of tokens from the mob powers for this mobile. // Generate a list of tokens from the mob powers for this mobile.
@@ -564,7 +564,7 @@ public class MobAI {
Zone mobCamp = mob.getParentZone(); Zone mobCamp = mob.getParentZone();
for (Mob helper : mobCamp.zoneMobSet) { for (Mob helper : mobCamp.zoneMobSet) {
if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) { if (helper.BehaviourType.respondsToCallForHelp && helper.BehaviourType.BehaviourHelperType.equals(mob.BehaviourType)) {
helper.setCombatTarget(mob.getCombatTarget()); helper.setCombatTarget(mob.getCombatTarget());
callGotResponse = true; callGotResponse = true;
} }
@@ -608,8 +608,8 @@ public class MobAI {
if (mob.despawned && mob.isPlayerGuard) { if (mob.despawned && mob.isPlayerGuard) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (mob.guardCaptain.isAlive() == false || ((Mob) mob.guardCaptain).despawned == true) { if (mob.npcOwner.isAlive() == false || ((Mob) mob.npcOwner).despawned == true) {
//minions don't respawn while guard captain is dead //minions don't respawn while guard captain is dead
@@ -625,7 +625,7 @@ public class MobAI {
//check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting //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.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
CheckToSendMobHome(mob); CheckToSendMobHome(mob);
return; return;
@@ -646,7 +646,7 @@ public class MobAI {
return; return;
} }
if (mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) if (mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal())
CheckToSendMobHome(mob); CheckToSendMobHome(mob);
if (mob.getCombatTarget() != null) { if (mob.getCombatTarget() != null) {
@@ -673,7 +673,7 @@ public class MobAI {
} }
} }
switch (mob.behaviourType) { switch (mob.BehaviourType) {
case GuardCaptain: case GuardCaptain:
GuardCaptainLogic(mob); GuardCaptainLogic(mob);
break; break;
@@ -684,7 +684,6 @@ public class MobAI {
GuardWallArcherLogic(mob); GuardWallArcherLogic(mob);
break; break;
case Pet1: case Pet1:
case SiegeEngine:
PetLogic(mob); PetLogic(mob);
break; break;
case HamletGuard: case HamletGuard:
@@ -694,6 +693,8 @@ public class MobAI {
DefaultLogic(mob); DefaultLogic(mob);
break; break;
} }
if(mob.isAlive())
RecoverHealth(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage());
} }
@@ -783,7 +784,7 @@ public class MobAI {
mob.updateLocation(); mob.updateLocation();
switch (mob.behaviourType) { switch (mob.BehaviourType) {
case Pet1: case Pet1:
if (mob.getOwner() == null) if (mob.getOwner() == null)
@@ -809,7 +810,7 @@ public class MobAI {
chaseTarget(mob); chaseTarget(mob);
break; break;
case GuardMinion: case GuardMinion:
if (!mob.guardCaptain.isAlive() || ((Mob) mob.guardCaptain).despawned) if (!mob.npcOwner.isAlive() && mob.getCombatTarget() == null)
randomGuardPatrolPoint(mob); randomGuardPatrolPoint(mob);
else { else {
if (mob.getCombatTarget() != null) { if (mob.getCombatTarget() != null) {
@@ -828,6 +829,7 @@ public class MobAI {
chaseTarget(mob); chaseTarget(mob);
} }
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckMobMovement" + " " + e.getMessage());
@@ -894,8 +896,7 @@ public class MobAI {
if (mob.getCombatTarget() == null) if (mob.getCombatTarget() == null)
return; return;
if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && if (mob.getCombatTarget().getObjectType().equals(Enum.GameObjectType.PlayerCharacter) && MovementUtilities.inRangeDropAggro(mob, (PlayerCharacter) mob.getCombatTarget()) == false && mob.BehaviourType.ordinal() != Enum.MobBehaviourType.Pet1.ordinal()) {
mob.behaviourType.equals(Enum.MobBehaviourType.Pet1) == false) {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
@@ -911,10 +912,10 @@ public class MobAI {
private static void CheckToSendMobHome(Mob mob) { private static void CheckToSendMobHome(Mob mob) {
try { try {
if (mob.behaviourType.isAgressive) { if (mob.BehaviourType.isAgressive) {
if (mob.isPlayerGuard()) { if (mob.isPlayerGuard()) {
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal())
CheckForPlayerGuardAggro(mob); CheckForPlayerGuardAggro(mob);
} else { } else {
CheckForAggro(mob); CheckForAggro(mob);
@@ -934,7 +935,7 @@ public class MobAI {
PowersManager.useMobPower(mob, mob, recall, 40); PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null); mob.setCombatTarget(null);
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain) && mob.isAlive()) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal() && mob.isAlive()) {
//guard captain pulls his minions home with him //guard captain pulls his minions home with him
@@ -1015,7 +1016,7 @@ public class MobAI {
if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD))) if ((aggroMob.agentType.equals(Enum.AIAgentType.GUARD)))
continue; continue;
if (aggroMob.behaviourType.equals(Enum.MobBehaviourType.Pet1)) if(aggroMob.BehaviourType.equals(Enum.MobBehaviourType.Pet1))
continue; continue;
if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50)) if (mob.getLoc().distanceSquared2D(aggroMob.getLoc()) > sqr(50))
@@ -1045,7 +1046,6 @@ public class MobAI {
mob.setCombatTarget(newTarget); mob.setCombatTarget(newTarget);
} }
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
@@ -1056,29 +1056,15 @@ public class MobAI {
public static void GuardMinionLogic(Mob mob) { public static void GuardMinionLogic(Mob mob) {
try { try {
if (!mob.guardCaptain.isAlive()) { boolean isComanded = mob.npcOwner.isAlive();
if (!isComanded) {
if (mob.getCombatTarget() == null) { GuardCaptainLogic(mob);
CheckForPlayerGuardAggro(mob);
} else {
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);
}
}
}else { }else {
if (mob.guardCaptain.getCombatTarget() != null) if (mob.npcOwner.getCombatTarget() != null)
mob.setCombatTarget(mob.guardCaptain.getCombatTarget()); mob.setCombatTarget(mob.npcOwner.getCombatTarget());
else if (mob.getCombatTarget() != null) else
mob.setCombatTarget(null); if (mob.getCombatTarget() != null)
mob.setCombatTarget(null);
} }
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
@@ -1107,26 +1093,10 @@ public class MobAI {
if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob))
mob.killCharacter("no owner"); mob.killCharacter("no owner");
if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam) if (MovementUtilities.canMove(mob) && mob.BehaviourType.canRoam)
CheckMobMovement(mob); CheckMobMovement(mob);
CheckForAttack(mob); CheckForAttack(mob);
//recover health
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage());
} }
@@ -1157,7 +1127,7 @@ public class MobAI {
if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false) if (mob.getCombatTarget() != null && mob.playerAgroMap.containsKey(mob.getCombatTarget().getObjectUUID()) == false)
mob.setCombatTarget(null); mob.setCombatTarget(null);
if (mob.behaviourType.isAgressive) { if (mob.BehaviourType.isAgressive) {
AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob);
@@ -1165,7 +1135,7 @@ public class MobAI {
mob.setCombatTarget(newTarget); mob.setCombatTarget(newTarget);
else { else {
if (mob.getCombatTarget() == null) { if (mob.getCombatTarget() == null) {
if (mob.behaviourType == Enum.MobBehaviourType.HamletGuard) if (mob.BehaviourType == Enum.MobBehaviourType.HamletGuard)
SafeGuardAggro(mob); //safehold guard SafeGuardAggro(mob); //safehold guard
else else
CheckForAggro(mob); //normal aggro CheckForAggro(mob); //normal aggro
@@ -1175,12 +1145,12 @@ public class MobAI {
//check if mob can move for patrol or moving to target //check if mob can move for patrol or moving to target
if (mob.behaviourType.canRoam) if (mob.BehaviourType.canRoam)
CheckMobMovement(mob); CheckMobMovement(mob);
//check if mob can attack if it isn't wimpy //check if mob can attack if it isn't wimpy
if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null) if (!mob.BehaviourType.isWimpy && mob.getCombatTarget() != null)
CheckForAttack(mob); CheckForAttack(mob);
} catch (Exception e) { } catch (Exception e) {
@@ -1245,8 +1215,8 @@ public class MobAI {
if (mob.getGuild().getNation().equals(target.getGuild().getNation())) if (mob.getGuild().getNation().equals(target.getGuild().getNation()))
return false; return false;
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardMinion)) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardMinion.ordinal()) {
if (((Mob) mob.guardCaptain).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { if (((Mob) mob.npcOwner).building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
return true; return true;
} }
} else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) { } else if (mob.building.getCity().cityOutlaws.contains(target.getObjectUUID()) == true) {
@@ -1330,7 +1300,7 @@ public class MobAI {
MovementUtilities.aiMove(mob, mob.destination, true); MovementUtilities.aiMove(mob, mob.destination, true);
if (mob.behaviourType.equals(Enum.MobBehaviourType.GuardCaptain)) { if (mob.BehaviourType.ordinal() == Enum.MobBehaviourType.GuardCaptain.ordinal()) {
for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) { for (Entry<Mob, Integer> minion : mob.siegeMinionMap.entrySet()) {
//make sure mob is out of combat stance //make sure mob is out of combat stance
@@ -1380,4 +1350,22 @@ public class MobAI {
} }
return null; return null;
} }
public static void RecoverHealth(Mob mob){
//recover health
if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false)
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000)
if (mob.getHealth() < mob.getHealthMax()) {
float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f);
mob.setHealth(mob.getHealth() + recoveredHealth);
mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis());
if (mob.getHealth() > mob.getHealthMax())
mob.setHealth(mob.getHealthMax());
}
}
} }
@@ -48,7 +48,7 @@ public class CombatUtilities {
} }
public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) { public static boolean inRange2D(AbstractWorldObject entity1, AbstractWorldObject entity2, double range) {
return entity1.getLoc().distanceSquared2D(entity2.getLoc()) < range * range; return entity1.getLoc().distance2D(entity2.getLoc()) < range;
} }
public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) { public static void swingIsBlock(Mob agent, AbstractWorldObject target, int animation) {
@@ -13,10 +13,10 @@ import engine.Enum;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.ModType; import engine.Enum.ModType;
import engine.Enum.SourceType; import engine.Enum.SourceType;
import engine.mobileAI.Threads.MobAIThread;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
import engine.gameManager.MovementManager; import engine.gameManager.MovementManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread;
import engine.net.client.msg.MoveToPointMsg; import engine.net.client.msg.MoveToPointMsg;
import engine.objects.*; import engine.objects.*;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -38,7 +38,7 @@ public class MovementUtilities {
if (agent.getContract() != null) if (agent.getContract() != null)
guardCaptain = agent; guardCaptain = agent;
else else
guardCaptain = (Mob) agent.guardCaptain; guardCaptain = (Mob) agent.npcOwner;
if (guardCaptain != null) { if (guardCaptain != null) {
Building barracks = guardCaptain.building; Building barracks = guardCaptain.building;
+1 -1
View File
@@ -1259,7 +1259,7 @@ public class ClientMessagePump implements NetMsgHandler {
cost *= profit; cost *= profit;
if (gold.getNumOfItems() + cost > 10000000) { if (gold.getNumOfItems() + cost > MBServerStatics.PLAYER_GOLD_LIMIT) {
return; return;
} }
@@ -8,6 +8,7 @@ import engine.gameManager.BuildingManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.NPCManager; import engine.gameManager.NPCManager;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
@@ -145,10 +146,42 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
if (mobBase == 0) if (mobBase == 0)
return true; return true;
Mob siegeMob = Mob.createSiegeMinion(npc, mobBase); Mob siegeMob = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1);
if (siegeMob == null) if (siegeMob == null)
return true; return true;
if (siegeMob != null) {
siegeMob.setSpawnTime(60 * 15);
Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID());
siegeMob.building = building;
siegeMob.parentZone = zone;
// Slot siege minion
// Can be either corner tower or bulwark.
int slot;
if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.ARTYTOWER))
slot = 2;
else
slot = ((NPC) siegeMob.npcOwner).getSiegeMinionMap().get(siegeMob) + 1; // First slot is for the captain
BuildingLocation slotLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
siegeMob.bindLoc = building.getLoc().add(slotLocation.getLocation());
// Rotate slot position by the building rotation
siegeMob.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), siegeMob.bindLoc, building.getBounds().getQuaternion().angleY);
siegeMob.loc = new Vector3fImmutable(siegeMob.bindLoc);
siegeMob.endLoc = new Vector3fImmutable(siegeMob.bindLoc);
zone.zoneMobSet.add(siegeMob);
siegeMob.setLoc(siegeMob.bindLoc);
}
} }
ManageNPCMsg mnm = new ManageNPCMsg(npc); ManageNPCMsg mnm = new ManageNPCMsg(npc);
@@ -265,12 +298,12 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
String pirateName = NPCManager.getPirateName(mobBase); String pirateName = NPCManager.getPirateName(mobBase);
Mob toCreate = Mob.createGuardMinion(npc, npc.getLevel(), pirateName); if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
if (toCreate == null)
return true; return true;
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1)) Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, building.getLoc(), npc.getLevel(), pirateName);
if (toCreate == null)
return true; return true;
if (toCreate != null) { if (toCreate != null) {
@@ -541,7 +541,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
} else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) { } else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) {
mob = Mob.getMob(orderNPCMsg.getNpcUUID()); mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID());
if (mob == null) if (mob == null)
return true; return true;
+3 -3
View File
@@ -366,7 +366,7 @@ public class ManageNPCMsg extends ClientNetMsg {
long timeLife = upgradeTime - curTime; long timeLife = upgradeTime - curTime;
if (upgradeTime * 1000 > System.currentTimeMillis()) { if (upgradeTime * 1000 > System.currentTimeMillis()) {
if (mob.guardCaptain.isAlive()) { if (mob.npcOwner.isAlive()) {
writer.put((byte) 0);//shows respawning timer writer.put((byte) 0);//shows respawning timer
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);
@@ -557,7 +557,7 @@ public class ManageNPCMsg extends ClientNetMsg {
} else if (this.targetType == GameObjectType.Mob.ordinal()) { } else if (this.targetType == GameObjectType.Mob.ordinal()) {
mobA = Mob.getMob(this.targetID); mobA = Mob.getFromCacheDBID(this.targetID);
if (mobA == null) { if (mobA == null) {
Logger.error("Missing Mob of ID " + this.targetID); Logger.error("Missing Mob of ID " + this.targetID);
@@ -689,7 +689,7 @@ public class ManageNPCMsg extends ClientNetMsg {
long timeLife = upgradeTime - curTime; long timeLife = upgradeTime - curTime;
if (upgradeTime * 1000 > System.currentTimeMillis()) { if (upgradeTime * 1000 > System.currentTimeMillis()) {
if (mob.guardCaptain.isAlive()) { if (mob.npcOwner.isAlive()) {
writer.put((byte) 0);//shows respawning timer writer.put((byte) 0);//shows respawning timer
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);
writer.putInt(mob.spawnTime); writer.putInt(mob.spawnTime);
+14 -22
View File
@@ -52,8 +52,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public int contractUUID; public int contractUUID;
public Contract contract; public Contract contract;
public String firstName; protected String firstName;
public String lastName; protected String lastName;
protected short statStrCurrent; protected short statStrCurrent;
protected short statDexCurrent; protected short statDexCurrent;
protected short statConCurrent; protected short statConCurrent;
@@ -119,31 +119,14 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
private long takeOffTime = 0; private long takeOffTime = 0;
private float hateValue = 0; private float hateValue = 0;
private long lastHateUpdate = 0; private long lastHateUpdate = 0;
private boolean collided = false;
private byte aoecntr = 0; private byte aoecntr = 0;
public AbstractCharacter() { public AbstractCharacter() {
super(); super();
this.firstName = "";
this.lastName = "";
this.statStrCurrent = (short) 0; this.powers = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.statDexCurrent = (short) 0; this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.statConCurrent = (short) 0;
this.statIntCurrent = (short) 0;
this.statSpiCurrent = (short) 0;
this.unusedStatPoints = (short) 0;
this.level = (short) 0; // TODO get this from MobsBase later
this.exp = 1;
this.walkMode = true;
this.bindLoc = Vector3fImmutable.ZERO;
this.faceDir = Vector3fImmutable.ZERO;
this.runningTrains = (byte) 0;
this.skills = new ConcurrentHashMap<>();
this.powers = new ConcurrentHashMap<>();
this.initializeCharacter(); this.initializeCharacter();
} }
@@ -231,6 +214,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); this.skills = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
this.initializeCharacter(); this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
} }
/** /**
@@ -273,6 +258,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>(); this.powers = new ConcurrentHashMap<>();
this.initializeCharacter(); this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
} }
/** /**
@@ -304,6 +291,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>(); this.powers = new ConcurrentHashMap<>();
initializeCharacter(); initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
} }
/** /**
@@ -353,6 +342,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
this.powers = new ConcurrentHashMap<>(); this.powers = new ConcurrentHashMap<>();
this.initializeCharacter(); this.initializeCharacter();
// Dangerous to use THIS in a constructor!!!
this.charItemManager = new CharacterItemManager(this);
} }
public static int getBankCapacity() { public static int getBankCapacity() {
@@ -9,7 +9,6 @@
package engine.objects; package engine.objects;
import ch.claude_martin.enumbitset.EnumBitSet;
import engine.Enum; import engine.Enum;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.ModType; import engine.Enum.ModType;
@@ -32,20 +31,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
protected Vector3fImmutable lastBindLoc; protected Vector3fImmutable lastBindLoc;
public boolean assist = false; public boolean assist = false;
public Enum.AIAgentType agentType = Enum.AIAgentType.MOBILE; 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);
;
public Enum.MobBehaviourType behaviourType;
public ArrayList<Vector3fImmutable> patrolPoints;
public int lastPatrolPointIndex = 0;
public long stopPatrolTime = 0;
public City guardedCity;
public AbstractIntelligenceAgent() {
super();
}
public AbstractIntelligenceAgent(ResultSet rs) throws SQLException { public AbstractIntelligenceAgent(ResultSet rs) throws SQLException {
super(rs); super(rs);
@@ -124,6 +110,14 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
return 0; return 0;
} }
public PlayerCharacter getOwner() {
if (this.getObjectType().equals(GameObjectType.Mob))
return this.getOwner();
return null;
}
public boolean getSafeZone() { public boolean getSafeZone() {
ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc()); ArrayList<Zone> allIn = ZoneManager.getAllZonesIn(this.getLoc());
@@ -164,7 +158,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
//clear owner //clear owner
PlayerCharacter owner = (PlayerCharacter) this.guardCaptain; PlayerCharacter owner = this.getOwner();
//close pet window //close pet window
+1 -1
View File
@@ -335,7 +335,7 @@ public class Blueprint {
availableSlots = 3; availableSlots = 3;
break; break;
case 8: case 8:
availableSlots = 1; availableSlots = Math.min(3, this.maxSlots);
break; break;
default: default:
availableSlots = 0; availableSlots = 0;
+4
View File
@@ -427,6 +427,10 @@ public class Building extends AbstractWorldObject {
BuildingManager.cleanupHirelings(this); BuildingManager.cleanupHirelings(this);
if (this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL
&& this.rank == 8)
BuildingManager.reslotHirelings(this);
this.isDeranking.compareAndSet(true, false); this.isDeranking.compareAndSet(true, false);
} }
+2 -3
View File
@@ -2335,15 +2335,14 @@ public class CharacterItemManager {
} }
if (this.getGoldInventory().getNumOfItems() + goldFrom2 > 10000000) { if (this.getGoldInventory().getNumOfItems() + goldFrom2 > MBServerStatics.PLAYER_GOLD_LIMIT) {
PlayerCharacter pc = (PlayerCharacter) this.absCharacter; PlayerCharacter pc = (PlayerCharacter) this.absCharacter;
if (pc.getClientConnection() != null) if (pc.getClientConnection() != null)
ErrorPopupMsg.sendErrorPopup(pc, 202); ErrorPopupMsg.sendErrorPopup(pc, 202);
return false; return false;
} }
if (tradingWith.getGoldInventory().getNumOfItems() + goldFrom1 > MBServerStatics.PLAYER_GOLD_LIMIT) {
if (tradingWith.getGoldInventory().getNumOfItems() + goldFrom1 > 10000000) {
PlayerCharacter pc = (PlayerCharacter) tradingWith.absCharacter; PlayerCharacter pc = (PlayerCharacter) tradingWith.absCharacter;
if (pc.getClientConnection() != null) if (pc.getClientConnection() != null)
ErrorPopupMsg.sendErrorPopup(pc, 202); ErrorPopupMsg.sendErrorPopup(pc, 202);
+39 -40
View File
@@ -674,46 +674,6 @@ public class Item extends AbstractWorldObject {
public static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType) { public static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType) {
return newGoldItem(awo, ib, containerType, true); return newGoldItem(awo, ib, containerType, true);
} }
//used for vault!
public static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType) {
return newGoldItem(accountID, ib, containerType, true);
}
private static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) {
int ownerID;
OwnerType ownerType;
ownerID = accountID;
ownerType = OwnerType.Account;
Item newGold = new Item(ib, ownerID, ownerType,
(byte) 0, (byte) 0, (short) 0, (short) 0, true, false, containerType, (byte) 0,
new ArrayList<>(), "");
synchronized (newGold) {
newGold.numberOfItems = 0;
}
if (persist) {
try {
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
if (newGold != null) {
synchronized (newGold) {
newGold.numberOfItems = 0;
}
}
} catch (Exception e) {
Logger.error(e);
}
DbManager.ItemQueries.ZERO_ITEM_STACK(newGold);
}
return newGold;
}
private static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) { private static Item newGoldItem(AbstractWorldObject awo, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) {
int ownerID; int ownerID;
@@ -771,10 +731,49 @@ public class Item extends AbstractWorldObject {
} }
DbManager.ItemQueries.ZERO_ITEM_STACK(newGold); DbManager.ItemQueries.ZERO_ITEM_STACK(newGold);
} }
newGold.containerType = containerType; newGold.containerType = containerType;
return newGold; return newGold;
} }
//used for vault!
public static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType) {
return newGoldItem(accountID, ib, containerType, true);
}
private static Item newGoldItem(int accountID, ItemBase ib, Enum.ItemContainerType containerType, boolean persist) {
int ownerID;
OwnerType ownerType;
ownerID = accountID;
ownerType = OwnerType.Account;
Item newGold = new Item(ib, ownerID, ownerType,
(byte) 0, (byte) 0, (short) 0, (short) 0, true, false, containerType, (byte) 0,
new ArrayList<>(), "");
synchronized (newGold) {
newGold.numberOfItems = 0;
}
if (persist) {
try {
newGold = DbManager.ItemQueries.ADD_ITEM(newGold);
if (newGold != null) {
synchronized (newGold) {
newGold.numberOfItems = 0;
}
}
} catch (Exception e) {
Logger.error(e);
}
DbManager.ItemQueries.ZERO_ITEM_STACK(newGold);
}
return newGold;
}
// This is to be used for trades - the new item is not stored in the database // This is to be used for trades - the new item is not stored in the database
public static Item newGoldItemTemp(AbstractWorldObject awo, ItemBase ib) { public static Item newGoldItemTemp(AbstractWorldObject awo, ItemBase ib) {
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -86,7 +86,6 @@ public class NPC extends AbstractCharacter {
public NPC() { public NPC() {
super();
this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.dbID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET; this.currentID = MBServerStatics.NO_DB_ROW_ASSIGNED_YET;
} }
@@ -806,8 +805,6 @@ public class NPC extends AbstractCharacter {
@Override @Override
public void runAfterLoad() { public void runAfterLoad() {
this.charItemManager = new CharacterItemManager(this);
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER)) if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
return; return;
@@ -849,6 +846,10 @@ public class NPC extends AbstractCharacter {
if (wordCount(this.name) < 2 && this.contract != null) if (wordCount(this.name) < 2 && this.contract != null)
this.name += " the " + this.contract.getName(); this.name += " the " + this.contract.getName();
// Initialize inventory
this.charItemManager = new CharacterItemManager(this);
// Configure parent zone adding this NPC to the // Configure parent zone adding this NPC to the
// zone collection // zone collection
+15 -8
View File
@@ -144,6 +144,7 @@ public class PlayerCharacter extends AbstractCharacter {
private long lastUpdateTime = System.currentTimeMillis(); private long lastUpdateTime = System.currentTimeMillis();
private long lastStamUpdateTime = System.currentTimeMillis(); private long lastStamUpdateTime = System.currentTimeMillis();
private boolean safeZone = false; private boolean safeZone = false;
private int bindBuildingID;
/* /*
DataWarehouse based kill/death tracking. DataWarehouse based kill/death tracking.
@@ -204,18 +205,15 @@ public class PlayerCharacter extends AbstractCharacter {
this.spiMod.set(spiMod); this.spiMod.set(spiMod);
this.guildStatus = new AtomicInteger(0); this.guildStatus = new AtomicInteger(0);
this.buildingUUID = -1; this.bindBuildingID = -1;
} }
/** /**
* ResultSet Constructor * ResultSet Constructor
*/ */
public PlayerCharacter(ResultSet rs) throws SQLException { public PlayerCharacter(ResultSet rs) throws SQLException {
super(rs, true); super(rs, true);
this.charItemManager = new CharacterItemManager(this);
this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID()); this.runes = DbManager.CharacterRuneQueries.GET_RUNES_FOR_CHARACTER(this.getObjectUUID());
int accountID = rs.getInt("parent"); int accountID = rs.getInt("parent");
this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID); this.account = DbManager.AccountQueries.GET_ACCOUNT(accountID);
@@ -267,7 +265,7 @@ public class PlayerCharacter extends AbstractCharacter {
this.intMod.set(rs.getShort("char_intMod")); this.intMod.set(rs.getShort("char_intMod"));
this.spiMod.set(rs.getShort("char_spiMod")); this.spiMod.set(rs.getShort("char_spiMod"));
this.buildingUUID = rs.getInt("char_bindBuilding"); this.bindBuildingID = rs.getInt("char_bindBuilding");
this.hash = rs.getString("hash"); this.hash = rs.getString("hash");
@@ -1241,12 +1239,17 @@ public class PlayerCharacter extends AbstractCharacter {
playerCharacter.deactivateCharacter(); playerCharacter.deactivateCharacter();
return null; return null;
} }
// Ebonreach: give new characters starter gold.
Item starterGold = Item.newGoldItem(playerCharacter, ItemBase.getItemBase(7), Enum.ItemContainerType.INVENTORY);
if (starterGold != null)
DbManager.ItemQueries.UPDATE_GOLD(starterGold, 10000);
// Get any new skills that belong to the player // Get any new skills that belong to the player
playerCharacter.calculateSkills(); playerCharacter.calculateSkills();
a.setLastCharacter(playerCharacter.getObjectUUID()); a.setLastCharacter(playerCharacter.getObjectUUID());
playerCharacter.charItemManager.load(); playerCharacter.getCharItemManager().load();
playerCharacter.activateCharacter(); playerCharacter.activateCharacter();
@@ -2723,12 +2726,12 @@ public class PlayerCharacter extends AbstractCharacter {
*/ */
public synchronized int getBindBuildingID() { public synchronized int getBindBuildingID() {
return this.buildingUUID; return this.bindBuildingID;
} }
public synchronized void setBindBuildingID(int value) { public synchronized void setBindBuildingID(int value) {
DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value); DbManager.PlayerCharacterQueries.SET_BIND_BUILDING(this, value);
this.buildingUUID = value; this.bindBuildingID = value;
} }
public AbstractGameObject getLastTarget() { public AbstractGameObject getLastTarget() {
@@ -4563,6 +4566,10 @@ public class PlayerCharacter extends AbstractCharacter {
@Override @Override
public void runAfterLoad() { public void runAfterLoad() {
// Init inventory
this.charItemManager = new CharacterItemManager(this);
Bounds playerBounds = Bounds.borrow(); Bounds playerBounds = Bounds.borrow();
playerBounds.setBounds(this.getLoc()); playerBounds.setBounds(this.getLoc());
this.setBounds(playerBounds); this.setBounds(playerBounds);
+23 -23
View File
@@ -99,29 +99,29 @@ public class Warehouse extends AbstractWorldObject {
public static ConcurrentHashMap<Integer, Integer> getMaxResources() { public static ConcurrentHashMap<Integer, Integer> getMaxResources() {
if (maxResources.size() != 23) { if (maxResources.size() != 23) {
maxResources.put(7, 100000000); maxResources.put(7, 1000000000);
maxResources.put(1580000, 10000); maxResources.put(1580000, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580001, 2000); maxResources.put(1580001, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580002, 2000); maxResources.put(1580002, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580003, 1000); maxResources.put(1580003, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580004, 10000); maxResources.put(1580004, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580005, 3000); maxResources.put(1580005, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580006, 3000); maxResources.put(1580006, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580007, 1000); maxResources.put(1580007, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580008, 3000); maxResources.put(1580008, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580009, 2000); maxResources.put(1580009, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580010, 2000); maxResources.put(1580010, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580011, 1000); maxResources.put(1580011, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580012, 2000); maxResources.put(1580012, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580013, 3000); maxResources.put(1580013, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580014, 1000); maxResources.put(1580014, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580015, 1000); maxResources.put(1580015, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580016, 1000); maxResources.put(1580016, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580017, 500); maxResources.put(1580017, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580018, 500); maxResources.put(1580018, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580019, 500); maxResources.put(1580019, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580020, 500); maxResources.put(1580020, MBServerStatics.RESOURCE_STACK_LIMIT);
maxResources.put(1580021, 500); maxResources.put(1580021, MBServerStatics.RESOURCE_STACK_LIMIT);
} }
return maxResources; return maxResources;
@@ -12,6 +12,7 @@ package engine.powers.poweractions;
import engine.Enum; import engine.Enum;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.MovementManager;
import engine.gameManager.NPCManager; import engine.gameManager.NPCManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
@@ -74,7 +75,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
return; return;
//create Pet //create Pet
Mob pet = Mob.createPetMinion(mobID, seaFloor, owner, (short) mobLevel); Mob pet = Mob.createPet(mobID, guild, seaFloor, owner, (short) mobLevel);
if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet if (pet.getMobBaseID() == 12021 || pet.getMobBaseID() == 12022) { //is a necro pet
@@ -83,6 +84,8 @@ public class CreateMobPowerAction extends AbstractPowerAction {
WorldGrid.RemoveWorldObject(currentPet); WorldGrid.RemoveWorldObject(currentPet);
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
//if (currentPet.getParentZone() != null)
//currentPet.getParentZone().zoneMobSet.remove(currentPet);
seaFloor.zoneMobSet.remove(currentPet); seaFloor.zoneMobSet.remove(currentPet);
currentPet.playerAgroMap.clear(); currentPet.playerAgroMap.clear();
@@ -92,6 +95,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
Logger.error(e.getMessage()); Logger.error(e.getMessage());
} }
//currentPet.disableIntelligence();
} else if (currentPet != null && currentPet.isSiege()) { } else if (currentPet != null && currentPet.isSiege()) {
currentPet.agentType = Enum.AIAgentType.MOBILE; currentPet.agentType = Enum.AIAgentType.MOBILE;
currentPet.setOwner(null); currentPet.setOwner(null);
@@ -102,6 +106,7 @@ public class CreateMobPowerAction extends AbstractPowerAction {
} }
//remove 10th pet //remove 10th pet
NPCManager.spawnNecroPet(owner, pet); NPCManager.spawnNecroPet(owner, pet);
} else { //is not a necro pet } else { //is not a necro pet
@@ -132,9 +137,26 @@ public class CreateMobPowerAction extends AbstractPowerAction {
NPCManager.resetNecroPets(owner); NPCManager.resetNecroPets(owner);
} }
} }
/* if(owner.getPet() != null) {
if(owner.getPet().getMobBaseID() != 12021 && owner.getPet().getMobBaseID() != 12022) {
//if not a necro pet, remove pet
WorldGrid.removeWorldObject(owner.getPet());
owner.getPet().disableIntelligence();
Mob.removePet(owner.getPet().getUUID());
owner.setPet(null);
}
else {
//if it is a necro pet, add it to the line and set as mob
owner.getPet().setMob();
}
}*/
// if (mobID == 12021 || mobID == 12022) //Necro Pets
// pet.setPet(owner, true);
owner.setPet(pet); owner.setPet(pet);
if(pet.isSiege() == false) {
MovementManager.translocate(pet, owner.getLoc(), owner.region);
}
pet.recalculateStats(); pet.recalculateStats();
pet.healthMax = pet.level * 0.5f * 120; pet.healthMax = pet.level * 0.5f * 120;
pet.setHealth(pet.healthMax); pet.setHealth(pet.healthMax);
+3 -2
View File
@@ -33,15 +33,16 @@ public class MBServerStatics {
// hit box // hit box
// calcs // calcs
public static final boolean PRINT_INCOMING_OPCODES = false; // print public static final boolean PRINT_INCOMING_OPCODES = false; // print
public static final int BANK_GOLD_LIMIT = 25000000; public static final int BANK_GOLD_LIMIT = 1000000000;
// incoming // incoming
// opcodes to // opcodes to
// console // console
public static final int PLAYER_GOLD_LIMIT = 10000000; public static final int PLAYER_GOLD_LIMIT = 500000000;
// buildings, npcs // buildings, npcs
/* /*
* Login cache flags * Login cache flags
*/ */
public static final int RESOURCE_STACK_LIMIT = 1000000000;
public static final boolean SKIP_CACHE_LOGIN = false; // skip caching // login server public static final boolean SKIP_CACHE_LOGIN = false; // skip caching // login server
public static final boolean SKIP_CACHE_LOGIN_PLAYER = false; // skip caching // on login public static final boolean SKIP_CACHE_LOGIN_PLAYER = false; // skip caching // on login
public static final boolean SKIP_CACHE_LOGIN_ITEM = false; // skip caching public static final boolean SKIP_CACHE_LOGIN_ITEM = false; // skip caching
+43 -42
View File
@@ -10,6 +10,7 @@
package engine.server.world; package engine.server.world;
import engine.Enum; import engine.Enum;
import engine.Enum.BuildingGroup;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;
import engine.Enum.MinionType; import engine.Enum.MinionType;
import engine.Enum.SupportMsgType; import engine.Enum.SupportMsgType;
@@ -17,7 +18,6 @@ import engine.InterestManagement.HeightMap;
import engine.InterestManagement.RealmMap; import engine.InterestManagement.RealmMap;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.db.archive.DataWarehouse; import engine.db.archive.DataWarehouse;
import engine.db.handlers.dbPowerHandler;
import engine.exception.MsgSendException; import engine.exception.MsgSendException;
import engine.gameManager.*; import engine.gameManager.*;
import engine.job.JobContainer; import engine.job.JobContainer;
@@ -352,7 +352,7 @@ public class WorldServer {
DbManager.MobBaseQueries.GET_ALL_MOBBASES(); DbManager.MobBaseQueries.GET_ALL_MOBBASES();
Logger.info("Loading Mob Powers"); Logger.info("Loading Mob Powers");
PowersManager.AllMobPowers = dbPowerHandler.LOAD_MOB_POWERS(); PowersManager.AllMobPowers = DbManager.PowerQueries.LOAD_MOB_POWERS();
Logger.info("Loading item enchants"); Logger.info("Loading item enchants");
DbManager.LootQueries.LOAD_ENCHANT_VALUES(); DbManager.LootQueries.LOAD_ENCHANT_VALUES();
@@ -482,7 +482,7 @@ public class WorldServer {
Logger.info("Initializing Client Connection Manager"); Logger.info("Initializing Client Connection Manager");
initClientConnectionManager(); initClientConnectionManager();
//intiate mob respawn thread //intiate mob respawn thread
Logger.info("Starting Mob Respawn Thread"); Logger.info("Starting Mob Respawn Thread");
MobRespawnThread.startRespawnThread(); MobRespawnThread.startRespawnThread();
@@ -551,40 +551,44 @@ public class WorldServer {
} }
//Set sea floor object for server //Set sea floor object for server
Zone seaFloor = rootParent.get(0); Zone seaFloor = rootParent.get(0);
seaFloor.setParent(null); seaFloor.setParent(null);
ZoneManager.setSeaFloor(seaFloor); ZoneManager.setSeaFloor(seaFloor);
// zoneManager.addZone(seaFloor.getLoadNum(), seaFloor); <- DIE IN A FUCKING CAR FIRE BONUS CODE LIKE THIS SUCKS FUCKING DICK
rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor)); rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor));
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
for (Zone zone : rootParent) { for (Zone zone : rootParent) {
ZoneManager.addZone(zone.getLoadNum(), zone);
zone.generateWorldAltitude();
//Handle Buildings
try { try {
ZoneManager.addZone(zone.getLoadNum(), zone);
try {
zone.generateWorldAltitude();
} catch (Exception e) {
Logger.error(e.getMessage());
e.printStackTrace();
}
//Handle Buildings
ArrayList<Building> bList; ArrayList<Building> bList;
bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone);
for (Building b : bList) { for (Building b : bList) {
b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); try {
b.setLoc(b.getLoc()); b.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
b.setLoc(b.getLoc());
} catch (Exception e) {
Logger.error(b.getObjectUUID() + " returned an Error Message :" + e.getMessage());
}
} }
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle Mobs //Handle Mobs
try {
ArrayList<Mob> mobs; ArrayList<Mob> mobs;
mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone); mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone);
@@ -592,22 +596,15 @@ public class WorldServer {
m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks()); m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks());
m.setLoc(m.getLoc()); m.setLoc(m.getLoc());
// Load Minions for Guard Captains here. //ADD GUARDS HERE.
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)
if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK) DbManager.MobQueries.LOAD_PATROL_POINTS(m);
DbManager.MobQueries.LOAD_GUARD_MINIONS(m);
} }
} catch (Exception e) {
Logger.error(e);
e.printStackTrace();
}
//Handle NPCs //Handle npc's
try {
ArrayList<NPC> npcs; ArrayList<NPC> npcs;
// Ignore NPCs on the seafloor (npc guild leaders, etc) // Ignore npc's on the seafloor (npc guild leaders, etc)
if (zone.equals(seaFloor)) if (zone.equals(seaFloor))
continue; continue;
@@ -615,22 +612,26 @@ public class WorldServer {
npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone); npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone);
for (NPC n : npcs) { for (NPC n : npcs) {
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
n.setLoc(n.getLoc()); try {
n.setObjectTypeMask(MBServerStatics.MASK_NPC);
n.setLoc(n.getLoc());
} catch (Exception e) {
Logger.error(n.getObjectUUID() + " returned an Error Message :" + e.getMessage());
}
} }
//Handle cities
ZoneManager.loadCities(zone);
ZoneManager.populateWorldZones(zone);
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.info(e.getMessage() + zone.getName() + ' ' + zone.getObjectUUID());
e.printStackTrace();
} }
//Handle cities
ZoneManager.loadCities(zone);
ZoneManager.populateWorldZones(zone);
} }
Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); Logger.info("time to load: " + (System.currentTimeMillis() - start) + " ms");
} }
/** /**
@@ -703,7 +704,7 @@ public class WorldServer {
return; return;
} }
//remove player from loaded mobs agro maps //remove player from loaded mobs agro maps
for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(), MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_MOB)) { for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(player.getLoc(),MBServerStatics.CHARACTER_LOAD_RANGE,MBServerStatics.MASK_MOB)) {
Mob loadedMob = (Mob) awo; Mob loadedMob = (Mob) awo;
loadedMob.playerAgroMap.remove(player.getObjectUUID()); loadedMob.playerAgroMap.remove(player.getObjectUUID());
} }