Partially reverted latest timed zone changes.

This commit is contained in:
MobiusDevelopment
2022-08-29 12:47:03 +00:00
parent 4ed3354380
commit 4196f51c41
97 changed files with 461 additions and 1830 deletions

View File

@@ -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));
}
}
}

View File

@@ -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.
*/

View File

@@ -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);

View File

@@ -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;

View File

@@ -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_";

View File

@@ -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));
}
}

View File

@@ -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);

View File

@@ -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