Support for time limited zones.

This commit is contained in:
MobiusDevelopment 2020-01-03 16:30:59 +00:00
parent 7fd4c6e159
commit eae968d570
23 changed files with 1707 additions and 10 deletions

View File

@ -0,0 +1,3 @@
<html><body>Investigators Guard:<br>
There are many dangerous monsters outside the camps. Don't let your guard down.
</body></html>

View File

@ -0,0 +1,3 @@
<html><body>Investigators Guard:<br>
There are many dangerous monsters outside the camps. Don't let your guard down.
</body></html>

View File

@ -24,6 +24,7 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.type.RespawnZone;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneEnter;
/**
* Loc user command.
@ -66,6 +67,8 @@ public class Loc implements IUserCommandHandler
sm.addString(player.getX() + ", " + player.getY() + ", " + player.getZ());
}
player.sendPacket(sm);
player.sendPacket(new TimedHuntingZoneEnter(1));
return true;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/teleporterData.xsd">
<npc id="34529"> <!-- Investigators Teleporter -->
<teleport type="OTHER">
<location x="194276" y="176595" z="-1888" /> <!-- Eastern Camp -->
<location x="167989" y="187546" z="-2232" /> <!-- Western Camp -->
<location x="191000" y="188118" z="-2656" /> <!-- Southern Camp -->
<location x="177925" y="172948" z="-2008" /> <!-- Northern Camp -->
</teleport>
</npc>
</list>

View File

@ -116,6 +116,7 @@ import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
import org.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import org.l2jmobius.gameserver.instancemanager.MentorManager;
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
@ -341,6 +342,7 @@ import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBook;
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookCloseForce;
import org.l2jmobius.gameserver.network.serverpackets.monsterbook.ExMonsterBookRewardIcon;
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.EnumIntBitmask;
@ -863,6 +865,8 @@ public class PlayerInstance extends Playable
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
private ScheduledFuture<?> _timedHuntingZoneFinishTask = null;
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@ -10312,12 +10316,18 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
}
// Close time limited zone window.
if (!isInTimedHuntingZone())
{
stopTimedHuntingZoneTask();
}
// send info to nearby players
broadcastInfo();
}
@ -14195,4 +14205,44 @@ public class PlayerInstance extends Playable
_autoSkills.remove(skillId);
stopAutoUseTask();
}
public boolean isInTimedHuntingZone()
{
final int x = ((getX() - World.MAP_MIN_X) >> 15) + World.TILE_X_MIN;
final int y = ((getY() - World.MAP_MIN_Y) >> 15) + World.TILE_Y_MIN;
if ((x == 25) && (y == 23)) // Storm Isle.
{
return true;
}
return false;
}
public void startTimedHuntingZone(long delay)
{
// TODO: Delay window.
// sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000)));
// For now close window.
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
_timedHuntingZoneFinishTask = ThreadPool.schedule(() ->
{
if ((isOnlineInt() > 0) && isInTimedHuntingZone())
{
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
abortCast();
stopMove(null);
teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN));
}
}, delay);
}
public void stopTimedHuntingZoneTask()
{
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone())
{
_timedHuntingZoneFinishTask.cancel(true);
_timedHuntingZoneFinishTask = null;
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
}
}
}

View File

@ -63,6 +63,7 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME";
private final int _objectId;

View File

@ -116,6 +116,7 @@ public class Disconnection
{
if (_player != null)
{
_player.stopTimedHuntingZoneTask();
_player.stopAutoPlayTask();
_player.stopAutoUseTask();
_player.storeMe();

View File

@ -111,6 +111,7 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers;
import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove;
import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart;
import org.l2jmobius.gameserver.network.clientpackets.sessionzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.sessionzones.ExTimedHuntingZoneList;
import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle;
import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
@ -508,7 +509,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_GACHA_SHOP_GACHA_GROUP(0x17D, null, ConnectionState.IN_GAME),
EX_GACHA_SHOP_GACHA_ITEM(0x17E, null, ConnectionState.IN_GAME),
EX_TIME_RESTRICT_FIELD_LIST(0x17F, ExTimedHuntingZoneList::new, ConnectionState.IN_GAME),
EX_TIME_RESTRICT_FIELD_USER_ENTER(0x180, null, ConnectionState.IN_GAME),
EX_TIME_RESTRICT_FIELD_USER_ENTER(0x180, ExTimedHuntingZoneEnter::new, ConnectionState.IN_GAME),
EX_RANKING_CHAR_INFO(0x181, RequestRankingCharInfo::new, ConnectionState.IN_GAME),
EX_RANKING_CHAR_HISTORY(0x182, null, ConnectionState.IN_GAME),
EX_RANKING_CHAR_RANKERS(0x183, RequestRankingCharRankers::new, ConnectionState.IN_GAME),

View File

@ -36,6 +36,7 @@ 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;
@ -639,6 +640,17 @@ public class EnterWorld implements IClientIncomingPacket
player.updateAbnormalVisualEffects();
}
// Check if in time limited hunting zone.
final long exitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0) - 3600000;
if (exitTime > System.currentTimeMillis())
{
player.startTimedHuntingZone(exitTime - System.currentTimeMillis());
}
else if (player.isInTimedHuntingZone())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
}
if (Config.ENABLE_ATTENDANCE_REWARDS)
{
ThreadPool.schedule(() ->

View File

@ -0,0 +1,104 @@
/*
* 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.network.clientpackets.sessionzones;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD(); // Zone id.
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (player.isMounted())
{
player.sendMessage("Cannot use time-limited hunting zones while mounted.");
return;
}
if (player.isInDuel())
{
player.sendMessage("Cannot use time-limited hunting zones during a duel.");
return;
}
if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
{
player.sendPacket(SystemMessageId.CANNOT_USE_TIME_LIMITED_HUNTING_ZONES_WHILE_WAITING_FOR_THE_OLYMPIAD);
return;
}
if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
}
if (player.isInInstance())
{
player.sendMessage("Cannot use time-limited hunting zones while in an instance.");
return;
}
if (player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0) > System.currentTimeMillis())
{
if (player.isInTimedHuntingZone())
{
player.sendPacket(SystemMessageId.YOU_WILL_EXCEED_THE_MAX_AMOUNT_OF_TIME_FOR_THE_HUNTING_ZONE_SO_YOU_CANNOT_ADD_ANY_MORE_TIME);
}
else
{
player.sendPacket(SystemMessageId.YOU_DON_T_HAVE_ENOUGH_TIME_AVAILABLE_TO_ENTER_THE_HUNTING_ZONE);
}
return;
}
if (player.getLevel() < 100)
{
player.sendMessage("Your level is too low.");
}
if (player.getAdena() > 150000)
{
player.reduceAdena("TimedHuntingZone", 150000, player, true);
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME, System.currentTimeMillis() + 64800000); // 64800000 = 18 hours
player.teleToLocation(194291, 176604, -1888); // Storm Isle
player.startTimedHuntingZone(18000000); // 300 minutes
}
else
{
player.sendPacket(SystemMessageId.NOT_ENOUGH_ADENA);
}
}
}

View File

@ -20,7 +20,7 @@ import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.timedhunting.TimedHuntingZoneList;
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneList;
public class ExTimedHuntingZoneList implements IClientIncomingPacket
{

View File

@ -0,0 +1,42 @@
/*
* 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.network.serverpackets.sessionzones;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class TimedHuntingZoneEnter implements IClientOutgoingPacket
{
private final int _remainingTime;
public TimedHuntingZoneEnter(int remainingTime)
{
_remainingTime = remainingTime;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
packet.writeC(_remainingTime);
return true;
}
}

View File

@ -0,0 +1,40 @@
/*
* 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.network.serverpackets.sessionzones;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
public TimedHuntingZoneExit()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
return true;
}
}

View File

@ -14,7 +14,7 @@
* 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.network.serverpackets.timedhunting;
package org.l2jmobius.gameserver.network.serverpackets.sessionzones;
import java.util.ArrayList;
import java.util.List;
@ -69,9 +69,9 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
{
final TimeRestrictedFieldInfo field = new TimeRestrictedFieldInfo();
field.resetCycle = 1;
field.fieldId = 2;
field.minLevel = 78;
field.maxLevel = 999;
field.fieldId = 1;
field.minLevel = 100;
field.maxLevel = 120;
field.remainTimeBase = 3600;
field.remainTime = 3600;
field.remainTimeMax = 21600;
@ -81,7 +81,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket
final FieldRequiredItem item = new FieldRequiredItem();
item.itemId = 57;
item.count = 10000;
item.count = 150000;
field.requiredItems = List.of(item);
infos.add(field);

View File

@ -116,6 +116,7 @@ import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
import org.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.instancemanager.MapRegionManager;
import org.l2jmobius.gameserver.instancemanager.MatchingRoomManager;
import org.l2jmobius.gameserver.instancemanager.MentorManager;
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
@ -338,6 +339,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExAutoPlayDoMacro;
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
import org.l2jmobius.gameserver.network.serverpackets.friend.FriendStatus;
import org.l2jmobius.gameserver.network.serverpackets.sessionzones.TimedHuntingZoneExit;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.EnumIntBitmask;
@ -856,6 +858,8 @@ public class PlayerInstance extends Playable
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
private ScheduledFuture<?> _timedHuntingZoneFinishTask = null;
// Selling buffs system
private boolean _isSellingBuffs = false;
private List<SellBuffHolder> _sellingBuffs = null;
@ -10225,12 +10229,18 @@ public class PlayerInstance extends Playable
s.updateAndBroadcastStatus(0);
});
// show movie if available
// Show movie if available
if (_movieHolder != null)
{
sendPacket(new ExStartScenePlayer(_movieHolder.getMovie()));
}
// Close time limited zone window.
if (!isInTimedHuntingZone())
{
stopTimedHuntingZoneTask();
}
// send info to nearby players
broadcastInfo();
}
@ -14141,4 +14151,44 @@ public class PlayerInstance extends Playable
_autoSkills.remove(skillId);
stopAutoUseTask();
}
public boolean isInTimedHuntingZone()
{
final int x = ((getX() - World.MAP_MIN_X) >> 15) + World.TILE_X_MIN;
final int y = ((getY() - World.MAP_MIN_Y) >> 15) + World.TILE_Y_MIN;
if ((x == 20) && (y == 15)) // Ancient Pirates' Tomb.
{
return true;
}
return false;
}
public void startTimedHuntingZone(long delay)
{
// TODO: Delay window.
// sendPacket(new TimedHuntingZoneEnter((int) (delay / 60 / 1000)));
// For now close window.
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
_timedHuntingZoneFinishTask = ThreadPool.schedule(() ->
{
if ((isOnlineInt() > 0) && isInTimedHuntingZone())
{
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
abortCast();
stopMove(null);
teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, TeleportWhereType.TOWN));
}
}, delay);
}
public void stopTimedHuntingZoneTask()
{
if ((_timedHuntingZoneFinishTask != null) && !_timedHuntingZoneFinishTask.isCancelled() && !_timedHuntingZoneFinishTask.isDone())
{
_timedHuntingZoneFinishTask.cancel(true);
_timedHuntingZoneFinishTask = null;
sendPacket(TimedHuntingZoneExit.STATIC_PACKET);
}
}
}

View File

@ -63,6 +63,7 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String HUNTING_ZONE_RESET_TIME = "HUNTING_ZONE_RESET_TIME";
private final int _objectId;

View File

@ -116,6 +116,7 @@ public class Disconnection
{
if (_player != null)
{
_player.stopTimedHuntingZoneTask();
_player.stopAutoPlayTask();
_player.stopAutoUseTask();
_player.storeMe();

View File

@ -102,6 +102,7 @@ import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingChar
import org.l2jmobius.gameserver.network.clientpackets.ranking.RequestRankingCharRankers;
import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMove;
import org.l2jmobius.gameserver.network.clientpackets.sayune.RequestFlyMoveStart;
import org.l2jmobius.gameserver.network.clientpackets.sessionzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.sessionzones.ExTimedHuntingZoneList;
import org.l2jmobius.gameserver.network.clientpackets.shuttle.CannotMoveAnymoreInShuttle;
import org.l2jmobius.gameserver.network.clientpackets.shuttle.MoveToLocationInShuttle;
@ -499,7 +500,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_GACHA_SHOP_GACHA_GROUP(0x17D, null, ConnectionState.IN_GAME),
EX_GACHA_SHOP_GACHA_ITEM(0x17E, null, ConnectionState.IN_GAME),
EX_TIME_RESTRICT_FIELD_LIST(0x17F, ExTimedHuntingZoneList::new, ConnectionState.IN_GAME),
EX_TIME_RESTRICT_FIELD_USER_ENTER(0x180, null, ConnectionState.IN_GAME),
EX_TIME_RESTRICT_FIELD_USER_ENTER(0x180, ExTimedHuntingZoneEnter::new, ConnectionState.IN_GAME),
EX_RANKING_CHAR_INFO(0x181, RequestRankingCharInfo::new, ConnectionState.IN_GAME),
EX_RANKING_CHAR_HISTORY(0x182, null, ConnectionState.IN_GAME),
EX_RANKING_CHAR_RANKERS(0x183, RequestRankingCharRankers::new, ConnectionState.IN_GAME),

View File

@ -35,6 +35,7 @@ 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;
@ -624,6 +625,17 @@ public class EnterWorld implements IClientIncomingPacket
player.updateAbnormalVisualEffects();
}
// Check if in time limited hunting zone.
final long exitTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0) - 3600000;
if (exitTime > System.currentTimeMillis())
{
player.startTimedHuntingZone(exitTime - System.currentTimeMillis());
}
else if (player.isInTimedHuntingZone())
{
player.teleToLocation(MapRegionManager.getInstance().getTeleToLocation(player, TeleportWhereType.TOWN));
}
if (Config.ENABLE_ATTENDANCE_REWARDS)
{
ThreadPool.schedule(() ->

View File

@ -0,0 +1,103 @@
/*
* 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.network.clientpackets.sessionzones;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class ExTimedHuntingZoneEnter implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD(); // Zone id.
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (player.isMounted())
{
player.sendMessage("Cannot use time-limited hunting zones while mounted.");
return;
}
if (player.isInDuel())
{
player.sendMessage("Cannot use time-limited hunting zones during a duel.");
return;
}
if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
{
player.sendMessage("Cannot use time-limited hunting zones while waiting for the Olympiad.");
return;
}
if (player.isOnEvent() || (player.getBlockCheckerArena() > -1))
{
player.sendMessage("Cannot use time-limited hunting zones while registered on an event.");
return;
}
if (player.isInInstance())
{
player.sendMessage("Cannot use time-limited hunting zones while in an instance.");
return;
}
if (player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME, 0) > System.currentTimeMillis())
{
if (player.isInTimedHuntingZone())
{
player.sendMessage("You will exceed the max amount of time for the hunting zone, so you cannot add any more time.");
}
else
{
player.sendMessage("You don't have enough time available to enter the hunting zone.");
}
return;
}
if (player.getLevel() < 78)
{
player.sendMessage("Your level is too low.");
}
if (player.getAdena() > 10000)
{
player.reduceAdena("TimedHuntingZone", 10000, player, true);
player.getVariables().set(PlayerVariables.HUNTING_ZONE_RESET_TIME, System.currentTimeMillis() + 64800000); // 64800000 = 18 hours
player.teleToLocation(13181, -78651, -5977); // Ancient Pirates' Tomb
player.startTimedHuntingZone(18000000); // 300 minutes
}
else
{
player.sendMessage("Not enough adena.");
}
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.network.serverpackets.sessionzones;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class TimedHuntingZoneEnter implements IClientOutgoingPacket
{
private final int _remainingTime;
public TimedHuntingZoneEnter(int remainingTime)
{
_remainingTime = remainingTime;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_ENTER.writeId(packet);
packet.writeC(_remainingTime);
return true;
}
}

View File

@ -0,0 +1,40 @@
/*
* 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.network.serverpackets.sessionzones;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class TimedHuntingZoneExit implements IClientOutgoingPacket
{
public static final TimedHuntingZoneExit STATIC_PACKET = new TimedHuntingZoneExit();
public TimedHuntingZoneExit()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_TIME_RESTRICT_FIELD_USER_EXIT.writeId(packet);
return true;
}
}