Adaptation of Hunt Pass for main version.

Contributed by Fakee.
This commit is contained in:
MobiusDevelopment 2022-10-29 21:51:33 +00:00
parent 4e62d0e920
commit 7bd978118d
22 changed files with 1241 additions and 5 deletions

View File

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

View File

@ -0,0 +1,16 @@
# --------------------------------------------------------------------------
# HuntPass Settings
# --------------------------------------------------------------------------
EnabledHuntPass = False
# Period to end.
# Retail 1 month.
DayOfMonth = 1
# Pass Premium Cost.
# Retail is 8000 Einhasad Coin.
PremiumCost = 8000
# Please take caution when changing anything.
# Required Points per Window or step.
PointsForstep = 3000

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/HuntPass.xsd">
<!-- Page 1 -->
<item id="60368" count="2" premiumId="60386" premiumCount="1"/> <!-- Season Pass Bonus / Hunter's Coin -->
<item id="48848" count="5" premiumId="60368" premiumCount="10" /> <!-- Freya's Ice Rose / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80960" premiumCount="1" /> <!-- Season Pass Bonus / Pantheon's Museum's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Freya's Ice Rose -->
<item id="48857" count="5" premiumId="60368" premiumCount="20" /> <!-- Glowing Dragon's Attribute Potion (XP) / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Shining Nevit's Gold Hourglass -->
<item id="81815" count="1" premiumId="60368" premiumCount="10" /> <!-- Homunculus' Hourglass / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Emperor's Special Cocktail Event -->
<item id="60306" count="10" premiumId="60306" premiumCount="650" /> <!-- Vitality Sustention Points / Vitality Sustention Points -->
<!-- Page 2 -->
<item id="60368" count="2" premiumId="81815" premiumCount="4"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80906" premiumCount="1" /> <!-- Season Pass Bonus / Jamoa's Camp's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Honey Dark Beer -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Glowing Dragon's Attribute Potion (XP) -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Freya's Scroll of Storm Event -->
<item id="60306" count="10" premiumId="82394" premiumCount="5" /> <!-- Vitality Sustention Points / Augmenting Stone: Accesories -->
<!-- Page 3 -->
<item id="60368" count="2" premiumId="81815" premiumCount="2"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="48848" count="5" premiumId="60368" premiumCount="10" /> <!-- Freya's Ice Rose / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80960" premiumCount="1" /> <!-- Season Pass Bonus / Pantheon's Museum's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Freya's Ice Rose -->
<item id="48857" count="5" premiumId="60368" premiumCount="20" /> <!-- Glowing Dragon's Attribute Potion (XP) / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Shining Nevit's Gold Hourglass -->
<item id="81815" count="1" premiumId="60368" premiumCount="10" /> <!-- Homunculus' Hourglass / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Emperor's Special Cocktail Event -->
<item id="60306" count="10" premiumId="60306" premiumCount="650" /> <!-- Vitality Sustention Points / Vitality Sustention Points -->
<!-- Page 4 -->
<item id="60368" count="2" premiumId="81815" premiumCount="4"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80906" premiumCount="1" /> <!-- Season Pass Bonus / Jamoa's Camp's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Honey Dark Beer -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Glowing Dragon's Attribute Potion (XP) -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Freya's Scroll of Storm Event -->
<item id="60306" count="40" premiumId="80393" premiumCount="5" /> <!-- Vitality Sustention Points / Augmenting Stone: Circlet -->
<!-- Page 5 -->
<item id="60368" count="2" premiumId="81815" premiumCount="2"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="48848" count="5" premiumId="60368" premiumCount="10" /> <!-- Freya's Ice Rose / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80960" premiumCount="1" /> <!-- Season Pass Bonus / Pantheon's Museum's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Freya's Ice Rose -->
<item id="48857" count="5" premiumId="60368" premiumCount="20" /> <!-- Glowing Dragon's Attribute Potion (XP) / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Shining Nevit's Gold Hourglass -->
<item id="81815" count="1" premiumId="60368" premiumCount="10" /> <!-- Homunculus' Hourglass / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Emperor's Special Cocktail Event -->
<item id="60306" count="10" premiumId="60306" premiumCount="650" /> <!-- Vitality Sustention Points / Vitality Sustention Points -->
<!-- Page 6 -->
<item id="60368" count="2" premiumId="81815" premiumCount="4"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80906" premiumCount="1" /> <!-- Season Pass Bonus / Jamoa's Camp's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Honey Dark Beer -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Glowing Dragon's Attribute Potion (XP) -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Freya's Scroll of Storm Event -->
<item id="60306" count="40" premiumId="80396" premiumCount="5" /> <!-- Vitality Sustention Points / Augmenting Stone: Kaliel's Bracelet -->
<!-- Page 7 -->
<item id="60368" count="2" premiumId="81815" premiumCount="2"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="48848" count="5" premiumId="60368" premiumCount="10" /> <!-- Freya's Ice Rose / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80960" premiumCount="1" /> <!-- Season Pass Bonus / Pantheon's Museum's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Freya's Ice Rose -->
<item id="48857" count="5" premiumId="60368" premiumCount="20" /> <!-- Glowing Dragon's Attribute Potion (XP) / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Shining Nevit's Gold Hourglass -->
<item id="81815" count="1" premiumId="60368" premiumCount="10" /> <!-- Homunculus' Hourglass / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Emperor's Special Cocktail Event -->
<item id="60306" count="10" premiumId="60306" premiumCount="650" /> <!-- Vitality Sustention Points / Vitality Sustention Points -->
<!-- Page 8 -->
<item id="60368" count="2" premiumId="81815" premiumCount="4"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80906" premiumCount="1" /> <!-- Season Pass Bonus / Jamoa's Camp's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Honey Dark Beer -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Glowing Dragon's Attribute Potion (XP) -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Freya's Scroll of Storm Event -->
<item id="60306" count="40" premiumId="80398" premiumCount="5" /> <!-- Vitality Sustention Points / Augmenting Stone: Artifact Book -->
<!-- Page 9 -->
<item id="60368" count="2" premiumId="81815" premiumCount="2"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="48848" count="5" premiumId="60368" premiumCount="10" /> <!-- Freya's Ice Rose / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80960" premiumCount="1" /> <!-- Season Pass Bonus / Pantheon's Museum's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Freya's Ice Rose -->
<item id="48857" count="5" premiumId="60368" premiumCount="20" /> <!-- Glowing Dragon's Attribute Potion (XP) / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Shining Nevit's Gold Hourglass -->
<item id="81815" count="1" premiumId="60368" premiumCount="10" /> <!-- Homunculus' Hourglass / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Emperor's Special Cocktail Event -->
<item id="60306" count="10" premiumId="60306" premiumCount="650" /> <!-- Vitality Sustention Points / Vitality Sustention Points -->
<!-- Page 10 -->
<item id="60368" count="2" premiumId="81815" premiumCount="4"/> <!-- Season Pass Bonus / Homunculus' Hourglass -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="80906" premiumCount="1" /> <!-- Season Pass Bonus / Jamoa's Camp's Time Stone -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Honey Dark Beer -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="40" /> <!-- Season Pass Bonus / Glowing Dragon's Attribute Potion (XP) -->
<item id="60368" count="2" premiumId="60368" premiumCount="10" /> <!-- Season Pass Bonus / Season Pass Bonus -->
<item id="60368" count="2" premiumId="60368" premiumCount="20" /> <!-- Season Pass Bonus / Freya's Scroll of Storm Event -->
<item id="82344" count="50" premiumId="60378" premiumCount="1" /> <!-- Tales of Dimensions / Final Reward Chest -->
</list>

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/items.xsd">
<item id="60306" name="Vitality Sustention Points" type="EtcItem">
<set name="icon" val="icon.icon" />
<set name="material" val="LIQUID" />
<set name="is_stackable" val="true" />
<set name="is_sellable" val="false" />
<set name="is_tradeable" val="false" />
<set name="is_dropable" val="false" />
</item>
<item id="60321" name="Forgotten Lord's Tattoo Lv. 1" additionalName="CON +1" type="EtcItem">
<!-- CON +1, received damage -1% -->
<set name="icon" val="branchicon.bm_dye_monarc_hena" />

