From b71bb6066968c46f4226ca890e31eed02dab9778 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 10 Jan 2025 09:28:08 -0600 Subject: [PATCH] allow 5th slot in r8 TOL + wall health upgrade for r8 trees --- src/engine/jobs/UpgradeBuildingJob.java | 14 ++++++++++++++ .../net/client/handlers/PlaceAssetMsgHandler.java | 9 +++++++++ src/engine/objects/Building.java | 15 +++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/engine/jobs/UpgradeBuildingJob.java b/src/engine/jobs/UpgradeBuildingJob.java index c9032af9..ac03a21c 100644 --- a/src/engine/jobs/UpgradeBuildingJob.java +++ b/src/engine/jobs/UpgradeBuildingJob.java @@ -1,7 +1,9 @@ package engine.jobs; +import engine.gameManager.ZoneManager; import engine.job.AbstractScheduleJob; import engine.objects.Building; +import engine.objects.City; import org.pmw.tinylog.Logger; /* @@ -41,6 +43,18 @@ public class UpgradeBuildingJob extends AbstractScheduleJob { rankingBuilding.setRank(rankingBuilding.getRank() + 1); + if(rankingBuilding.getBlueprint().isWallPiece()){ + City cityObject = ZoneManager.getCityAtLocation(rankingBuilding.loc); + if(cityObject.getTOL().getRank() == 8) { + if (rankingBuilding.getBlueprint() != null && rankingBuilding.getBlueprint().getBuildingGroup() != null && rankingBuilding.getBlueprint().isWallPiece()) { + float currentHealthRatio = rankingBuilding.getCurrentHitpoints() / rankingBuilding.healthMax; + float newMax = rankingBuilding.healthMax * 1.1f; + rankingBuilding.setMaxHitPoints(newMax); + rankingBuilding.setHealth(rankingBuilding.healthMax * currentHealthRatio); + } + } + } + // Reload the object diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 382b6547..9d96dfb3 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -1148,6 +1148,15 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { wallPiece.setProtectionState(ProtectionState.PROTECTED); PlaceAssetMsg.sendPlaceAssetConfirmWall(origin, serverZone); + //walls in R8 city are immediately granted extra HP by 10% + if(cityObject.getTOL().getRank() == 8) { + if (wallPiece.getBlueprint() != null && wallPiece.getBlueprint().getBuildingGroup() != null && wallPiece.getBlueprint().isWallPiece()) { + float currentHealthRatio = wallPiece.getCurrentHitpoints() / wallPiece.healthMax; + float newMax = wallPiece.healthMax * 1.1f; + wallPiece.setMaxHitPoints(newMax); + wallPiece.setHealth(wallPiece.healthMax * currentHealthRatio); + } + } } // Deduct gold from character's inventory diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 6a54b8c9..7ccfbb42 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -166,8 +166,19 @@ public class Building extends AbstractWorldObject { if (this.blueprintUUID != 0) this.meshUUID = blueprint.getMeshForRank(rank); - this.healthMax = blueprint.getMaxHealth(this.rank); - + if(this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() != null && this.getBlueprint().isWallPiece()){ + City cityObject = ZoneManager.getCityAtLocation(this.loc); + if(cityObject.getTOL().getRank() == 8) { + float currentHealthRatio = this.getCurrentHitpoints() / this.healthMax; + float newMax = this.healthMax * 1.1f; + this.setMaxHitPoints(newMax); + this.setHealth(this.healthMax * currentHealthRatio); + }else { + this.healthMax = blueprint.getMaxHealth(this.rank); + } + } else { + this.healthMax = blueprint.getMaxHealth(this.rank); + } // If this object has no blueprint but is a blueprint // mesh then set it's current health to max health