Addition of isSiegeFriend method.

Contributed by Sahar.
This commit is contained in:
MobiusDevelopment
2019-11-08 10:52:40 +00:00
parent 6e1df8a43a
commit 6e64ab3dfd
141 changed files with 744 additions and 197 deletions

View File

@ -949,7 +949,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((target.getActingPlayer() != null) && (getActingPlayer().getSiegeState() > 0) && isInsideZone(ZoneId.SIEGE) && (target.getActingPlayer().getSiegeState() == getActingPlayer().getSiegeState()) && (target.getActingPlayer() != this) && (target.getActingPlayer().getSiegeSide() == getActingPlayer().getSiegeSide()))
else if (getActingPlayer().isSiegeFriend(target))
{
sendPacket(SystemMessageId.FORCE_ATTACK_IS_IMPOSSIBLE_AGAINST_A_TEMPORARY_ALLIED_MEMBER_DURING_A_SIEGE);
sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -1004,7 +1004,7 @@ public abstract class Summon extends Playable
return false;
}
if ((target.getActingPlayer() != null) && (_owner.getSiegeState() > 0) && _owner.isInsideZone(ZoneId.SIEGE) && (target.getActingPlayer().getSiegeSide() == _owner.getSiegeSide()))
if (_owner.isSiegeFriend(target))
{
sendPacket(SystemMessageId.FORCE_ATTACK_IS_IMPOSSIBLE_AGAINST_A_TEMPORARY_ALLIED_MEMBER_DURING_A_SIEGE);
sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -1637,6 +1637,41 @@ public class PlayerInstance extends Playable
return _siegeSide;
}
public boolean isSiegeFriend(WorldObject target)
{
// If i'm natural or not in siege zone, not friends.
if ((_siegeState == 0) || !isInsideZone(ZoneId.SIEGE))
{
return false;
}
// If target isn't a player, is self, isn't on same siege or not on same state, not friends.
final PlayerInstance targetPlayer = target.getActingPlayer();
if ((targetPlayer == null) || (targetPlayer == this) || (targetPlayer.getSiegeSide() != _siegeSide) || (_siegeState != targetPlayer.getSiegeState()))
{
return false;
}
// Attackers are considered friends only if castle has no owner.
if (_siegeState == 1)
{
final Castle castle = CastleManager.getInstance().getCastleById(_siegeSide);
if (castle == null)
{
return false;
}
if (castle.getOwner() == null)
{
return true;
}
return false;
}
// Both are defenders, friends.
return true;
}
/**
* Set the PvP Flag of the PlayerInstance.
* @param pvpFlag
@ -5162,7 +5197,7 @@ public class PlayerInstance extends Playable
// If both players are in SIEGE zone just increase siege kills/deaths
if (isInsideZone(ZoneId.SIEGE) && killedPlayer.isInsideZone(ZoneId.SIEGE))
{
if ((getSiegeState() > 0) && (killedPlayer.getSiegeState() > 0) && (getSiegeState() != killedPlayer.getSiegeState()))
if (!isSiegeFriend(killedPlayer))
{
final Clan targetClan = killedPlayer.getClan();
if ((_clan != null) && (targetClan != null))