From bde07be6da600e6d77481a663f2c556b0a7b8956 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 9 Feb 2021 22:10:35 +0000 Subject: [PATCH] Weekly hunting zone. Contributed by Sero. --- .../dist/game/config/TimeLimitedZones.ini | 16 +++++++++++++-- .../effecthandlers/AddHuntingTime.java | 14 +++++++++++-- .../java/org/l2jmobius/Config.java | 8 +++++++- .../sessionzones/ExTimedHuntingZoneEnter.java | 7 ++++++- .../sessionzones/TimedHuntingZoneList.java | 20 +++++++++---------- 5 files changed, 49 insertions(+), 16 deletions(-) diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/config/TimeLimitedZones.ini b/L2J_Mobius_8.0_Homunculus/dist/game/config/TimeLimitedZones.ini index 5b54b0c9f7..d6bc0894d8 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/config/TimeLimitedZones.ini +++ b/L2J_Mobius_8.0_Homunculus/dist/game/config/TimeLimitedZones.ini @@ -6,14 +6,26 @@ # Default: 3600000 (1 hour) InitialTime = 3600000 +# Initial free time. +# Default: 36000000 (10 hour) +InitialTimeWeekly = 36000000 + # Maximum added time. -# Default: 18000000 (5 hours) -MaximumAddedTime = 18000000 +# Default: 18000000 (6 hours) +MaximumAddedTime = 21600000 + +# Maximum added time Weekly. +# Default: 43200000 (12 hours) +MaximumAddedTimeWeekly = 43200000 # Reset delay. # Default: 36000000 (10 hours) ResetDelay = 36000000 +# Reset Weekly. +# Default: 604800000 (7 Days) +ResetWeekly = 604800000 + # Teleport fee. # Default: 150000 TeleportFee = 150000 diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java index bfe0c1ce4b..0b04c4ff59 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java +++ b/L2J_Mobius_8.0_Homunculus/dist/game/data/scripts/handlers/effecthandlers/AddHuntingTime.java @@ -57,7 +57,13 @@ public class AddHuntingTime extends AbstractEffect final long currentTime = System.currentTimeMillis(); long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME)) + if ((_zoneId == 8) && (endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME_WEEKLY)) + { + player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); + player.sendMessage("You cannot exceed the time zone limit."); + return; + } + else if ((endTime > currentTime) && (((endTime - currentTime) + _time) >= Config.TIME_LIMITED_MAX_ADDED_TIME)) { player.getInventory().addItem("AddHuntingTime effect refund", item.getId(), 1, player, player); player.sendMessage("You cannot exceed the time zone limit."); @@ -72,7 +78,11 @@ public class AddHuntingTime extends AbstractEffect } else { - if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + if ((_zoneId == 8) && ((endTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime)) + { + endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; + } + else if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java index d53600f9ae..92c1eaaa69 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java @@ -834,8 +834,11 @@ public class Config public static List TELNET_HOSTS; public static int TELNET_PORT; public static long TIME_LIMITED_ZONE_INITIAL_TIME; + public static long TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; public static long TIME_LIMITED_MAX_ADDED_TIME; + public static long TIME_LIMITED_MAX_ADDED_TIME_WEEKLY; public static long TIME_LIMITED_ZONE_RESET_DELAY; + public static long TIME_LIMITED_ZONE_RESET_WEEKLY; public static long TIME_LIMITED_ZONE_TELEPORT_FEE; public static boolean TRAINING_CAMP_ENABLE; public static boolean TRAINING_CAMP_PREMIUM_ONLY; @@ -1985,8 +1988,11 @@ public class Config // Load Time Limited Zone config file (if exists) final PropertiesParser timeLimitedZoneSettings = new PropertiesParser(TIME_LIMITED_ZONE_CONFIG_FILE); TIME_LIMITED_ZONE_INITIAL_TIME = timeLimitedZoneSettings.getLong("InitialTime", 3600000); - TIME_LIMITED_MAX_ADDED_TIME = timeLimitedZoneSettings.getLong("MaximumAddedTime", 18000000); + TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY = timeLimitedZoneSettings.getLong("InitialTimeWeekly", 36000000); + TIME_LIMITED_MAX_ADDED_TIME = timeLimitedZoneSettings.getLong("MaximumAddedTime", 21600000); + TIME_LIMITED_MAX_ADDED_TIME_WEEKLY = timeLimitedZoneSettings.getLong("MaximumAddedTimeWeekly", 43200000); TIME_LIMITED_ZONE_RESET_DELAY = timeLimitedZoneSettings.getLong("ResetDelay", 36000000); + TIME_LIMITED_ZONE_RESET_WEEKLY = timeLimitedZoneSettings.getLong("ResetWeekly", 604800000); TIME_LIMITED_ZONE_TELEPORT_FEE = timeLimitedZoneSettings.getLong("TeleportFee", 150000); // Load Training Camp config file (if exists) diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java index a7db2bae30..8823bb6077 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/sessionzones/ExTimedHuntingZoneEnter.java @@ -97,7 +97,12 @@ public class ExTimedHuntingZoneEnter implements IClientIncomingPacket final long currentTime = System.currentTimeMillis(); long endTime = player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + _zoneId, 0); - if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + + if ((_zoneId == 8) && ((endTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime)) + { + endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; + } + else if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java index cc67b3a30c..9900991a39 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/sessionzones/TimedHuntingZoneList.java @@ -55,7 +55,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(1); // zone id packet.writeD(100); // min level packet.writeD(120); // max level - packet.writeD(0); // remain time base? + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 1, 0); if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { @@ -76,7 +76,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(6); // zone id packet.writeD(105); // min level packet.writeD(120); // max level - packet.writeD(0); // remain time base? + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 6, 0); if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { @@ -97,7 +97,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(7); // zone id packet.writeD(107); // min level packet.writeD(120); // max level - packet.writeD(0); // remain time base? + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 7, 0); if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { @@ -118,7 +118,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(11); // zone id packet.writeD(99); // min level packet.writeD(105); // max level - packet.writeD(0); // remain time base? + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 11, 0); if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) { @@ -135,18 +135,18 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(1); // required item count packet.writeD(57); // item id packet.writeQ(Config.TIME_LIMITED_ZONE_TELEPORT_FEE); // item count - packet.writeD(1); // reset cycle + packet.writeD(0); // reset cycle packet.writeD(8); // zone id packet.writeD(110); // min level packet.writeD(130); // max level - packet.writeD(0); // remain time base? + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY / 1000)); // remain time base? endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 8, 0); - if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) + if ((endTime + Config.TIME_LIMITED_ZONE_RESET_WEEKLY) < currentTime) { - endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME; + endTime = currentTime + Config.TIME_LIMITED_ZONE_INITIAL_TIME_WEEKLY; } packet.writeD((int) (Math.max(endTime - currentTime, 0)) / 1000); // remain time - packet.writeD((int) (Config.TIME_LIMITED_MAX_ADDED_TIME / 1000)); + packet.writeD((int) (Config.TIME_LIMITED_MAX_ADDED_TIME_WEEKLY / 1000)); packet.writeD(3600); // remain refill time packet.writeD(3600); // refill time max packet.writeD(_isInTimedHuntingZone ? 0 : 1); // field activated (272 C to D) @@ -160,7 +160,7 @@ public class TimedHuntingZoneList implements IClientOutgoingPacket packet.writeD(12); // zone id packet.writeD(105); // min level packet.writeD(130); // max level - packet.writeD(0); // remain time base? + packet.writeD((int) (Config.TIME_LIMITED_ZONE_INITIAL_TIME / 1000)); // remain time base? endTime = _player.getVariables().getLong(PlayerVariables.HUNTING_ZONE_RESET_TIME + 12, 0); if ((endTime + Config.TIME_LIMITED_ZONE_RESET_DELAY) < currentTime) {