From 93025b72cd0029f930eb008edad65a1417bfa2ee Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 31 Dec 2024 18:23:03 -0600 Subject: [PATCH] bane mechanic thread finalized --- src/engine/objects/Bane.java | 21 +++++++++++++++++---- src/engine/objects/City.java | 20 ++++++++++---------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/engine/objects/Bane.java b/src/engine/objects/Bane.java index 903a866a..7c6ecdc4 100644 --- a/src/engine/objects/Bane.java +++ b/src/engine/objects/Bane.java @@ -728,7 +728,7 @@ public final class Bane { ArrayList defenders = new ArrayList<>(); Guild attackNation = this.getOwner().getGuild().getNation(); Guild defendNation = this.getCity().getGuild().getNation(); - for(int uuid : city.baneAttendees.keySet()){ + for(int uuid : city._playerMemory){ PlayerCharacter player = PlayerCharacter.getPlayerCharacter(uuid); if(player == null) continue; @@ -739,12 +739,25 @@ public final class Bane { else if(playerNation.equals(attackNation)) attackers.add(uuid); else - MovementManager.translocate(player,player.bindLoc,Regions.GetRegionForTeleport(player.bindLoc)); + if(city._playerMemory.contains(uuid)) + MovementManager.translocate(player,new Vector3fImmutable(88853,32,45079),Regions.GetRegionForTeleport(player.bindLoc)); + } + int attackerSize = 0; + int defenderSize = 0; + for(int uuid : city.baneAttendees.keySet()){ + PlayerCharacter player = PlayerCharacter.getPlayerCharacter(uuid); + if(player == null) + continue; + if(player.guild.getNation().equals(defendNation)) + defenderSize += 1; + else if(player.guild.getNation().equals(attackNation)) + attackerSize += 1; } + this.capSize = 3; //apply zerg mechanic for attackers - float attackerMultiplier = ZergManager.getCurrentMultiplier(attackers.size(),this.capSize); - float defenderMultiplier = ZergManager.getCurrentMultiplier(defenders.size(),this.capSize); + float attackerMultiplier = ZergManager.getCurrentMultiplier(attackerSize,this.capSize); + float defenderMultiplier = ZergManager.getCurrentMultiplier(defenderSize,this.capSize); for(int uuid : attackers){ if(city._playerMemory.contains(uuid)) //player is still physically here, needs updated multiplier PlayerCharacter.getPlayerCharacter(uuid).ZergMultiplier = attackerMultiplier; diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 4c4fd8b9..88953db5 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -1012,7 +1012,7 @@ public class City extends AbstractWorldObject { // Gather current list of players within the zone bounds - currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); + currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.extents * 2, MBServerStatics.MASK_PLAYER); currentMemory = new HashSet<>(); for (AbstractWorldObject playerObject : currentPlayers) { @@ -1061,20 +1061,20 @@ public class City extends AbstractWorldObject { } } - private void onExitBane(){ - ArrayList toRemove = new ArrayList<>(); - for(int uuid : this.baneAttendees.keySet()){ - if(!_playerMemory.contains(uuid)){ - if(System.currentTimeMillis() - this.baneAttendees.get(uuid) > 180000){ - toRemove.add(uuid); + private void onExitBane() { + Iterator iterator = this.baneAttendees.keySet().iterator(); + while (iterator.hasNext()) { + Integer uuid = iterator.next(); + if (!_playerMemory.contains(uuid)) { + long timeGone = System.currentTimeMillis() - this.baneAttendees.get(uuid).longValue(); + if (timeGone > 180000) { // 3 minutes + iterator.remove(); } } } - for(Integer uuid : toRemove){ - this.baneAttendees.remove(uuid); - } } + private void onExit(HashSet currentMemory) { PlayerCharacter player;