forked from MagicBane/Server
New method implemented.
This commit is contained in:
@@ -119,82 +119,6 @@ public enum NPCManager {
|
|||||||
playerCharacter.necroPets.clear();
|
playerCharacter.necroPets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void removeSiegeMinions(Mob mobile) {
|
|
||||||
|
|
||||||
for (Integer minionUUID : mobile.minions) {
|
|
||||||
|
|
||||||
Mob siegeMinion = Mob.getMob(minionUUID);
|
|
||||||
|
|
||||||
if (mobile.isMoving()) {
|
|
||||||
|
|
||||||
mobile.stopMovement(mobile.getLoc());
|
|
||||||
|
|
||||||
if (siegeMinion.parentZone != null)
|
|
||||||
siegeMinion.parentZone.zoneMobSet.remove(siegeMinion);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
siegeMinion.clearEffects();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (siegeMinion.parentZone != null)
|
|
||||||
siegeMinion.parentZone.zoneMobSet.remove(siegeMinion);
|
|
||||||
|
|
||||||
WorldGrid.RemoveWorldObject(siegeMinion);
|
|
||||||
WorldGrid.removeObject(siegeMinion);
|
|
||||||
DbManager.removeFromCache(siegeMinion);
|
|
||||||
|
|
||||||
|
|
||||||
PlayerCharacter petOwner = (PlayerCharacter) siegeMinion.guardCaptain;
|
|
||||||
|
|
||||||
if (petOwner != null) {
|
|
||||||
|
|
||||||
petOwner.setPet(null);
|
|
||||||
|
|
||||||
siegeMinion.guardCaptain = null;
|
|
||||||
|
|
||||||
PetMsg petMsg = new PetMsg(5, null);
|
|
||||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean removeMobileFromBuilding(Mob mobile, Building building) {
|
|
||||||
|
|
||||||
// Remove npc from it's building
|
|
||||||
|
|
||||||
try {
|
|
||||||
mobile.clearEffects();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mobile.parentZone != null)
|
|
||||||
mobile.parentZone.zoneMobSet.remove(mobile);
|
|
||||||
|
|
||||||
if (building != null) {
|
|
||||||
building.getHirelings().remove(mobile);
|
|
||||||
removeSiegeMinions(mobile);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete npc from database
|
|
||||||
|
|
||||||
if (DbManager.MobQueries.DELETE_MOB(mobile) == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Remove npc from the simulation
|
|
||||||
|
|
||||||
mobile.removeFromCache();
|
|
||||||
DbManager.removeFromCache(mobile);
|
|
||||||
WorldGrid.RemoveWorldObject(mobile);
|
|
||||||
WorldGrid.removeObject(mobile);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadAllPirateNames() {
|
public static void loadAllPirateNames() {
|
||||||
|
|
||||||
DbManager.NPCQueries.LOAD_PIRATE_NAMES();
|
DbManager.NPCQueries.LOAD_PIRATE_NAMES();
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import engine.Enum.ProfitType;
|
|||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.NPCManager;
|
|
||||||
import engine.gameManager.SessionManager;
|
import engine.gameManager.SessionManager;
|
||||||
import engine.math.FastMath;
|
import engine.math.FastMath;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
@@ -37,7 +36,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
super(OrderNPCMsg.class);
|
super(OrderNPCMsg.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processRedeedHireling(Mob hireling, Building building, ClientConnection origin) {
|
public static void processRedeedHireling(AbstractCharacter hireling, Building building, ClientConnection origin) {
|
||||||
|
|
||||||
PlayerCharacter player;
|
PlayerCharacter player;
|
||||||
Contract contract;
|
Contract contract;
|
||||||
@@ -48,7 +47,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
player = SessionManager.getPlayerCharacter(origin);
|
player = SessionManager.getPlayerCharacter(origin);
|
||||||
itemMan = player.getCharItemManager();
|
itemMan = player.getCharItemManager();
|
||||||
|
|
||||||
contract = hireling.getContract();
|
contract = hireling.contract;
|
||||||
|
|
||||||
if (!player.getCharItemManager().hasRoomInventory((short) 1)) {
|
if (!player.getCharItemManager().hasRoomInventory((short) 1)) {
|
||||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||||
@@ -277,28 +276,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static synchronized void processRedeedNPC(AbstractCharacter abstractCharacter, Building building, ClientConnection origin) {
|
|
||||||
|
|
||||||
// Member variable declaration
|
|
||||||
|
|
||||||
switch (abstractCharacter.getObjectType()) {
|
|
||||||
case NPC:
|
|
||||||
NPC npc = (NPC) abstractCharacter;
|
|
||||||
|
|
||||||
Building cityBuilding = npc.getBuilding();
|
|
||||||
|
|
||||||
if (cityBuilding == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BuildingManager.processRedeedNPC(npc, npc.building, origin);
|
|
||||||
break;
|
|
||||||
case Mob:
|
|
||||||
Mob mob = (Mob) abstractCharacter;
|
|
||||||
processRedeedHireling(mob, mob.building, origin);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean AddPatrolPoints(int buildingID, ArrayList<Vector3fImmutable> patrolPoints) {
|
private static boolean AddPatrolPoints(int buildingID, ArrayList<Vector3fImmutable> patrolPoints) {
|
||||||
|
|
||||||
Building building = BuildingManager.getBuildingFromCache(buildingID);
|
Building building = BuildingManager.getBuildingFromCache(buildingID);
|
||||||
@@ -489,7 +466,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
|
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
processRedeedNPC(npc, building, origin);
|
processRedeedHireling(npc, building, origin);
|
||||||
return true;
|
return true;
|
||||||
//MB TODO HANDLE all profits.
|
//MB TODO HANDLE all profits.
|
||||||
case 7:
|
case 7:
|
||||||
@@ -557,10 +534,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (building.getHirelings().containsKey(mob) == false)
|
if (building.getHirelings().containsKey(mob) == false)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (NPCManager.removeMobileFromBuilding(mob, building) == false) {
|
BuildingManager.removeHireling(building, mob);
|
||||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg();
|
ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg();
|
||||||
manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW;
|
manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW;
|
||||||
@@ -595,7 +569,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
|
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
processRedeedNPC(mob, building, origin);
|
processRedeedHireling(mob, building, origin);
|
||||||
return true;
|
return true;
|
||||||
//MB TODO HANDLE all profits.
|
//MB TODO HANDLE all profits.
|
||||||
case 7:
|
case 7:
|
||||||
|
|||||||
Reference in New Issue
Block a user