if (getDefenderClans().size() == 0 && // If defender doesn't exist (Pc vs Npc)
getAttackerClans().size() == 1 // Only 1 attacker
)
{
L2SiegeClan sc_newowner = getAttackerClan(getCastle().getOwnerId());
removeAttacker(sc_newowner);
addDefender(sc_newowner, SiegeClanType.OWNER);
endSiege();
return;
}
if (getCastle().getOwnerId() > 0) {
int allyId = ClanTable.getInstance().getClan(getCastle().getOwnerId()).getAllyId();
if (getDefenderClans().size() == 0) // If defender doesn't exist (Pc vs Npc)
// and only an alliance attacks
{
// The player's clan is in an alliance
if (allyId != 0)
{
boolean allinsamealliance = true;
for (L2SiegeClan sc : getAttackerClans())
{
if(sc != null)
{
if(ClanTable.getInstance().getClan(sc.getClanId()).getAllyId() != allyId)
allinsamealliance = false;
}
}
if(allinsamealliance)
{
L2SiegeClan sc_newowner = getAttackerClan(getCastle().getOwnerId());
removeAttacker(sc_newowner);
addDefender(sc_newowner, SiegeClanType.OWNER);
endSiege();
return;
}
}
}
for (L2SiegeClan sc : getDefenderClans())
{
if(sc != null) {
removeDefender(sc);
addAttacker(sc);
}
}
L2SiegeClan sc_newowner = getAttackerClan(getCastle().getOwnerId());
removeAttacker(sc_newowner);
addDefender(sc_newowner, SiegeClanType.OWNER);
// The player's clan is in an alliance
if (allyId != 0)
{
L2Clan[] clanList = ClanTable.getInstance().getClans();
for (L2Clan clan : clanList) {
if (clan.getAllyId() == allyId) {
L2SiegeClan sc = getAttackerClan(clan.getClanId());
if(sc != null) {
removeAttacker(sc);
addDefender(sc, SiegeClanType.DEFENDER);
}
}