Browse Source

Merge branch 'magicbox1.5' into feature-guard-patrol

master
FatBoy-DOTC 2 years ago
parent
commit
b3c7db9214
  1. 8
      src/engine/Enum.java
  2. 6
      src/engine/ai/utilities/MovementUtilities.java
  3. 13
      src/engine/devcmd/cmds/RemoveObjectCmd.java
  4. 53
      src/engine/gameManager/ZoneManager.java
  5. 29
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java
  6. 5
      src/engine/objects/Bane.java
  7. 4
      src/engine/objects/Building.java
  8. 6
      src/engine/objects/City.java
  9. 15
      src/engine/objects/NPC.java
  10. 9
      src/engine/objects/Portal.java

8
src/engine/Enum.java

@ -2269,14 +2269,14 @@ public class Enum {
public enum CityBoundsType { public enum CityBoundsType {
GRID(512), GRID(640),
ZONE(576), ZONE(875),
SIEGE(1040); PLACEMENT(1050);
public final float extents; public final float extents;
CityBoundsType(float extents) { CityBoundsType(float extents) {
this.extents = extents; this.extents = extents;
} }
} }

6
src/engine/ai/utilities/MovementUtilities.java

@ -53,9 +53,9 @@ public class MovementUtilities {
//Guards recall distance = 814. //Guards recall distance = 814.
if (tol != null){ if (tol != null){
if (agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.SIEGE.extents)) { if (agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.extents)) {
return false; return false;
} }
} }
} }

13
src/engine/devcmd/cmds/RemoveObjectCmd.java

