diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/db_installer/sql/game/huntpass.sql b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/db_installer/sql/game/huntpass.sql new file mode 100644 index 0000000000..737b879bf2 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/db_installer/sql/game/huntpass.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS `huntpass`; +CREATE TABLE IF NOT EXISTS `huntpass` ( + `account_name` VARCHAR(45) NOT NULL DEFAULT '', + `current_step` INT NOT NULL DEFAULT 0, + `points` INT NOT NULL DEFAULT 0, + `reward_step` INT NOT NULL DEFAULT 0, + `is_paytowin` BOOLEAN NOT NULL DEFAULT FALSE, + `premium_reward_step` INT NOT NULL DEFAULT 0, + `sayha_points_available` INT NOT NULL DEFAULT 0, + `sayha_points_used` INT NOT NULL DEFAULT 0, + `unclaimed_reward` BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (`account_name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/config/HuntPass.ini b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/config/HuntPass.ini new file mode 100644 index 0000000000..127696f66a --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/config/HuntPass.ini @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# HuntPass Settings +# -------------------------------------------------------------------------- +EnabledHuntPass = False + +# Period to end. +# Retail 1 month. +DayOfMonth = 16 + +# Pass Premium Cost. +# Retail is 3600 L-Coin. +PremiumCost = 4000 + +# Please take caution when changing anything. +# Required Points per Window or step. +PointsForstep = 3000 diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/HuntPass.xml b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/HuntPass.xml new file mode 100644 index 0000000000..9ee6b46215 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/HuntPass.xml @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/EffectMasterHandler.java index cb7e56e8c5..84fedc255c 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -189,6 +189,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("HpLimit", HpLimit::new); EffectHandler.getInstance().registerHandler("HpRegen", HpRegen::new); EffectHandler.getInstance().registerHandler("HpToOwner", HpToOwner::new); + EffectHandler.getInstance().registerHandler("HuntPassPoints", HuntPassPoints::new); EffectHandler.getInstance().registerHandler("IgnoreDeath", IgnoreDeath::new); EffectHandler.getInstance().registerHandler("ImmobileDamageBonus", ImmobileDamageBonus::new); EffectHandler.getInstance().registerHandler("ImmobileDamageResist", ImmobileDamageResist::new); diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/HuntPassPoints.java b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/HuntPassPoints.java new file mode 100644 index 0000000000..1734211321 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/scripts/handlers/effecthandlers/HuntPassPoints.java @@ -0,0 +1,65 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.item.instance.Item; +import org.l2jmobius.gameserver.model.skill.Skill; + +/** + * @author Serenitty + */ +public class HuntPassPoints extends AbstractEffect +{ + private final int _amount; + + public HuntPassPoints(StatSet params) + { + _amount = params.getInt("amount"); + } + + @Override + public boolean isInstant() + { + return true; + } + + @Override + public void instant(Creature effector, Creature effected, Skill skill, Item item) + { + if (effected == null) + { + return; + } + + final Player player = effected.getActingPlayer(); + if (player == null) + { + return; + } + + final HuntPass huntpass = player.getHuntPass(); + if (huntpass != null) + { + huntpass.addPassPoint(_amount); + } + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/items/72200-72299.xml b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/items/72200-72299.xml index 4b60bfb49b..1754077578 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/items/72200-72299.xml +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/items/72200-72299.xml @@ -312,6 +312,7 @@ + diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/skills/documentation.txt index 915062c17a..45e380c51e 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/stats/skills/documentation.txt @@ -160,6 +160,7 @@ Hp: Increases current HP by a static value. HpLimit: Increase a character's max hp limit (l2jmobius) HpRegen: HP Regeneration stat. HpToOwner: DOT effect that absorbs HP over time. +HuntPassPoints: Modify HuntPass points. (l2jmobius) IgnoreDeath: Become undying. Hp cannot decrease below 1. ImmobileDamageBonus: Bonus damage to immobile targets. (l2jmobius) ImmobileDamageResist: Resist damage while immobile. (l2jmobius) diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/xsd/HuntPass.xsd b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/xsd/HuntPass.xsd new file mode 100644 index 0000000000..1e63b87cf0 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/data/xsd/HuntPass.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java index 3f512a9ebd..f4d65c0ee1 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java @@ -99,6 +99,7 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; + private static final String HUNT_PASS_CONFIG_FILE = "./config/HuntPass.ini"; private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; @@ -904,6 +905,12 @@ public class Config public static int RANDOM_CRAFT_CREATE_FEE; public static boolean DROP_RANDOM_CRAFT_MATERIALS; + // HuntPass + public static boolean ENABLE_HUNT_PASS; + public static int HUNT_PASS_PERIOD; + public static int HUNT_PASS_PREMIUM_COST; + public static int HUNT_PASS_POINTS_FOR_STEP; + // GrandBoss Settings // Antharas @@ -2501,6 +2508,13 @@ public class Config ZAKEN_SPAWN_INTERVAL = grandBossConfig.getInt("IntervalOfZakenSpawn", 168); ZAKEN_SPAWN_RANDOM = grandBossConfig.getInt("RandomOfZakenSpawn", 48); + // Load HuntPass (if exists) + final PropertiesParser huntPassConfig = new PropertiesParser(HUNT_PASS_CONFIG_FILE); + ENABLE_HUNT_PASS = huntPassConfig.getBoolean("EnabledHuntPass", true); + HUNT_PASS_PREMIUM_COST = huntPassConfig.getInt("PremiumCost", 3600); + HUNT_PASS_POINTS_FOR_STEP = huntPassConfig.getInt("PointsForstep", 2400); + HUNT_PASS_PERIOD = huntPassConfig.getInt("DayOfMonth", 1); + // Gracia Seeds final PropertiesParser graciaSeedsConfig = new PropertiesParser(GRACIASEEDS_CONFIG_FILE); SOD_TIAT_KILL_COUNT = graciaSeedsConfig.getInt("TiatKillCountForNextState", 10); diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/HuntPassData.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/HuntPassData.java new file mode 100644 index 0000000000..078f9012c9 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/data/xml/HuntPassData.java @@ -0,0 +1,115 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.data.xml; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.w3c.dom.Document; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.util.IXmlReader; +import org.l2jmobius.gameserver.data.ItemTable; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.holders.ItemHolder; + +/** + * @author Serenitty + */ +public class HuntPassData implements IXmlReader +{ + private static final Logger LOGGER = Logger.getLogger(HuntPassData.class.getName()); + private final List _rewards = new ArrayList<>(); + private final List _premiumRewards = new ArrayList<>(); + private int _rewardCount = 0; + private final int _premiumRewardCount = 0; + + protected HuntPassData() + { + load(); + } + + @Override + public void load() + { + if (Config.ENABLE_HUNT_PASS) + { + _rewards.clear(); + parseDatapackFile("data/HuntPass.xml"); + _rewardCount = _rewards.size(); + LOGGER.info(getClass().getSimpleName() + ": Loaded " + _rewardCount + " HuntPass rewards."); + } + else + { + LOGGER.info(getClass().getSimpleName() + ": Disabled."); + } + } + + @Override + public void parseDocument(Document doc, File f) + { + forEach(doc, "list", listNode -> forEach(listNode, "item", rewardNode -> + { + final StatSet set = new StatSet(parseAttributes(rewardNode)); + final int itemId = set.getInt("id"); + final int itemCount = set.getInt("count"); + final int premiumitemId = set.getInt("premiumId"); + final int premiumitemCount = set.getInt("premiumCount"); + if (ItemTable.getInstance().getTemplate(itemId) == null) + { + LOGGER.info(getClass().getSimpleName() + ": Item with id " + itemId + " does not exist."); + } + else + { + _rewards.add(new ItemHolder(itemId, itemCount)); + _premiumRewards.add(new ItemHolder(premiumitemId, premiumitemCount)); + } + })); + } + + public List getRewards() + { + return _rewards; + } + + public int getRewardsCount() + { + return _rewardCount; + } + + public List getPremiumRewards() + { + return _premiumRewards; + } + + public int getPremiumRewardsCount() + { + return _premiumRewardCount; + } + + public static HuntPassData getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final HuntPassData INSTANCE = new HuntPassData(); + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/HuntPass.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/HuntPass.java new file mode 100644 index 0000000000..71b7a07a52 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/HuntPass.java @@ -0,0 +1,334 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Calendar; +import java.util.concurrent.ScheduledFuture; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.database.DatabaseFactory; +import org.l2jmobius.commons.threads.ThreadPool; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; + +/** + * @author Serenitty + */ +public class HuntPass +{ + private static final Logger LOGGER = Logger.getLogger(HuntPass.class.getName()); + private static final String INSERT_SEASONPASS = "REPLACE INTO huntpass (`account_name`, `current_step`, `points`, `reward_step`, `is_paytowin`, `premium_reward_step`, `sayha_points_available`, `sayha_points_used`, `unclaimed_reward`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; + private static final String RESTORE_SEASONPASS = "SELECT * FROM huntpass WHERE account_name=?"; + + private final Player _user; + private int _availableSayhaTime; + private int _points; + private boolean _isPremium = false; + private boolean _rewardAlert = false; + + private int _rewardStep; + private int _currentStep; + private int _premiumRewardStep; + + private boolean _toggleSayha = false; + private ScheduledFuture _sayhasSustentionTask = null; + private int _toggleStartTime = 0; + private int _usedSayhaTime; + + private static int _dayEnd = 0; + + public HuntPass(Player user) + { + _user = user; + restoreHuntPass(); + huntPassDayEnd(); + store(); + } + + public void restoreHuntPass() + { + final Calendar calendar = Calendar.getInstance(); + if ((calendar.get(Calendar.DAY_OF_MONTH) == Config.HUNT_PASS_PERIOD) && (calendar.get(Calendar.HOUR_OF_DAY) == 6) && (calendar.get(Calendar.MINUTE) == 30)) + { + deleteHuntPass(); + } + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement statement = con.prepareStatement(RESTORE_SEASONPASS)) + { + statement.setString(1, getAccountName()); + try (ResultSet rset = statement.executeQuery()) + { + if (rset.next()) + { + setPoints(rset.getInt("points")); + setCurrentStep(rset.getInt("current_step")); + setRewardStep(rset.getInt("reward_step")); + setPremium(rset.getBoolean("is_paytowin")); + setPremiumRewardStep(rset.getInt("premium_reward_step")); + setAvailableSayhaTime(rset.getInt("sayha_points_available")); + setUsedSayhaTime(rset.getInt("sayha_points_used")); + setRewardAlert(rset.getBoolean("unclaimed_reward")); + } + rset.close(); + statement.close(); + } + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not restore Season Pass for playerId: " + _user.getAccountName()); + } + } + + public String getAccountName() + { + return _user.getAccountName(); + } + + public void store() + { + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement statement = con.prepareStatement(INSERT_SEASONPASS)) + { + statement.setString(1, getAccountName()); + statement.setInt(2, getCurrentStep()); + statement.setInt(3, getPoints()); + statement.setInt(4, getRewardStep()); + statement.setBoolean(5, isPremium()); + statement.setInt(6, getPremiumRewardStep()); + statement.setInt(7, getAvailableSayhaTime()); + statement.setInt(8, getUsedSayhaTime()); + statement.setBoolean(9, rewardAlert()); + statement.execute(); + statement.close(); + } + catch (SQLException e) + { + LOGGER.log(Level.SEVERE, "Could not store Season-Pass data for Account " + _user.getAccountName() + ": ", e); + } + } + + public void deleteHuntPass() + { + try (Connection con = DatabaseFactory.getConnection()) + { + PreparedStatement statement = con.prepareStatement("UPDATE huntpass SET current_step = ?, reward_step = ?, premium_reward_step = ?, sayha_points_available = ?, sayha_points_used = ? "); + statement.execute(); + statement.close(); + } + catch (SQLException e) + { + LOGGER.log(Level.WARNING, "HuntPass : Can't clear steps: " + e.getMessage(), e); + } + } + + public int getHuntPassDayEnd() + { + return _dayEnd; + } + + public void huntPassDayEnd() + { + final Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + calendar.set(Calendar.DAY_OF_MONTH, Config.HUNT_PASS_PERIOD); + calendar.set(Calendar.HOUR_OF_DAY, 6); + calendar.set(Calendar.MINUTE, 30); + if (calendar.getTimeInMillis() < System.currentTimeMillis()) + { + calendar.add(Calendar.MONTH, 1); + } + + _dayEnd = (int) (calendar.getTimeInMillis() / 1000); + } + + public boolean toggleSayha() + { + return _toggleSayha; + } + + public int getPoints() + { + return _points; + } + + public void addPassPoint(double point) // TODO: point is unused. + { + if (Config.ENABLE_HUNT_PASS) + { + final int seasonPasspoint = 1; + int calculate = seasonPasspoint + getPoints(); + if ((getPoints() == Config.HUNT_PASS_POINTS_FOR_STEP)) + { + calculate %= Config.HUNT_PASS_POINTS_FOR_STEP; + setCurrentStep(getCurrentStep() + 1); + setRewardAlert(true); + _user.sendPacket(new HuntPassSimpleInfo(_user)); + } + setPoints(calculate); + inTimeHuntingZone(calculate); + } + } + + public void inTimeHuntingZone(int points) // TODO: points is unused. + { + final boolean Inhuntingzone = _user.isInTimedHuntingZone(_user.getX(), _user.getY()); + if (Inhuntingzone) + { + _points += 1; + } + return; + } + + public void setPoints(int points) + { + _points = points; + } + + public int getCurrentStep() + { + return _currentStep; + } + + public void setCurrentStep(int step) + { + _currentStep = step; + } + + public int getRewardStep() + { + return _rewardStep; + } + + public void setRewardStep(int step) + { + if (_isPremium && (_premiumRewardStep <= _rewardStep)) + { + _rewardStep += 0; + } + else + { + _rewardStep = step; + } + } + + public boolean isPremium() + { + return _isPremium; + } + + public void setPremium(boolean premium) + { + _isPremium = premium; + } + + public int getPremiumRewardStep() + { + return _premiumRewardStep; + } + + public void setPremiumRewardStep(int step) + { + _premiumRewardStep = step; + } + + public boolean rewardAlert() + { + return _rewardAlert; + } + + public void setRewardAlert(boolean enable) + { + _rewardAlert = enable; + } + + public int getAvailableSayhaTime() + { + return _availableSayhaTime; + } + + public void setAvailableSayhaTime(int time) + { + _availableSayhaTime = time; + } + + public void addSayhaTime(int time) + { + // microsec to sec to database. 1 hour 3600 sec + _availableSayhaTime += time * 60; + } + + public int getUsedSayhaTime() + { + return _usedSayhaTime; + } + + private void onSayhaEndTime() + { + setSayhasSustention(false); + } + + public void setUsedSayhaTime(int time) + { + _usedSayhaTime = time; + } + + public void addSayhasSustentionTimeUsed(int time) + { + _usedSayhaTime += time; + } + + public int getToggleStartTime() + { + return _toggleStartTime; + } + + public void setSayhasSustention(boolean active) + { + _toggleSayha = active; + if (active) + { + _toggleStartTime = (int) (System.currentTimeMillis() / 1000); + if (_sayhasSustentionTask != null) + { + _sayhasSustentionTask.cancel(true); + _sayhasSustentionTask = null; + } + _user.sendPacket(new SystemMessage(SystemMessageId.SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_IS_ACTIVATED_AVAILABLE_SAYHA_S_GRACE_SUSTENTION_TIME_IS_RUNNING)); + _sayhasSustentionTask = ThreadPool.schedule(this::onSayhaEndTime, Math.max(0, getAvailableSayhaTime() - getUsedSayhaTime()) * 1000L); + } + else + { + if (_sayhasSustentionTask != null) + { + addSayhasSustentionTimeUsed((int) ((System.currentTimeMillis() / 1000) - _toggleStartTime)); + _toggleStartTime = 0; + _sayhasSustentionTask.cancel(true); + _sayhasSustentionTask = null; + _user.sendPacket(new SystemMessage(SystemMessageId.SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_IS_SWITCHED_OFF_AVAILABLE_SAYHA_S_GRACE_SUSTENTION_TIME_IS_NOT_RUNNING)); + } + } + } + +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/Party.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/Party.java index 9849d177ef..1df9b30157 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/Party.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/Party.java @@ -878,7 +878,9 @@ public class Party extends AbstractPlayerGroup if (clan != null) { double finalExp = exp; + if (target.useVitalityRate()) + { finalExp *= member.getStat().getExpBonusMultiplier(); } @@ -887,6 +889,12 @@ public class Party extends AbstractPlayerGroup member.updateVitalityPoints(target.getVitalityPoints(member.getLevel(), exp, target.isRaid()), true, false); PcCafePointsManager.getInstance().givePcCafePoint(member, exp); MagicLampData.getInstance().addLampExp(member, exp, true); + + final HuntPass huntpass = member.getHuntPass(); + if (huntpass != null) + { + huntpass.addPassPoint(exp); + } } } else diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Attackable.java index e2b366c103..aa536d2888 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -50,6 +50,7 @@ import org.l2jmobius.gameserver.model.AggroInfo; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.DamageDoneInfo; import org.l2jmobius.gameserver.model.ElementalSpirit; +import org.l2jmobius.gameserver.model.HuntPass; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.Seed; import org.l2jmobius.gameserver.model.WorldObject; @@ -613,6 +614,12 @@ public class Attackable extends Npc } PcCafePointsManager.getInstance().givePcCafePoint(attacker, exp); MagicLampData.getInstance().addLampExp(attacker, exp, true); + + final HuntPass huntPass = attacker.getHuntPass(); + if (huntPass != null) + { + attacker.getHuntPass().addPassPoint(exp); + } } } diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java index cf8ef436bb..2adc0c32d5 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -148,6 +148,7 @@ import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; import org.l2jmobius.gameserver.model.ElementalSpirit; +import org.l2jmobius.gameserver.model.HuntPass; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.Macro; import org.l2jmobius.gameserver.model.MacroList; @@ -944,6 +945,8 @@ public class Player extends Playable private final Map _purgePoints = new HashMap<>(); + private final HuntPass _huntPass; + private final Map _petEvolves = new HashMap<>(); private int _clanDonationPoints = 3; @@ -1226,6 +1229,8 @@ public class Player extends Playable app.setOwner(this); _appearance = app; + _huntPass = Config.ENABLE_HUNT_PASS ? new HuntPass(this) : null; + // Create an AI getAI(); @@ -1316,6 +1321,11 @@ public class Player extends Playable return PlayerTemplateData.getInstance().getTemplate(_baseClass); } + public HuntPass getHuntPass() + { + return _huntPass; + } + /** * @return the PlayerTemplate link to the Player. */ @@ -7268,6 +7278,11 @@ public class Player extends Playable { _randomCraft.store(); } + + if (_huntPass != null) + { + _huntPass.store(); + } } @Override @@ -12031,6 +12046,10 @@ public class Player extends Playable public void updateVitalityPoints(int points, boolean useRates, boolean quiet) { + if ((_huntPass != null) && _huntPass.toggleSayha()) + { + return; + } getStat().updateVitalityPoints(points, useRates, quiet); } diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 7420e4658b..54f3e56d20 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -88,6 +88,11 @@ import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUp import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo; import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter; import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.HuntpassSayhasToggle; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassBuyPremium; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassInfo; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassReward; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassRewardAll; import org.l2jmobius.gameserver.network.clientpackets.limitshop.RequestPurchaseLimitShopItemBuy; import org.l2jmobius.gameserver.network.clientpackets.limitshop.RequestPurchaseLimitShopItemList; import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay; @@ -723,11 +728,11 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ITEM_USABLE_LIST(0x21F, null, ConnectionState.IN_GAME), EX_PACKETREADCOUNTPERSECOND(0x220, null, ConnectionState.IN_GAME), EX_SELECT_GLOBAL_EVENT_UI(0x221, null, ConnectionState.IN_GAME), - EX_L2PASS_INFO(0x222, null, ConnectionState.IN_GAME), - EX_L2PASS_REQUEST_REWARD(0x2231, null, ConnectionState.IN_GAME), - EX_L2PASS_REQUEST_REWARD_ALL(0x224, null, ConnectionState.IN_GAME), - EX_L2PASS_BUY_PREMIUM(0x225, null, ConnectionState.IN_GAME), - EX_SAYHAS_SUPPORT_TOGGLE(0x226, null, ConnectionState.IN_GAME), + EX_L2PASS_INFO(0x222, RequestHuntPassInfo::new, ConnectionState.IN_GAME), + EX_L2PASS_REQUEST_REWARD(0x223, RequestHuntPassReward::new, ConnectionState.IN_GAME), + EX_L2PASS_REQUEST_REWARD_ALL(0x224, RequestHuntPassRewardAll::new, ConnectionState.IN_GAME), + EX_L2PASS_BUY_PREMIUM(0x225, RequestHuntPassBuyPremium::new, ConnectionState.IN_GAME), + EX_SAYHAS_SUPPORT_TOGGLE(0x226, HuntpassSayhasToggle::new, ConnectionState.IN_GAME), EX_MAX(0x227, null, ConnectionState.IN_GAME); public static final ExIncomingPackets[] PACKET_ARRAY; diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index e3c6f5c1af..9fd31bb0b5 100644 --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -117,6 +117,7 @@ import org.l2jmobius.gameserver.network.serverpackets.collection.ExCollectionInf import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExConnectedTimeAndGettableReward; import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList; import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI; import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeContributionList; @@ -668,6 +669,11 @@ public class EnterWorld implements IClientIncomingPacket player.sendPacket(new ExCraftInfo(player)); } + if (Config.ENABLE_HUNT_PASS) + { + player.sendPacket(new HuntPassSimpleInfo(player)); + } + for (int category = 1; category <= 7; category++) { player.sendPacket(new ExCollectionInfo(player, category)); diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/HuntpassSayhasToggle.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/HuntpassSayhasToggle.java new file mode 100644 index 0000000000..8584c63888 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/HuntpassSayhasToggle.java @@ -0,0 +1,73 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; + +public class HuntpassSayhasToggle implements IClientIncomingPacket +{ + private boolean _sayhaToggle; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _sayhaToggle = packet.readC() != 0; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final HuntPass huntPass = player.getHuntPass(); + if (huntPass == null) + { + return; + } + + int timeEarned = huntPass.getAvailableSayhaTime(); + int timeUsed = huntPass.getUsedSayhaTime(); + if (player.getVitalityPoints() < 35000) + { + player.sendPacket(new SystemMessage(SystemMessageId.THE_CONDITIONS_ARE_NOT_MET_ACTIVATION_IS_IMPOSSIBLE_SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_IS_AVAILABLE_ONLY_IF_YOU_HAVE_MORE_THAN_35_000_SAYHA_S_GRACE_POINTS)); + return; + } + + if (_sayhaToggle && (timeEarned > 0) && (timeEarned > timeUsed)) + { + huntPass.setSayhasSustention(true); + } + else + { + huntPass.setSayhasSustention(false); + } + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + } + +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassBuyPremium.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassBuyPremium.java new file mode 100644 index 0000000000..d9b08aa39a --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassBuyPremium.java @@ -0,0 +1,71 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import java.util.Calendar; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassBuyPremium implements IClientIncomingPacket +{ + private int _huntPassType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _huntPassType = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final Calendar calendar = Calendar.getInstance(); + if ((calendar.get(Calendar.DAY_OF_MONTH) == Config.HUNT_PASS_PERIOD) && (calendar.get(Calendar.HOUR_OF_DAY) == 6) && (calendar.get(Calendar.MINUTE) < 30)) + { + player.sendPacket(new SystemMessage(SystemMessageId.THIS_SERVICE_CANNOT_BE_PURCHASED_AT_THE_MOMENT_SEASON_PASS_PREMIUM_SERVICES_IS_AVAILABLE_FOR_PURCHASE_BEFORE_6_30_A_M_ON_THE_BEFORE_THE_SEASON_END)); + return; + } + + if (!player.destroyItemByItemId("L-Coin", 91663, Config.HUNT_PASS_PREMIUM_COST, player, true)) + { + player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_MONEY_TO_USE_THE_FUNCTION)); + return; + } + + player.getHuntPass().setPremium(true); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + player.sendPacket(new HuntPassInfo(player, _huntPassType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassInfo.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassInfo.java new file mode 100644 index 0000000000..31d2ed8e32 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassInfo.java @@ -0,0 +1,52 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassInfo implements IClientIncomingPacket +{ + private int _passType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _passType = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.sendPacket(new HuntPassInfo(player, _passType)); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassReward.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassReward.java new file mode 100644 index 0000000000..e02b311b09 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassReward.java @@ -0,0 +1,115 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.data.ItemTable; +import org.l2jmobius.gameserver.data.xml.HuntPassData; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.ItemHolder; +import org.l2jmobius.gameserver.model.item.ItemTemplate; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassReward implements IClientIncomingPacket +{ + private int _huntPassType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _huntPassType = packet.readC(); + packet.readC(); // is Premium? + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final HuntPass huntPass = player.getHuntPass(); + final int normalReward = huntPass.getRewardStep(); + final ItemHolder reward = HuntPassData.getInstance().getRewards().get(normalReward); + final ItemTemplate itemTemplate = ItemTable.getInstance().getTemplate(reward.getId()); + + final long weight = itemTemplate.getWeight() * reward.getCount(); + final long slots = itemTemplate.isStackable() ? 1 : reward.getCount(); + if (!player.getInventory().validateWeight(weight) || !player.getInventory().validateCapacity(slots)) + { + player.sendPacket(new SystemMessage(SystemMessageId.YOUR_INVENTORY_S_WEIGHT_LIMIT_HAS_BEEN_EXCEEDED_SO_YOU_CAN_T_RECEIVE_THE_REWARD_PLEASE_FREE_UP_SOME_SPACE_AND_TRY_AGAIN)); + return; + } + + updateSayhaTime(player); + premiumReward(player); + huntPass.setRewardStep(normalReward + 1); + huntPass.setRewardAlert(false); + player.sendPacket(new HuntPassInfo(player, _huntPassType)); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + player.sendPacket(new HuntPassSimpleInfo(player)); + } + + private void updateSayhaTime(Player player) + { + final HuntPass huntpass = player.getHuntPass(); + final int normalreward = huntpass.getRewardStep(); + final int premiumreward = huntpass.getPremiumRewardStep(); + final ItemHolder reward = HuntPassData.getInstance().getRewards().get(normalreward); + + final int sayhaPoints = 0; // TODO: 0? + final long count = reward.getCount(); + final int calc = (int) (sayhaPoints + count); + final boolean isPremium = huntpass.isPremium(); + if (isPremium && (premiumreward < normalreward)) + { + return; + } + + huntpass.addSayhaTime(calc); + player.addItem("HuntPassReward", reward, player, true); + final SystemMessage msg = new SystemMessage(SystemMessageId.SAYHA_S_GRACE_SUSTENTION_POINTS_RECEIVED_S1); + msg.addInt((int) (count)); + player.sendPacket(msg); + } + + private void premiumReward(Player player) + { + final HuntPass huntPass = player.getHuntPass(); + final int rewardStep = huntPass.getPremiumRewardStep(); + final ItemHolder premiumReward = HuntPassData.getInstance().getPremiumRewards().get(rewardStep); + final boolean isPremium = huntPass.isPremium(); + if (isPremium) + { + player.addItem("SeasonPassReward", premiumReward, player, true); + huntPass.setPremiumRewardStep(rewardStep + 1); + } + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassRewardAll.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassRewardAll.java new file mode 100644 index 0000000000..5530b31981 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassRewardAll.java @@ -0,0 +1,54 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassRewardAll implements IClientIncomingPacket +{ + private int _huntPassType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _huntPassType = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.sendPacket(new HuntPassInfo(player, _huntPassType)); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + player.sendPacket(new HuntPassSimpleInfo(player)); + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassInfo.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassInfo.java new file mode 100644 index 0000000000..0f6371c103 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassInfo.java @@ -0,0 +1,66 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.serverpackets.huntpass; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Serenitty + */ +public class HuntPassInfo implements IClientOutgoingPacket +{ + private final int _interfaceType; + private final HuntPass _huntPass; + private final int _timeEnd; + private final int _isPremium; + private final int _points; + private final int _step; + private final int _rewardStep; + private final int _premiumRewardStep; + + public HuntPassInfo(Player player, int interfaceType) + { + + _interfaceType = interfaceType; + _huntPass = player.getHuntPass(); + _timeEnd = _huntPass.getHuntPassDayEnd(); + _isPremium = _huntPass.isPremium() ? 1 : 0; + _points = _huntPass.getPoints(); + _step = _huntPass.getCurrentStep(); + _rewardStep = _huntPass.getRewardStep(); + _premiumRewardStep = _huntPass.getPremiumRewardStep(); + + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_L2PASS_INFO.writeId(packet); + packet.writeC(_interfaceType); + packet.writeD(_timeEnd); // LeftTime + packet.writeC(_isPremium); // Premium + packet.writeD(_points); // Points + packet.writeD(_step); // CurrentStep + packet.writeD(_rewardStep); // Reward + packet.writeD(_premiumRewardStep); // PremiumReward + return true; + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSayhasSupportInfo.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSayhasSupportInfo.java new file mode 100644 index 0000000000..ef690a8fe9 --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSayhasSupportInfo.java @@ -0,0 +1,50 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.serverpackets.huntpass; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Serenitty + */ +public class HuntPassSayhasSupportInfo implements IClientOutgoingPacket +{ + private final HuntPass _huntPass; + private final int _timeUsed; + private final boolean _sayhaToggle; + + public HuntPassSayhasSupportInfo(Player player) + { + _huntPass = player.getHuntPass(); + _sayhaToggle = _huntPass.toggleSayha(); + _timeUsed = _huntPass.getUsedSayhaTime() + (int) (_huntPass.getToggleStartTime() > 0 ? (System.currentTimeMillis() / 1000) - _huntPass.getToggleStartTime() : 0); + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_SAYHAS_SUPPORT_INFO.writeId(packet); + packet.writeC(_sayhaToggle ? 1 : 0); + packet.writeD(_huntPass.getAvailableSayhaTime()); + packet.writeD(_timeUsed); + return true; + } +} diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSimpleInfo.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSimpleInfo.java new file mode 100644 index 0000000000..c380234e3e --- /dev/null +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSimpleInfo.java @@ -0,0 +1,50 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.serverpackets.huntpass; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Serenitty + */ +public class HuntPassSimpleInfo implements IClientOutgoingPacket +{ + private final HuntPass _huntPassInfo; + + public HuntPassSimpleInfo(Player player) + { + _huntPassInfo = player.getHuntPass(); + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_L2PASS_SIMPLE_INFO.writeId(packet); + + packet.writeD(1); // passInfos + packet.writeC(0); + packet.writeC(1); // isOn + + packet.writeC(_huntPassInfo.rewardAlert() ? 1 : 0); + packet.writeD(0); + return true; + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/db_installer/sql/game/huntpass.sql b/L2J_Mobius_Essence_6.2_Vanguard/dist/db_installer/sql/game/huntpass.sql new file mode 100644 index 0000000000..737b879bf2 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/db_installer/sql/game/huntpass.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS `huntpass`; +CREATE TABLE IF NOT EXISTS `huntpass` ( + `account_name` VARCHAR(45) NOT NULL DEFAULT '', + `current_step` INT NOT NULL DEFAULT 0, + `points` INT NOT NULL DEFAULT 0, + `reward_step` INT NOT NULL DEFAULT 0, + `is_paytowin` BOOLEAN NOT NULL DEFAULT FALSE, + `premium_reward_step` INT NOT NULL DEFAULT 0, + `sayha_points_available` INT NOT NULL DEFAULT 0, + `sayha_points_used` INT NOT NULL DEFAULT 0, + `unclaimed_reward` BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (`account_name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/HuntPass.ini b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/HuntPass.ini new file mode 100644 index 0000000000..c1cac51f14 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/config/HuntPass.ini @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# HuntPass Settings +# -------------------------------------------------------------------------- +EnabledHuntPass = False + +# Period to end. +# Retail 1 month. +DayOfMonth = 16 + +# Pass Premium Cost. +# Retail is 3600 L-Coin. +PremiumCost = 3600 + +# Please take caution when changing anything. +# Required Points per Window or step. +PointsForstep = 2400 diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/HuntPass.xml b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/HuntPass.xml new file mode 100644 index 0000000000..9ee6b46215 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/HuntPass.xml @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/EffectMasterHandler.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/EffectMasterHandler.java index 5478f3cf7f..e342190034 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/EffectMasterHandler.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/EffectMasterHandler.java @@ -191,6 +191,7 @@ public class EffectMasterHandler EffectHandler.getInstance().registerHandler("HpLimit", HpLimit::new); EffectHandler.getInstance().registerHandler("HpRegen", HpRegen::new); EffectHandler.getInstance().registerHandler("HpToOwner", HpToOwner::new); + EffectHandler.getInstance().registerHandler("HuntPassPoints", HuntPassPoints::new); EffectHandler.getInstance().registerHandler("IgnoreDeath", IgnoreDeath::new); EffectHandler.getInstance().registerHandler("ImmobileDamageBonus", ImmobileDamageBonus::new); EffectHandler.getInstance().registerHandler("ImmobileDamageResist", ImmobileDamageResist::new); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/HuntPassPoints.java b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/HuntPassPoints.java new file mode 100644 index 0000000000..1734211321 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/scripts/handlers/effecthandlers/HuntPassPoints.java @@ -0,0 +1,65 @@ +/* + * 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 . + */ +package handlers.effecthandlers; + +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.actor.Creature; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; +import org.l2jmobius.gameserver.model.item.instance.Item; +import org.l2jmobius.gameserver.model.skill.Skill; + +/** + * @author Serenitty + */ +public class HuntPassPoints extends AbstractEffect +{ + private final int _amount; + + public HuntPassPoints(StatSet params) + { + _amount = params.getInt("amount"); + } + + @Override + public boolean isInstant() + { + return true; + } + + @Override + public void instant(Creature effector, Creature effected, Skill skill, Item item) + { + if (effected == null) + { + return; + } + + final Player player = effected.getActingPlayer(); + if (player == null) + { + return; + } + + final HuntPass huntpass = player.getHuntPass(); + if (huntpass != null) + { + huntpass.addPassPoint(_amount); + } + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/items/72200-72299.xml b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/items/72200-72299.xml index d92c90a4af..c84a1525a6 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/items/72200-72299.xml +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/items/72200-72299.xml @@ -312,6 +312,7 @@ + diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/skills/documentation.txt b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/skills/documentation.txt index 8eb58042d8..222cfb0c5f 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/skills/documentation.txt +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/stats/skills/documentation.txt @@ -162,6 +162,7 @@ Hp: Increases current HP by a static value. HpLimit: Increase a character's max hp limit (l2jmobius) HpRegen: HP Regeneration stat. HpToOwner: DOT effect that absorbs HP over time. +HuntPassPoints: Modify HuntPass points. (l2jmobius) IgnoreDeath: Become undying. Hp cannot decrease below 1. ImmobileDamageBonus: Bonus damage to immobile targets. (l2jmobius) ImmobileDamageResist: Resist damage while immobile. (l2jmobius) diff --git a/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/xsd/HuntPass.xsd b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/xsd/HuntPass.xsd new file mode 100644 index 0000000000..1e63b87cf0 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/dist/game/data/xsd/HuntPass.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java index 652704404c..0f3c9ff517 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/Config.java @@ -99,6 +99,7 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; + private static final String HUNT_PASS_CONFIG_FILE = "./config/HuntPass.ini"; private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; @@ -904,6 +905,12 @@ public class Config public static int RANDOM_CRAFT_CREATE_FEE; public static boolean DROP_RANDOM_CRAFT_MATERIALS; + // HuntPass + public static boolean ENABLE_HUNT_PASS; + public static int HUNT_PASS_PERIOD; + public static int HUNT_PASS_PREMIUM_COST; + public static int HUNT_PASS_POINTS_FOR_STEP; + // GrandBoss Settings // Antharas @@ -2501,6 +2508,13 @@ public class Config ZAKEN_SPAWN_INTERVAL = grandBossConfig.getInt("IntervalOfZakenSpawn", 168); ZAKEN_SPAWN_RANDOM = grandBossConfig.getInt("RandomOfZakenSpawn", 48); + // Load HuntPass (if exists) + final PropertiesParser huntPassConfig = new PropertiesParser(HUNT_PASS_CONFIG_FILE); + ENABLE_HUNT_PASS = huntPassConfig.getBoolean("EnabledHuntPass", true); + HUNT_PASS_PREMIUM_COST = huntPassConfig.getInt("PremiumCost", 3600); + HUNT_PASS_POINTS_FOR_STEP = huntPassConfig.getInt("PointsForstep", 2400); + HUNT_PASS_PERIOD = huntPassConfig.getInt("DayOfMonth", 1); + // Gracia Seeds final PropertiesParser graciaSeedsConfig = new PropertiesParser(GRACIASEEDS_CONFIG_FILE); SOD_TIAT_KILL_COUNT = graciaSeedsConfig.getInt("TiatKillCountForNextState", 10); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/data/xml/HuntPassData.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/data/xml/HuntPassData.java new file mode 100644 index 0000000000..078f9012c9 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/data/xml/HuntPassData.java @@ -0,0 +1,115 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.data.xml; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.w3c.dom.Document; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.util.IXmlReader; +import org.l2jmobius.gameserver.data.ItemTable; +import org.l2jmobius.gameserver.model.StatSet; +import org.l2jmobius.gameserver.model.holders.ItemHolder; + +/** + * @author Serenitty + */ +public class HuntPassData implements IXmlReader +{ + private static final Logger LOGGER = Logger.getLogger(HuntPassData.class.getName()); + private final List _rewards = new ArrayList<>(); + private final List _premiumRewards = new ArrayList<>(); + private int _rewardCount = 0; + private final int _premiumRewardCount = 0; + + protected HuntPassData() + { + load(); + } + + @Override + public void load() + { + if (Config.ENABLE_HUNT_PASS) + { + _rewards.clear(); + parseDatapackFile("data/HuntPass.xml"); + _rewardCount = _rewards.size(); + LOGGER.info(getClass().getSimpleName() + ": Loaded " + _rewardCount + " HuntPass rewards."); + } + else + { + LOGGER.info(getClass().getSimpleName() + ": Disabled."); + } + } + + @Override + public void parseDocument(Document doc, File f) + { + forEach(doc, "list", listNode -> forEach(listNode, "item", rewardNode -> + { + final StatSet set = new StatSet(parseAttributes(rewardNode)); + final int itemId = set.getInt("id"); + final int itemCount = set.getInt("count"); + final int premiumitemId = set.getInt("premiumId"); + final int premiumitemCount = set.getInt("premiumCount"); + if (ItemTable.getInstance().getTemplate(itemId) == null) + { + LOGGER.info(getClass().getSimpleName() + ": Item with id " + itemId + " does not exist."); + } + else + { + _rewards.add(new ItemHolder(itemId, itemCount)); + _premiumRewards.add(new ItemHolder(premiumitemId, premiumitemCount)); + } + })); + } + + public List getRewards() + { + return _rewards; + } + + public int getRewardsCount() + { + return _rewardCount; + } + + public List getPremiumRewards() + { + return _premiumRewards; + } + + public int getPremiumRewardsCount() + { + return _premiumRewardCount; + } + + public static HuntPassData getInstance() + { + return SingletonHolder.INSTANCE; + } + + private static class SingletonHolder + { + protected static final HuntPassData INSTANCE = new HuntPassData(); + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/HuntPass.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/HuntPass.java new file mode 100644 index 0000000000..2cc03af3ce --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/HuntPass.java @@ -0,0 +1,334 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Calendar; +import java.util.concurrent.ScheduledFuture; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.database.DatabaseFactory; +import org.l2jmobius.commons.threads.ThreadPool; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; + +/** + * @author Serenitty + */ +public class HuntPass +{ + private static final Logger LOGGER = Logger.getLogger(HuntPass.class.getName()); + private static final String INSERT_SEASONPASS = "REPLACE INTO huntpass (`account_name`, `current_step`, `points`, `reward_step`, `is_paytowin`, `premium_reward_step`, `sayha_points_available`, `sayha_points_used`, `unclaimed_reward`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; + private static final String RESTORE_SEASONPASS = "SELECT * FROM huntpass WHERE account_name=?"; + + private final Player _user; + private int _availableSayhaTime; + private int _points; + private boolean _isPremium = false; + private boolean _rewardAlert = false; + + private int _rewardStep; + private int _currentStep; + private int _premiumRewardStep; + + private boolean _toggleSayha = false; + private ScheduledFuture _sayhasSustentionTask = null; + private int _toggleStartTime = 0; + private int _usedSayhaTime; + + private static int _dayEnd = 0; + + public HuntPass(Player user) + { + _user = user; + restoreHuntPass(); + huntPassDayEnd(); + store(); + } + + public void restoreHuntPass() + { + final Calendar calendar = Calendar.getInstance(); + if ((calendar.get(Calendar.DAY_OF_MONTH) == Config.HUNT_PASS_PERIOD) && (calendar.get(Calendar.HOUR_OF_DAY) == 6) && (calendar.get(Calendar.MINUTE) == 30)) + { + deleteHuntPass(); + } + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement statement = con.prepareStatement(RESTORE_SEASONPASS)) + { + statement.setString(1, getAccountName()); + try (ResultSet rset = statement.executeQuery()) + { + if (rset.next()) + { + setPoints(rset.getInt("points")); + setCurrentStep(rset.getInt("current_step")); + setRewardStep(rset.getInt("reward_step")); + setPremium(rset.getBoolean("is_paytowin")); + setPremiumRewardStep(rset.getInt("premium_reward_step")); + setAvailableSayhaTime(rset.getInt("sayha_points_available")); + setUsedSayhaTime(rset.getInt("sayha_points_used")); + setRewardAlert(rset.getBoolean("unclaimed_reward")); + } + rset.close(); + statement.close(); + } + } + catch (Exception e) + { + LOGGER.log(Level.SEVERE, "Could not restore Season Pass for playerId: " + _user.getAccountName()); + } + } + + public String getAccountName() + { + return _user.getAccountName(); + } + + public void store() + { + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement statement = con.prepareStatement(INSERT_SEASONPASS)) + { + statement.setString(1, getAccountName()); + statement.setInt(2, getCurrentStep()); + statement.setInt(3, getPoints()); + statement.setInt(4, getRewardStep()); + statement.setBoolean(5, isPremium()); + statement.setInt(6, getPremiumRewardStep()); + statement.setInt(7, getAvailableSayhaTime()); + statement.setInt(8, getUsedSayhaTime()); + statement.setBoolean(9, rewardAlert()); + statement.execute(); + statement.close(); + } + catch (SQLException e) + { + LOGGER.log(Level.SEVERE, "Could not store Season-Pass data for Account " + _user.getAccountName() + ": ", e); + } + } + + public void deleteHuntPass() + { + try (Connection con = DatabaseFactory.getConnection()) + { + PreparedStatement statement = con.prepareStatement("UPDATE huntpass SET current_step = ?, reward_step = ?, premium_reward_step = ?, sayha_points_available = ?, sayha_points_used = ? "); + statement.execute(); + statement.close(); + } + catch (SQLException e) + { + LOGGER.log(Level.WARNING, "HuntPass : Can't clear steps: " + e.getMessage(), e); + } + } + + public int getHuntPassDayEnd() + { + return _dayEnd; + } + + public void huntPassDayEnd() + { + final Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + calendar.set(Calendar.DAY_OF_MONTH, Config.HUNT_PASS_PERIOD); + calendar.set(Calendar.HOUR_OF_DAY, 6); + calendar.set(Calendar.MINUTE, 30); + if (calendar.getTimeInMillis() < System.currentTimeMillis()) + { + calendar.add(Calendar.MONTH, 1); + } + + _dayEnd = (int) (calendar.getTimeInMillis() / 1000); + } + + public boolean toggleSayha() + { + return _toggleSayha; + } + + public int getPoints() + { + return _points; + } + + public void addPassPoint(double point) // TODO: point is unused. + { + if (Config.ENABLE_HUNT_PASS) + { + final int seasonPasspoint = 1; + int calculate = seasonPasspoint + getPoints(); + if ((getPoints() == Config.HUNT_PASS_POINTS_FOR_STEP)) + { + calculate %= Config.HUNT_PASS_POINTS_FOR_STEP; + setCurrentStep(getCurrentStep() + 1); + setRewardAlert(true); + _user.sendPacket(new HuntPassSimpleInfo(_user)); + } + setPoints(calculate); + inTimeHuntingZone(calculate); + } + } + + public void inTimeHuntingZone(int points) // TODO: points is unused. + { + final boolean Inhuntingzone = _user.isInTimedHuntingZone(_user.getX(), _user.getY()); + if (Inhuntingzone) + { + _points += 1; + } + return; + } + + public void setPoints(int points) + { + _points = points; + } + + public int getCurrentStep() + { + return _currentStep; + } + + public void setCurrentStep(int step) + { + _currentStep = step; + } + + public int getRewardStep() + { + return _rewardStep; + } + + public void setRewardStep(int step) + { + if (_isPremium && (_premiumRewardStep <= _rewardStep)) + { + _rewardStep += 0; + } + else + { + _rewardStep = step; + } + } + + public boolean isPremium() + { + return _isPremium; + } + + public void setPremium(boolean premium) + { + _isPremium = premium; + } + + public int getPremiumRewardStep() + { + return _premiumRewardStep; + } + + public void setPremiumRewardStep(int step) + { + _premiumRewardStep = step; + } + + public boolean rewardAlert() + { + return _rewardAlert; + } + + public void setRewardAlert(boolean enable) + { + _rewardAlert = enable; + } + + public int getAvailableSayhaTime() + { + return _availableSayhaTime; + } + + public void setAvailableSayhaTime(int time) + { + _availableSayhaTime = time; + } + + public void addSayhaTime(int time) + { + // microsec to sec to database. 1 hour 3600 sec + _availableSayhaTime += time * 60; + } + + public int getUsedSayhaTime() + { + return _usedSayhaTime; + } + + private void onSayhaEndTime() + { + setSayhasSustention(false); + } + + public void setUsedSayhaTime(int time) + { + _usedSayhaTime = time; + } + + public void addSayhasSustentionTimeUsed(int time) + { + _usedSayhaTime += time; + } + + public int getToggleStartTime() + { + return _toggleStartTime; + } + + public void setSayhasSustention(boolean active) + { + _toggleSayha = active; + if (active) + { + _toggleStartTime = (int) (System.currentTimeMillis() / 1000); + if (_sayhasSustentionTask != null) + { + _sayhasSustentionTask.cancel(true); + _sayhasSustentionTask = null; + } + _user.sendPacket(new SystemMessage(SystemMessageId.SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_IS_ACTIVATED_AVAILABLE_SAYHA_S_GRACE_SUSTENTION_TIME_IS_RUNNING)); + _sayhasSustentionTask = ThreadPool.schedule(this::onSayhaEndTime, Math.max(0, getAvailableSayhaTime() - getUsedSayhaTime()) * 1000L); + } + else + { + if (_sayhasSustentionTask != null) + { + addSayhasSustentionTimeUsed((int) ((System.currentTimeMillis() / 1000) - _toggleStartTime)); + _toggleStartTime = 0; + _sayhasSustentionTask.cancel(true); + _sayhasSustentionTask = null; + _user.sendPacket(new SystemMessage(SystemMessageId.SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_HAS_BEEN_DEACTIVATED_THE_SUSTENTION_TIME_YOU_HAVE_DOES_NOT_DECREASE)); + } + } + } + +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/Party.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/Party.java index 9849d177ef..1df9b30157 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/Party.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/Party.java @@ -878,7 +878,9 @@ public class Party extends AbstractPlayerGroup if (clan != null) { double finalExp = exp; + if (target.useVitalityRate()) + { finalExp *= member.getStat().getExpBonusMultiplier(); } @@ -887,6 +889,12 @@ public class Party extends AbstractPlayerGroup member.updateVitalityPoints(target.getVitalityPoints(member.getLevel(), exp, target.isRaid()), true, false); PcCafePointsManager.getInstance().givePcCafePoint(member, exp); MagicLampData.getInstance().addLampExp(member, exp, true); + + final HuntPass huntpass = member.getHuntPass(); + if (huntpass != null) + { + huntpass.addPassPoint(exp); + } } } else diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Attackable.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Attackable.java index e2b366c103..aa536d2888 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Attackable.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/model/actor/Attackable.java @@ -50,6 +50,7 @@ import org.l2jmobius.gameserver.model.AggroInfo; import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.DamageDoneInfo; import org.l2jmobius.gameserver.model.ElementalSpirit; +import org.l2jmobius.gameserver.model.HuntPass; import org.l2jmobius.gameserver.model.Party; import org.l2jmobius.gameserver.model.Seed; import org.l2jmobius.gameserver.model.WorldObject; @@ -613,6 +614,12 @@ public class Attackable extends Npc } PcCafePointsManager.getInstance().givePcCafePoint(attacker, exp); MagicLampData.getInstance().addLampExp(attacker, exp, true); + + final HuntPass huntPass = attacker.getHuntPass(); + if (huntPass != null) + { + attacker.getHuntPass().addPassPoint(exp); + } } } 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 dac22b7d2e..bc8ab856ef 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 @@ -148,6 +148,7 @@ import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.ContactList; import org.l2jmobius.gameserver.model.Duel; import org.l2jmobius.gameserver.model.ElementalSpirit; +import org.l2jmobius.gameserver.model.HuntPass; import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.Macro; import org.l2jmobius.gameserver.model.MacroList; @@ -949,6 +950,8 @@ public class Player extends Playable private final Map _purgePoints = new HashMap<>(); + private final HuntPass _huntPass; + private final Map _petEvolves = new HashMap<>(); private int _clanDonationPoints = 3; @@ -1231,6 +1234,8 @@ public class Player extends Playable app.setOwner(this); _appearance = app; + _huntPass = Config.ENABLE_HUNT_PASS ? new HuntPass(this) : null; + // Create an AI getAI(); @@ -1321,6 +1326,11 @@ public class Player extends Playable return PlayerTemplateData.getInstance().getTemplate(_baseClass); } + public HuntPass getHuntPass() + { + return _huntPass; + } + /** * @return the PlayerTemplate link to the Player. */ @@ -7277,6 +7287,11 @@ public class Player extends Playable { _randomCraft.store(); } + + if (_huntPass != null) + { + _huntPass.store(); + } } @Override @@ -12084,6 +12099,10 @@ public class Player extends Playable public void updateVitalityPoints(int points, boolean useRates, boolean quiet) { + if ((_huntPass != null) && _huntPass.toggleSayha()) + { + return; + } getStat().updateVitalityPoints(points, useRates, quiet); } diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java index 67cd31726c..9bdf7ad57c 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/ExIncomingPackets.java @@ -99,6 +99,11 @@ import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUp import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo; import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter; import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.HuntpassSayhasToggle; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassBuyPremium; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassInfo; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassReward; +import org.l2jmobius.gameserver.network.clientpackets.huntpass.RequestHuntPassRewardAll; import org.l2jmobius.gameserver.network.clientpackets.limitshop.RequestPurchaseLimitShopItemBuy; import org.l2jmobius.gameserver.network.clientpackets.limitshop.RequestPurchaseLimitShopItemList; import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay; @@ -740,11 +745,11 @@ public enum ExIncomingPackets implements IIncomingPackets EX_ITEM_USABLE_LIST(0x21F, null, ConnectionState.IN_GAME), EX_PACKETREADCOUNTPERSECOND(0x220, null, ConnectionState.IN_GAME), EX_SELECT_GLOBAL_EVENT_UI(0x221, null, ConnectionState.IN_GAME), - EX_L2PASS_INFO(0x222, null, ConnectionState.IN_GAME), - EX_L2PASS_REQUEST_REWARD(0x223, null, ConnectionState.IN_GAME), - EX_L2PASS_REQUEST_REWARD_ALL(0x224, null, ConnectionState.IN_GAME), - EX_L2PASS_BUY_PREMIUM(0x225, null, ConnectionState.IN_GAME), - EX_SAYHAS_SUPPORT_TOGGLE(0x226, null, ConnectionState.IN_GAME), + EX_L2PASS_INFO(0x222, RequestHuntPassInfo::new, ConnectionState.IN_GAME), + EX_L2PASS_REQUEST_REWARD(0x223, RequestHuntPassReward::new, ConnectionState.IN_GAME), + EX_L2PASS_REQUEST_REWARD_ALL(0x224, RequestHuntPassRewardAll::new, ConnectionState.IN_GAME), + EX_L2PASS_BUY_PREMIUM(0x225, RequestHuntPassBuyPremium::new, ConnectionState.IN_GAME), + EX_SAYHAS_SUPPORT_TOGGLE(0x226, HuntpassSayhasToggle::new, ConnectionState.IN_GAME), // 362 EX_REQ_ENCHANT_FAIL_REWARD_INFO(0x227, ExRequestEnchantFailRewardInfo::new, ConnectionState.IN_GAME), EX_SET_ENCHANT_CHALLENGE_POINT(0x228, null, ConnectionState.IN_GAME), diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java index 6494ae921e..3d9266d4bd 100644 --- a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java @@ -117,6 +117,7 @@ import org.l2jmobius.gameserver.network.serverpackets.collection.ExCollectionInf import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExConnectedTimeAndGettableReward; import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList; import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI; import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeContributionList; @@ -674,6 +675,11 @@ public class EnterWorld implements IClientIncomingPacket player.sendPacket(new ExCraftInfo(player)); } + if (Config.ENABLE_HUNT_PASS) + { + player.sendPacket(new HuntPassSimpleInfo(player)); + } + for (int category = 1; category <= 7; category++) { player.sendPacket(new ExCollectionInfo(player, category)); diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/HuntpassSayhasToggle.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/HuntpassSayhasToggle.java new file mode 100644 index 0000000000..a6c195932f --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/HuntpassSayhasToggle.java @@ -0,0 +1,73 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; + +public class HuntpassSayhasToggle implements IClientIncomingPacket +{ + private boolean _sayhaToggle; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _sayhaToggle = packet.readC() != 0; + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final HuntPass huntPass = player.getHuntPass(); + if (huntPass == null) + { + return; + } + + int timeEarned = huntPass.getAvailableSayhaTime(); + int timeUsed = huntPass.getUsedSayhaTime(); + if (player.getVitalityPoints() < 35000) + { + player.sendPacket(new SystemMessage(SystemMessageId.UNABLE_TO_ACTIVATE_YOU_CAN_USE_SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_ONLY_IF_YOU_HAVE_AT_LEAST_35_000_SAYHA_S_GRACE_POINTS)); + return; + } + + if (_sayhaToggle && (timeEarned > 0) && (timeEarned > timeUsed)) + { + huntPass.setSayhasSustention(true); + } + else + { + huntPass.setSayhasSustention(false); + } + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + } + +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassBuyPremium.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassBuyPremium.java new file mode 100644 index 0000000000..9c52016fc8 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassBuyPremium.java @@ -0,0 +1,71 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import java.util.Calendar; + +import org.l2jmobius.Config; +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassBuyPremium implements IClientIncomingPacket +{ + private int _huntPassType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _huntPassType = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final Calendar calendar = Calendar.getInstance(); + if ((calendar.get(Calendar.DAY_OF_MONTH) == Config.HUNT_PASS_PERIOD) && (calendar.get(Calendar.HOUR_OF_DAY) == 6) && (calendar.get(Calendar.MINUTE) < 30)) + { + player.sendPacket(new SystemMessage(SystemMessageId.CURRENTLY_UNAVAILABLE_FOR_PURCHASE_YOU_CAN_BUY_THE_SEASON_PASS_ADDITIONAL_REWARDS_ONLY_UNTIL_6_30_A_M_OF_THE_SEASON_S_LAST_DAY)); + return; + } + + if (!player.destroyItemByItemId("L-Coin", 91663, Config.HUNT_PASS_PREMIUM_COST, player, true)) + { + player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_MONEY_TO_USE_THE_FUNCTION)); + return; + } + + player.getHuntPass().setPremium(true); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + player.sendPacket(new HuntPassInfo(player, _huntPassType)); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassInfo.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassInfo.java new file mode 100644 index 0000000000..31d2ed8e32 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassInfo.java @@ -0,0 +1,52 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassInfo implements IClientIncomingPacket +{ + private int _passType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _passType = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.sendPacket(new HuntPassInfo(player, _passType)); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassReward.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassReward.java new file mode 100644 index 0000000000..3f5cd54f58 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassReward.java @@ -0,0 +1,115 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.data.ItemTable; +import org.l2jmobius.gameserver.data.xml.HuntPassData; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.model.holders.ItemHolder; +import org.l2jmobius.gameserver.model.item.ItemTemplate; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassReward implements IClientIncomingPacket +{ + private int _huntPassType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _huntPassType = packet.readC(); + packet.readC(); // is Premium? + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + final HuntPass huntPass = player.getHuntPass(); + final int normalReward = huntPass.getRewardStep(); + final ItemHolder reward = HuntPassData.getInstance().getRewards().get(normalReward); + final ItemTemplate itemTemplate = ItemTable.getInstance().getTemplate(reward.getId()); + + final long weight = itemTemplate.getWeight() * reward.getCount(); + final long slots = itemTemplate.isStackable() ? 1 : reward.getCount(); + if (!player.getInventory().validateWeight(weight) || !player.getInventory().validateCapacity(slots)) + { + player.sendPacket(new SystemMessage(SystemMessageId.YOUR_INVENTORY_S_WEIGHT_LIMIT_HAS_BEEN_EXCEEDED_SO_YOU_CAN_T_RECEIVE_THE_REWARD_PLEASE_FREE_UP_SOME_SPACE_AND_TRY_AGAIN)); + return; + } + + updateSayhaTime(player); + premiumReward(player); + huntPass.setRewardStep(normalReward + 1); + huntPass.setRewardAlert(false); + player.sendPacket(new HuntPassInfo(player, _huntPassType)); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + player.sendPacket(new HuntPassSimpleInfo(player)); + } + + private void updateSayhaTime(Player player) + { + final HuntPass huntpass = player.getHuntPass(); + final int normalreward = huntpass.getRewardStep(); + final int premiumreward = huntpass.getPremiumRewardStep(); + final ItemHolder reward = HuntPassData.getInstance().getRewards().get(normalreward); + + final int sayhaPoints = 0; // TODO: 0? + final long count = reward.getCount(); + final int calc = (int) (sayhaPoints + count); + final boolean isPremium = huntpass.isPremium(); + if (isPremium && (premiumreward < normalreward)) + { + return; + } + + huntpass.addSayhaTime(calc); + player.addItem("HuntPassReward", reward, player, true); + final SystemMessage msg = new SystemMessage(SystemMessageId.YOU_RECEIVED_S1_SAYHA_S_GRACE_SUSTENTION_POINTS); + msg.addInt((int) (count)); + player.sendPacket(msg); + } + + private void premiumReward(Player player) + { + final HuntPass huntPass = player.getHuntPass(); + final int rewardStep = huntPass.getPremiumRewardStep(); + final ItemHolder premiumReward = HuntPassData.getInstance().getPremiumRewards().get(rewardStep); + final boolean isPremium = huntPass.isPremium(); + if (isPremium) + { + player.addItem("SeasonPassReward", premiumReward, player, true); + huntPass.setPremiumRewardStep(rewardStep + 1); + } + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassRewardAll.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassRewardAll.java new file mode 100644 index 0000000000..5530b31981 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/clientpackets/huntpass/RequestHuntPassRewardAll.java @@ -0,0 +1,54 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.clientpackets.huntpass; + +import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.GameClient; +import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSayhasSupportInfo; +import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo; + +/** + * @author Serenitty + */ +public class RequestHuntPassRewardAll implements IClientIncomingPacket +{ + private int _huntPassType; + + @Override + public boolean read(GameClient client, PacketReader packet) + { + _huntPassType = packet.readC(); + return true; + } + + @Override + public void run(GameClient client) + { + final Player player = client.getPlayer(); + if (player == null) + { + return; + } + + player.sendPacket(new HuntPassInfo(player, _huntPassType)); + player.sendPacket(new HuntPassSayhasSupportInfo(player)); + player.sendPacket(new HuntPassSimpleInfo(player)); + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassInfo.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassInfo.java new file mode 100644 index 0000000000..0f6371c103 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassInfo.java @@ -0,0 +1,66 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.serverpackets.huntpass; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Serenitty + */ +public class HuntPassInfo implements IClientOutgoingPacket +{ + private final int _interfaceType; + private final HuntPass _huntPass; + private final int _timeEnd; + private final int _isPremium; + private final int _points; + private final int _step; + private final int _rewardStep; + private final int _premiumRewardStep; + + public HuntPassInfo(Player player, int interfaceType) + { + + _interfaceType = interfaceType; + _huntPass = player.getHuntPass(); + _timeEnd = _huntPass.getHuntPassDayEnd(); + _isPremium = _huntPass.isPremium() ? 1 : 0; + _points = _huntPass.getPoints(); + _step = _huntPass.getCurrentStep(); + _rewardStep = _huntPass.getRewardStep(); + _premiumRewardStep = _huntPass.getPremiumRewardStep(); + + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_L2PASS_INFO.writeId(packet); + packet.writeC(_interfaceType); + packet.writeD(_timeEnd); // LeftTime + packet.writeC(_isPremium); // Premium + packet.writeD(_points); // Points + packet.writeD(_step); // CurrentStep + packet.writeD(_rewardStep); // Reward + packet.writeD(_premiumRewardStep); // PremiumReward + return true; + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSayhasSupportInfo.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSayhasSupportInfo.java new file mode 100644 index 0000000000..ef690a8fe9 --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSayhasSupportInfo.java @@ -0,0 +1,50 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.serverpackets.huntpass; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Serenitty + */ +public class HuntPassSayhasSupportInfo implements IClientOutgoingPacket +{ + private final HuntPass _huntPass; + private final int _timeUsed; + private final boolean _sayhaToggle; + + public HuntPassSayhasSupportInfo(Player player) + { + _huntPass = player.getHuntPass(); + _sayhaToggle = _huntPass.toggleSayha(); + _timeUsed = _huntPass.getUsedSayhaTime() + (int) (_huntPass.getToggleStartTime() > 0 ? (System.currentTimeMillis() / 1000) - _huntPass.getToggleStartTime() : 0); + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_SAYHAS_SUPPORT_INFO.writeId(packet); + packet.writeC(_sayhaToggle ? 1 : 0); + packet.writeD(_huntPass.getAvailableSayhaTime()); + packet.writeD(_timeUsed); + return true; + } +} diff --git a/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSimpleInfo.java b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSimpleInfo.java new file mode 100644 index 0000000000..c380234e3e --- /dev/null +++ b/L2J_Mobius_Essence_6.2_Vanguard/java/org/l2jmobius/gameserver/network/serverpackets/huntpass/HuntPassSimpleInfo.java @@ -0,0 +1,50 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.network.serverpackets.huntpass; + +import org.l2jmobius.commons.network.PacketWriter; +import org.l2jmobius.gameserver.model.HuntPass; +import org.l2jmobius.gameserver.model.actor.Player; +import org.l2jmobius.gameserver.network.OutgoingPackets; +import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; + +/** + * @author Serenitty + */ +public class HuntPassSimpleInfo implements IClientOutgoingPacket +{ + private final HuntPass _huntPassInfo; + + public HuntPassSimpleInfo(Player player) + { + _huntPassInfo = player.getHuntPass(); + } + + @Override + public boolean write(PacketWriter packet) + { + OutgoingPackets.EX_L2PASS_SIMPLE_INFO.writeId(packet); + + packet.writeD(1); // passInfos + packet.writeC(0); + packet.writeC(1); // isOn + + packet.writeC(_huntPassInfo.rewardAlert() ? 1 : 0); + packet.writeD(0); + return true; + } +}