View File

@ -0,0 +1,20 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:int" name="id" use="required"/>
<xs:attribute type="xs:int" name="count" use="required"/>
<xs:attribute type="xs:int" name="premiumId" use="optional"/>
<xs:attribute type="xs:int" name="premiumCount" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -101,6 +101,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";
@ -906,6 +907,12 @@ public class Config
public static int WORLD_EXCHANGE_ITEM_BACK_PERIOD;
public static int WORLD_EXCHANGE_PAYMENT_TAKE_PERIOD;
// 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
@ -2637,6 +2644,13 @@ public class Config
FAFURION_MAX_PLAYERS = grandBossConfig.getInt("FafurionMaxPlayers", 200);
FAFURION_MIN_PLAYER_LEVEL = grandBossConfig.getInt("FafurionMinPlayerLvl", 105);
// 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);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<ItemHolder> _rewards = new ArrayList<>();
private final List<ItemHolder> _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<ItemHolder> getRewards()
{
return _rewards;
}
public int getRewardsCount()
{
return _rewardCount;
}
public List<ItemHolder> 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();
}
}

View File

@ -0,0 +1,339 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model;
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();
boolean hasNewLevel = false;
while (calculate >= Config.HUNT_PASS_POINTS_FOR_STEP)
{
calculate = calculate - Config.HUNT_PASS_POINTS_FOR_STEP;
setCurrentStep(getCurrentStep() + 1);
hasNewLevel = true;
}
if (hasNewLevel)
{
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));
}
}
}
}

