Browse Source

24.3 placement ruleset.

512/576/1040 grid/zone/siege
pull/13/head
MagicBot 2 years ago
parent
commit
168a4f2a17
  1. 6
      src/engine/Enum.java
  2. 325
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java

6
src/engine/Enum.java

@ -2416,9 +2416,9 @@ public class Enum {
public enum CityBoundsType { public enum CityBoundsType {
GRID(576), GRID(512),
ZONE(640), ZONE(576),
SIEGE(814); SIEGE(1040);
public final float extents; public final float extents;

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

@ -92,7 +92,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (buildingList == null) { if (buildingList == null) {
Logger.error("Player " + playerCharacter.getCombinedName() Logger.error("Player " + playerCharacter.getCombinedName()
+ " null building list on deed use"); + " null building list on deed use");
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
closePlaceAssetWindow(origin); closePlaceAssetWindow(origin);
return true; return true;
@ -115,7 +115,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (buildingBlueprint == null) { if (buildingBlueprint == null) {
Logger.error("Player " + playerCharacter.getCombinedName() Logger.error("Player " + playerCharacter.getCombinedName()
+ " null blueprint UUID: " + buildingList.getBlueprintUUID() + " on deed use"); + " null blueprint UUID: " + buildingList.getBlueprintUUID() + " on deed use");
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
closePlaceAssetWindow(origin); closePlaceAssetWindow(origin);
return true; return true;
@ -130,66 +130,66 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
boolean close = true; boolean close = true;
lock.writeLock().lock(); lock.writeLock().lock();
boolean isSiege = false;
try { try {
switch (buildingBlueprint.getBuildingGroup()) { switch (buildingBlueprint.getBuildingGroup()) {
case TOL: case TOL:
if (contract == null) if (contract == null)
break; break;
buildingCreated = placeTreeOfLife(playerCharacter, origin, msg); buildingCreated = placeTreeOfLife(playerCharacter, origin, msg);
break;
case WAREHOUSE:
if (contract == null)
break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
break;
buildingCreated = placeWarehouse(playerCharacter, origin, msg);
break;
case SIEGETENT:
case BULWARK:
if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) case WAREHOUSE:
if (contract == null)
break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
break;
buildingCreated = placeWarehouse(playerCharacter, origin, msg);
break; break;
buildingCreated = placeSiegeEquip(playerCharacter, origin, msg); case SIEGETENT:
break; case BULWARK:
case SPIRE: if (contract == null)
if (contract == null) break;
break; if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) break;
buildingCreated = placeSiegeEquip(playerCharacter, origin, msg);
break; break;
buildingCreated = placeSpire(playerCharacter, origin, msg); case SPIRE:
break; if (contract == null)
case SHRINE: break;
if (contract == null) if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
break;
buildingCreated = placeSpire(playerCharacter, origin, msg);
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) case SHRINE:
if (contract == null)
break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
break;
buildingCreated = placeShrine(playerCharacter, origin, msg);
break; break;
buildingCreated = placeShrine(playerCharacter, origin, msg); case BARRACK:
break; if (contract == null)
case BARRACK: break;
if (contract == null) if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
break;
buildingCreated = placeBarrack(playerCharacter, origin, msg);
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID())) case WALLSTRAIGHT:
case WALLCORNER:
case SMALLGATE:
case ARTYTOWER:
case WALLSTAIRS:
buildingCreated = placeCityWalls(playerCharacter, origin, msg);
close = false;
break; break;
buildingCreated = placeBarrack(playerCharacter, origin, msg); default:
break; if (contract == null)
case WALLSTRAIGHT: break;
case WALLCORNER: if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
case SMALLGATE: break;
case ARTYTOWER: buildingCreated = placeSingleBuilding(playerCharacter, origin, msg);
case WALLSTAIRS:
buildingCreated = placeCityWalls(playerCharacter, origin, msg);
close = false;
break;
default:
if (contract == null)
break; break;
if (!playerCharacter.getCharItemManager().doesCharOwnThisItem(contract.getObjectUUID()))
break;
buildingCreated = placeSingleBuilding(playerCharacter, origin, msg);
break;
} }
} catch (Exception e) { } catch (Exception e) {
Logger.error("PlaceAssetHandler", e.getMessage()); Logger.error("PlaceAssetHandler", e.getMessage());
@ -230,7 +230,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
buildingList = msg.getFirstPlacementInfo(); buildingList = msg.getFirstPlacementInfo();
serverZone = ZoneManager.findSmallestZone(buildingList.getLoc()); serverZone = ZoneManager.findSmallestZone(buildingList.getLoc());
// Early exit if something went horribly wrong // Early exit if something went horribly wrong
// with locating the current or zone // with locating the current or zone
@ -349,7 +348,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (attackerCity != null) if (attackerCity != null)
if (buildingList.getLoc().isInsideCircle(attackerCity.getLoc(), Enum.CityBoundsType.SIEGE.extents)) if (buildingList.getLoc().isInsideCircle(attackerCity.getLoc(), Enum.CityBoundsType.SIEGE.extents))
serverCity = attackerCity; serverCity = attackerCity;
} }
//no city found for attacker city, //no city found for attacker city,
//check if defender city //check if defender city
@ -363,18 +362,18 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if ((serverCity != null) && if ((serverCity != null) &&
(serverCity.getBane() != null)) { (serverCity.getBane() != null)) {
// Set the server zone to the city zone in order to account for being inside // Set the server zone to the city zone in order to account for being inside
// the siege bounds buffer area // the siege bounds buffer area
serverZone = serverCity.getParent(); serverZone = serverCity.getParent();
if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild()) == false) if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild()) == false)
&& (player.getGuild().equals(serverCity.getGuild()) == false)) { && (player.getGuild().equals(serverCity.getGuild()) == false)) {
PlaceAssetMsg.sendPlaceAssetError(origin, 54, ""); // Must belong to attacker or defender PlaceAssetMsg.sendPlaceAssetError(origin, 54, ""); // Must belong to attacker or defender
return false; return false;
} }
} }
// cant place siege equipment off city zone. // cant place siege equipment off city zone.
@ -382,22 +381,22 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
// Create the siege Building // Create the siege Building
siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone); siegeBuilding = createStructure(player, msg.getFirstPlacementInfo(), serverZone);
if (serverCity == null) if (serverCity == null)
return true; return true;
// Oops something went really wrong // Oops something went really wrong
if (siegeBuilding == null) if (siegeBuilding == null)
return false; return false;
if (serverCity.getBane() == null) if (serverCity.getBane() == null)
return true; return true;
// If there is an bane placed, we protect 2x the stone rank's worth of attacker assets // If there is an bane placed, we protect 2x the stone rank's worth of attacker assets
// and 1x the tree rank's worth of assets automatically // and 1x the tree rank's worth of assets automatically
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(serverCity, 1000, MBServerStatics.MASK_BUILDING); HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(serverCity, 1000, MBServerStatics.MASK_BUILDING);
@ -421,15 +420,15 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if (!building.getGuild().equals(serverCity.getGuild()) && !building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) if (!building.getGuild().equals(serverCity.getGuild()) && !building.getGuild().equals(serverCity.getBane().getOwner().getGuild()))
continue; continue;
// Only count auto protected buildings // Only count auto protected buildings
if (building.getProtectionState() != ProtectionState.PROTECTED) if (building.getProtectionState() != ProtectionState.PROTECTED)
continue; continue;
if (building.getGuild().equals(serverCity.getGuild())) if (building.getGuild().equals(serverCity.getGuild()))
numDefenderBuildings++; numDefenderBuildings++;
else else
if (building.getGuild().equals(serverCity.getBane().getOwner().getGuild())) if (building.getGuild().equals(serverCity.getBane().getOwner().getGuild()))
numAttackerBuildings++; numAttackerBuildings++;
} }
@ -437,10 +436,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
// Validate bane limits on siege assets // Validate bane limits on siege assets
if (serverCity.getBane() != null) if (serverCity.getBane() != null)
if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) && if ((player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) &&
(numAttackerBuildings >= serverCity.getBane().getStone().getRank() * 2)) { (numAttackerBuildings >= serverCity.getBane().getStone().getRank() * 2)) {
return true; return true;
} }
if ((player.getGuild().equals(serverCity.getGuild())) && if ((player.getGuild().equals(serverCity.getGuild())) &&
(numDefenderBuildings >= serverCity.getTOL().getRank())) { (numDefenderBuildings >= serverCity.getTOL().getRank())) {
@ -452,9 +451,9 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
// passes validation: can assign auto-protection to war asset // passes validation: can assign auto-protection to war asset
if (serverCity.getBane() != null) if (serverCity.getBane() != null)
if (serverCity.isLocationOnCityGrid(siegeBuilding.getBounds())) if (serverCity.isLocationOnCityGrid(siegeBuilding.getBounds()))
if (player.getGuild().equals(serverCity.getBane().getOwner().getGuild())) if (player.getGuild().equals(serverCity.getBane().getOwner().getGuild()))
return true; return true;
@ -507,8 +506,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
} }
Vector3fImmutable plantLoc = new Vector3fImmutable(treeInfo.getLoc().x, Vector3fImmutable plantLoc = new Vector3fImmutable(treeInfo.getLoc().x,
serverZone.getHeightMap().getInterpolatedTerrainHeight(treeInfo.getLoc()), serverZone.getHeightMap().getInterpolatedTerrainHeight(treeInfo.getLoc()),
treeInfo.getLoc().z); treeInfo.getLoc().z);
cityObjects = DbManager.CityQueries.CREATE_CITY(playerCharacter.getObjectUUID(), serverZone.getObjectUUID(), cityObjects = DbManager.CityQueries.CREATE_CITY(playerCharacter.getObjectUUID(), serverZone.getObjectUUID(),
serverRealm.getRealmID(), serverRealm.getRealmID(),
@ -527,18 +526,18 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
for (AbstractGameObject gameObject : cityObjects) { for (AbstractGameObject gameObject : cityObjects) {
switch (gameObject.getObjectType()) { switch (gameObject.getObjectType()) {
case Building: case Building:
treeObject = (Building) gameObject; treeObject = (Building) gameObject;
treeObject.runAfterLoad(); treeObject.runAfterLoad();
break; break;
case City: case City:
cityObject = (City) gameObject; cityObject = (City) gameObject;
break; break;
case Zone: case Zone:
cityZone = (Zone) gameObject; cityZone = (Zone) gameObject;
break; break;
default: default:
// log some error here? *** Refactor // log some error here? *** Refactor
} }
} }
@ -813,10 +812,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
return false; return false;
if (player.getCharItemManager().getGoldTrading() > 0){ if (player.getCharItemManager().getGoldTrading() > 0){
ErrorPopupMsg.sendErrorPopup(player, 195); ErrorPopupMsg.sendErrorPopup(player, 195);
return false; return false;
} }
// Method checks validation conditions arising when placing // Method checks validation conditions arising when placing
@ -956,7 +955,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
// 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,
ClientConnection origin, PlaceAssetMsg msg) { ClientConnection origin, PlaceAssetMsg msg) {
PlacementInfo placementInfo = msg.getFirstPlacementInfo(); PlacementInfo placementInfo = msg.getFirstPlacementInfo();
@ -995,7 +994,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if ( if (
(realmType.equals(RealmType.MAELSTROM)) || (realmType.equals(RealmType.MAELSTROM)) ||
(realmType.equals(RealmType.OBLIVION))) { (realmType.equals(RealmType.OBLIVION))) {
PlaceAssetMsg.sendPlaceAssetError(origin, 57, playerCharacter.getName()); // No building may be placed within this territory PlaceAssetMsg.sendPlaceAssetError(origin, 57, playerCharacter.getName()); // No building may be placed within this territory
return false; return false;
} }
@ -1121,20 +1120,20 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
for (AbstractGameObject ago : shrineObjects) { for (AbstractGameObject ago : shrineObjects) {
switch (ago.getObjectType()) { switch (ago.getObjectType()) {
case Building: case Building:
newMesh = (Building) ago; newMesh = (Building) ago;
newMesh.runAfterLoad(); newMesh.runAfterLoad();
newMesh.setObjectTypeMask(MBServerStatics.MASK_BUILDING); newMesh.setObjectTypeMask(MBServerStatics.MASK_BUILDING);
MaintenanceManager.setMaintDateTime(newMesh, LocalDateTime.now().plusDays(7)); MaintenanceManager.setMaintDateTime(newMesh, LocalDateTime.now().plusDays(7));
WorldGrid.addObject(newMesh, player); WorldGrid.addObject(newMesh, player);
break; break;
case Shrine: case Shrine:
newShrine = (Shrine) ago; newShrine = (Shrine) ago;
newShrine.getShrineType().addShrineToServerList(newShrine); newShrine.getShrineType().addShrineToServerList(newShrine);
break; break;
default: default:
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
break; break;
} }
} }
@ -1249,6 +1248,85 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
RealmType currentRealm; RealmType currentRealm;
if(Blueprint.getBlueprint(placementInfo.getBlueprintUUID()).isSiegeEquip() == false)
{
if (serverZone.isPlayerCity() == false) {
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
City city = ZoneManager.getCityAtLocation(placementInfo.getLoc());
if (player.getGuild().equals(city.getGuild()) == false) {
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
if (city.isLocationOnCityGrid(placementInfo.getLoc()) == false) {
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
}
else
{
City city = ZoneManager.getCityAtLocation(placementInfo.getLoc());
if(city == null)
{
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
Bane bane = city.getBane();
//check if player is owner/IC of tree or bane
if (player.getGuild().equals(city.getGuild()) == true)
{
//is from owners guild
if(GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false)
{
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
}
else
{
//is not from owners guild
if(bane == null)
{
//bane was null
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
if(city == null)
{
//city was null
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
//check if player is from siege guild
if(player.getGuild().equals(bane.getOwner().getGuild()) == false)
{
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
//check if player is GL or IC of the bane guild
if(GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false)
{
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
//cannot place on grid until bane is live
if(bane.getSiegePhase() != SiegePhase.WAR && city.isLocationOnCityGrid(placementInfo.getLoc()) == true)
{
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
if(city.isLocationWithinSiegeBounds(placementInfo.getLoc()) == false && city.isLocationOnCityZone(placementInfo.getLoc()) == false)
{
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName());
return false;
}
}
}
// Retrieve the building details we're placing // Retrieve the building details we're placing
if (serverZone.isNPCCity() == true) { if (serverZone.isNPCCity() == true) {
@ -1259,7 +1337,14 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
// Errant guilds cannot place assets // Errant guilds cannot place assets
if (player.getGuild().getGuildState() == GuildState.Errant) { if (player.getGuild().getGuildState() == GuildState.Errant) {
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Only soverign or sworn guilds may place assets."); PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Only sovereign or sworn guilds may place assets.");
return false;
}
// Player must be GL or IC of a guild to place buildings.
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false) {
PlaceAssetMsg.sendPlaceAssetError(origin, 10, ""); // You must be a guild leader
return false; return false;
} }
@ -1282,7 +1367,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
if ( if (
(currentRealm.equals(RealmType.MAELSTROM)) || (currentRealm.equals(RealmType.MAELSTROM)) ||
(currentRealm.equals(RealmType.OBLIVION))) { (currentRealm.equals(RealmType.OBLIVION))) {
PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName()); // No building may be placed within this territory PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName()); // No building may be placed within this territory
return false; return false;
} }
@ -1373,8 +1458,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
PlaceAssetMsg.sendPlaceAssetError(origin, 9, ""); //You must be a guild member to place this asset PlaceAssetMsg.sendPlaceAssetError(origin, 9, ""); //You must be a guild member to place this asset
return false; return false;
} }
return true; return true;
} }
} }
Loading…
Cancel
Save