@ -204,7 +204,10 @@ public class RemoveObjectCmd extends AbstractDevCmd {
return; return;
} }
// Remove npc from hirelings list.
if (npc.building != null)
npc.building.getHirelings().remove(npc);
for (Mob mob : npc.getSiegeMinionMap().keySet()) { for (Mob mob : npc.getSiegeMinionMap().keySet()) {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
@ -225,6 +228,7 @@ public class RemoveObjectCmd extends AbstractDevCmd {
private void removeMob(PlayerCharacter pc, Mob mob) { private void removeMob(PlayerCharacter pc, Mob mob) {
Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc()); Zone currentZone = ZoneManager.findSmallestZone(pc.getLoc());
if (currentZone == null) { if (currentZone == null) {
this.throwbackError(pc, "Could not locate zone for player."); this.throwbackError(pc, "Could not locate zone for player.");
return; return;
@ -235,8 +239,13 @@ public class RemoveObjectCmd extends AbstractDevCmd {
return; return;
} }
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane.. // Remove npc from hirelings list.
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
if (mob.building != null)
mob.building.getHirelings().remove(mob);
mob.setLoc(Vector3fImmutable.ZERO); //Move it off the plane..
mob.setBindLoc(Vector3fImmutable.ZERO); //Reset the bind loc..
//mob.setHealth(-1, pc); //Kill it! //mob.setHealth(-1, pc); //Kill it!
DbManager.MobQueries.DELETE_MOB(mob); DbManager.MobQueries.DELETE_MOB(mob);

53
src/engine/gameManager/ZoneManager.java

@ -271,24 +271,6 @@ public enum ZoneManager {
return true; return true;
} }
/**
* Gets a MacroZone by name.
*
* @param inputName MacroZone name to search for
* @return Zone of the MacroZone, or Null
*/
public static Zone findMacroZoneByName(String inputName) {
synchronized (ZoneManager.macroZones) {
for (Zone zone : ZoneManager.macroZones) {
String zoneName = zone.getName();
if (zoneName.equalsIgnoreCase(inputName))
return zone;
}
}
return null;
}
// Converts world coordinates to coordinates local to a given zone. // Converts world coordinates to coordinates local to a given zone.
public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector, public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector,
@ -353,10 +335,11 @@ public enum ZoneManager {
// convert from SB rotation value to radians // convert from SB rotation value to radians
if (building.getBounds().getQuaternion() == null) if (building.getBounds().getQuaternion() == null)
return building.getLoc(); return building.getLoc();
Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion()); Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion());
// handle building rotation // handle building rotation
// handle building translation // handle building translation
@ -371,6 +354,7 @@ public enum ZoneManager {
Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion()); Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion());
// handle building rotation // handle building rotation
// handle building translation // handle building translation
@ -380,7 +364,6 @@ public enum ZoneManager {
public static Vector3fImmutable convertWorldToLocal(Building building, Vector3fImmutable WorldPos) { public static Vector3fImmutable convertWorldToLocal(Building building, Vector3fImmutable WorldPos) {
Vector3fImmutable convertLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), WorldPos, -building.getBounds().getQuaternion().angleY); Vector3fImmutable convertLoc = Vector3fImmutable.rotateAroundPoint(building.getLoc(), WorldPos, -building.getBounds().getQuaternion().angleY);
convertLoc = convertLoc.subtract(building.getLoc()); convertLoc = convertLoc.subtract(building.getLoc());
// convert from SB rotation value to radians // convert from SB rotation value to radians
@ -389,14 +372,8 @@ public enum ZoneManager {
} }
public static Vector3fImmutable convertNPCLoc(Building building, Vector3fImmutable npcLoc) {
return Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, npcLoc, -building.getBounds().getQuaternion().angleY);
}
// Method returns a city if the given location is within // Method returns a city if the given location is within
// a city siege radius. // a city zone.
public static City getCityAtLocation(Vector3fImmutable worldLoc) { public static City getCityAtLocation(Vector3fImmutable worldLoc) {
@ -409,25 +386,6 @@ public enum ZoneManager {
if (currentZone.isPlayerCity()) if (currentZone.isPlayerCity())
return City.getCity(currentZone.getPlayerCityUUID()); return City.getCity(currentZone.getPlayerCityUUID());
// Not currently on a city grid. Test nearby cities
// to see if we are on one of their seige bounds.
zoneList = currentZone.getNodes();
for (Zone zone : zoneList) {
if (zone == currentZone)
continue;
if (zone.isPlayerCity() == false)
continue;
city = City.getCity(zone.getPlayerCityUUID());
if (worldLoc.isInsideCircle(city.getLoc(), Enum.CityBoundsType.SIEGE.extents))
return city;
}
return null; return null;
} }
@ -449,11 +407,10 @@ public enum ZoneManager {
treeBounds = Bounds.borrow(); treeBounds = Bounds.borrow();
treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.SIEGE.extents, Enum.CityBoundsType.SIEGE.extents), 0.0f); treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.extents, Enum.CityBoundsType.PLACEMENT.extents), 0.0f);
zoneList = currentZone.getNodes(); zoneList = currentZone.getNodes();
for (Zone zone : zoneList) { for (Zone zone : zoneList) {
if (zone.isContinent()) if (zone.isContinent())

29
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -346,11 +346,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
return false; return false;
} }
// Set the server zone to the city zone in order to account for being inside
// the siege bounds buffer area
serverZone = serverCity.getParent();
// Must belong to either attacker or defenders. // Must belong to either attacker or defenders.
if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild()) == false) if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild()) == false)
@ -427,7 +422,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (!building.getBlueprint().isSiegeEquip()) if (!building.getBlueprint().isSiegeEquip())
continue; continue;
if (!building.getLoc().isInsideCircle(serverCity.getLoc(), Enum.CityBoundsType.SIEGE.extents)) if (!building.getLoc().isInsideCircle(serverCity.getLoc(), CityBoundsType.ZONE.extents))
continue; continue;
if (building.getGuild() == null) if (building.getGuild() == null)
@ -929,28 +924,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
} }
// Method deletes one item from the player's inventory
// based on the mesh UUID the deed/seed spawns
private static void removeDeedByMeshUUID(PlayerCharacter player, int meshUUID) {
CharacterItemManager inventoryManager;
ArrayList<Item> itemList;
inventoryManager = player.getCharItemManager();
itemList = player.getInventory();
for (Item inventoryItem : itemList) {
if (inventoryItem.getItemBase().getUseID() == meshUUID) {
inventoryManager.delete(inventoryItem);
inventoryManager.updateInventory();
return;
}
}
}
// Method validates the location we have selected for our new city // Method validates the location we have selected for our new city
private static boolean validateTreeOfLifePlacement(PlayerCharacter playerCharacter, Realm serverRealm, Zone serverZone, private static boolean validateTreeOfLifePlacement(PlayerCharacter playerCharacter, Realm serverRealm, Zone serverZone,

5
src/engine/objects/Bane.java

@ -135,15 +135,14 @@ public final class Bane {
return false; return false;
} }
// Cannot place banestones underwater; // Cannot place banestone underwater;
if (HeightMap.isLocUnderwater(player.getLoc())) { if (HeightMap.isLocUnderwater(player.getLoc())) {
PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater
return false; return false;
} }
// figure out which city we're standing on // figure out which city zone we are standing on.
// must be within a city's seige Bounds
targetCity = ZoneManager.getCityAtLocation(player.getLoc()); targetCity = ZoneManager.getCityAtLocation(player.getLoc());

4
src/engine/objects/Building.java

@ -276,14 +276,14 @@ public class Building extends AbstractWorldObject {
if (this.getBlueprint() != null && this.getBlueprint().isSiegeEquip() && this.protectionState.equals(ProtectionState.PROTECTED)){ if (this.getBlueprint() != null && this.getBlueprint().isSiegeEquip() && this.protectionState.equals(ProtectionState.PROTECTED)){
if (this.getGuild() != null){ if (this.getGuild() != null){
if (this.getGuild().getOwnedCity() != null){ if (this.getGuild().getOwnedCity() != null){
if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), Enum.CityBoundsType.SIEGE.extents)) if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.extents))
return this.getGuild().getOwnedCity(); return this.getGuild().getOwnedCity();
}else{ }else{
Bane bane = Bane.getBaneByAttackerGuild(this.getGuild()); Bane bane = Bane.getBaneByAttackerGuild(this.getGuild());
if (bane != null){ if (bane != null){
if (bane.getCity() != null){ if (bane.getCity() != null){
if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), Enum.CityBoundsType.SIEGE.extents)) if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.extents))
return bane.getCity(); return bane.getCity();
} }
} }

