Support for no PvP zones.

Contributed by Edoo.
This commit is contained in:
MobiusDevelopment 2020-02-06 04:19:59 +00:00
parent 298641d570
commit c28ca9fbc1
136 changed files with 2128 additions and 123 deletions

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3955,7 +3955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1836,6 +1836,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8213,7 +8222,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9411,7 +9420,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA; _noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA;
return false; return false;

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3955,7 +3955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1842,6 +1842,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8220,7 +8229,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9418,7 +9427,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA; _noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA;
return false; return false;

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3955,7 +3955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1844,6 +1844,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8222,7 +8231,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9420,7 +9429,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA; _noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA;
return false; return false;

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3955,7 +3955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1853,6 +1853,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8203,7 +8212,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9404,7 +9413,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL; _noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL;
return false; return false;

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3955,7 +3955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1846,6 +1846,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8181,7 +8190,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9390,7 +9399,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL; _noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL;
return false; return false;

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3955,7 +3955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1846,6 +1846,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8181,7 +8190,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9390,7 +9399,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL; _noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL;
return false; return false;
@ -12198,16 +12207,16 @@ public class PlayerInstance extends Playable
final int relation1 = getRelation(player); final int relation1 = getRelation(player);
final RelationChanged rc1 = new RelationChanged(); final RelationChanged rc1 = new RelationChanged();
rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE)); rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
if (hasSummon()) if (hasSummon())
{ {
if (_pet != null) if (_pet != null)
{ {
rc1.addRelation(_pet, relation1, !isInsideZone(ZoneId.PEACE)); rc1.addRelation(_pet, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
} }
if (hasServitors()) if (hasServitors())
{ {
getServitors().values().forEach(s -> rc1.addRelation(s, relation1, !isInsideZone(ZoneId.PEACE))); getServitors().values().forEach(s -> rc1.addRelation(s, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP)));
} }
} }
player.sendPacket(rc1); player.sendPacket(rc1);

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3955,7 +3955,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1846,6 +1846,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8182,7 +8191,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9391,7 +9400,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL; _noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL;
return false; return false;
@ -12204,16 +12213,16 @@ public class PlayerInstance extends Playable
final int relation1 = getRelation(player); final int relation1 = getRelation(player);
final RelationChanged rc1 = new RelationChanged(); final RelationChanged rc1 = new RelationChanged();
rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE)); rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
if (hasSummon()) if (hasSummon())
{ {
if (_pet != null) if (_pet != null)
{ {
rc1.addRelation(_pet, relation1, !isInsideZone(ZoneId.PEACE)); rc1.addRelation(_pet, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
} }
if (hasServitors()) if (hasServitors())
{ {
getServitors().values().forEach(s -> rc1.addRelation(s, relation1, !isInsideZone(ZoneId.PEACE))); getServitors().values().forEach(s -> rc1.addRelation(s, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP)));
} }
} }
player.sendPacket(rc1); player.sendPacket(rc1);

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/zones.xsd">
<!-- No PvP Zones -->
<zone name="storm_island" type="NoPvPZone" shape="NPoly" minZ="-4620" maxZ="50"> <!-- [25_23] -->
<node X="166552" Y="161325" />
<node X="196546" Y="161974" />
<node X="198036" Y="195723" />
<node X="164904" Y="195931" />
</zone>
</list>

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -393,7 +393,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3954,7 +3954,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1855,6 +1855,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8147,7 +8156,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9356,7 +9365,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_HE_OR_SHE_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_HE_OR_SHE_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL; _noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL;
return false; return false;
@ -12160,16 +12169,16 @@ public class PlayerInstance extends Playable
final int relation1 = getRelation(player); final int relation1 = getRelation(player);
final RelationChanged rc1 = new RelationChanged(); final RelationChanged rc1 = new RelationChanged();
rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE)); rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
if (hasSummon()) if (hasSummon())
{ {
if (_pet != null) if (_pet != null)
{ {
rc1.addRelation(_pet, relation1, !isInsideZone(ZoneId.PEACE)); rc1.addRelation(_pet, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
} }
if (hasServitors()) if (hasServitors())
{ {
getServitors().values().forEach(s -> rc1.addRelation(s, relation1, !isInsideZone(ZoneId.PEACE))); getServitors().values().forEach(s -> rc1.addRelation(s, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP)));
} }
} }
player.sendPacket(rc1); player.sendPacket(rc1);

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -392,7 +392,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3954,7 +3954,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1817,6 +1817,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8171,7 +8180,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9356,7 +9365,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA; _noDuelReason = SystemMessageId.C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_BATTLE_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA;
return false; return false;