View File

@ -882,6 +882,12 @@ public class Party extends AbstractPlayerGroup
member.removeSymbolSealSkills();
}
}
final HuntPass huntpass = member.getHuntPass();
if (huntpass != null)
{
huntpass.addPassPoint(exp);
}
}
}
else

View File

@ -47,6 +47,7 @@ import org.l2jmobius.gameserver.instancemanager.events.EventDropManager;
import org.l2jmobius.gameserver.model.AggroInfo;
import org.l2jmobius.gameserver.model.CommandChannel;
import org.l2jmobius.gameserver.model.DamageDoneInfo;
import org.l2jmobius.gameserver.model.HuntPass;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Seed;
import org.l2jmobius.gameserver.model.WorldObject;
@ -591,6 +592,11 @@ public class Attackable extends Npc
attacker.removeSymbolSealSkills();
}
}
final HuntPass huntPass = attacker.getHuntPass();
if (huntPass != null)
{
attacker.getHuntPass().addPassPoint(exp);
}
}
}
}

View File

@ -143,6 +143,7 @@ import org.l2jmobius.gameserver.model.ClientSettings;
import org.l2jmobius.gameserver.model.CommandChannel;
import org.l2jmobius.gameserver.model.ContactList;
import org.l2jmobius.gameserver.model.Duel;
import org.l2jmobius.gameserver.model.HuntPass;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.Macro;
import org.l2jmobius.gameserver.model.MacroList;
@ -929,6 +930,8 @@ public class Player extends Playable
private HeroBookInfoHolder _heroBookInfo = null;
private final HuntPass _huntPass;
private final List<QuestTimer> _questTimers = new ArrayList<>();
private final List<TimerHolder<?>> _timerHolders = new ArrayList<>();
@ -1220,6 +1223,8 @@ public class Player extends Playable
app.setOwner(this);
_appearance = app;
_huntPass = Config.ENABLE_HUNT_PASS ? new HuntPass(this) : null;
// Create an AI
getAI();
@ -1305,6 +1310,11 @@ public class Player extends Playable
getVariables().remove(ORIGINAL_CLASS_VAR);
}
public HuntPass getHuntPass()
{
return _huntPass;
}
/**
* @return the PlayerTemplate link to the Player.
*/
@ -7350,6 +7360,11 @@ public class Player extends Playable
getInventory().updateDatabase();
getWarehouse().updateDatabase();
getFreight().updateDatabase();
if (_huntPass != null)
{
_huntPass.store();
}
}
@Override
@ -12145,6 +12160,11 @@ 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);
}

View File

@ -120,6 +120,11 @@ import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExShowHo
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExSummonHomunculusCouponResult;
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;
@ -748,11 +753,11 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ITEM_USABLE_LIST(0x220, null, ConnectionState.IN_GAME),
EX_PACKETREADCOUNTPERSECOND(0x221, null, ConnectionState.IN_GAME),
EX_SELECT_GLOBAL_EVENT_UI(0x222, null, ConnectionState.IN_GAME),
EX_L2PASS_INFO(0x223, null, ConnectionState.IN_GAME),
EX_L2PASS_REQUEST_REWARD(0x224, null, ConnectionState.IN_GAME),
EX_L2PASS_REQUEST_REWARD_ALL(0x225, null, ConnectionState.IN_GAME),
EX_L2PASS_BUY_PREMIUM(0x226, null, ConnectionState.IN_GAME),
EX_SAYHAS_SUPPORT_TOGGLE(0x227, null, ConnectionState.IN_GAME),
EX_L2PASS_INFO(0x223, RequestHuntPassInfo::new, ConnectionState.IN_GAME),
EX_L2PASS_REQUEST_REWARD(0x224, RequestHuntPassReward::new, ConnectionState.IN_GAME),
EX_L2PASS_REQUEST_REWARD_ALL(0x225, RequestHuntPassRewardAll::new, ConnectionState.IN_GAME),
EX_L2PASS_BUY_PREMIUM(0x226, RequestHuntPassBuyPremium::new, ConnectionState.IN_GAME),
EX_SAYHAS_SUPPORT_TOGGLE(0x227, HuntpassSayhasToggle::new, ConnectionState.IN_GAME),
// 362
EX_REQ_ENCHANT_FAIL_REWARD_INFO(0x228, ExRequestEnchantFailRewardInfo::new, ConnectionState.IN_GAME),
EX_SET_ENCHANT_CHALLENGE_POINT(0x229, null, ConnectionState.IN_GAME),

