forked from MagicBane/Server
Merge branch 'magicbox1.5' into feature-guard-patrol
This commit is contained in:
@@ -14,8 +14,11 @@ import engine.Enum.GameObjectType;
|
|||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.ChatManager;
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SlotTestCmd extends AbstractDevCmd {
|
public class SlotTestCmd extends AbstractDevCmd {
|
||||||
|
|
||||||
public SlotTestCmd() {
|
public SlotTestCmd() {
|
||||||
@@ -26,6 +29,7 @@ public class SlotTestCmd extends AbstractDevCmd {
|
|||||||
protected void _doCmd(PlayerCharacter playerCharacter, String[] args,
|
protected void _doCmd(PlayerCharacter playerCharacter, String[] args,
|
||||||
AbstractGameObject target) {
|
AbstractGameObject target) {
|
||||||
|
|
||||||
|
ArrayList<BuildingLocation> buildingLocations;
|
||||||
String outString = "Available Slots\r\n";
|
String outString = "Available Slots\r\n";
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
@@ -34,36 +38,43 @@ public class SlotTestCmd extends AbstractDevCmd {
|
|||||||
if (target.getObjectType() != GameObjectType.Building)
|
if (target.getObjectType() != GameObjectType.Building)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Building building = (Building)target;
|
Building building = (Building) target;
|
||||||
|
|
||||||
|
buildingLocations = BuildingManager._slotLocations.get(building.meshUUID);
|
||||||
|
|
||||||
|
if (buildingLocations == null) {
|
||||||
|
outString = "No slot information for mesh: " + building.meshUUID;
|
||||||
|
ChatManager.chatSystemInfo(playerCharacter, outString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Goto slot location
|
||||||
|
|
||||||
|
if (args[0].isEmpty() == false) {
|
||||||
|
|
||||||
|
int slot = Integer.parseInt(args[0]);
|
||||||
|
Vector3fImmutable slotLocation;
|
||||||
|
BuildingLocation buildingLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot - 1);
|
||||||
|
slotLocation = building.getLoc().add(buildingLocation.getLocation());
|
||||||
|
slotLocation = Vector3fImmutable.rotateAroundPoint(building.getLoc(), slotLocation, building.getBounds().getQuaternion().angleY);
|
||||||
|
playerCharacter.teleport(slotLocation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (BuildingLocation buildingLocation : BuildingManager._slotLocations.get(building.meshUUID))
|
for (BuildingLocation buildingLocation : BuildingManager._slotLocations.get(building.meshUUID))
|
||||||
outString += buildingLocation.getSlot() + buildingLocation.getLoc().toString() + "\r\n";
|
outString += buildingLocation.getSlot() + buildingLocation.getLocation().toString() + "\r\n";
|
||||||
|
|
||||||
outString += "\r\nNeext Available Slot: " + BuildingManager.getAvailableSlot(building);
|
outString += "\r\nNext Available Slot: " + BuildingManager.getAvailableSlot(building);
|
||||||
|
|
||||||
if (building.getHirelings().isEmpty() == false) {
|
if (building.getHirelings().isEmpty() == false) {
|
||||||
|
|
||||||
outString += "\r\n\r\n";
|
outString += "\r\n\r\n";
|
||||||
outString += "Hirelings List: name / slot / floor";
|
outString += "Hirelings List:";
|
||||||
|
|
||||||
for (AbstractCharacter hireling : building.getHirelings().keySet()) {
|
for (AbstractCharacter hireling : building.getHirelings().keySet())
|
||||||
|
outString += "\r\n" + hireling.getName() + " slot : " + building.getHirelings().get(hireling);
|
||||||
|
|
||||||
NPC npc;
|
|
||||||
Mob mob;
|
|
||||||
|
|
||||||
outString += "\r\n" + hireling.getName() + " slot " + building.getHirelings().get(hireling);
|
|
||||||
|
|
||||||
/* if (hireling.getObjectType().equals(GameObjectType.NPC)) {
|
|
||||||
npc = (NPC) hireling;
|
|
||||||
outString += "\r\n" + "location " + npc.inBuildingLoc.toString();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
mob = (Mob) hireling;
|
|
||||||
|
|
||||||
outString += "\r\n" + "location " + mob.inBuildingLoc.toString();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager.chatSystemInfo(playerCharacter,outString);
|
ChatManager.chatSystemInfo(playerCharacter,outString);
|
||||||
@@ -72,12 +83,12 @@ public class SlotTestCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getHelpString() {
|
protected String _getHelpString() {
|
||||||
return "Temporarily Changes SubRace";
|
return "Displays slot information for building";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String _getUsageString() {
|
protected String _getUsageString() {
|
||||||
return "' /setBuildingCollidables add/remove 'add creates a collision line.' needs 4 integers. startX, endX, startY, endY";
|
return "./slottest <target builing> n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import engine.job.JobContainer;
|
|||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.UpgradeBuildingJob;
|
import engine.jobs.UpgradeBuildingJob;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
|
import engine.math.Quaternion;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
@@ -49,25 +50,42 @@ public enum BuildingManager {
|
|||||||
int numOfSlots = _slotLocations.get(building.meshUUID).size();
|
int numOfSlots = _slotLocations.get(building.meshUUID).size();
|
||||||
|
|
||||||
for (int i = 1; i <= numOfSlots; i++) {
|
for (int i = 1; i <= numOfSlots; i++) {
|
||||||
|
|
||||||
if (!building.getHirelings().containsValue(i))
|
if (!building.getHirelings().containsValue(i))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3fImmutable getSlotLocation(Building building, int slot) {
|
public static BuildingLocation getSlotLocation(Building building, int slot) {
|
||||||
|
|
||||||
|
BuildingLocation buildingLocation = new BuildingLocation();
|
||||||
|
|
||||||
if (slot == -1)
|
if (slot == -1)
|
||||||
return Vector3fImmutable.ZERO;
|
return buildingLocation;
|
||||||
|
|
||||||
BuildingLocation buildingLocation;
|
|
||||||
buildingLocation = _slotLocations.get(building.meshUUID).get(slot - 1); // array index
|
buildingLocation = _slotLocations.get(building.meshUUID).get(slot - 1); // array index
|
||||||
|
|
||||||
if (buildingLocation == null) {
|
if (buildingLocation == null) {
|
||||||
Logger.error("Invalid slot for building: " + building.getObjectUUID());
|
Logger.error("Invalid slot for building: " + building.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildingLocation.getLoc();
|
return buildingLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Quaternion getSlotRotation(Building building, int slot) {
|
||||||
|
|
||||||
|
if (slot == -1)
|
||||||
|
return new Quaternion();
|
||||||
|
|
||||||
|
BuildingLocation buildingLocation;
|
||||||
|
buildingLocation = _slotLocations.get(building.meshUUID).get(slot - 1); // array index
|
||||||
|
|
||||||
|
if (buildingLocation == null) {
|
||||||
|
Logger.error("Invalid slot rotation for building: " + building.getObjectUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildingLocation.getRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean playerCanManage(PlayerCharacter player, Building building) {
|
public static boolean playerCanManage(PlayerCharacter player, Building building) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import engine.Enum.GameObjectType;
|
|||||||
import engine.Enum.ModType;
|
import engine.Enum.ModType;
|
||||||
import engine.Enum.SourceType;
|
import engine.Enum.SourceType;
|
||||||
import engine.InterestManagement.InterestManager;
|
import engine.InterestManagement.InterestManager;
|
||||||
import engine.InterestManagement.WorldGrid;
|
|
||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
@@ -27,7 +26,6 @@ import engine.objects.*;
|
|||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static engine.math.FastMath.sqr;
|
import static engine.math.FastMath.sqr;
|
||||||
@@ -500,59 +498,6 @@ public enum MovementManager {
|
|||||||
InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter)teleporter);
|
InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter)teleporter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void translocateToObject(AbstractCharacter teleporter, AbstractWorldObject worldObject) {
|
|
||||||
|
|
||||||
Vector3fImmutable targetLoc = teleporter.getLoc();
|
|
||||||
|
|
||||||
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
|
||||||
|
|
||||||
teleporter.stopMovement(teleporter.getLoc());
|
|
||||||
|
|
||||||
//mobs ignore region sets for now.
|
|
||||||
if (teleporter.getObjectType().equals(GameObjectType.Mob)){
|
|
||||||
teleporter.setInBuildingID(0);
|
|
||||||
teleporter.setInBuilding(-1);
|
|
||||||
teleporter.setInFloorID(-1);
|
|
||||||
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean collide = false;
|
|
||||||
int maxFloor = -1;
|
|
||||||
int buildingID = 0;
|
|
||||||
boolean isGroundLevel = false;
|
|
||||||
HashSet<AbstractWorldObject> buildings = WorldGrid.getObjectsInRangePartial(teleporter, 200, MBServerStatics.MASK_BUILDING);
|
|
||||||
for (AbstractWorldObject awo : buildings) {
|
|
||||||
Building building = (Building) awo;
|
|
||||||
if (collide)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!collide) {
|
|
||||||
teleporter.setInBuildingID(0);
|
|
||||||
teleporter.setInBuilding(-1);
|
|
||||||
teleporter.setInFloorID(-1);
|
|
||||||
} else {
|
|
||||||
if (isGroundLevel) {
|
|
||||||
teleporter.setInBuilding(0);
|
|
||||||
teleporter.setInFloorID(-1);
|
|
||||||
} else {
|
|
||||||
teleporter.setInBuilding(maxFloor - 1);
|
|
||||||
teleporter.setInFloorID(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
|
|
||||||
//we shouldnt need to send teleport message to new area, as loadjob should pick it up.
|
|
||||||
// DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
|
||||||
|
|
||||||
if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter))
|
|
||||||
InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter)teleporter);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) {
|
private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) {
|
||||||
ac.teleport(ac.getLoc());
|
ac.teleport(ac.getLoc());
|
||||||
|
|||||||
@@ -49,9 +49,12 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
for (Item hirelings : player.getInventory()) {
|
for (Item hirelings : player.getInventory()) {
|
||||||
if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) {
|
if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) {
|
||||||
|
|
||||||
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID());
|
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID());
|
||||||
|
|
||||||
if (contract == null)
|
if (contract == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (contract.canSlotinBuilding(building))
|
if (contract.canSlotinBuilding(building))
|
||||||
ItemLists.add(hirelings);
|
ItemLists.add(hirelings);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,11 +368,11 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//cannot place on grid until bane is live
|
// Attackers cannot place on grid until bane is live
|
||||||
|
|
||||||
if(bane.getSiegePhase() != SiegePhase.WAR &&
|
if (bane.getSiegePhase() != SiegePhase.WAR &&
|
||||||
serverCity.isLocationOnCityGrid(buildingList.getLoc()) == true)
|
player.getGuild().equals(serverCity.getBane().getOwner().getGuild()) &&
|
||||||
{
|
serverCity.isLocationOnCityGrid(buildingList.getLoc())) {
|
||||||
PlaceAssetMsg.sendPlaceAssetError(origin, 53, player.getName()); // Buildings of war cannot be placed around a city grid unless there is an active bane
|
PlaceAssetMsg.sendPlaceAssetError(origin, 53, player.getName()); // Buildings of war cannot be placed around a city grid unless there is an active bane
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,9 +117,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
private long lastHateUpdate = 0;
|
private long lastHateUpdate = 0;
|
||||||
private boolean collided = false;
|
private boolean collided = false;
|
||||||
protected Regions lastRegion = null;
|
protected Regions lastRegion = null;
|
||||||
|
|
||||||
protected boolean movingUp = false;
|
protected boolean movingUp = false;
|
||||||
|
public Contract contract;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No Id Constructor
|
* No Id Constructor
|
||||||
@@ -1301,20 +1302,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
|||||||
locationLock.writeLock().unlock();
|
locationLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void teleportToObject(final AbstractWorldObject worldObject) {
|
|
||||||
locationLock.writeLock().lock();
|
|
||||||
try{
|
|
||||||
MovementManager.translocateToObject(this, worldObject);
|
|
||||||
}catch(Exception e){
|
|
||||||
Logger.error(e);
|
|
||||||
}finally{
|
|
||||||
locationLock.writeLock().unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Serializing
|
* Serializing
|
||||||
|
|||||||
@@ -474,7 +474,8 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
for (Building building : city.getParent().zoneBuildingSet) {
|
for (Building building : city.getParent().zoneBuildingSet) {
|
||||||
|
|
||||||
//dont add -1 rank buildings.
|
//don't add -1 rank buildings.
|
||||||
|
|
||||||
if (building.rank <= 0)
|
if (building.rank <= 0)
|
||||||
continue;
|
continue;
|
||||||
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() == BuildingGroup.SPIRE)
|
||||||
@@ -553,8 +554,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handling of exploding TOL's
|
|
||||||
|
|
||||||
// Must remove a bane before considering destruction of a TOL
|
// Must remove a bane before considering destruction of a TOL
|
||||||
|
|
||||||
if (bane != null) {
|
if (bane != null) {
|
||||||
@@ -673,10 +672,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
return this.w;
|
return this.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setMeshScale(Vector3f value) {
|
|
||||||
this.meshScale = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Vector3f getMeshScale() {
|
public final Vector3f getMeshScale() {
|
||||||
return this.meshScale;
|
return this.meshScale;
|
||||||
}
|
}
|
||||||
@@ -1049,7 +1044,9 @@ public class Building extends AbstractWorldObject {
|
|||||||
public final void rebuildMine(){
|
public final void rebuildMine(){
|
||||||
this.setRank(1);
|
this.setRank(1);
|
||||||
this.meshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
this.meshUUID = this.getBlueprint().getMeshForRank(this.rank);
|
||||||
|
|
||||||
// New rank mean new max hitpoints.
|
// New rank mean new max hitpoints.
|
||||||
|
|
||||||
this.healthMax = this.getBlueprint().getMaxHealth(this.rank);
|
this.healthMax = this.getBlueprint().getMaxHealth(this.rank);
|
||||||
this.setCurrentHitPoints(this.healthMax);
|
this.setCurrentHitPoints(this.healthMax);
|
||||||
this.getBounds().setBounds(this);
|
this.getBounds().setBounds(this);
|
||||||
@@ -1077,8 +1074,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
// Submit upgrade job if building is currently set to rank.
|
// Submit upgrade job if building is currently set to rank.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID);
|
DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID);
|
||||||
this.ownerIsNPC = (objectType == DbObjectType.NPC);
|
this.ownerIsNPC = (objectType == DbObjectType.NPC);
|
||||||
@@ -1142,6 +1137,7 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
//create a new list for children if the building is not a child. children list default is null.
|
//create a new list for children if the building is not a child. children list default is null.
|
||||||
//TODO Remove Furniture/Child buildings from building class and move them into a seperate class.
|
//TODO Remove Furniture/Child buildings from building class and move them into a seperate class.
|
||||||
|
|
||||||
if (this.parentBuildingID == 0)
|
if (this.parentBuildingID == 0)
|
||||||
this.children = new ArrayList<>();
|
this.children = new ArrayList<>();
|
||||||
|
|
||||||
@@ -1150,7 +1146,9 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
if (parent != null){
|
if (parent != null){
|
||||||
parent.children.add(this);
|
parent.children.add(this);
|
||||||
|
|
||||||
//add furniture to region cache. floor and level are reversed in database, //TODO Fix
|
//add furniture to region cache. floor and level are reversed in database, //TODO Fix
|
||||||
|
|
||||||
Regions region = BuildingManager.GetRegion(parent, this.level,this.floor, this.getLoc().x, this.getLoc().z);
|
Regions region = BuildingManager.GetRegion(parent, this.level,this.floor, this.getLoc().x, this.getLoc().z);
|
||||||
if (region != null)
|
if (region != null)
|
||||||
Regions.FurnitureRegionMap.put(this.getObjectUUID(), region);
|
Regions.FurnitureRegionMap.put(this.getObjectUUID(), region);
|
||||||
@@ -1161,28 +1159,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
if (this.upgradeDateTime != null)
|
if (this.upgradeDateTime != null)
|
||||||
BuildingManager.submitUpgradeJob(this);
|
BuildingManager.submitUpgradeJob(this);
|
||||||
|
|
||||||
// Run Once move buildings
|
|
||||||
// 64 / -64 to align with pads
|
|
||||||
|
|
||||||
// Don't move furniture
|
|
||||||
/*
|
|
||||||
if (parentBuildingID != 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Don't move buildings not on a city zone
|
|
||||||
// or buildings that are in npc owned city
|
|
||||||
|
|
||||||
City city = getCity();
|
|
||||||
|
|
||||||
if (city == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (city.getIsNpcOwned() == 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PullCmd.MoveBuilding(this, null, getLoc().add(new Vector3fImmutable(0, 0, 0)), getParentZone());
|
|
||||||
*/
|
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -1196,21 +1172,8 @@ public class Building extends AbstractWorldObject {
|
|||||||
else
|
else
|
||||||
newOwnerID = newOwner.getObjectUUID();
|
newOwnerID = newOwner.getObjectUUID();
|
||||||
|
|
||||||
// ***BONUS CODE BELOW!
|
|
||||||
/*
|
|
||||||
if (newOwner == null) {
|
|
||||||
this.ownerIsNPC = false;
|
|
||||||
this.ownerUUID = 0;
|
|
||||||
} else if (newOwner instanceof PlayerCharacter) {
|
|
||||||
this.ownerIsNPC = false;
|
|
||||||
this.ownerUUID = newOwner.getObjectUUID();
|
|
||||||
} else {
|
|
||||||
this.ownerIsNPC = true;
|
|
||||||
this.ownerUUID = newOwner.getObjectUUID();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Save new owner to database
|
// Save new owner to database
|
||||||
|
|
||||||
if (!DbManager.BuildingQueries.updateBuildingOwner(this, newOwnerID))
|
if (!DbManager.BuildingQueries.updateBuildingOwner(this, newOwnerID))
|
||||||
@@ -1285,7 +1248,7 @@ public class Building extends AbstractWorldObject {
|
|||||||
stuckLocations.isEmpty())
|
stuckLocations.isEmpty())
|
||||||
return this.getLoc();
|
return this.getLoc();
|
||||||
|
|
||||||
stuckLocation = stuckLocations.get(ThreadLocalRandom.current().nextInt(stuckLocations.size())).getLoc();
|
stuckLocation = stuckLocations.get(ThreadLocalRandom.current().nextInt(stuckLocations.size())).getLocation();
|
||||||
|
|
||||||
return stuckLocation;
|
return stuckLocation;
|
||||||
}
|
}
|
||||||
@@ -1316,6 +1279,7 @@ public class Building extends AbstractWorldObject {
|
|||||||
|
|
||||||
// Can't have an invalid door number
|
// Can't have an invalid door number
|
||||||
// Log error?
|
// Log error?
|
||||||
|
|
||||||
if (doorNumber < 1 || doorNumber > 16)
|
if (doorNumber < 1 || doorNumber > 16)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1344,10 +1308,6 @@ public class Building extends AbstractWorldObject {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDoorstate(){
|
|
||||||
return this.doorState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateEffects() {
|
public void updateEffects() {
|
||||||
|
|
||||||
ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(0x00720063, 1, this.getObjectType().ordinal(), this.getObjectUUID(), this.effectFlags);
|
ApplyBuildingEffectMsg applyBuildingEffectMsg = new ApplyBuildingEffectMsg(0x00720063, 1, this.getObjectType().ordinal(), this.getObjectUUID(), this.effectFlags);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ package engine.objects;
|
|||||||
|
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.math.Quaternion;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -25,11 +26,20 @@ public class BuildingLocation extends AbstractGameObject {
|
|||||||
private final int type;
|
private final int type;
|
||||||
private final int slot;
|
private final int slot;
|
||||||
private final int unknown;
|
private final int unknown;
|
||||||
private final Vector3fImmutable loc;
|
private final Vector3fImmutable location;
|
||||||
private final Vector3fImmutable rot;
|
private final Quaternion rotation;
|
||||||
private final float w;
|
|
||||||
|
|
||||||
|
|
||||||
|
public BuildingLocation() {
|
||||||
|
|
||||||
|
this.buildingUUID = 0;
|
||||||
|
this.type = 0;
|
||||||
|
this.slot = 0;
|
||||||
|
this.unknown = 0;
|
||||||
|
this.location = Vector3fImmutable.ZERO;
|
||||||
|
this.rotation = new Quaternion();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
*/
|
*/
|
||||||
@@ -39,9 +49,8 @@ public class BuildingLocation extends AbstractGameObject {
|
|||||||
this.type = rs.getInt("type");
|
this.type = rs.getInt("type");
|
||||||
this.slot = rs.getInt("slot");
|
this.slot = rs.getInt("slot");
|
||||||
this.unknown = rs.getInt("unknown");
|
this.unknown = rs.getInt("unknown");
|
||||||
this.loc = new Vector3fImmutable(rs.getFloat("locX"), rs.getFloat("locY"), rs.getFloat("locZ"));
|
this.location = new Vector3fImmutable(rs.getFloat("locX"), rs.getFloat("locY"), rs.getFloat("locZ"));
|
||||||
this.rot = new Vector3fImmutable(rs.getFloat("rotX"), rs.getFloat("rotY"), rs.getFloat("rotZ"));
|
this.rotation = new Quaternion(rs.getFloat("rotX"), rs.getFloat("rotY"), rs.getFloat("rotZ"), rs.getFloat("w"));
|
||||||
this.w = rs.getFloat("w");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -52,24 +61,6 @@ public class BuildingLocation extends AbstractGameObject {
|
|||||||
return this.buildingUUID;
|
return this.buildingUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3fImmutable rotatedLoc() {
|
|
||||||
Vector3fImmutable convertLoc = null;
|
|
||||||
|
|
||||||
|
|
||||||
double rotY = 2.0 * Math.asin(this.rot.y);
|
|
||||||
|
|
||||||
|
|
||||||
// handle building rotation
|
|
||||||
|
|
||||||
convertLoc = new Vector3fImmutable(
|
|
||||||
(float) ((loc.z * Math.sin(rotY)) + (loc.x * Math.cos(rotY))),
|
|
||||||
loc.y,
|
|
||||||
(float) ((loc.z * Math.cos(rotY)) - (loc.x * Math.sin(rotY))));
|
|
||||||
|
|
||||||
return convertLoc;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
@@ -83,42 +74,22 @@ public class BuildingLocation extends AbstractGameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getLocX() {
|
public float getLocX() {
|
||||||
return this.loc.x;
|
return this.location.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getLocY() {
|
public float getLocY() {
|
||||||
return this.loc.y;
|
return this.location.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getLocZ() {
|
|
||||||
return this.loc.z;
|
public Vector3fImmutable getLocation() {
|
||||||
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRotX() {
|
public Quaternion getRotation() {
|
||||||
return this.rot.x;
|
return this.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRotY() {
|
|
||||||
return this.rot.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getRotZ() {
|
|
||||||
return this.rot.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getW() {
|
|
||||||
return this.w;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3fImmutable getLoc() {
|
|
||||||
return this.loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3fImmutable getRot() {
|
|
||||||
return this.rot;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDatabase() {
|
public void updateDatabase() {
|
||||||
}
|
}
|
||||||
@@ -141,7 +112,7 @@ public class BuildingLocation extends AbstractGameObject {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add location to the collection in BuildingManager
|
// Add location to collection in BuildingManager
|
||||||
|
|
||||||
if (locationCollection.containsKey(buildingLocation.buildingUUID))
|
if (locationCollection.containsKey(buildingLocation.buildingUUID))
|
||||||
locationCollection.get(buildingLocation.buildingUUID).add(buildingLocation);
|
locationCollection.get(buildingLocation.buildingUUID).add(buildingLocation);
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ public class Contract extends AbstractGameObject {
|
|||||||
if (building == null)
|
if (building == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Can't slot in anything but a blueprintted building
|
// Can't slot in anything but a blueprinted building
|
||||||
if (building.getBlueprintUUID() == 0)
|
if (building.getBlueprintUUID() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -256,8 +256,7 @@ public class Contract extends AbstractGameObject {
|
|||||||
|
|
||||||
// Binary match
|
// Binary match
|
||||||
return (building.getBlueprint().getBuildingGroup().elementOf(this.allowedBuildings));
|
return (building.getBlueprint().getBuildingGroup().elementOf(this.allowedBuildings));
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public int getEquipmentSet() {
|
public int getEquipmentSet() {
|
||||||
return equipmentSet;
|
return equipmentSet;
|
||||||
|
|||||||
+27
-15
@@ -20,6 +20,8 @@ import engine.jobs.DeferredPowerJob;
|
|||||||
import engine.jobs.UpgradeNPCJob;
|
import engine.jobs.UpgradeNPCJob;
|
||||||
import engine.loot.LootManager;
|
import engine.loot.LootManager;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
|
import engine.math.Quaternion;
|
||||||
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
@@ -39,6 +41,7 @@ import java.util.HashSet;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
|
import static engine.math.FastMath.acos;
|
||||||
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
||||||
|
|
||||||
public class Mob extends AbstractIntelligenceAgent {
|
public class Mob extends AbstractIntelligenceAgent {
|
||||||
@@ -62,7 +65,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
public int spawnTime;
|
public int spawnTime;
|
||||||
public Zone parentZone;
|
public Zone parentZone;
|
||||||
public Building building;
|
public Building building;
|
||||||
public Contract contract;
|
|
||||||
public boolean hasLoot = false;
|
public boolean hasLoot = false;
|
||||||
public boolean isPlayerGuard = false;
|
public boolean isPlayerGuard = false;
|
||||||
public AbstractCharacter npcOwner;
|
public AbstractCharacter npcOwner;
|
||||||
@@ -265,16 +267,16 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
this.notEnemy = EnumBitSet.asEnumBitSet(rs.getLong("notEnemy"), Enum.MonsterType.class);
|
this.notEnemy = EnumBitSet.asEnumBitSet(rs.getLong("notEnemy"), Enum.MonsterType.class);
|
||||||
this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class);
|
this.enemy = EnumBitSet.asEnumBitSet(rs.getLong("enemy"), Enum.MonsterType.class);
|
||||||
this.firstName = rs.getString("mob_name");
|
this.firstName = rs.getString("mob_name");
|
||||||
if (this.firstName.isEmpty()) {
|
|
||||||
|
if (this.firstName.isEmpty())
|
||||||
this.firstName = this.mobBase.getFirstName();
|
this.firstName = this.mobBase.getFirstName();
|
||||||
}
|
|
||||||
if (this.contract != null) {
|
if (this.contract != null) {
|
||||||
this.equipmentSetID = this.contract.getEquipmentSet();
|
this.equipmentSetID = this.contract.getEquipmentSet();
|
||||||
this.lastName = this.getContract().getName();
|
this.lastName = this.getContract().getName();
|
||||||
} else {
|
} else
|
||||||
this.equipmentSetID = rs.getInt("equipmentSet");
|
this.equipmentSetID = rs.getInt("equipmentSet");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rs.getString("fsm").length() > 1)
|
if (rs.getString("fsm").length() > 1)
|
||||||
this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm"));
|
this.BehaviourType = MobBehaviourType.valueOf(rs.getString("fsm"));
|
||||||
@@ -370,11 +372,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
writer.putFloat(1.0f);
|
writer.putFloat(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Location serialization matches NPC
|
|
||||||
|
|
||||||
if (mob.region != null)
|
|
||||||
writer.putVector3f(ZoneManager.convertWorldToLocal(mob.building, mob.getLoc()));
|
|
||||||
else
|
|
||||||
writer.putVector3f(mob.getLoc());
|
writer.putVector3f(mob.getLoc());
|
||||||
|
|
||||||
//Rotation
|
//Rotation
|
||||||
@@ -868,6 +865,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
int slot;
|
int slot;
|
||||||
Vector3fImmutable slotLocation;
|
Vector3fImmutable slotLocation;
|
||||||
|
Quaternion slotRotation;
|
||||||
|
|
||||||
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
|
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
|
||||||
return;
|
return;
|
||||||
@@ -896,8 +894,6 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon);
|
this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon);
|
||||||
this.bindLoc = this.building.getLoc().add(this.bindLoc);
|
this.bindLoc = this.building.getLoc().add(this.bindLoc);
|
||||||
this.loc = new Vector3fImmutable(bindLoc);
|
|
||||||
this.endLoc = new Vector3fImmutable(bindLoc);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -914,14 +910,30 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
// Override bind and location for this contracted Mobile
|
// Override bind and location for this contracted Mobile
|
||||||
// derived from BuildingManager slot location data.
|
// derived from BuildingManager slot location data.
|
||||||
|
|
||||||
slotLocation = BuildingManager.getSlotLocation(building, slot);
|
slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation();
|
||||||
|
|
||||||
this.bindLoc = building.getLoc().add(slotLocation);
|
this.bindLoc = building.getLoc().add(slotLocation);
|
||||||
this.loc = building.getLoc().add(slotLocation);
|
|
||||||
this.endLoc = bindLoc;
|
// Rotate MOB by slot rotation
|
||||||
|
|
||||||
|
slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation();
|
||||||
|
this.setRot(new Vector3f(0, slotRotation.y, 0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rotate slot position by the building rotation
|
||||||
|
|
||||||
|
this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, building.getBounds().getQuaternion().angleY);
|
||||||
|
|
||||||
|
this.loc = new Vector3fImmutable(bindLoc);
|
||||||
|
this.endLoc = new Vector3fImmutable(bindLoc);
|
||||||
|
|
||||||
|
// Rotate mobile rotation by the building's rotation
|
||||||
|
|
||||||
|
slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0);
|
||||||
|
slotRotation = slotRotation.mult(building.getBounds().getQuaternion());
|
||||||
|
this.setRot(new Vector3f(0, slotRotation.y, 0));
|
||||||
|
|
||||||
// Configure building region and floor/level for this Mobile
|
// Configure building region and floor/level for this Mobile
|
||||||
|
|
||||||
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
|
this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import engine.job.JobContainer;
|
|||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.UpgradeNPCJob;
|
import engine.jobs.UpgradeNPCJob;
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
|
import engine.math.Quaternion;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
@@ -37,6 +38,7 @@ import java.util.HashSet;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
|
import static engine.math.FastMath.acos;
|
||||||
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
||||||
import static engine.objects.MobBase.loadEquipmentSet;
|
import static engine.objects.MobBase.loadEquipmentSet;
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ public class NPC extends AbstractCharacter {
|
|||||||
protected MobBase mobBase;
|
protected MobBase mobBase;
|
||||||
protected String name;
|
protected String name;
|
||||||
public Building building;
|
public Building building;
|
||||||
protected Contract contract;
|
|
||||||
protected int dbID;
|
protected int dbID;
|
||||||
protected int currentID;
|
protected int currentID;
|
||||||
private DateTime upgradeDateTime = null;
|
private DateTime upgradeDateTime = null;
|
||||||
@@ -319,6 +321,7 @@ public class NPC extends AbstractCharacter {
|
|||||||
|
|
||||||
int slot;
|
int slot;
|
||||||
Vector3fImmutable slotLocation;
|
Vector3fImmutable slotLocation;
|
||||||
|
Quaternion slotRotation;
|
||||||
|
|
||||||
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
|
if (ConfigManager.serverType.equals(ServerType.LOGINSERVER))
|
||||||
return;
|
return;
|
||||||
@@ -358,10 +361,26 @@ public class NPC extends AbstractCharacter {
|
|||||||
// 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.
|
||||||
|
|
||||||
slotLocation = BuildingManager.getSlotLocation(building, slot);
|
slotLocation = BuildingManager.getSlotLocation(building, slot).getLocation();
|
||||||
|
|
||||||
this.bindLoc = building.getLoc().add(slotLocation);
|
this.bindLoc = building.getLoc().add(slotLocation);
|
||||||
this.loc = building.getLoc().add(slotLocation);
|
|
||||||
|
// Rotate slot position by the building rotation
|
||||||
|
|
||||||
|
this.bindLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), this.bindLoc, building.getBounds().getQuaternion().angleY);
|
||||||
|
|
||||||
|
this.loc = new Vector3fImmutable(bindLoc);
|
||||||
|
|
||||||
|
// Rotate NPC by slot rotation
|
||||||
|
|
||||||
|
slotRotation = BuildingManager.getSlotLocation(building, slot).getRotation();
|
||||||
|
this.setRot(new Vector3f(0, slotRotation.y, 0));
|
||||||
|
|
||||||
|
// Rotate NPC rotation by the building's rotation
|
||||||
|
|
||||||
|
slotRotation = new Quaternion().fromAngles(0, acos(this.getRot().y) * 2, 0);
|
||||||
|
slotRotation = slotRotation.mult(building.getBounds().getQuaternion());
|
||||||
|
this.setRot(new Vector3f(0, slotRotation.y, 0));
|
||||||
|
|
||||||
// Configure region and floor/level for this NPC
|
// Configure region and floor/level for this NPC
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user