Skip to content

Commit

Permalink
Fixed team assignment and tribe relation issues in AhserionRaid
Browse files Browse the repository at this point in the history
  • Loading branch information
Estrayl committed Nov 24, 2024
1 parent 2c61382 commit a9a411d
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -172,7 +173,7 @@ private PanesterraFaction findWinnerTeam(Map<PanesterraFaction, Integer> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -124,7 +125,7 @@ private PanesterraFaction findWinnerTeam(Map<PanesterraFaction, Integer> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
}
}
}
Expand All @@ -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())
Expand All @@ -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);
Expand All @@ -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();
}
Expand All @@ -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()))
Expand All @@ -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 -> {
Expand Down
Loading

0 comments on commit a9a411d

Please sign in to comment.