diff --git a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionAI.java b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionAI.java index 22a8bfc71..4a3d7b813 100644 --- a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionAI.java +++ b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionAI.java @@ -15,6 +15,7 @@ import com.aionemu.gameserver.model.gameobjects.player.Player; import com.aionemu.gameserver.model.stats.calc.Stat2; import com.aionemu.gameserver.model.stats.container.StatEnum; +import com.aionemu.gameserver.services.panesterra.PanesterraService; import com.aionemu.gameserver.services.panesterra.ahserion.AhserionRaid; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraFaction; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraTeam; @@ -121,7 +122,7 @@ private void handleSupportSpawns() { private void handleBaseAssault() { if (getOwner().getWorldId() == 400030000 && AhserionRaid.getInstance().isStarted()) { for (PanesterraFaction faction : PanesterraFaction.values()) { - PanesterraTeam team = AhserionRaid.getInstance().getFactionTeam(faction); + PanesterraTeam team = PanesterraService.getInstance().getTeam(faction); if (team != null && !team.isEliminated()) AhserionRaid.getInstance().spawnStage(5, faction); } @@ -152,7 +153,7 @@ protected void handleDied() { // Only players can attack Ahserion on this map. for (AggroInfo ai : getOwner().getAggroList().getFinalDamageList(false)) { if (ai.getAttacker() instanceof Player) { - PanesterraTeam team = AhserionRaid.getInstance().getPanesterraFactionTeam((Player) ai.getAttacker()); + PanesterraTeam team = PanesterraService.getInstance().getTeam((Player) ai.getAttacker()); if (team != null && !team.isEliminated()) { PanesterraFaction faction = team.getFaction(); panesterraDamage.merge(faction, ai.getDamage(), Integer::sum); @@ -172,7 +173,7 @@ private PanesterraFaction findWinnerTeam(Map paneste int maxDmg = 0; for (PanesterraFaction faction : PanesterraFaction.values()) { Integer dmg = panesterraDamage.get(faction); - if (dmg != null && !AhserionRaid.getInstance().getFactionTeam(faction).isEliminated()) { + if (dmg != null && !PanesterraService.getInstance().getTeam(faction).isEliminated()) { if (dmg > maxDmg) { maxDmg = dmg; winner = faction; diff --git a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionMountableTankAI.java b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionMountableTankAI.java index b46673332..979e47576 100644 --- a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionMountableTankAI.java +++ b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionMountableTankAI.java @@ -9,15 +9,15 @@ import com.aionemu.gameserver.model.TaskId; import com.aionemu.gameserver.model.gameobjects.Npc; import com.aionemu.gameserver.model.gameobjects.player.Player; +import com.aionemu.gameserver.services.panesterra.PanesterraService; import com.aionemu.gameserver.services.panesterra.ahserion.AhserionRaid; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraFaction; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraTeam; import com.aionemu.gameserver.skillengine.SkillEngine; +import com.aionemu.gameserver.utils.ThreadPoolManager; import ai.ActionItemNpcAI; -import com.aionemu.gameserver.utils.ThreadPoolManager; - /** * @author Estrayl */ @@ -57,7 +57,7 @@ protected void handleUseItemFinish(Player player) { private boolean canUseTank(Player player) { if (AhserionRaid.getInstance().isStarted()) { - PanesterraTeam team = AhserionRaid.getInstance().getPanesterraFactionTeam(player); + PanesterraTeam team = PanesterraService.getInstance().getTeam(player); return team != null && team.getFaction() == ownerFaction; } return false; diff --git a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionRegistrationCorridor.java b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionRegistrationCorridor.java index 93dbbb350..c58db6a94 100644 --- a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionRegistrationCorridor.java +++ b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionRegistrationCorridor.java @@ -12,6 +12,7 @@ import com.aionemu.gameserver.model.gameobjects.player.Player; import com.aionemu.gameserver.network.aion.serverpackets.SM_QUESTION_WINDOW; import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE; +import com.aionemu.gameserver.services.panesterra.PanesterraService; import com.aionemu.gameserver.services.panesterra.ahserion.AhserionRaid; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraFaction; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraTeam; @@ -59,13 +60,14 @@ public void acceptRequest(Creature requester, Player responder, int requestId) { if (!AhserionRaid.getInstance().isStarted()) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_CANT_READY_PANGAEA()); return; - } else if (AhserionRaid.getInstance().getTeamMemberCountByFaction(faction) >= SiegeConfig.AHSERION_MAX_PLAYERS_PER_TEAM) { + } else if (PanesterraService.getInstance().getTeamMemberCount(faction) >= SiegeConfig.AHSERION_MAX_PLAYERS_PER_TEAM) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_CANNOT_USE_SVS_DIRECT_PORTAL_USE_COUNT_LIMIT()); return; } - PanesterraTeam team = AhserionRaid.getInstance().getFactionTeam(faction); + PanesterraTeam team = PanesterraService.getInstance().getTeam(faction); team.addTeamMemberIfAbsent(player.getObjectId()); team.movePlayerToStartPosition(player); + player.setPanesterraFaction(team.getFaction()); } }); } diff --git a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionTankControllerAI.java b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionTankControllerAI.java index b693c97ac..fe30be935 100644 --- a/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionTankControllerAI.java +++ b/game-server/data/handlers/ai/worlds/panesterra/ahserionsflight/AhserionTankControllerAI.java @@ -12,6 +12,7 @@ import com.aionemu.gameserver.model.gameobjects.player.Player; import com.aionemu.gameserver.model.templates.npc.NpcTemplateType; import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE; +import com.aionemu.gameserver.services.panesterra.PanesterraService; import com.aionemu.gameserver.services.panesterra.ahserion.AhserionRaid; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraFaction; import com.aionemu.gameserver.services.panesterra.ahserion.PanesterraTeam; @@ -102,8 +103,8 @@ public void handleDied() { // Only players or balaur can attack the controller, there are no other npcs on this map for (AggroInfo ai : getOwner().getAggroList().getFinalDamageList(false)) { PanesterraFaction faction = null; - if (ai.getAttacker() instanceof Player) { - PanesterraTeam team = AhserionRaid.getInstance().getPanesterraFactionTeam((Player) ai.getAttacker()); + if (ai.getAttacker() instanceof Player player) { + PanesterraTeam team = PanesterraService.getInstance().getTeam(player); if (team != null && !team.isEliminated()) faction = team.getFaction(); } else @@ -124,7 +125,7 @@ private PanesterraFaction findWinnerTeam(Map paneste int maxDmg = panesterraDamage.getOrDefault(PanesterraFaction.BALAUR, 0); for (PanesterraFaction faction : PanesterraFaction.values()) { Integer dmg = panesterraDamage.get(faction); - PanesterraTeam team = AhserionRaid.getInstance().getFactionTeam(faction); + PanesterraTeam team = PanesterraService.getInstance().getTeam(faction); if (dmg != null && team != null && !team.isEliminated()) { if (dmg > maxDmg) { maxDmg = dmg; diff --git a/game-server/src/com/aionemu/gameserver/services/TribeRelationService.java b/game-server/src/com/aionemu/gameserver/services/TribeRelationService.java index ac191232b..c122691a5 100644 --- a/game-server/src/com/aionemu/gameserver/services/TribeRelationService.java +++ b/game-server/src/com/aionemu/gameserver/services/TribeRelationService.java @@ -56,10 +56,10 @@ public static boolean isAggressive(Creature creature1, Creature creature2) { break; } if (creature1.getTribe().name().startsWith("GAB1_") && creature2 instanceof Player p && p.getPanesterraFaction() != null) { - TribeClass playerTribe = p.getWorldId() == 400030000 ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); + TribeClass playerTribe = creature1.getTribe().name().startsWith("GAB1_SUB") ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); if (creature1.getTribe() == playerTribe) return false; - return DataManager.TRIBE_RELATIONS_DATA.isAggressiveRelation(creature1.getTribe(), p.getPanesterraFaction().getTribe()); + return DataManager.TRIBE_RELATIONS_DATA.isAggressiveRelation(creature1.getTribe(), playerTribe); } return DataManager.TRIBE_RELATIONS_DATA.isAggressiveRelation(creature1.getTribe(), creature2.getTribe()); @@ -102,10 +102,10 @@ public static boolean isFriend(Creature creature1, Creature creature2) { break; } if (creature1.getTribe().name().startsWith("GAB1_") && creature2 instanceof Player p && p.getPanesterraFaction() != null) { - TribeClass playerTribe = p.getWorldId() == 400030000 ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); + TribeClass playerTribe = creature1.getTribe().name().startsWith("GAB1_SUB") ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); if (creature1.getTribe() == playerTribe) return true; - return DataManager.TRIBE_RELATIONS_DATA.isFriendlyRelation(creature1.getTribe(), p.getPanesterraFaction().getTribe()); + return DataManager.TRIBE_RELATIONS_DATA.isFriendlyRelation(creature1.getTribe(), playerTribe); } return DataManager.TRIBE_RELATIONS_DATA.isFriendlyRelation(creature1.getTribe(), creature2.getTribe()); @@ -127,10 +127,10 @@ public static boolean isSupport(Creature creature1, Creature creature2) { break; } if (creature1.getTribe().name().startsWith("GAB1_") && creature2 instanceof Player p && p.getPanesterraFaction() != null) { - TribeClass playerTribe = p.getWorldId() == 400030000 ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); + TribeClass playerTribe = creature1.getTribe().name().startsWith("GAB1_SUB") ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); if (creature1.getTribe() == playerTribe) return true; - return DataManager.TRIBE_RELATIONS_DATA.isSupportRelation(creature1.getTribe(), p.getPanesterraFaction().getTribe()); + return DataManager.TRIBE_RELATIONS_DATA.isSupportRelation(creature1.getTribe(), playerTribe); } return DataManager.TRIBE_RELATIONS_DATA.isSupportRelation(creature1.getTribe(), creature2.getTribe()); @@ -180,7 +180,7 @@ public static boolean isHostile(Creature creature1, Creature creature2) { } if (creature1.getTribe().name().startsWith("GAB1_") && creature2 instanceof Player p && p.getPanesterraFaction() != null) { - TribeClass playerTribe = p.getWorldId() == 400030000 ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); + TribeClass playerTribe = creature1.getTribe().name().startsWith("GAB1_SUB") ? p.getPanesterraFaction().getSubTribe() : p.getPanesterraFaction().getTribe(); if (creature1.getTribe() == playerTribe) return false; return DataManager.TRIBE_RELATIONS_DATA.isHostileRelation(creature1.getTribe(), playerTribe); diff --git a/game-server/src/com/aionemu/gameserver/services/panesterra/PanesterraService.java b/game-server/src/com/aionemu/gameserver/services/panesterra/PanesterraService.java index 74fa447e7..9126fee58 100644 --- a/game-server/src/com/aionemu/gameserver/services/panesterra/PanesterraService.java +++ b/game-server/src/com/aionemu/gameserver/services/panesterra/PanesterraService.java @@ -29,6 +29,8 @@ import com.aionemu.gameserver.world.World; import com.aionemu.gameserver.world.WorldMapType; +import static com.aionemu.gameserver.services.panesterra.ahserion.PanesterraFaction.*; + /** * Workflow for Panesterra sieges: * 1. Stop all outer bases @@ -90,14 +92,10 @@ public void startFortressSiege(FortressLocation loc) { public void stopFortressSiege(FortressLocation loc) { // Remove Teams switch (loc.getLocationId()) { - case 10111 -> removeTeams(PanesterraFaction.IVY_TEMPLE, PanesterraFaction.HIGHLAND_TEMPLE, PanesterraFaction.ALPINE_TEMPLE, - PanesterraFaction.GRANDWEIR_TEMPLE); - case 10211 -> removeTeams(PanesterraFaction.NOERREN_TEMPLE, PanesterraFaction.BOREALIS_TEMPLE, PanesterraFaction.MYRKREN_TEMPLE, - PanesterraFaction.GLUMVEILEN_TEMPLE); - case 10311 -> removeTeams(PanesterraFaction.MEMORIA_TEMPLE, PanesterraFaction.SYBILLINE_TEMPLE, PanesterraFaction.AUSTERITY_TEMPLE, - PanesterraFaction.SERENITY_TEMPLE); - case 10411 -> removeTeams(PanesterraFaction.NECROLUCE_TEMPLE, PanesterraFaction.ESMERAUDUS_TEMPLE, PanesterraFaction.VOLTAIC_TEMPLE, - PanesterraFaction.ILLUMINATUS_TEMPLE); + case 10111 -> removeTeams(IVY_TEMPLE, HIGHLAND_TEMPLE, ALPINE_TEMPLE, GRANDWEIR_TEMPLE); + case 10211 -> removeTeams(NOERREN_TEMPLE, BOREALIS_TEMPLE, MYRKREN_TEMPLE, GLUMVEILEN_TEMPLE); + case 10311 -> removeTeams(MEMORIA_TEMPLE, SYBILLINE_TEMPLE, AUSTERITY_TEMPLE, SERENITY_TEMPLE); + case 10411 -> removeTeams(NECROLUCE_TEMPLE, ESMERAUDUS_TEMPLE, VOLTAIC_TEMPLE, ILLUMINATUS_TEMPLE); } // Change base states SiegeRelatedBases relatedBases = loc.getTemplate().getSiegeRelatedBases(); @@ -156,48 +154,68 @@ public void startAhserionRaid() { log.error("Ahserion raid cannot be started while any Panesterra fortress is under siege."); return; } + createTeams(-1); + SpawnEngine.spawnObject(SpawnEngine.newSingleTimeSpawn(110070000, 802223, 485.692f, 401.079f, 127.789f, (byte) 0), 1); + SpawnEngine.spawnObject(SpawnEngine.newSingleTimeSpawn(120080000, 802225, 400.772f, 231.517f, 93.113f, (byte) 30), 1); AhserionRaid.getInstance().start(); } public void stopAhserionRaid() { AhserionRaid.getInstance().stop(); + if (!activeFactionTeams.isEmpty()) { + for (PanesterraTeam team : activeFactionTeams.values()) { + team.setIsEliminated(true); + team.moveTeamMembersToOriginPosition(); + } + activeFactionTeams.clear(); + } } - public void handleTeamElimination(PanesterraFaction faction) { + public PanesterraTeam handleTeamElimination(PanesterraFaction faction) { PanesterraTeam team = activeFactionTeams.get(faction); if (team == null) - return; // Using the //base command + return null; // Using the //base command team.setIsEliminated(true); team.moveTeamMembersToOriginPosition(); + return team; } private void createTeams(int siegeId) { - // TODO: Ahserion Teams switch (siegeId) { - case 10111 -> { - activeFactionTeams.put(PanesterraFaction.IVY_TEMPLE, new PanesterraTeam(PanesterraFaction.IVY_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.HIGHLAND_TEMPLE, new PanesterraTeam(PanesterraFaction.HIGHLAND_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.ALPINE_TEMPLE, new PanesterraTeam(PanesterraFaction.ALPINE_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.GRANDWEIR_TEMPLE, new PanesterraTeam(PanesterraFaction.GRANDWEIR_TEMPLE)); + case -1 -> { // Transidium Annex + if (SiegeService.getInstance().getSiegeLocation(10111).getRace() != SiegeRace.BALAUR) + activeFactionTeams.put(BELUS, new PanesterraTeam(BELUS)); + if (SiegeService.getInstance().getSiegeLocation(10211).getRace() != SiegeRace.BALAUR) + activeFactionTeams.put(ASPIDA, new PanesterraTeam(ASPIDA)); + if (SiegeService.getInstance().getSiegeLocation(10311).getRace() != SiegeRace.BALAUR) + activeFactionTeams.put(ATANATOS, new PanesterraTeam(ATANATOS)); + if (SiegeService.getInstance().getSiegeLocation(10411).getRace() != SiegeRace.BALAUR) + activeFactionTeams.put(DISILLON, new PanesterraTeam(DISILLON)); + } + case 10111 -> { // Belus + activeFactionTeams.put(IVY_TEMPLE, new PanesterraTeam(IVY_TEMPLE)); + activeFactionTeams.put(HIGHLAND_TEMPLE, new PanesterraTeam(HIGHLAND_TEMPLE)); + activeFactionTeams.put(ALPINE_TEMPLE, new PanesterraTeam(ALPINE_TEMPLE)); + activeFactionTeams.put(GRANDWEIR_TEMPLE, new PanesterraTeam(GRANDWEIR_TEMPLE)); } - case 10211 -> { - activeFactionTeams.put(PanesterraFaction.NOERREN_TEMPLE, new PanesterraTeam(PanesterraFaction.NOERREN_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.BOREALIS_TEMPLE, new PanesterraTeam(PanesterraFaction.BOREALIS_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.MYRKREN_TEMPLE, new PanesterraTeam(PanesterraFaction.MYRKREN_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.GLUMVEILEN_TEMPLE, new PanesterraTeam(PanesterraFaction.GLUMVEILEN_TEMPLE)); + case 10211 -> { // Aspida + activeFactionTeams.put(NOERREN_TEMPLE, new PanesterraTeam(NOERREN_TEMPLE)); + activeFactionTeams.put(BOREALIS_TEMPLE, new PanesterraTeam(BOREALIS_TEMPLE)); + activeFactionTeams.put(MYRKREN_TEMPLE, new PanesterraTeam(MYRKREN_TEMPLE)); + activeFactionTeams.put(GLUMVEILEN_TEMPLE, new PanesterraTeam(GLUMVEILEN_TEMPLE)); } - case 10311 -> { - activeFactionTeams.put(PanesterraFaction.MEMORIA_TEMPLE, new PanesterraTeam(PanesterraFaction.MEMORIA_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.SYBILLINE_TEMPLE, new PanesterraTeam(PanesterraFaction.SYBILLINE_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.AUSTERITY_TEMPLE, new PanesterraTeam(PanesterraFaction.AUSTERITY_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.SERENITY_TEMPLE, new PanesterraTeam(PanesterraFaction.SERENITY_TEMPLE)); + case 10311 -> { // Atanatos + activeFactionTeams.put(MEMORIA_TEMPLE, new PanesterraTeam(MEMORIA_TEMPLE)); + activeFactionTeams.put(SYBILLINE_TEMPLE, new PanesterraTeam(SYBILLINE_TEMPLE)); + activeFactionTeams.put(AUSTERITY_TEMPLE, new PanesterraTeam(AUSTERITY_TEMPLE)); + activeFactionTeams.put(SERENITY_TEMPLE, new PanesterraTeam(SERENITY_TEMPLE)); } - case 10411 -> { - activeFactionTeams.put(PanesterraFaction.NECROLUCE_TEMPLE, new PanesterraTeam(PanesterraFaction.NECROLUCE_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.ESMERAUDUS_TEMPLE, new PanesterraTeam(PanesterraFaction.ESMERAUDUS_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.VOLTAIC_TEMPLE, new PanesterraTeam(PanesterraFaction.VOLTAIC_TEMPLE)); - activeFactionTeams.put(PanesterraFaction.ILLUMINATUS_TEMPLE, new PanesterraTeam(PanesterraFaction.ILLUMINATUS_TEMPLE)); + case 10411 -> { // Disillon + activeFactionTeams.put(NECROLUCE_TEMPLE, new PanesterraTeam(NECROLUCE_TEMPLE)); + activeFactionTeams.put(ESMERAUDUS_TEMPLE, new PanesterraTeam(ESMERAUDUS_TEMPLE)); + activeFactionTeams.put(VOLTAIC_TEMPLE, new PanesterraTeam(VOLTAIC_TEMPLE)); + activeFactionTeams.put(ILLUMINATUS_TEMPLE, new PanesterraTeam(ILLUMINATUS_TEMPLE)); } } } @@ -222,9 +240,9 @@ public void onEnterPanesterra(Player player) { int siegeId = getSiegeId(player.getWorldId()); if (siegeId == 0) return; - // Player is in Transidium Annex or on an active map with an active siege + // Player is in Transidium Annex or on a map with an active siege if (siegeId == -1 || SiegeService.getInstance().isSiegeInProgress(siegeId)) { - PanesterraTeam team = getPanesterraFactionTeam(player); + PanesterraTeam team = getTeam(player); if (team == null) TeleportService.moveToBindLocation(player); else if (team.isEliminated()) @@ -236,9 +254,9 @@ else if (team.isEliminated()) // Check if the player's faction owns any related fortress PanesterraFaction faction = Stream.of(10111, 10211, 10311, 10411) .filter(id -> SiegeService.getInstance().getFortress(id).getRace() == SiegeRace.getByRace(player.getRace())) - .map(PanesterraFaction::getByFortressId).findFirst().orElse(PanesterraFaction.PEACE); + .map(PanesterraFaction::getByFortressId).findFirst().orElse(PEACE); - if (faction == PanesterraFaction.PEACE) + if (faction == PEACE) TeleportService.moveToBindLocation(player); player.setPanesterraFaction(faction); @@ -256,14 +274,6 @@ private int getSiegeId(int worldId) { }; } - public PanesterraTeam getPanesterraFactionTeam(Player player) { - for (PanesterraTeam team : activeFactionTeams.values()) { - if (team.isTeamMember(player.getObjectId())) - return team; - } - return null; - } - public boolean isAhserionRaidStarted() { return AhserionRaid.getInstance().isStarted(); } @@ -276,7 +286,27 @@ public int getTeamMemberCount(PanesterraFaction faction) { public PanesterraTeam getTeam(PanesterraFaction faction) { return activeFactionTeams.get(faction); } - + + public PanesterraTeam getTeam(Player player) { + for (PanesterraTeam team : activeFactionTeams.values()) { + if (team.isTeamMember(player.getObjectId())) + return team; + } + return null; + } + + public boolean teleportToStartPosition(Player player) { + if (!WorldMapType.isPanesterraMap(player.getWorldId())) + return false; + + PanesterraTeam team = getTeam(player); + if (team != null && !team.isEliminated()) { + team.movePlayerToStartPosition(player); + return true; + } + return false; + } + // TODO: Event START public boolean reviveInEventLocation(Player player) { if (!WorldMapType.isPanesterraMap(player.getWorldId())) @@ -285,12 +315,12 @@ public boolean reviveInEventLocation(Player player) { teleportToEventLocation(player); return true; } - + public void teleportToEventLocation(Player player) { teleport(player); PanesterraService.getInstance().onEnterPanesterra(player); } - + private void teleport(Player player) { switch (player.getRace()) { case ELYOS -> { diff --git a/game-server/src/com/aionemu/gameserver/services/panesterra/ahserion/AhserionRaid.java b/game-server/src/com/aionemu/gameserver/services/panesterra/ahserion/AhserionRaid.java index 51b76e62d..603006a49 100644 --- a/game-server/src/com/aionemu/gameserver/services/panesterra/ahserion/AhserionRaid.java +++ b/game-server/src/com/aionemu/gameserver/services/panesterra/ahserion/AhserionRaid.java @@ -1,11 +1,11 @@ package com.aionemu.gameserver.services.panesterra.ahserion; -import java.util.Collections; -import java.util.EnumMap; +import static com.aionemu.gameserver.services.panesterra.ahserion.PanesterraFaction.*; + import java.util.List; -import java.util.Map; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; import org.slf4j.LoggerFactory; @@ -22,6 +22,7 @@ import com.aionemu.gameserver.model.templates.spawns.panesterra.AhserionsFlightSpawnTemplate; import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE; import com.aionemu.gameserver.services.mail.SystemMailService; +import com.aionemu.gameserver.services.panesterra.PanesterraService; import com.aionemu.gameserver.services.teleport.TeleportService; import com.aionemu.gameserver.spawnengine.SpawnEngine; import com.aionemu.gameserver.utils.PacketSendUtility; @@ -36,7 +37,7 @@ */ public class AhserionRaid { - private final Map panesterraTeams = Collections.synchronizedMap(new EnumMap<>(PanesterraFaction.class)); + private final List factions = List.of(BELUS, ASPIDA, ATANATOS, DISILLON); private final AtomicBoolean isStarted = new AtomicBoolean(); private PanesterraTeam winner; private Future progressTask; @@ -47,7 +48,6 @@ public static AhserionRaid getInstance() { public void start() { if (isStarted.compareAndSet(false, true)) { - spawnAdvanceCorridorsAndInitTeams(); spawnRaid(); startInstanceTimer(); } @@ -58,13 +58,6 @@ public void stop() { return; winner = null; cancelProgressTask(); - if (!panesterraTeams.isEmpty()) { - for (PanesterraTeam team : panesterraTeams.values()) { - team.setIsEliminated(true); - team.moveTeamMembersToOriginPosition(); - } - panesterraTeams.clear(); - } cleanUp(); } @@ -129,10 +122,10 @@ public void run() { sendMsg(SM_SYSTEM_MESSAGE.STR_MSG_GAB1_SUB_ALARM_11()); break; case 60: - sendMsg(SM_SYSTEM_MESSAGE.STR_MSG_GAB1_SUB_ALARM_12()); - for (PanesterraFaction faction : PanesterraFaction.values()) - if (panesterraTeams.containsKey(faction) && !panesterraTeams.get(faction).isEliminated()) - spawnStage(4, faction); + forEachTeam(team -> { + if (!team.isEliminated()) + spawnStage(4, team.getFaction()); + }); break; case 130: sendMsg(SM_SYSTEM_MESSAGE.STR_MSG_GAB1_SUB_ALARM_13()); @@ -141,7 +134,10 @@ public void run() { sendMsg(SM_SYSTEM_MESSAGE.STR_MSG_GAB1_SUB_ALARM_14()); break; case 150: - panesterraTeams.values().stream().filter(team -> !team.isEliminated()).forEach(team -> sendConsolationReward(team)); + forEachTeam(team -> { + if (!team.isEliminated()) + sendConsolationReward(team); + }); stop(); break; } @@ -150,7 +146,7 @@ public void run() { } private void checkForIllegalMovement() { - panesterraTeams.values().forEach(team -> { + forEachTeam(team -> { WorldPosition startPosition = team.getStartPosition(); team.forEachMember(player -> { if (player.getPosition().getMapId() == 400030000 @@ -162,55 +158,42 @@ private void checkForIllegalMovement() { }); } - /** - * Currently hard coded due to hard coded tribe relations - * TODO: Implement more flexibility for fortress occupation - */ - private void spawnAdvanceCorridorsAndInitTeams() { - PanesterraFaction elyos = PanesterraFaction.ATANATOS; - PanesterraFaction asmodians = PanesterraFaction.DISILLON; - panesterraTeams.put(elyos, new PanesterraTeam(elyos)); - panesterraTeams.put(asmodians, new PanesterraTeam(asmodians)); - SpawnEngine.spawnObject(SpawnEngine.newSingleTimeSpawn(110070000, 802223, 485.692f, 401.079f, 127.789f, (byte) 0), 1); - SpawnEngine.spawnObject(SpawnEngine.newSingleTimeSpawn(120080000, 802225, 400.772f, 231.517f, 93.113f, (byte) 30), 1); - } - private void spawnRaid() { // spawn Barricades & Tank Fleets - spawnStage(0, PanesterraFaction.BALAUR); - spawnStage(180, PanesterraFaction.BALAUR); - spawnStage(181, PanesterraFaction.BALAUR); - spawnStage(182, PanesterraFaction.BALAUR); - spawnStage(183, PanesterraFaction.BALAUR); + spawnStage(0, BALAUR); + spawnStage(180, BALAUR); + spawnStage(181, BALAUR); + spawnStage(182, BALAUR); + spawnStage(183, BALAUR); // spawn flags & cannons for all registered teams - for (PanesterraFaction faction : panesterraTeams.keySet()) { - if (faction != null) - spawnStage(0, faction); - spawnStage(1, faction); - } + forEachTeam(team -> { + spawnStage(0, team.getFaction()); + spawnStage(1, team.getFaction()); + }); // spawn white flags for not existing teams - if (!panesterraTeams.containsKey(PanesterraFaction.BELUS)) { + if (PanesterraService.getInstance().getTeam(BELUS) == null) { SpawnTemplate template = SpawnEngine.newSingleTimeSpawn(400030000, 804106, 282.73f, 289.1f, 687.38f, (byte) 1); SpawnEngine.spawnObject(template, 1); } - if (!panesterraTeams.containsKey(PanesterraFaction.ASPIDA)) { + if (PanesterraService.getInstance().getTeam(ASPIDA) == null) { SpawnTemplate template = SpawnEngine.newSingleTimeSpawn(400030000, 804108, 282.49f, 739.62f, 689.66f, (byte) 1); SpawnEngine.spawnObject(template, 1); } - if (!panesterraTeams.containsKey(PanesterraFaction.ATANATOS)) { + if (PanesterraService.getInstance().getTeam(ATANATOS) == null) { SpawnTemplate template = SpawnEngine.newSingleTimeSpawn(400030000, 804110, 734.06f, 740.75f, 681.16f, (byte) 1); SpawnEngine.spawnObject(template, 1); } - if (!panesterraTeams.containsKey(PanesterraFaction.DISILLON)) { + if (PanesterraService.getInstance().getTeam(DISILLON) == null) { SpawnTemplate template = SpawnEngine.newSingleTimeSpawn(400030000, 804112, 738.58f, 286.02f, 680.71f, (byte) 1); SpawnEngine.spawnObject(template, 1); } } public void spawnStage(int stage, PanesterraFaction faction) { - if (faction != PanesterraFaction.BALAUR && (panesterraTeams.get(faction) == null || panesterraTeams.get(faction).isEliminated())) + PanesterraTeam team = PanesterraService.getInstance().getTeam(faction); + if (faction != BALAUR && (team == null || team.isEliminated())) return; List ahserionSpawns = DataManager.SPAWNS_DATA.getAhserionSpawnByTeamId(faction.ordinal()); @@ -237,29 +220,26 @@ public void handleCorridorShieldDestruction(int npcId) { switch (npcId) { case 297306 -> { - eliminatedFaction = PanesterraFaction.BELUS; + eliminatedFaction = BELUS; template = SpawnEngine.newSingleTimeSpawn(400030000, 804106, 282.73f, 289.1f, 687.38f, (byte) 1); } case 297307 -> { - eliminatedFaction = PanesterraFaction.ASPIDA; + eliminatedFaction = ASPIDA; template = SpawnEngine.newSingleTimeSpawn(400030000, 804108, 282.49f, 739.62f, 689.66f, (byte) 1); } case 297308 -> { - eliminatedFaction = PanesterraFaction.ATANATOS; + eliminatedFaction = ATANATOS; template = SpawnEngine.newSingleTimeSpawn(400030000, 804110, 734.06f, 740.75f, 681.16f, (byte) 1); } case 297309 -> { - eliminatedFaction = PanesterraFaction.DISILLON; + eliminatedFaction = DISILLON; template = SpawnEngine.newSingleTimeSpawn(400030000, 804112, 738.58f, 286.02f, 680.71f, (byte) 1); } } - PanesterraTeam eliminatedTeam = panesterraTeams.remove(eliminatedFaction); - if (eliminatedTeam != null) { - eliminatedTeam.setIsEliminated(true); - eliminatedTeam.moveTeamMembersToOriginPosition(); + PanesterraTeam eliminatedTeam = PanesterraService.getInstance().handleTeamElimination(eliminatedFaction); + if (eliminatedTeam != null) sendConsolationReward(eliminatedTeam); - } deleteNpcs(eliminatedFaction, npcId + 1); SpawnEngine.spawnObject(template, 1); } @@ -271,7 +251,7 @@ private void sendConsolationReward(PanesterraTeam eliminatedTeam) { } public void handleBossKilled(Npc ahserion, PanesterraFaction winnerFaction) { - winner = panesterraTeams.get(winnerFaction); + winner = PanesterraService.getInstance().getTeam(winnerFaction); if (winner == null || winner.isEliminated()) { // something went wrong, remove all players from the map LoggerFactory.getLogger(AhserionRaid.class).warn("Ahserion got killed but winnerTeam is missing or eliminated. Skipping rewards."); @@ -279,12 +259,11 @@ public void handleBossKilled(Npc ahserion, PanesterraFaction winnerFaction) { return; } cancelProgressTask(); - for (PanesterraFaction faction : panesterraTeams.keySet()) { - if (faction != null && faction != winnerFaction) { - panesterraTeams.get(faction).setIsEliminated(true); - panesterraTeams.get(faction).moveTeamMembersToOriginPosition(); - } - } + factions.forEach(faction -> { + if (faction != winnerFaction) + PanesterraService.getInstance().handleTeamElimination(faction); + }); + ahserion.getPosition().getWorldMapInstance().forEachNpc(npc -> npc.getController().deleteIfAliveOrCancelRespawn()); spawnStage(10, winnerFaction); // Quest Npc "Pasha" ThreadPoolManager.getInstance().schedule(this::stop, 900000); // 15min @@ -305,52 +284,17 @@ private void deleteNpcs(PanesterraFaction eliminatedFaction, int flagToDelete) { }); } - private void cancelProgressTask() { - if (progressTask != null && !progressTask.isCancelled()) - progressTask.cancel(true); - } - - public PanesterraTeam getPanesterraFactionTeam(Player player) { - for (PanesterraTeam team : panesterraTeams.values()) { - if (team.isTeamMember(player.getObjectId())) - return team; + public void forEachTeam(Consumer consumer) { + for (PanesterraFaction faction : factions) { + PanesterraTeam team = PanesterraService.getInstance().getTeam(faction); + if (team != null) + consumer.accept(team); } - return null; - } - - public boolean teleportToTeamStartPosition(Player player) { - PanesterraTeam team = getPanesterraFactionTeam(player); - if (team != null && !team.isEliminated()) { - team.movePlayerToStartPosition(player); - return true; - } - return false; - } - - /** - * Validates players position - */ - public void onPlayerLogin(Player player) { - if (player.isStaff() || player.getWorldId() != 400030000) - return; - PanesterraTeam team = getPanesterraFactionTeam(player); - if (team == null) - TeleportService.moveToBindLocation(player); - else if (team.isEliminated()) - team.movePlayerToOriginPosition(player); - else - player.setPanesterraFaction(team.getFaction()); - } - - public int getTeamMemberCountByFaction(PanesterraFaction faction) { - PanesterraTeam team = panesterraTeams.get(faction); - if (team != null) - return team.getMemberCount(); - return 0; } - public PanesterraTeam getFactionTeam(PanesterraFaction faction) { - return panesterraTeams.get(faction); + private void cancelProgressTask() { + if (progressTask != null && !progressTask.isCancelled()) + progressTask.cancel(true); } public boolean isStarted() { diff --git a/game-server/src/com/aionemu/gameserver/services/player/PlayerEnterWorldService.java b/game-server/src/com/aionemu/gameserver/services/player/PlayerEnterWorldService.java index e5dfc8413..8eef67221 100644 --- a/game-server/src/com/aionemu/gameserver/services/player/PlayerEnterWorldService.java +++ b/game-server/src/com/aionemu/gameserver/services/player/PlayerEnterWorldService.java @@ -186,7 +186,7 @@ private static void enterWorld(AionConnection client, Player player) { World.getInstance().storeObject(player); - // change players position if he isn't allowed to spawn in the current zone + // change player position if he isn't allowed to spawn in the current zone if (validateFortressZone(player)) // only check vortex zone if fortress check was ok (otherwise, the player is already set to bind point) validateVortexZone(player); @@ -230,7 +230,7 @@ private static void enterWorld(AionConnection client, Player player) { player.getTitleList().setBonusTitle(pcd.getBonusTitleId()); } client.sendPacket(new SM_MOTION(player.getMotions().getMotions().values())); - client.sendPacket(new SM_AFTER_TIME_CHECK_4_7_5());// it is also send after enter world check + client.sendPacket(new SM_AFTER_TIME_CHECK_4_7_5());// it is also sent after enter world check byte[] uiSettings = player.getPlayerSettings().getUiSettings(); byte[] shortcuts = player.getPlayerSettings().getShortcuts(); @@ -254,7 +254,6 @@ private static void enterWorld(AionConnection client, Player player) { TeleportService.sendKiskBindPoint(player); PanesterraService.getInstance().onEnterPanesterra(player); - AhserionRaid.getInstance().onPlayerLogin(player); // ----------------------------- Retail sequence ----------------------------- client.sendPacket(new SM_PLAYER_SPAWN(player)); diff --git a/game-server/src/com/aionemu/gameserver/services/player/PlayerReviveService.java b/game-server/src/com/aionemu/gameserver/services/player/PlayerReviveService.java index ad13a54da..fb266e994 100644 --- a/game-server/src/com/aionemu/gameserver/services/player/PlayerReviveService.java +++ b/game-server/src/com/aionemu/gameserver/services/player/PlayerReviveService.java @@ -119,7 +119,7 @@ public static void bindRevive(Player player, int skillId) { TeleportService.teleportToEvent(player); } else if (WorldMapType.getWorld(player.getWorldId()) == WorldMapType.BELUS) { PanesterraService.getInstance().reviveInEventLocation(player); - } else if (player.getWorldId() != 400030000 || !AhserionRaid.getInstance().teleportToTeamStartPosition(player)) { + } else if (!PanesterraService.getInstance().teleportToStartPosition(player)) { WorldPosition resPos = null; for (VortexLocation loc : VortexService.getInstance().getVortexLocations().values()) { if (loc.isInsideActiveVotrex(player) && player.getRace().equals(loc.getInvadersRace())) {