View File

@ -15847,6 +15847,27 @@ public class SystemMessageId
@ClientString(id = 6208, message = "The Festival has ended. Please participate in the next round.")
public static SystemMessageId THE_FESTIVAL_HAS_ENDED_PLEASE_PARTICIPATE_IN_THE_NEXT_ROUND;
@ClientString(id = 6212, message = "Sayha's Grace sustention effect of the Season Pass is activated. Available Sayha's Grace sustention time is running.")
public static SystemMessageId SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_IS_ACTIVATED_AVAILABLE_SAYHA_S_GRACE_SUSTENTION_TIME_IS_RUNNING;
@ClientString(id = 6213, message = "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.")
public static 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;
@ClientString(id = 6214, message = "Sayha's Grace sustention effect of the Season Pass has been deactivated. The sustention time you have does not decrease.")
public static SystemMessageId SAYHA_S_GRACE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_HAS_BEEN_DEACTIVATED_THE_SUSTENTION_TIME_YOU_HAVE_DOES_NOT_DECREASE;
@ClientString(id = 6215, message = "Sayha's Grace sustention time has expired. The sustention effect of the Season Pass is deactivated.")
public static SystemMessageId SAYHA_S_GRACE_SUSTENTION_TIME_HAS_EXPIRED_THE_SUSTENTION_EFFECT_OF_THE_SEASON_PASS_IS_DEACTIVATED;
@ClientString(id = 6216, message = "Your inventory's weight/limit has been exceeded so you can't receive the reward. Please free up some space and try again.")
public static SystemMessageId YOUR_INVENTORY_S_WEIGHT_LIMIT_HAS_BEEN_EXCEEDED_SO_YOU_CAN_T_RECEIVE_THE_REWARD_PLEASE_FREE_UP_SOME_SPACE_AND_TRY_AGAIN;
@ClientString(id = 6219, message = "You received $s1 Sayha's Grace sustention points.")
public static SystemMessageId YOU_RECEIVED_S1_SAYHA_S_GRACE_SUSTENTION_POINTS;
@ClientString(id = 6220, message = "Currently unavailable for purchase. You can buy the Season Pass' additional rewards only until 6:30 a.m. of the season's last day.")
public static 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;
@ClientString(id = 6221, message = "Creation is possible if there is 1 main material. Please, check your inventory and try again.")
public static SystemMessageId CREATION_IS_POSSIBLE_IF_THERE_IS_1_MAIN_MATERIAL_PLEASE_CHECK_YOUR_INVENTORY_AND_TRY_AGAIN;

View File

@ -122,6 +122,7 @@ import org.l2jmobius.gameserver.network.serverpackets.herobook.ExHeroBookInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusReady;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.huntpass.HuntPassSimpleInfo;
import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount;
import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadInfo;
import org.l2jmobius.gameserver.network.serverpackets.settings.ExItemAnnounceSetting;
@ -689,6 +690,11 @@ public class EnterWorld implements IClientIncomingPacket
player.updateAbnormalVisualEffects();
}
if (Config.ENABLE_HUNT_PASS)
{
player.sendPacket(new HuntPassSimpleInfo(player));
}
for (int category = 1; category <= 7; category++)
{
player.sendPacket(new ExCollectionInfo(player, category));

View File

@ -0,0 +1,72 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets.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.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(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));
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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.model.itemcontainer.Inventory;
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.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(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("RequestHuntPassBuyPremium", Inventory.EINHASAD_COIN_ID, Config.HUNT_PASS_PREMIUM_COST, player, true))
{
player.sendPacket(SystemMessageId.NOT_ENOUGH_MONEY_TO_USE_THE_FUNCTION);
return;
}
player.getHuntPass().setPremium(true);
player.sendPacket(new HuntPassSayhasSupportInfo(player));
player.sendPacket(new HuntPassInfo(player, _huntPassType));
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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));
}
}

View File

@ -0,0 +1,119 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.network.clientpackets.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(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 boolean isPremium = huntpass.isPremium();
if (isPremium && (premiumreward < normalreward))
{
return;
}
if (reward.getId() == 60306) // Vitality Sustention Points
{
final int count = (int) reward.getCount();
huntpass.addSayhaTime(count);
final SystemMessage msg = new SystemMessage(SystemMessageId.YOU_RECEIVED_S1_SAYHA_S_GRACE_SUSTENTION_POINTS);
msg.addInt(count);
player.sendPacket(msg);
}
else
{
player.addItem("HuntPassReward", reward, player, true);
}
}
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);
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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));
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}