View File

@ -903,7 +903,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -392,7 +392,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3954,7 +3954,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1818,6 +1818,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8172,7 +8181,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9363,7 +9372,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL; _noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL;
return false; return false;

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

View File

@ -153,6 +153,7 @@
<xs:enumeration value="NoDropItemZone" /> <xs:enumeration value="NoDropItemZone" />
<xs:enumeration value="NoLandingZone" /> <xs:enumeration value="NoLandingZone" />
<xs:enumeration value="NoRestartZone" /> <xs:enumeration value="NoRestartZone" />
<xs:enumeration value="NoPvPZone" />
<xs:enumeration value="NoStoreZone" /> <xs:enumeration value="NoStoreZone" />
<xs:enumeration value="NoSummonFriendZone" /> <xs:enumeration value="NoSummonFriendZone" />
<xs:enumeration value="NpcSpawnTerritory" /> <xs:enumeration value="NpcSpawnTerritory" />

View File

@ -170,7 +170,7 @@ public class AttackableAI extends CreatureAI
{ {
// depending on config, do not allow mobs to attack _new_ players in peacezones, // depending on config, do not allow mobs to attack _new_ players in peacezones,
// unless they are already following those players from outside the peacezone. // unless they are already following those players from outside the peacezone.
if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE)) if (!Config.ALT_MOB_AGRO_IN_PEACEZONE && target.isInsideZone(ZoneId.PEACE) && target.isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }

View File

