diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml
index efa9eb03f0..b58aca5c81 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml
@@ -5,7 +5,6 @@
3600
36000
21600
- 3600
3600
150000
100
@@ -16,7 +15,6 @@
3600
36000
21600
- 3600
3600
150000
105
diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 5e4408d5f8..72c9d9036d 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -19,6 +18,8 @@
+
+
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 7fb23816fa..d17bceb877 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,13 +85,14 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 150000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
boolean weekly = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -143,11 +144,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -168,9 +164,19 @@ public class TimedHuntingZoneData implements IXmlReader
weekly = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java
index 4788e24e13..e6a9bb72ef 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -891,6 +891,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private final List _questTimers = new ArrayList<>();
@@ -4147,6 +4148,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final int relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14581,11 +14628,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 60dc7be542..39556bda3f 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -42,8 +41,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -54,13 +55,14 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
_weekly = weekly;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -110,11 +112,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -145,6 +142,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index f83f66bf95..4824aa86c4 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -841,7 +841,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22C),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22D),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22E),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22F),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22F),
EX_RANKING_CHAR_INFO(0xFE, 0x230),
EX_RANKING_CHAR_HISTORY(0xFE, 0x231),
EX_RANKING_CHAR_RANKERS(0xFE, 0x232),
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index eb27fe958f..daeaed1ffe 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -158,9 +157,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
QuestManager.getInstance().getQuest("TimedHunting").notifyEvent("ENTER " + _zoneId, null, player);
}
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
// Send time icon.
player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
}
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
similarity index 61%
rename from L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
rename to L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
index 24bb180c20..433bd1c05c 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -21,20 +21,28 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius
+ * @author dontknowdontcare
*/
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
- public TimedHuntingZoneClose()
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
{
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
}
@Override
public boolean write(PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
return true;
}
-}
\ No newline at end of file
+}
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 5b3919fd7c..fb8c878a57 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated
}
diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_08.2_Homunculus/dist/game/data/TimedHuntingZoneData.xml
index ca505bdd9d..41cb279602 100644
--- a/L2J_Mobius_08.2_Homunculus/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/TimedHuntingZoneData.xml
@@ -5,7 +5,6 @@
3600
864000
21600
- 7200
3600
150000
100
@@ -16,7 +15,6 @@
3600
864000
21600
- 7200
3600
150000
105
@@ -27,7 +25,6 @@
3600
864000
21600
- 7200
3600
150000
107
@@ -38,7 +35,6 @@
3600
864000
21600
- 18000
3600
150000
99
@@ -49,7 +45,6 @@
36000
864000
36000
- 0
3600
150000
110
@@ -62,7 +57,6 @@
3600
864000
3600
- 0
3600
150000
105
diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_08.2_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_08.2_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..352854753e 100644
--- a/L2J_Mobius_08.2_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -20,6 +19,8 @@
+
+
@@ -29,4 +30,4 @@
-
\ No newline at end of file
+
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6606ae8fe1..110f32967d 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 150000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java
index a7d58821f7..cb14639138 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -899,6 +899,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private final HomunculusList _homunculusList = new HomunculusList(this);
@@ -4185,6 +4186,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14692,11 +14739,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 655b7643be..ed212dac46 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index eb27fe958f..daeaed1ffe 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -158,9 +157,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
QuestManager.getInstance().getQuest("TimedHunting").notifyEvent("ENTER " + _zoneId, null, player);
}
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
// Send time icon.
player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
}
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
similarity index 61%
rename from L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
rename to L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
index 24bb180c20..433bd1c05c 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -21,20 +21,28 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius
+ * @author dontknowdontcare
*/
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
- public TimedHuntingZoneClose()
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
{
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
}
@Override
public boolean write(PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
return true;
}
-}
\ No newline at end of file
+}
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml
index 7b5d3a553c..1dd53e1071 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml
@@ -1,34 +1,37 @@
- 194291,176604,-1888
+ 194284,176597,-1888
+ 110975,220094,-3664
3600
864000
21600
- 7200
- 3600
+ 7200
150000
100
130
+ false
+ true
- 9400,-21720,-3634
+ 9365,-21407,-3584
+ 43792,-48928,-792
3600
864000
21600
- 7200
- 3600
+ 7200
150000
105
130
+ false
- -122259,73678,-2872
+ -122260,73669,-2872
+ 148353,28032,-2264
3600
86400
21600
- 7200
- 3600
+ 7200
150000
107
130
@@ -36,46 +39,50 @@
false
- 139411,-169382,-1600
+ 139405,-169389,-1600
+ 146561,28042,-2264
3600
864000
21600
- 18000
- 3600
+ 18000
150000
99
105
+ false
+ true
-82014,16247,-15416
36000
864000
36000
- 0
3600
150000
110
130
+ 1020
+ false
true
true
- 181409,-78389,-2728
+ 181406,-78395,-2728
+ 147714,-55409,-2728
3600
864000
3600
- 0
- 3600
+ 0
150000
105
130
+ false
- 90327,198818,-3280
+ 90359,198833,-3280
+ 111563,220512,-3664
3600
36000
21600
- 18000
36000
150000
100
@@ -84,13 +91,16 @@
false
- -49013,15351,-8808
+ -49020,15369,-8808
+ 82795,53888,-1488
3600
21600
- 7200
3600
150000
112
130
+ false
+ true
+ true
\ No newline at end of file
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..352854753e 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -20,6 +19,8 @@
+
+
@@ -29,4 +30,4 @@
-
\ No newline at end of file
+
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6606ae8fe1..110f32967d 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 150000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java
index 945dbb81d9..77c877a1f5 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -912,6 +912,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private final HomunculusList _homunculusList = new HomunculusList(this);
@@ -4202,6 +4203,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14730,11 +14777,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 9b28069346..ad37a023bf 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index eb27fe958f..daeaed1ffe 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -158,9 +157,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
QuestManager.getInstance().getQuest("TimedHunting").notifyEvent("ENTER " + _zoneId, null, player);
}
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
// Send time icon.
player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
}
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
similarity index 61%
rename from L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
rename to L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
index 24bb180c20..433bd1c05c 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -21,20 +21,28 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius
+ * @author dontknowdontcare
*/
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
- public TimedHuntingZoneClose()
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
{
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
}
@Override
public boolean write(PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
return true;
}
-}
\ No newline at end of file
+}
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound
diff --git a/L2J_Mobius_10.1_MasterClass/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_10.1_MasterClass/dist/game/data/TimedHuntingZoneData.xml
index a4514e5889..ed2daac926 100644
--- a/L2J_Mobius_10.1_MasterClass/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_10.1_MasterClass/dist/game/data/TimedHuntingZoneData.xml
@@ -1,34 +1,37 @@
- 194291,176604,-1888
+ 194284,176597,-1888
+ 110975,220094,-3664
3600
864000
21600
- 7200
- 3600
+ 7200
150000
100
130
+ false
+ true
- 9400,-21720,-3634
+ 9365,-21407,-3584
+ 43792,-48928,-792
3600
864000
21600
- 7200
- 3600
+ 7200
150000
105
130
+ false
- -122259,73678,-2872
+ -122260,73669,-2872
+ 148353,28032,-2264
3600
86400
21600
- 7200
- 3600
+ 7200
150000
107
130
@@ -36,34 +39,37 @@
false
- 139411,-169382,-1600
+ 139405,-169389,-1600
+ 146561,28042,-2264
3600
864000
21600
- 18000
- 3600
+ 18000
150000
99
105
+ false
+ true
-82014,16247,-15416
36000
864000
36000
- 0
3600
150000
110
130
+ 1020
+ false
true
+ true
-147664,21384,-14517
36000
864000
36000
- 0
3600
150000
110
@@ -72,22 +78,23 @@
true
- 181409,-78389,-2728
+ 181406,-78395,-2728
+ 147714,-55409,-2728
3600
864000
3600
- 0
- 3600
+ 0
150000
105
130
+ false
- 90327,198818,-3280
+ 90359,198833,-3280
+ 111563,220512,-3664
3600
36000
21600
- 18000
36000
150000
100
@@ -96,13 +103,16 @@
false
- -49013,15351,-8808
+ -49020,15369,-8808
+ 82795,53888,-1488
3600
21600
- 7200
3600
150000
112
130
+ false
+ true
+ true
\ No newline at end of file
diff --git a/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_10.1_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_10.1_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_10.1_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..352854753e 100644
--- a/L2J_Mobius_10.1_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_10.1_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -20,6 +19,8 @@
+
+
@@ -29,4 +30,4 @@
-
\ No newline at end of file
+
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6606ae8fe1..110f32967d 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 150000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java
index b8f0ee4936..9c772303f6 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -914,6 +914,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private final HomunculusList _homunculusList = new HomunculusList(this);
@@ -4223,6 +4224,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14780,11 +14827,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 90e7c7e439..364c1faec5 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index 4167df6d93..a3352f5e25 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -158,9 +157,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
QuestManager.getInstance().getQuest("TimedHunting").notifyEvent("ENTER " + _zoneId, null, player);
}
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
// Send time icon.
player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
}
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
similarity index 61%
rename from L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
rename to L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
index 24bb180c20..433bd1c05c 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -21,20 +21,28 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius
+ * @author dontknowdontcare
*/
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
- public TimedHuntingZoneClose()
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
{
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
}
@Override
public boolean write(PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
return true;
}
-}
\ No newline at end of file
+}
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound
diff --git a/L2J_Mobius_10.2_MasterClass/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_10.2_MasterClass/dist/game/data/TimedHuntingZoneData.xml
index 00aad5da90..962b0b0566 100644
--- a/L2J_Mobius_10.2_MasterClass/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_10.2_MasterClass/dist/game/data/TimedHuntingZoneData.xml
@@ -1,34 +1,37 @@
- 194291,176604,-1888
+ 194284,176597,-1888
+ 110975,220094,-3664
3600
864000
21600
- 7200
- 3600
+ 7200
150000
100
130
+ false
+ true
- 9400,-21720,-3634
+ 9365,-21407,-3584
+ 43792,-48928,-792
3600
864000
21600
- 7200
- 3600
+ 7200
150000
105
130
+ false
- -122259,73678,-2872
+ -122260,73669,-2872
+ 148353,28032,-2264
3600
86400
21600
- 7200
- 3600
+ 7200
150000
107
130
@@ -36,22 +39,23 @@
false
- 139411,-169382,-1600
+ 139405,-169389,-1600
+ 146561,28042,-2264
3600
864000
21600
- 18000
- 3600
+ 18000
150000
99
105
+ false
+ true
-82014,16247,-15416
36000
864000
54000
- 18000
3600
1500000
110
@@ -62,22 +66,23 @@
true
- 181409,-78389,-2728
+ 181406,-78395,-2728
+ 147714,-55409,-2728
3600
864000
3600
- 0
- 3600
+ 0
150000
105
130
+ false
- 90327,198818,-3280
+ 90359,198833,-3280
+ 111563,220512,-3664
3600
36000
21600
- 18000
36000
150000
100
@@ -86,15 +91,17 @@
false
- -49013,15351,-8808
+ -49020,15369,-8808
+ 82795,53888,-1488
36000
864000
43200
- 0
- 3600
+ 7200
1500000
112
130
+ false
true
+ true
\ No newline at end of file
diff --git a/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_10.2_MasterClass/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_10.2_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_10.2_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..352854753e 100644
--- a/L2J_Mobius_10.2_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_10.2_MasterClass/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -20,6 +19,8 @@
+
+
@@ -29,4 +30,4 @@
-
\ No newline at end of file
+
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6606ae8fe1..110f32967d 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 150000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java
index a773e1e0e6..e955ed84e0 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -914,6 +914,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private final HomunculusList _homunculusList = new HomunculusList(this);
@@ -4251,6 +4252,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14808,11 +14855,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 5c50125894..342fbf03fa 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index 4167df6d93..a3352f5e25 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -158,9 +157,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
QuestManager.getInstance().getQuest("TimedHunting").notifyEvent("ENTER " + _zoneId, null, player);
}
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
// Send time icon.
player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
}
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
new file mode 100644
index 0000000000..433bd1c05c
--- /dev/null
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -0,0 +1,48 @@
+/*
+ * 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author dontknowdontcare
+ */
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
+{
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
+
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
+ {
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
+ return true;
+ }
+}
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
deleted file mode 100644
index 24bb180c20..0000000000
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 .
- */
-package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
-
-import org.l2jmobius.commons.network.PacketWriter;
-import org.l2jmobius.gameserver.network.OutgoingPackets;
-import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-
-/**
- * @author Mobius
- */
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
-{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
-
- public TimedHuntingZoneClose()
- {
- }
-
- @Override
- public boolean write(PacketWriter packet)
- {
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
- return true;
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml
index 663de6c94e..1ee4bb12ea 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/TimedHuntingZoneData.xml
@@ -5,7 +5,6 @@
3600
36000
18000
- 3600
3600
10000
78
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 5e4408d5f8..72c9d9036d 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -19,6 +18,8 @@
+
+
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 971b79ff25..d17bceb877 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -82,16 +82,17 @@ public class TimedHuntingZoneData implements IXmlReader
int maxAddedTime = 0;
int resetDelay = 0;
int entryItemId = 57;
- int entryFee = 10000;
+ int entryFee = 150000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
boolean weekly = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -143,11 +144,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -168,9 +164,19 @@ public class TimedHuntingZoneData implements IXmlReader
weekly = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java
index 6a619a7bbf..4b407ac709 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -882,6 +882,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private final List _questTimers = new ArrayList<>();
@@ -4097,6 +4098,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final int relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14494,11 +14541,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 60dc7be542..39556bda3f 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -42,8 +41,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -54,13 +55,14 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
_weekly = weekly;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -110,11 +112,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -145,6 +142,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index f83f66bf95..4824aa86c4 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -841,7 +841,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22C),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22D),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22E),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22F),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22F),
EX_RANKING_CHAR_INFO(0xFE, 0x230),
EX_RANKING_CHAR_HISTORY(0xFE, 0x231),
EX_RANKING_CHAR_RANKERS(0xFE, 0x232),
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index 2b7f1f8029..c5c47a110e 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -85,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
@@ -149,9 +148,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime);
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
if (instanceId == 0)
{
player.teleToLocation(holder.getEnterLocation());
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
new file mode 100644
index 0000000000..433bd1c05c
--- /dev/null
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -0,0 +1,48 @@
+/*
+ * 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author dontknowdontcare
+ */
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
+{
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
+
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
+ {
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
deleted file mode 100644
index 24bb180c20..0000000000
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 .
- */
-package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
-
-import org.l2jmobius.commons.network.PacketWriter;
-import org.l2jmobius.gameserver.network.OutgoingPackets;
-import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-
-/**
- * @author Mobius
- */
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
-{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
-
- public TimedHuntingZoneClose()
- {
- }
-
- @Override
- public boolean write(PacketWriter packet)
- {
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
- return true;
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 5b3919fd7c..fb8c878a57 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated
}
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/TimedHuntingZoneData.xml
index da063d1a86..fd3212f933 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/TimedHuntingZoneData.xml
@@ -5,7 +5,6 @@
3600
36000
46800
- 43200
3600
10000
40
@@ -16,7 +15,6 @@
3600
36000
21600
- 18000
3600
10000
76
@@ -27,7 +25,6 @@
3600
36000
46800
- 7200
3600
10000
60
@@ -38,7 +35,6 @@
25200
604800
151200
- 126000
3600
10000
80
@@ -50,7 +46,6 @@
3600
36000
46800
- 3600
3600
10000
40
@@ -62,7 +57,6 @@
3600
36000
46800
- 3600
3600
10000
50
@@ -74,7 +68,6 @@
3600
36000
46800
- 3600
3600
10000
60
@@ -86,7 +79,6 @@
3600
36000
46800
- 3600
3600
10000
70
@@ -98,7 +90,6 @@
3600
36000
46800
- 3600
3600
10000
80
@@ -110,7 +101,6 @@
3600
36000
46800
- 3600
3600
10000
85
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
index 3c8e489b89..02028aa56f 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
@@ -244,7 +244,7 @@ public class TimedHunting extends AbstractInstance
instance.setParameter("TimedHuntingTaskFinished", false);
}
player.sendPacket(new ExSendUIEvent(player, true, false, 600, 0, NpcStringId.TIME_LEFT));
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
+ player.sendPacket(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
player.getEffectList().stopSkillEffects(SkillFinishType.REMOVED, BUFF);
instance.setParameter("PlayerIsOut", true);
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..72c9d9036d 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -19,7 +18,8 @@
-
+
+
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6e6aeba205..a99ab2fc29 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 10000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java
index 606fd58e52..02d982cd3c 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -910,6 +910,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private PlayerRandomCraft _randomCraft = null;
@@ -4179,6 +4180,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14780,11 +14827,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 65fecd1ae8..d86b20e7a1 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index b2aa5d3834..59f2788c6e 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -85,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
@@ -157,9 +156,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime);
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
if (instanceId == 0)
{
player.teleToLocation(holder.getEnterLocation());
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
new file mode 100644
index 0000000000..433bd1c05c
--- /dev/null
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -0,0 +1,48 @@
+/*
+ * 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author dontknowdontcare
+ */
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
+{
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
+
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
+ {
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
deleted file mode 100644
index 24bb180c20..0000000000
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 .
- */
-package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
-
-import org.l2jmobius.commons.network.PacketWriter;
-import org.l2jmobius.gameserver.network.OutgoingPackets;
-import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-
-/**
- * @author Mobius
- */
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
-{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
-
- public TimedHuntingZoneClose()
- {
- }
-
- @Override
- public boolean write(PacketWriter packet)
- {
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
- return true;
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/TimedHuntingZoneData.xml
index 3ca5317e1a..e11d9e7b10 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/TimedHuntingZoneData.xml
@@ -5,7 +5,6 @@
3600
36000
46800
- 43200
3600
10000
40
@@ -16,7 +15,6 @@
3600
36000
21600
- 18000
3600
10000
76
@@ -27,7 +25,6 @@
3600
36000
46800
- 7200
3600
10000
60
@@ -38,7 +35,6 @@
25200
604800
151200
- 126000
3600
10000
80
@@ -50,7 +46,6 @@
3600
36000
46800
- 3600
3600
1000000
80
@@ -61,7 +56,6 @@
3600
36000
46800
- 3600
3600
10000
40
@@ -73,7 +67,6 @@
3600
36000
46800
- 3600
3600
10000
50
@@ -85,7 +78,6 @@
3600
36000
46800
- 3600
3600
10000
60
@@ -97,7 +89,6 @@
3600
36000
46800
- 3600
3600
10000
70
@@ -109,7 +100,6 @@
3600
36000
46800
- 3600
3600
10000
80
@@ -121,7 +111,6 @@
3600
36000
46800
- 3600
3600
10000
85
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
index 3c8e489b89..02028aa56f 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
@@ -244,7 +244,7 @@ public class TimedHunting extends AbstractInstance
instance.setParameter("TimedHuntingTaskFinished", false);
}
player.sendPacket(new ExSendUIEvent(player, true, false, 600, 0, NpcStringId.TIME_LEFT));
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
+ player.sendPacket(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
player.getEffectList().stopSkillEffects(SkillFinishType.REMOVED, BUFF);
instance.setParameter("PlayerIsOut", true);
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..72c9d9036d 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_Essence_5.2_FrostLord/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -19,7 +18,8 @@
-
+
+
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6e6aeba205..a99ab2fc29 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 10000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java
index ffb805ab2b..73aa896250 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -931,6 +931,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private PlayerRandomCraft _randomCraft = null;
@@ -4216,6 +4217,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -14863,11 +14910,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 8edfc37edf..d889ef2430 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index b2aa5d3834..59f2788c6e 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -85,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
@@ -157,9 +156,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime);
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
if (instanceId == 0)
{
player.teleToLocation(holder.getEnterLocation());
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
new file mode 100644
index 0000000000..433bd1c05c
--- /dev/null
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -0,0 +1,48 @@
+/*
+ * 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author dontknowdontcare
+ */
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
+{
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
+
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
+ {
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
deleted file mode 100644
index 24bb180c20..0000000000
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 .
- */
-package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
-
-import org.l2jmobius.commons.network.PacketWriter;
-import org.l2jmobius.gameserver.network.OutgoingPackets;
-import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-
-/**
- * @author Mobius
- */
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
-{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
-
- public TimedHuntingZoneClose()
- {
- }
-
- @Override
- public boolean write(PacketWriter packet)
- {
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
- return true;
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/TimedHuntingZoneData.xml
index 3ca5317e1a..e11d9e7b10 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/TimedHuntingZoneData.xml
@@ -5,7 +5,6 @@
3600
36000
46800
- 43200
3600
10000
40
@@ -16,7 +15,6 @@
3600
36000
21600
- 18000
3600
10000
76
@@ -27,7 +25,6 @@
3600
36000
46800
- 7200
3600
10000
60
@@ -38,7 +35,6 @@
25200
604800
151200
- 126000
3600
10000
80
@@ -50,7 +46,6 @@
3600
36000
46800
- 3600
3600
1000000
80
@@ -61,7 +56,6 @@
3600
36000
46800
- 3600
3600
10000
40
@@ -73,7 +67,6 @@
3600
36000
46800
- 3600
3600
10000
50
@@ -85,7 +78,6 @@
3600
36000
46800
- 3600
3600
10000
60
@@ -97,7 +89,6 @@
3600
36000
46800
- 3600
3600
10000
70
@@ -109,7 +100,6 @@
3600
36000
46800
- 3600
3600
10000
80
@@ -121,7 +111,6 @@
3600
36000
46800
- 3600
3600
10000
85
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
index 3c8e489b89..02028aa56f 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
@@ -244,7 +244,7 @@ public class TimedHunting extends AbstractInstance
instance.setParameter("TimedHuntingTaskFinished", false);
}
player.sendPacket(new ExSendUIEvent(player, true, false, 600, 0, NpcStringId.TIME_LEFT));
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
+ player.sendPacket(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
player.getEffectList().stopSkillEffects(SkillFinishType.REMOVED, BUFF);
instance.setParameter("PlayerIsOut", true);
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..72c9d9036d 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -19,7 +18,8 @@
-
+
+
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6e6aeba205..a99ab2fc29 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 10000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java
index 714e63df86..333b2e544b 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -937,6 +937,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private PlayerRandomCraft _randomCraft = null;
@@ -4231,6 +4232,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -15043,11 +15090,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 233e510c4b..46f47aeb44 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index b2aa5d3834..59f2788c6e 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -85,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
@@ -157,9 +156,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime);
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
if (instanceId == 0)
{
player.teleToLocation(holder.getEnterLocation());
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
new file mode 100644
index 0000000000..433bd1c05c
--- /dev/null
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -0,0 +1,48 @@
+/*
+ * 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author dontknowdontcare
+ */
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
+{
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
+
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
+ {
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
deleted file mode 100644
index 24bb180c20..0000000000
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 .
- */
-package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
-
-import org.l2jmobius.commons.network.PacketWriter;
-import org.l2jmobius.gameserver.network.OutgoingPackets;
-import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-
-/**
- * @author Mobius
- */
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
-{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
-
- public TimedHuntingZoneClose()
- {
- }
-
- @Override
- public boolean write(PacketWriter packet)
- {
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
- return true;
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/TimedHuntingZoneData.xml b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/TimedHuntingZoneData.xml
index 695aa49117..c4cf5f19db 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/TimedHuntingZoneData.xml
@@ -5,7 +5,6 @@
25200
604800
86400
- 61200
61200
200000
76
@@ -17,7 +16,6 @@
3600
36000
46800
- 7200
7200
10000
70
@@ -28,7 +26,6 @@
18000
604800
64800
- 46800
46800
1000000
80
@@ -40,7 +37,6 @@
18000
604800
64800
- 46800
46800
1000000
85
@@ -122,7 +118,6 @@
7200
36000
46800
- 43200
3600
10000
76
@@ -133,7 +128,6 @@
3600
36000
46800
- 3600
3600
10000
80
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
index e49103f8b7..0b4cbf0c0d 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java
@@ -25,8 +25,7 @@ import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneList;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneChargeResult;
/**
* @author Mobius
@@ -64,7 +63,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- final long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= holder.getMaximumAddedTime()))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
@@ -72,24 +71,37 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
- if ((_time < remainRefill) || (remainRefill == 0))
+ long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
+ remainRefillTime -= _time / 1000;
+ if (remainRefillTime < 0)
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("You cannot exceed the time zone limit.");
+ player.sendMessage("Time for this zone can be extended no further.");
return;
}
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, holder.getInitialTime());
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime + _time);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefill - (_time / 1000));
-
+ final long remainTime;
if (player.isInTimedHuntingZone(_zoneId))
{
+ remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- player.sendPacket(new TimedHuntingZoneEnter(player, _zoneId));
+ }
+ else
+ {
+ if ((endTime + holder.getResetDelay()) < currentTime)
+ {
+ endTime = currentTime + holder.getInitialTime();
+ }
+ else if (endTime < currentTime)
+ {
+ endTime = currentTime;
+ }
+ remainTime = (endTime - currentTime) + _time;
+ player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
}
- player.sendPacket(new TimedHuntingZoneList(player));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
}
}
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
index 83f680f5e0..39ec882b27 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TimedHunting/TimedHunting.java
@@ -248,7 +248,7 @@ public class TimedHunting extends AbstractInstance
instance.setParameter("TimedHuntingTaskFinished", false);
}
player.sendPacket(new ExSendUIEvent(player, true, false, 600, 0, NpcStringId.TIME_LEFT));
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
+ player.sendPacket(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
player.getEffectList().stopSkillEffects(SkillFinishType.REMOVED, BUFF);
instance.setParameter("PlayerIsOut", true);
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TrainingZone/TrainingZone.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TrainingZone/TrainingZone.java
index f1f7fed34b..5c17db38d7 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TrainingZone/TrainingZone.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/instances/TrainingZone/TrainingZone.java
@@ -875,7 +875,7 @@ public class TrainingZone extends AbstractInstance
public void onInstanceLeave(Player player, Instance instance)
{
player.sendPacket(new ExSendUIEvent(player, true, false, 3600, 0, NpcStringId.TIME_LEFT));
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
+ player.sendPacket(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
removeBuffs(player);
instance.getParameters().remove("TRAINIG_AREA_TELEPORT");
instance.finishInstance();
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/xsd/TimedHuntingZoneData.xsd b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/xsd/TimedHuntingZoneData.xsd
index 086251165c..72c9d9036d 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/xsd/TimedHuntingZoneData.xsd
+++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/xsd/TimedHuntingZoneData.xsd
@@ -10,7 +10,6 @@
-
@@ -19,7 +18,8 @@
-
+
+
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
index 6e6aeba205..a99ab2fc29 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/data/xml/TimedHuntingZoneData.java
@@ -85,7 +85,6 @@ public class TimedHuntingZoneData implements IXmlReader
int entryFee = 10000;
int minLevel = 1;
int maxLevel = 999;
- int remainRefillTime = 3600;
int refillTimeMax = 3600;
int instanceId = 0;
boolean soloInstance = true;
@@ -93,6 +92,8 @@ public class TimedHuntingZoneData implements IXmlReader
boolean useWorldPrefix = false;
Location enterLocation = null;
Location exitLocation = null;
+ boolean pvpZone = false;
+ boolean noPvpZone = false;
for (Node zoneNode = listNode.getFirstChild(); zoneNode != null; zoneNode = zoneNode.getNextSibling())
{
switch (zoneNode.getNodeName())
@@ -144,11 +145,6 @@ public class TimedHuntingZoneData implements IXmlReader
maxLevel = Integer.parseInt(zoneNode.getTextContent());
break;
}
- case "remainRefillTime":
- {
- remainRefillTime = Integer.parseInt(zoneNode.getTextContent());
- break;
- }
case "refillTimeMax":
{
refillTimeMax = Integer.parseInt(zoneNode.getTextContent());
@@ -174,9 +170,19 @@ public class TimedHuntingZoneData implements IXmlReader
useWorldPrefix = Boolean.parseBoolean(zoneNode.getTextContent());
break;
}
+ case "pvpZone":
+ {
+ pvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
+ case "noPvpZone":
+ {
+ noPvpZone = Boolean.parseBoolean(zoneNode.getTextContent());
+ break;
+ }
}
}
- _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
}
}
}
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Playable.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Playable.java
index a5f49074e9..2491ae895a 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Playable.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Playable.java
@@ -17,9 +17,11 @@
package org.l2jmobius.gameserver.model.actor;
import org.l2jmobius.gameserver.ai.CtrlEvent;
+import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.InstanceType;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
+import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.stat.PlayableStat;
import org.l2jmobius.gameserver.model.actor.status.PlayableStatus;
@@ -31,6 +33,7 @@ import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.OnCreatureDeath;
import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
+import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -230,6 +233,28 @@ public abstract class Playable extends Creature
return false;
}
+ public boolean isInTimedHuntingZone(int zoneId)
+ {
+ return isInTimedHuntingZone(zoneId, getX(), getY());
+ }
+
+ public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
+ {
+ final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
+ if (holder == null)
+ {
+ return false;
+ }
+
+ final int instanceId = holder.getInstanceId();
+ if (instanceId > 0)
+ {
+ return isInInstance() && (instanceId == getInstanceWorld().getTemplateId());
+ }
+
+ return (holder.getMapX() == (((locX - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN)) && (holder.getMapY() == (((locY - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN));
+ }
+
/**
* Return True.
*/
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java
index c351f05463..421b25c579 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Player.java
@@ -944,6 +944,7 @@ public class Player extends Playable
private final AutoUseSettingsHolder _autoUseSettings = new AutoUseSettingsHolder();
private boolean _resumedAutoPlay = false;
+ private TimedHuntingZoneHolder _lastTimeZone = null;
private ScheduledFuture> _timedHuntingZoneTask = null;
private PlayerRandomCraft _randomCraft = null;
@@ -4268,6 +4269,52 @@ public class Player extends Playable
});
}
+ public void updateRelationsToVisiblePlayers(boolean bothWays)
+ {
+ World.getInstance().forEachVisibleObject(this, Player.class, nearby ->
+ {
+ if (!isVisibleFor(nearby))
+ {
+ return;
+ }
+
+ updateRelation(this, nearby);
+ if (bothWays)
+ {
+ nearby.updateRelation(nearby, this);
+ }
+ });
+ }
+
+ public void updateRelation(Player player, Player target)
+ {
+ final long relation = player.getRelation(target);
+ final boolean isAutoAttackable = player.isAutoAttackable(target);
+ final RelationCache oldrelation = player.getKnownRelations().get(target.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(player, relation, isAutoAttackable);
+ if (player.hasSummon())
+ {
+ final Summon pet = player.getPet();
+ if (pet != null)
+ {
+ rc.addRelation(pet, relation, isAutoAttackable);
+ }
+ if (player.hasServitors())
+ {
+ player.getServitors().values().forEach(s -> rc.addRelation(s, relation, isAutoAttackable));
+ }
+ }
+
+ // Delay by 125ms so the CharInfo packet of characters moving into field of view will arrive first,
+ // otherwise this relation packet will be ignored by the client.
+ ThreadPool.schedule(() -> target.sendPacket(rc), 125);
+ player.getKnownRelations().put(target.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
+ }
+
public void broadcastTitleInfo()
{
// Send a Server->Client packet UserInfo to this Player
@@ -15132,11 +15179,23 @@ public class Player extends Playable
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
}
+ public TimedHuntingZoneHolder getLastTimeZone()
+ {
+ return _lastTimeZone;
+ }
+
+ public void setLastTimeZone(TimedHuntingZoneHolder lastTimeZone)
+ {
+ _lastTimeZone = lastTimeZone;
+ }
+
+ @Override
public boolean isInTimedHuntingZone(int zoneId)
{
return isInTimedHuntingZone(zoneId, getX(), getY());
}
+ @Override
public boolean isInTimedHuntingZone(int zoneId, int locX, int locY)
{
final TimedHuntingZoneHolder holder = TimedHuntingZoneData.getInstance().getHuntingZone(zoneId);
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
index 7b4f4d1b31..9f2deba5ed 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/holders/TimedHuntingZoneHolder.java
@@ -33,7 +33,6 @@ public class TimedHuntingZoneHolder
private final int _entryFee;
private final int _minLevel;
private final int _maxLevel;
- private final int _remainRefillTime;
private final int _refillTimeMax;
private final int _instanceId;
private final boolean _soloInstance;
@@ -43,8 +42,10 @@ public class TimedHuntingZoneHolder
private final Location _exitLocation;
private final int _mapX;
private final int _mapY;
+ private final boolean _pvpZone;
+ private final boolean _noPvpZone;
- public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int remainRefillTime, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation)
+ public TimedHuntingZoneHolder(int id, String name, int initialTime, int maximumAddedTime, int resetDelay, int entryItemId, int entryFee, int minLevel, int maxLevel, int refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, boolean noPvpZone)
{
_id = id;
_name = name;
@@ -55,7 +56,6 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
- _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,6 +63,8 @@ public class TimedHuntingZoneHolder
_useWorldPrefix = useWorldPrefix;
_enterLocation = enterLocation;
_exitLocation = exitLocation;
+ _pvpZone = pvpZone;
+ _noPvpZone = noPvpZone;
_mapX = ((_enterLocation.getX() - World.WORLD_X_MIN) >> 15) + World.TILE_X_MIN;
_mapY = ((_enterLocation.getY() - World.WORLD_Y_MIN) >> 15) + World.TILE_Y_MIN;
}
@@ -112,11 +114,6 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
- public int getRemainRefillTime()
- {
- return _remainRefillTime;
- }
-
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -152,6 +149,16 @@ public class TimedHuntingZoneHolder
return _exitLocation;
}
+ public boolean isPvpZone()
+ {
+ return _pvpZone;
+ }
+
+ public boolean isNoPvpZone()
+ {
+ return _noPvpZone;
+ }
+
public int getMapX()
{
return _mapX;
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
index 94d2b306da..0fc06ca3b5 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/zone/type/TimedHuntingZone.java
@@ -16,20 +16,21 @@
*/
package org.l2jmobius.gameserver.model.zone.type;
-import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.data.xml.TimedHuntingZoneData;
import org.l2jmobius.gameserver.enums.TeleportWhereType;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
+import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
+ * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -43,9 +44,29 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ Playable summon = (Playable) creature;
+ for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, true);
+ }
+ break;
+ }
+ }
return;
}
-
+ // Check summons spawning or porting inside.
final Player player = creature.getActingPlayer();
if (player != null)
{
@@ -57,16 +78,25 @@ public class TimedHuntingZone extends ZoneType
{
continue;
}
-
final int remainingTime = player.getTimedHuntingZoneRemainingTime(holder.getZoneId());
if (remainingTime > 0)
{
+ player.setLastTimeZone(holder);
player.startTimedHuntingZone(holder.getZoneId(), remainingTime);
+ if (holder.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, true);
+ player.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, true);
+ }
return;
}
break;
}
-
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -79,22 +109,56 @@ public class TimedHuntingZone extends ZoneType
{
if (!creature.isPlayer())
{
+ if (creature.isPlayable())
+ {
+ final Playable summon = (Playable) creature;
+ for (final TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())
+ {
+ if (!summon.isInTimedHuntingZone(holder.getZoneId()))
+ {
+ continue;
+ }
+ if (holder.isPvpZone())
+ {
+ summon.setInsideZone(ZoneId.PVP, false);
+ }
+ else if (holder.isNoPvpZone())
+ {
+ summon.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ break;
+ }
+ }
return;
}
final Player player = creature.getActingPlayer();
- if (player != null)
+ if (player == null)
{
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
-
- ThreadPool.schedule(() ->
- {
- if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
- {
- player.sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
- }
- }, 1000);
+ return;
}
+
+ // We default to zone 6 aka Primeval Isle so we spawn in rune town by default.
+ int nZoneId = 6;
+
+ final TimedHuntingZoneHolder lastTimeZone = player.getLastTimeZone();
+ if (lastTimeZone != null)
+ {
+ nZoneId = lastTimeZone.getZoneId();
+ if (lastTimeZone.isPvpZone())
+ {
+ player.setInsideZone(ZoneId.PVP, false);
+ player.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
+ player.updateRelationsToVisiblePlayers(true);
+ }
+ else if (lastTimeZone.isNoPvpZone())
+ {
+ player.setInsideZone(ZoneId.NO_PVP, false);
+ }
+ player.setLastTimeZone(null);
+ }
+
+ player.setInsideZone(ZoneId.TIMED_HUNTING, false);
+ player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/OutgoingPackets.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
index 213342c5ef..80f65e3b87 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/OutgoingPackets.java
@@ -840,7 +840,7 @@ public enum OutgoingPackets
EX_TIME_RESTRICT_FIELD_USER_ENTER(0xFE, 0x22A),
EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT(0xFE, 0x22B),
EX_TIME_RESTRICT_FIELD_USER_ALARM(0xFE, 0x22C),
- EX_TIME_RESTRICT_FIELD_USER_CLOSE(0xFE, 0x22D),
+ EX_TIME_RESTRICT_FIELD_USER_EXIT(0xFE, 0x22D),
EX_RANKING_CHAR_INFO(0xFE, 0x22E),
EX_RANKING_CHAR_HISTORY(0xFE, 0x22F),
EX_RANKING_CHAR_RANKERS(0xFE, 0x230),
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index b2aa5d3834..59f2788c6e 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
@@ -29,7 +29,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
-import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneClose;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
@@ -85,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
@@ -157,9 +156,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, endTime - currentTime);
- // Close window.
- player.sendPacket(TimedHuntingZoneClose.STATIC_PACKET);
-
if (instanceId == 0)
{
player.teleToLocation(holder.getEnterLocation());
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
new file mode 100644
index 0000000000..433bd1c05c
--- /dev/null
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneChargeResult.java
@@ -0,0 +1,48 @@
+/*
+ * 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 .
+ */
+package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
+
+import org.l2jmobius.commons.network.PacketWriter;
+import org.l2jmobius.gameserver.network.OutgoingPackets;
+import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
+
+/**
+ * @author dontknowdontcare
+ */
+public class TimedHuntingZoneChargeResult implements IClientOutgoingPacket
+{
+ private final int _zoneId;
+ private final int _secondsLeft;
+ private final int _newExtensionValue;
+
+ public TimedHuntingZoneChargeResult(int zoneId, int secondsLeft, int newExtensionValue)
+ {
+ _zoneId = zoneId;
+ _secondsLeft = secondsLeft;
+ _newExtensionValue = newExtensionValue;
+ }
+
+ @Override
+ public boolean write(PacketWriter packet)
+ {
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CHARGE_RESULT.writeId(packet);
+ packet.writeD(_zoneId);
+ packet.writeD(_secondsLeft); // Remaining Time in zone.
+ packet.writeD(_newExtensionValue); // New Extension value.
+ return true;
+ }
+}
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
deleted file mode 100644
index 24bb180c20..0000000000
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneClose.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 .
- */
-package org.l2jmobius.gameserver.network.serverpackets.huntingzones;
-
-import org.l2jmobius.commons.network.PacketWriter;
-import org.l2jmobius.gameserver.network.OutgoingPackets;
-import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
-
-/**
- * @author Mobius
- */
-public class TimedHuntingZoneClose implements IClientOutgoingPacket
-{
- public static final TimedHuntingZoneClose STATIC_PACKET = new TimedHuntingZoneClose();
-
- public TimedHuntingZoneClose()
- {
- }
-
- @Override
- public boolean write(PacketWriter packet)
- {
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_CLOSE.writeId(packet);
- return true;
- }
-}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
index c80dbcfa6a..1708170e53 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneExit.java
@@ -21,21 +21,22 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
- * @author Mobius, Index
+ * @author dontknowdontcare
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
- public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
+ private final int _zoneId;
- public TimedHuntingZoneExit()
+ public TimedHuntingZoneExit(final int zoneId)
{
+ _zoneId = zoneId;
}
@Override
- public boolean write(PacketWriter packet)
+ public boolean write(final PacketWriter packet)
{
- OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
- packet.writeC(0); // bEnterSuccess
+ OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
+ packet.writeD(_zoneId);
return true;
}
}
\ No newline at end of file
diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
index 36d05e9317..d57be233ab 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntingzones/TimedHuntingZoneList.java
@@ -62,7 +62,8 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
+ long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
+ packet.writeD((int) remainRefillTime);
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound