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 b58aca5c81..efa9eb03f0 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_07.0_PreludeOfWar/dist/game/data/TimedHuntingZoneData.xml
@@ -5,6 +5,7 @@
3600
36000
21600
+ 3600
3600
150000
100
@@ -15,6 +16,7 @@
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 72c9d9036d..5e4408d5f8 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,6 +10,7 @@
+
@@ -18,8 +19,6 @@
-
-
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 d17bceb877..7fb23816fa 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,14 +85,13 @@ 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())
@@ -144,6 +143,11 @@ 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());
@@ -164,19 +168,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 9a3c147e4a..80fa3b79f0 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,7 +891,6 @@ 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<>();
@@ -4148,52 +4147,6 @@ 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
@@ -14628,23 +14581,11 @@ 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 39556bda3f..60dc7be542 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,6 +33,7 @@ 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;
@@ -41,10 +42,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -55,14 +54,13 @@ 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;
}
@@ -112,6 +110,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -142,16 +145,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index 4e93ae46f3..2d5fd6cbff 100644
--- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -67,6 +67,7 @@ public class PlayerVariables extends AbstractVariables
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- 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 4824aa86c4..71aec03238 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
@@ -857,7 +857,7 @@ public enum OutgoingPackets
EX_PVPBOOK_NEW_PK(0xFE, 0x23C),
EX_PLEDGE_MERCENARY_MEMBER_JOIN(0xFE, 0x23D),
EX_RAID_DROP_ITEM_ANNOUNCE(0xFE, 0x23E),
- EX_LETTER_COLLECTOR_UI_LAUNCER(0xFE, 0x23F),
+ EX_LETTER_COLLECTOR_UI_LAUNCHER(0xFE, 0x23F),
EX_OLYMPIAD_MY_RANKING_INFO(0xFE, 0x240),
EX_OLYMPIAD_RANKING_INFO(0xFE, 0x241),
EX_OLYMPIAD_HERO_AND_LEGEND_INFO(0xFE, 0x242),
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 fb8c878a57..5b3919fd7c 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
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 41cb279602..ca505bdd9d 100644
--- a/L2J_Mobius_08.2_Homunculus/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_08.2_Homunculus/dist/game/data/TimedHuntingZoneData.xml
@@ -5,6 +5,7 @@
3600
864000
21600
+ 7200
3600
150000
100
@@ -15,6 +16,7 @@
3600
864000
21600
+ 7200
3600
150000
105
@@ -25,6 +27,7 @@
3600
864000
21600
+ 7200
3600
150000
107
@@ -35,6 +38,7 @@
3600
864000
21600
+ 18000
3600
150000
99
@@ -45,6 +49,7 @@
36000
864000
36000
+ 0
3600
150000
110
@@ -57,6 +62,7 @@
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 352854753e..086251165c 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,6 +10,7 @@
+
@@ -19,8 +20,6 @@
-
-
@@ -30,4 +29,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 110f32967d..6606ae8fe1 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,6 +85,7 @@ 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;
@@ -92,8 +93,6 @@ 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())
@@ -145,6 +144,11 @@ 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());
@@ -170,19 +174,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 a722ed623a..6f52e7273e 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,7 +899,6 @@ 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);
@@ -4186,52 +4185,6 @@ 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
@@ -14739,23 +14692,11 @@ 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 9f2deba5ed..7b4f4d1b31 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,6 +33,7 @@ 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,10 +43,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -56,6 +55,7 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
+ _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,8 +63,6 @@ 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;
}
@@ -114,6 +112,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -149,16 +152,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index bd0614d1c6..21899a1e2b 100644
--- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -67,6 +67,7 @@ public class PlayerVariables extends AbstractVariables
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
- player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 d57be233ab..36d05e9317 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
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 1dd53e1071..7b5d3a553c 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/game/data/TimedHuntingZoneData.xml
@@ -1,37 +1,34 @@
- 194284,176597,-1888
- 110975,220094,-3664
+ 194291,176604,-1888
3600
864000
21600
- 7200
+ 7200
+ 3600
150000
100
130
- false
- true
- 9365,-21407,-3584
- 43792,-48928,-792
+ 9400,-21720,-3634
3600
864000
21600
- 7200
+ 7200
+ 3600
150000
105
130
- false
- -122260,73669,-2872
- 148353,28032,-2264
+ -122259,73678,-2872
3600
86400
21600
- 7200
+ 7200
+ 3600
150000
107
130
@@ -39,50 +36,46 @@
false
- 139405,-169389,-1600
- 146561,28042,-2264
+ 139411,-169382,-1600
3600
864000
21600
- 18000
+ 18000
+ 3600
150000
99
105
- false
- true
-82014,16247,-15416
36000
864000
36000
+ 0
3600
150000
110
130
- 1020
- false
true
true
- 181406,-78395,-2728
- 147714,-55409,-2728
+ 181409,-78389,-2728
3600
864000
3600
- 0
+ 0
+ 3600
150000
105
130
- false
- 90359,198833,-3280
- 111563,220512,-3664
+ 90327,198818,-3280
3600
36000
21600
+ 18000
36000
150000
100
@@ -91,16 +84,13 @@
false
- -49020,15369,-8808
- 82795,53888,-1488
+ -49013,15351,-8808
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 352854753e..086251165c 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,6 +10,7 @@
+
@@ -19,8 +20,6 @@
-
-
@@ -30,4 +29,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 110f32967d..6606ae8fe1 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,6 +85,7 @@ 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;
@@ -92,8 +93,6 @@ 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())
@@ -145,6 +144,11 @@ 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());
@@ -170,19 +174,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 3571af26f7..e80bb3172d 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,7 +912,6 @@ 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);
@@ -4203,52 +4202,6 @@ 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
@@ -14777,23 +14730,11 @@ 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 9f2deba5ed..7b4f4d1b31 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,6 +33,7 @@ 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,10 +43,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -56,6 +55,7 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
+ _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,8 +63,6 @@ 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;
}
@@ -114,6 +112,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -149,16 +152,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index 2aa14eb946..2ff00dbf61 100644
--- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -68,6 +68,7 @@ public class PlayerVariables extends AbstractVariables
public static final String BALTHUS_REWARD = "BALTHUS_REWARD";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
- player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 d57be233ab..36d05e9317 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
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 962b0b0566..00aad5da90 100644
--- a/L2J_Mobius_10.2_MasterClass/dist/game/data/TimedHuntingZoneData.xml
+++ b/L2J_Mobius_10.2_MasterClass/dist/game/data/TimedHuntingZoneData.xml
@@ -1,37 +1,34 @@
- 194284,176597,-1888
- 110975,220094,-3664
+ 194291,176604,-1888
3600
864000
21600
- 7200
+ 7200
+ 3600
150000
100
130
- false
- true
- 9365,-21407,-3584
- 43792,-48928,-792
+ 9400,-21720,-3634
3600
864000
21600
- 7200
+ 7200
+ 3600
150000
105
130
- false
- -122260,73669,-2872
- 148353,28032,-2264
+ -122259,73678,-2872
3600
86400
21600
- 7200
+ 7200
+ 3600
150000
107
130
@@ -39,23 +36,22 @@
false
- 139405,-169389,-1600
- 146561,28042,-2264
+ 139411,-169382,-1600
3600
864000
21600
- 18000
+ 18000
+ 3600
150000
99
105
- false
- true
-82014,16247,-15416
36000
864000
54000
+ 18000
3600
1500000
110
@@ -66,23 +62,22 @@
true
- 181406,-78395,-2728
- 147714,-55409,-2728
+ 181409,-78389,-2728
3600
864000
3600
- 0
+ 0
+ 3600
150000
105
130
- false
- 90359,198833,-3280
- 111563,220512,-3664
+ 90327,198818,-3280
3600
36000
21600
+ 18000
36000
150000
100
@@ -91,17 +86,15 @@
false
- -49020,15369,-8808
- 82795,53888,-1488
+ -49013,15351,-8808
36000
864000
43200
- 7200
+ 0
+ 3600
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 352854753e..086251165c 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,6 +10,7 @@
+
@@ -19,8 +20,6 @@
-
-
@@ -30,4 +29,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 110f32967d..6606ae8fe1 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,6 +85,7 @@ 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;
@@ -92,8 +93,6 @@ 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())
@@ -145,6 +144,11 @@ 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());
@@ -170,19 +174,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 cc7e95067b..0bae1d06a2 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,7 +914,6 @@ 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);
@@ -4252,52 +4251,6 @@ 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
@@ -14855,23 +14808,11 @@ 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 9f2deba5ed..7b4f4d1b31 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,6 +33,7 @@ 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,10 +43,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -56,6 +55,7 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
+ _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,8 +63,6 @@ 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;
}
@@ -114,6 +112,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -149,16 +152,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index 2aa14eb946..2ff00dbf61 100644
--- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -68,6 +68,7 @@ public class PlayerVariables extends AbstractVariables
public static final String BALTHUS_REWARD = "BALTHUS_REWARD";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- player.setInsideZone(ZoneId.TIMED_HUNTING, false);
- player.sendPacket(new TimedHuntingZoneExit(nZoneId));
}
}
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 d57be233ab..36d05e9317 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
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 1ee4bb12ea..663de6c94e 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,6 +5,7 @@
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 72c9d9036d..5e4408d5f8 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,6 +10,7 @@
+
@@ -18,8 +19,6 @@
-
-
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 d17bceb877..7fb23816fa 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
@@ -85,14 +85,13 @@ 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())
@@ -144,6 +143,11 @@ 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());
@@ -164,19 +168,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 82cf3f315a..d561fa24c4 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,7 +882,6 @@ 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<>();
@@ -4098,52 +4097,6 @@ 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
@@ -14541,23 +14494,11 @@ 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 39556bda3f..60dc7be542 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,6 +33,7 @@ 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;
@@ -41,10 +42,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -55,14 +54,13 @@ 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;
}
@@ -112,6 +110,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -142,16 +145,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index 60feb19d8a..0cc17732cb 100644
--- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -61,6 +61,7 @@ public class PlayerVariables extends AbstractVariables
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- 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 4824aa86c4..71aec03238 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
@@ -857,7 +857,7 @@ public enum OutgoingPackets
EX_PVPBOOK_NEW_PK(0xFE, 0x23C),
EX_PLEDGE_MERCENARY_MEMBER_JOIN(0xFE, 0x23D),
EX_RAID_DROP_ITEM_ANNOUNCE(0xFE, 0x23E),
- EX_LETTER_COLLECTOR_UI_LAUNCER(0xFE, 0x23F),
+ EX_LETTER_COLLECTOR_UI_LAUNCHER(0xFE, 0x23F),
EX_OLYMPIAD_MY_RANKING_INFO(0xFE, 0x240),
EX_OLYMPIAD_RANKING_INFO(0xFE, 0x241),
EX_OLYMPIAD_HERO_AND_LEGEND_INFO(0xFE, 0x242),
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 fb8c878a57..5b3919fd7c 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
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 fd3212f933..da063d1a86 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,6 +5,7 @@
3600
36000
46800
+ 43200
3600
10000
40
@@ -15,6 +16,7 @@
3600
36000
21600
+ 18000
3600
10000
76
@@ -25,6 +27,7 @@
3600
36000
46800
+ 7200
3600
10000
60
@@ -35,6 +38,7 @@
25200
604800
151200
+ 126000
3600
10000
80
@@ -46,6 +50,7 @@
3600
36000
46800
+ 3600
3600
10000
40
@@ -57,6 +62,7 @@
3600
36000
46800
+ 3600
3600
10000
50
@@ -68,6 +74,7 @@
3600
36000
46800
+ 3600
3600
10000
60
@@ -79,6 +86,7 @@
3600
36000
46800
+ 3600
3600
10000
70
@@ -90,6 +98,7 @@
3600
36000
46800
+ 3600
3600
10000
80
@@ -101,6 +110,7 @@
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 02028aa56f..732722885a 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(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
+ player.sendPacket(new TimedHuntingZoneExit(108)); // Training Zone id.
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 72c9d9036d..086251165c 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,6 +10,7 @@
+
@@ -18,8 +19,7 @@
-
-
+
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 a99ab2fc29..6e6aeba205 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,6 +85,7 @@ 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;
@@ -92,8 +93,6 @@ 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())
@@ -145,6 +144,11 @@ 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());
@@ -170,19 +174,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 0352d4167d..f41bb2c92f 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,7 +910,6 @@ 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;
@@ -4180,52 +4179,6 @@ 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
@@ -14827,23 +14780,11 @@ 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 9f2deba5ed..7b4f4d1b31 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,6 +33,7 @@ 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,10 +43,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -56,6 +55,7 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
+ _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,8 +63,6 @@ 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;
}
@@ -114,6 +112,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -149,16 +152,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index 90867caea7..21c335145a 100644
--- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -61,6 +61,7 @@ public class PlayerVariables extends AbstractVariables
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- 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/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index 59f2788c6e..67a5417859 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
@@ -84,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 d57be233ab..36d05e9317 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
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 e11d9e7b10..3ca5317e1a 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,6 +5,7 @@
3600
36000
46800
+ 43200
3600
10000
40
@@ -15,6 +16,7 @@
3600
36000
21600
+ 18000
3600
10000
76
@@ -25,6 +27,7 @@
3600
36000
46800
+ 7200
3600
10000
60
@@ -35,6 +38,7 @@
25200
604800
151200
+ 126000
3600
10000
80
@@ -46,6 +50,7 @@
3600
36000
46800
+ 3600
3600
1000000
80
@@ -56,6 +61,7 @@
3600
36000
46800
+ 3600
3600
10000
40
@@ -67,6 +73,7 @@
3600
36000
46800
+ 3600
3600
10000
50
@@ -78,6 +85,7 @@
3600
36000
46800
+ 3600
3600
10000
60
@@ -89,6 +97,7 @@
3600
36000
46800
+ 3600
3600
10000
70
@@ -100,6 +109,7 @@
3600
36000
46800
+ 3600
3600
10000
80
@@ -111,6 +121,7 @@
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 02028aa56f..732722885a 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(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
+ player.sendPacket(new TimedHuntingZoneExit(108)); // Training Zone id.
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 72c9d9036d..086251165c 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,6 +10,7 @@
+
@@ -18,8 +19,7 @@
-
-
+
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 a99ab2fc29..6e6aeba205 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,6 +85,7 @@ 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;
@@ -92,8 +93,6 @@ 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())
@@ -145,6 +144,11 @@ 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());
@@ -170,19 +174,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 68cc96e67b..529bd692bd 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,7 +931,6 @@ 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;
@@ -4217,52 +4216,6 @@ 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
@@ -14910,23 +14863,11 @@ 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 9f2deba5ed..7b4f4d1b31 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,6 +33,7 @@ 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,10 +43,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -56,6 +55,7 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
+ _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,8 +63,6 @@ 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;
}
@@ -114,6 +112,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -149,16 +152,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index 6fac3c416c..fb2ce801ff 100644
--- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -61,6 +61,7 @@ public class PlayerVariables extends AbstractVariables
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- 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/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index 59f2788c6e..67a5417859 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
@@ -84,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 d57be233ab..36d05e9317 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
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 c4cf5f19db..695aa49117 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,6 +5,7 @@
25200
604800
86400
+ 61200
61200
200000
76
@@ -16,6 +17,7 @@
3600
36000
46800
+ 7200
7200
10000
70
@@ -26,6 +28,7 @@
18000
604800
64800
+ 46800
46800
1000000
80
@@ -37,6 +40,7 @@
18000
604800
64800
+ 46800
46800
1000000
85
@@ -118,6 +122,7 @@
7200
36000
46800
+ 43200
3600
10000
76
@@ -128,6 +133,7 @@
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 0b4cbf0c0d..6270963bd2 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
@@ -26,6 +26,7 @@ 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.TimedHuntingZoneChargeResult;
+import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneEnter;
/**
* @author Mobius
@@ -63,7 +64,7 @@ public class AddHuntingTime extends AbstractEffect
}
final long currentTime = System.currentTimeMillis();
- long endTime = currentTime + player.getTimedHuntingZoneRemainingTime(_zoneId);
+ final 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);
@@ -71,37 +72,24 @@ public class AddHuntingTime extends AbstractEffect
return;
}
- long remainRefillTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRefillTimeMax());
- remainRefillTime -= _time / 1000;
- if (remainRefillTime < 0)
+ final long remainRefill = player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, holder.getRemainRefillTime());
+ if ((_time < remainRefill) || (remainRefill == 0))
{
player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player);
- player.sendMessage("Time for this zone can be extended no further.");
+ player.sendMessage("You cannot exceed the time zone limit.");
return;
}
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + _zoneId, remainRefillTime);
- final long remainTime;
+ 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));
+
if (player.isInTimedHuntingZone(_zoneId))
{
- remainTime = _time + player.getTimedHuntingZoneRemainingTime(_zoneId);
- player.getVariables().set(PlayerVariables.HUNTING_ZONE_TIME + _zoneId, remainTime);
player.startTimedHuntingZone(_zoneId, endTime);
- }
- 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 TimedHuntingZoneEnter(player, _zoneId));
}
- player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) remainRefillTime));
+ player.sendPacket(new TimedHuntingZoneChargeResult(_zoneId, (int) (remainTime / 1000), (int) (remainRefill - (_time / 1000))));
}
}
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 39ec882b27..2ee6a005e5 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(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
+ player.sendPacket(new TimedHuntingZoneExit(108)); // Training Zone id.
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 5c17db38d7..2effd0547b 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
@@ -31,6 +31,7 @@ import org.l2jmobius.gameserver.model.holders.SkillHolder;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.skill.SkillCaster;
+import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.serverpackets.ExSendUIEvent;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
@@ -875,7 +876,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(new TimedHuntingZoneExit(player.getLastTimeZone().getZoneId()));
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
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 72c9d9036d..086251165c 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,6 +10,7 @@
+
@@ -18,8 +19,7 @@
-
-
+
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 a99ab2fc29..6e6aeba205 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,6 +85,7 @@ 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;
@@ -92,8 +93,6 @@ 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())
@@ -145,6 +144,11 @@ 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());
@@ -170,19 +174,9 @@ 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, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation, pvpZone, noPvpZone));
+ _timedHuntingZoneData.put(id, new TimedHuntingZoneHolder(id, name, initialTime, maxAddedTime, resetDelay, entryItemId, entryFee, minLevel, maxLevel, remainRefillTime, refillTimeMax, instanceId, soloInstance, weekly, useWorldPrefix, enterLocation, exitLocation));
}
}
}
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 2491ae895a..a5f49074e9 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,11 +17,9 @@
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;
@@ -33,7 +31,6 @@ 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;
@@ -233,28 +230,6 @@ 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 d4bc34e0ce..d6f971e2fc 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,7 +944,6 @@ 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;
@@ -4269,52 +4268,6 @@ 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
@@ -15158,23 +15111,11 @@ 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 9f2deba5ed..7b4f4d1b31 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,6 +33,7 @@ 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,10 +43,8 @@ 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 refillTimeMax, int instanceId, boolean soloInstance, boolean weekly, boolean useWorldPrefix, Location enterLocation, Location exitLocation, boolean pvpZone, 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)
{
_id = id;
_name = name;
@@ -56,6 +55,7 @@ public class TimedHuntingZoneHolder
_entryFee = entryFee;
_minLevel = minLevel;
_maxLevel = maxLevel;
+ _remainRefillTime = remainRefillTime;
_refillTimeMax = refillTimeMax;
_instanceId = instanceId;
_soloInstance = soloInstance;
@@ -63,8 +63,6 @@ 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;
}
@@ -114,6 +112,11 @@ public class TimedHuntingZoneHolder
return _maxLevel;
}
+ public int getRemainRefillTime()
+ {
+ return _remainRefillTime;
+ }
+
public int getRefillTimeMax()
{
return _refillTimeMax;
@@ -149,16 +152,6 @@ 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/variables/PlayerVariables.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
index 1538a79131..1bbb925636 100644
--- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
+++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/variables/PlayerVariables.java
@@ -61,6 +61,7 @@ public class PlayerVariables extends AbstractVariables
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
+ public static final String LAST_HUNTING_ZONE_ID = "LAST_HUNTING_ZONE_ID";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String HUNTING_ZONE_REMAIN_REFILL = "HUNTING_ZONE_REMAIN_REFILL_";
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 0fc06ca3b5..4d552ef7de 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,21 +16,20 @@
*/
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.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
-import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.huntingzones.TimedHuntingZoneExit;
/**
* @author Mobius
- * @author dontknowdontcare
*/
public class TimedHuntingZone extends ZoneType
{
@@ -44,29 +43,9 @@ 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)
{
@@ -78,25 +57,17 @@ 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);
- }
+ player.getVariables().set(PlayerVariables.LAST_HUNTING_ZONE_ID, holder.getZoneId());
return;
}
break;
}
+
if (!player.isGM())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
@@ -109,56 +80,21 @@ 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)
{
- 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.TIMED_HUNTING, false);
+
+ ThreadPool.schedule(() ->
{
- 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);
+ if (!player.isInTimedHuntingZone(player.getX(), player.getY()))
+ {
+ player.sendPacket(new TimedHuntingZoneExit(player.getVariables().getInt(PlayerVariables.LAST_HUNTING_ZONE_ID, 0)));
+ }
+ }, 1000);
}
-
- 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/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntingzones/ExTimedHuntingZoneEnter.java
index 59f2788c6e..67a5417859 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
@@ -84,7 +84,7 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
- if (player.isRegisteredOnEvent() || (player.getBlockCheckerArena() > -1))
+ if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
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 1708170e53..f15edc7580 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
@@ -27,13 +27,13 @@ public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
private final int _zoneId;
- public TimedHuntingZoneExit(final int zoneId)
+ public TimedHuntingZoneExit(int zoneId)
{
_zoneId = zoneId;
}
@Override
- public boolean write(final PacketWriter packet)
+ public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
packet.writeD(_zoneId);
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 d57be233ab..36d05e9317 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,8 +62,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
}
packet.writeD(remainingTime / 1000); // remain time
packet.writeD(holder.getMaximumAddedTime() / 1000);
- long remainRefillTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRefillTimeMax());
- packet.writeD((int) remainRefillTime);
+ packet.writeD(_player.getVariables().getInt(PlayerVariables.HUNTING_ZONE_REMAIN_REFILL + holder.getZoneId(), holder.getRemainRefillTime()));
packet.writeD(holder.getRefillTimeMax());
packet.writeC(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D)
packet.writeC(0); // bUserBound