6
src/engine/objects/City.java

@ -943,7 +943,7 @@ public class City extends AbstractWorldObject {
public boolean isLocationWithinSiegeBounds(Vector3fImmutable insideLoc) { public boolean isLocationWithinSiegeBounds(Vector3fImmutable insideLoc) {
return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.SIEGE.extents); return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.extents);
} }
@ -1001,9 +1001,9 @@ public class City extends AbstractWorldObject {
HashSet<Integer> currentMemory; HashSet<Integer> currentMemory;
PlayerCharacter player; PlayerCharacter player;
// Gather current list of players within a distance defined by the seige bounds // Gather current list of players within the zone bounds
currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.SIEGE.extents, MBServerStatics.MASK_PLAYER); currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER);
currentMemory = new HashSet<>(); currentMemory = new HashSet<>();
for (AbstractWorldObject playerObject : currentPlayers) { for (AbstractWorldObject playerObject : currentPlayers) {

15
src/engine/objects/NPC.java

@ -184,9 +184,12 @@ public class NPC extends AbstractCharacter {
if (this.contract != null) if (this.contract != null)
this.loadID = this.contract.getMobbaseID(); this.loadID = this.contract.getMobbaseID();
else else
this.loadID = 2011; //default to human this.loadID = rs.getInt("npc_raceID");
this.loadID = rs.getInt("npc_raceID"); // Default to human male
if (loadID == 0)
loadID = 2100;
this.mobBase = MobBase.getMobBase(this.loadID); this.mobBase = MobBase.getMobBase(this.loadID);
this.level = rs.getByte("npc_level"); this.level = rs.getByte("npc_level");
@ -242,11 +245,11 @@ public class NPC extends AbstractCharacter {
this.name = rs.getString("npc_name"); this.name = rs.getString("npc_name");
// Name override for player owned npcs // Name override for npc
// with an owner.
if (this.building != null && if (this.guild != null &&
this.building.getOwner() != null && !this.guild.isEmptyGuild())
this.building.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter))
this.name += " the " + this.contract.getName(); this.name += " the " + this.contract.getName();
}catch(Exception e){ }catch(Exception e){

9
src/engine/objects/Portal.java

@ -26,13 +26,20 @@ public class Portal {
private long lastActive = 0; private long lastActive = 0;
public Portal(Building sourceGate, PortalType portalType, Building targetGate) { public Portal(Building sourceGate, PortalType portalType, Building targetGate) {
Vector3fImmutable tmpLocation;
this.active = false; this.active = false;
this.sourceGate = sourceGate; this.sourceGate = sourceGate;
this.targetGate = targetGate; this.targetGate = targetGate;
this.portalType = portalType; this.portalType = portalType;
this.portalLocation = sourceGate.getLoc().add(new Vector3fImmutable(portalType.offset.x, 6, portalType.offset.y)); tmpLocation = sourceGate.getLoc().add(new Vector3fImmutable(portalType.offset.x, 6, portalType.offset.y));
// Rotate portal by gate rotation
tmpLocation = Vector3fImmutable.rotateAroundPoint(sourceGate.getLoc(), tmpLocation, sourceGate.getBounds().getQuaternion().angleY);
this.portalLocation = tmpLocation;
} }
public boolean isActive() { public boolean isActive() {

Loading…
Cancel
Save