Addition of timed hunting zones.
This commit is contained in:
@@ -79,6 +79,7 @@ import org.l2jmobius.gameserver.model.zone.type.SpawnTerritory;
|
||||
import org.l2jmobius.gameserver.model.zone.type.SwampZone;
|
||||
import org.l2jmobius.gameserver.model.zone.type.TaxZone;
|
||||
import org.l2jmobius.gameserver.model.zone.type.TeleportZone;
|
||||
import org.l2jmobius.gameserver.model.zone.type.TimedHuntingZone;
|
||||
import org.l2jmobius.gameserver.model.zone.type.UndyingZone;
|
||||
import org.l2jmobius.gameserver.model.zone.type.WaterZone;
|
||||
|
||||
@@ -457,6 +458,7 @@ public class ZoneManager implements IXmlReader
|
||||
_classZones.put(SwampZone.class, new ConcurrentHashMap<>());
|
||||
_classZones.put(TaxZone.class, new ConcurrentHashMap<>());
|
||||
_classZones.put(TeleportZone.class, new ConcurrentHashMap<>());
|
||||
_classZones.put(TimedHuntingZone.class, new ConcurrentHashMap<>());
|
||||
_classZones.put(UndyingZone.class, new ConcurrentHashMap<>());
|
||||
_classZones.put(WaterZone.class, new ConcurrentHashMap<>());
|
||||
_spawnTerritories.clear();
|
||||
|
@@ -10335,7 +10335,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
// Close time limited zone window.
|
||||
if (!isInTimedHuntingZone())
|
||||
if (!isInsideZone(ZoneId.TIMED_HUNTING))
|
||||
{
|
||||
stopTimedHuntingZoneTask();
|
||||
}
|
||||
@@ -14126,11 +14126,6 @@ public class PlayerInstance extends Playable
|
||||
return _autoUseSettings;
|
||||
}
|
||||
|
||||
public boolean isInTimedHuntingZone()
|
||||
{
|
||||
return isInTimedHuntingZone(getX(), getY());
|
||||
}
|
||||
|
||||
public boolean isInTimedHuntingZone(int x, int y)
|
||||
{
|
||||
return isInTimedHuntingZone(1, x, y) // Storm Isle
|
||||
|
@@ -48,7 +48,8 @@ public enum ZoneId
|
||||
SAYUNE,
|
||||
FISHING,
|
||||
UNDYING,
|
||||
TAX;
|
||||
TAX,
|
||||
TIMED_HUNTING;
|
||||
|
||||
public static int getZoneCount()
|
||||
{
|
||||
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.zone.type;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.TeleportWhereType;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class TimedHuntingZone extends ZoneType
|
||||
{
|
||||
public TimedHuntingZone(int id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnter(Creature creature)
|
||||
{
|
||||
final PlayerInstance player = creature.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
player.setInsideZone(ZoneId.TIMED_HUNTING, true);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final long stormIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0);
|
||||
final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0);
|
||||
final long goldenAltarExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 7, 0);
|
||||
final long coalMinesExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0);
|
||||
final long toiExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 8, 0);
|
||||
final long imperialTombExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0);
|
||||
if ((stormIsleExitTime > currentTime) && player.isInTimedHuntingZone(1))
|
||||
{
|
||||
player.startTimedHuntingZone(1, stormIsleExitTime - currentTime);
|
||||
}
|
||||
else if ((primevalIsleExitTime > currentTime) && player.isInTimedHuntingZone(6))
|
||||
{
|
||||
player.startTimedHuntingZone(6, primevalIsleExitTime - currentTime);
|
||||
}
|
||||
else if ((goldenAltarExitTime > currentTime) && player.isInTimedHuntingZone(7))
|
||||
{
|
||||
player.startTimedHuntingZone(7, goldenAltarExitTime - currentTime);
|
||||
}
|
||||
else if ((coalMinesExitTime > currentTime) && player.isInTimedHuntingZone(11))
|
||||
{
|
||||
player.startTimedHuntingZone(11, coalMinesExitTime - currentTime);
|
||||
}
|
||||
else if ((toiExitTime > currentTime) && player.isInTimedHuntingZone(8))
|
||||
{
|
||||
player.startTimedHuntingZone(8, toiExitTime - currentTime);
|
||||
}
|
||||
else if ((imperialTombExitTime > currentTime) && player.isInTimedHuntingZone(12))
|
||||
{
|
||||
player.startTimedHuntingZone(12, imperialTombExitTime - currentTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExit(Creature creature)
|
||||
{
|
||||
final PlayerInstance player = creature.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
player.setInsideZone(ZoneId.TIMED_HUNTING, false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -40,7 +40,6 @@ import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.ServerRestartManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
@@ -660,46 +659,6 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
player.updateAbnormalVisualEffects();
|
||||
}
|
||||
|
||||
// Check if in time limited hunting zone.
|
||||
if (player.isInTimedHuntingZone())
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final long stormIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0);
|
||||
final long primevalIsleExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0);
|
||||
final long goldenAltarExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 7, 0);
|
||||
final long coalMinesExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0);
|
||||
final long toiExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 8, 0);
|
||||
final long imperialTombExitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0);
|
||||
if ((stormIsleExitTime > currentTime) && player.isInTimedHuntingZone(1))
|
||||
{
|
||||
player.startTimedHuntingZone(1, stormIsleExitTime - currentTime);
|
||||
}
|
||||
else if ((primevalIsleExitTime > currentTime) && player.isInTimedHuntingZone(6))
|
||||
{
|
||||
player.startTimedHuntingZone(6, primevalIsleExitTime - currentTime);
|
||||
}
|
||||
else if ((goldenAltarExitTime > currentTime) && player.isInTimedHuntingZone(7))
|
||||
{
|
||||
player.startTimedHuntingZone(7, goldenAltarExitTime - currentTime);
|
||||
}
|
||||
else if ((coalMinesExitTime > currentTime) && player.isInTimedHuntingZone(11))
|
||||
{
|
||||
player.startTimedHuntingZone(11, coalMinesExitTime - currentTime);
|
||||
}
|
||||
else if ((toiExitTime > currentTime) && player.isInTimedHuntingZone(11))
|
||||
{
|
||||
player.startTimedHuntingZone(8, toiExitTime - currentTime);
|
||||
}
|
||||
else if ((imperialTombExitTime > currentTime) && player.isInTimedHuntingZone(11))
|
||||
{
|
||||
player.startTimedHuntingZone(12, imperialTombExitTime - currentTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.ENABLE_ATTENDANCE_REWARDS)
|
||||
{
|
||||
ThreadPool.schedule(() ->
|
||||
|
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
|
||||
/**
|
||||
@@ -48,7 +49,7 @@ public class RequestSaveBookMarkSlot implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isInTimedHuntingZone())
|
||||
if (player.isInsideZone(ZoneId.TIMED_HUNTING))
|
||||
{
|
||||
player.sendMessage("You cannot bookmark this location.");
|
||||
return;
|
||||
|
@@ -114,6 +114,8 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime);
|
||||
|
||||
switch (_zoneId)
|
||||
{
|
||||
case 1: // Storm Isle
|
||||
@@ -147,9 +149,6 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, endTime);
|
||||
player.startTimedHuntingZone(_zoneId, endTime - currentTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.entity.Castle;
|
||||
import org.l2jmobius.gameserver.model.holders.TeleportListHolder;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
@@ -58,7 +59,7 @@ public class ExRequestTeleport implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
// Players should not be able to teleport if in combat, or in a special location.
|
||||
if (player.isCastingNow() || player.isInCombat() || player.isInInstance() || player.isOnEvent() || player.isInOlympiadMode() || player.inObserverMode() || player.isInTraingCamp() || player.isInTimedHuntingZone())
|
||||
if (player.isCastingNow() || player.isInCombat() || player.isInInstance() || player.isOnEvent() || player.isInOlympiadMode() || player.inObserverMode() || player.isInTraingCamp() || player.isInsideZone(ZoneId.TIMED_HUNTING))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_TELEPORT_RIGHT_NOW);
|
||||
return;
|
||||
|
@@ -20,6 +20,7 @@ import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
@@ -34,7 +35,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
|
||||
public TimedHuntingZoneList(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
_isInTimedHuntingZone = player.isInTimedHuntingZone();
|
||||
_isInTimedHuntingZone = player.isInsideZone(ZoneId.TIMED_HUNTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user