@ -392,7 +392,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
{ {
return true; return true;
} }
return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0); return (_zones[ZoneId.PVP.ordinal()] > 0) && (_zones[ZoneId.PEACE.ordinal()] == 0) && (_zones[ZoneId.NO_PVP.ordinal()] == 0);
} }
case PEACE: case PEACE:
{ {
@ -3954,7 +3954,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
return false; return false;
} }
return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE)); return (target.isInsideZone(ZoneId.PEACE) || attacker.isInsideZone(ZoneId.PEACE) || target.isInsideZone(ZoneId.NO_PVP) || attacker.isInsideZone(ZoneId.NO_PVP));
} }
/** /**

View File

@ -636,7 +636,7 @@ public abstract class Summon extends Playable
final WorldObject currentTarget = _owner.getTarget(); final WorldObject currentTarget = _owner.getTarget();
if (currentTarget != null) if (currentTarget != null)
{ {
target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE)), dontMove, false); target = skill.getTarget(this, forceUse && (!currentTarget.isPlayable() || !currentTarget.isInsideZone(ZoneId.PEACE) || !currentTarget.isInsideZone(ZoneId.NO_PVP)), dontMove, false);
final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer(); final PlayerInstance currentTargetPlayer = currentTarget.getActingPlayer();
if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner)) if (!forceUse && (currentTargetPlayer != null) && !currentTargetPlayer.isAutoAttackable(_owner))
{ {

View File

@ -1816,6 +1816,15 @@ public class PlayerInstance extends Playable
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE; _lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE)); sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
} }
else if (isInsideZone(ZoneId.NO_PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.NOPVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.NOPVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.NOPVPZONE));
}
else else
{ {
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE) if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
@ -8157,7 +8166,7 @@ public class PlayerInstance extends Playable
// Check if the attacker is a Playable // Check if the attacker is a Playable
if (attacker.isPlayable()) if (attacker.isPlayable())
{ {
if (isInsideZone(ZoneId.PEACE)) if (isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.NO_PVP))
{ {
return false; return false;
} }
@ -9348,7 +9357,7 @@ public class PlayerInstance extends Playable
_noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING; _noDuelReason = SystemMessageId.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING;
return false; return false;
} }
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE)) if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE) || isInsideZone(ZoneId.NO_PVP))
{ {
_noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL; _noDuelReason = SystemMessageId.C1_IS_IN_AN_AREA_WHERE_DUEL_IS_NOT_ALLOWED_AND_YOU_CANNOT_APPLY_FOR_A_DUEL;
return false; return false;

View File

@ -920,7 +920,7 @@ public class Duel
} }
// is one of the players in a Siege, Peace or PvP zone? // is one of the players in a Siege, Peace or PvP zone?
if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP)) if (_playerA.isInsideZone(ZoneId.PEACE) || _playerB.isInsideZone(ZoneId.PEACE) ||_playerA.isInsideZone(ZoneId.NO_PVP) || _playerB.isInsideZone(ZoneId.NO_PVP) || _playerA.isInsideZone(ZoneId.SIEGE) || _playerB.isInsideZone(ZoneId.SIEGE) || _playerA.isInsideZone(ZoneId.PVP) || _playerB.isInsideZone(ZoneId.PVP))
{ {
return DuelResult.CANCELED; return DuelResult.CANCELED;
} }

View File

@ -37,6 +37,7 @@ public enum ZoneId
NO_SUMMON_FRIEND, NO_SUMMON_FRIEND,
FORT, FORT,
NO_STORE, NO_STORE,
NO_PVP,
SCRIPT, SCRIPT,
HQ, HQ,
DANGER_AREA, DANGER_AREA,

View File

@ -0,0 +1,120 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.zone.type;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
/**
* No PVP Zone
* @author Edoo
*/
public class NoPvPZone extends ZoneType
{
public NoPvPZone(int id)
{
super(id);
}
@Override
protected void onEnter(Creature creature)
{
if (!isEnabled())
{
return;
}
if (creature.isPlayer())
{
final PlayerInstance player = creature.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, true);
}
// Send player info to nearby players.
if (creature.isPlayer())
{
creature.broadcastInfo();
}
}
@Override
protected void onExit(Creature creature)
{
if (Config.PEACE_ZONE_MODE != 2)
{
creature.setInsideZone(ZoneId.NO_PVP, false);
}
// Send player info to nearby players.
if (creature.isPlayer() && !creature.isTeleporting())
{
creature.broadcastInfo();
}
}
@Override
public void setEnabled(boolean value)
{
super.setEnabled(value);
if (value)
{
for (PlayerInstance player : World.getInstance().getPlayers())
{
if ((player != null) && isInsideZone(player))
{
revalidateInZone(player);
if (player.getPet() != null)
{
revalidateInZone(player.getPet());
}
for (Summon summon : player.getServitors().values())
{
revalidateInZone(summon);
}
}
}
}
else
{
for (Creature creature : getCharactersInside())
{
if (creature != null)
{
removeCharacter(creature);
}
}
}
}
}

View File

@ -32,6 +32,8 @@ public class ExSetCompassZoneCode implements IClientOutgoingPacket
public static final int SEVENSIGNSZONE = 0x0D; public static final int SEVENSIGNSZONE = 0x0D;
public static final int PVPZONE = 0x0E; public static final int PVPZONE = 0x0E;
public static final int GENERALZONE = 0x0F; public static final int GENERALZONE = 0x0F;
// TODO: need to find the desired value
public static final int NOPVPZONE = 0x0C;
private final int _zoneType; private final int _zoneType;

Some files were not shown because too many files have changed in this diff Show More