Initial changes.

This commit is contained in:
MobiusDevelopment
2020-06-14 05:49:47 +00:00
parent 141764df73
commit 082558d4ac
1882 changed files with 22149 additions and 90093 deletions
@@ -27,7 +27,6 @@ import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.OutputStream;
import java.math.BigInteger;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -129,9 +128,6 @@ public class Config
public static int TRADE_PVP_AMOUNT;
public static boolean GLOBAL_CHAT_WITH_PVP;
public static int GLOBAL_PVP_AMOUNT;
public static int BRUT_AVG_TIME;
public static int BRUT_LOGON_ATTEMPTS;
public static int BRUT_BAN_IP_TIME;
public static int MAX_CHAT_LENGTH;
public static boolean TRADE_CHAT_IS_NOOBLE;
public static boolean PRECISE_DROP_CALCULATION;
@@ -147,7 +143,6 @@ public class Config
public static boolean ALLOWFISHING;
public static boolean ALLOW_MANOR;
public static int AUTODESTROY_ITEM_AFTER;
public static int HERB_AUTO_DESTROY_TIME;
public static String PROTECTED_ITEMS;
public static List<Integer> LIST_PROTECTED_ITEMS = new ArrayList<>();
public static boolean DESTROY_DROPPED_PLAYER_ITEM;
@@ -168,7 +163,6 @@ public class Config
public static boolean ALLOW_RACE;
public static boolean ALLOW_RENTPET;
public static boolean ALLOW_BOAT;
public static boolean ALLOW_CURSED_WEAPONS;
public static boolean ALLOW_NPC_WALKERS;
public static int MIN_NPC_ANIMATION;
public static int MAX_NPC_ANIMATION;
@@ -254,11 +248,6 @@ public class Config
public static float RATE_DROP_QUEST;
public static float RATE_KARMA_EXP_LOST;
public static float RATE_SIEGE_GUARDS_PRICE;
public static float RATE_DROP_COMMON_HERBS;
public static float RATE_DROP_MP_HP_HERBS;
public static float RATE_DROP_GREATER_HERBS;
public static float RATE_DROP_SUPERIOR_HERBS;
public static float RATE_DROP_SPECIAL_HERBS;
public static int PLAYER_DROP_LIMIT;
public static int PLAYER_RATE_DROP;
public static int PLAYER_RATE_DROP_ITEM;
@@ -311,13 +300,6 @@ public class Config
public static float ALT_LOTTERY_4_NUMBER_RATE;
public static float ALT_LOTTERY_3_NUMBER_RATE;
public static int ALT_LOTTERY_2_AND_1_NUMBER_PRIZE;
public static boolean ALT_FISH_CHAMPIONSHIP_ENABLED;
public static int ALT_FISH_CHAMPIONSHIP_REWARD_ITEM;
public static int ALT_FISH_CHAMPIONSHIP_REWARD_1;
public static int ALT_FISH_CHAMPIONSHIP_REWARD_2;
public static int ALT_FISH_CHAMPIONSHIP_REWARD_3;
public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
public static int RIFT_MIN_PARTY_SIZE;
public static int RIFT_SPAWN_DELAY;
public static int RIFT_MAX_JUMPS;
@@ -357,7 +339,6 @@ public class Config
public static int LEVEL_TO_GET_PENALTY;
public static boolean MASTERY_WEAPON_PENALTY;
public static int LEVEL_TO_GET_WEAPON_PENALTY;
public static int ACTIVE_AUGMENTS_START_REUSE_TIME;
public static boolean NPC_ATTACKABLE;
public static List<Integer> INVUL_NPC_LIST;
public static boolean DISABLE_ATTACK_NPC_TYPE;
@@ -495,7 +476,6 @@ public class Config
public static boolean TVT_ANNOUNCE_TEAM_STATS;
public static boolean TVT_ANNOUNCE_REWARD;
public static boolean TVT_PRICE_NO_KILLS;
public static boolean TVT_JOIN_CURSED;
public static boolean TVT_COMMAND;
public static long TVT_REVIVE_DELAY;
public static boolean TVT_OPEN_FORT_DOORS;
@@ -577,7 +557,6 @@ public class Config
public static boolean DM_ALLOW_INTERFERENCE;
public static boolean DM_ALLOW_POTIONS;
public static boolean DM_ALLOW_SUMMON;
public static boolean DM_JOIN_CURSED;
public static boolean DM_ON_START_REMOVE_ALL_EFFECTS;
public static boolean DM_ON_START_UNSUMMON_PET;
public static long DM_REVIVE_DELAY;
@@ -600,7 +579,6 @@ public class Config
public static boolean CTF_ON_START_UNSUMMON_PET;
public static boolean CTF_ANNOUNCE_TEAM_STATS;
public static boolean CTF_ANNOUNCE_REWARD;
public static boolean CTF_JOIN_CURSED;
public static boolean CTF_REVIVE_RECOVERY;
public static boolean CTF_COMMAND;
public static boolean CTF_AURA;
@@ -786,7 +764,6 @@ public class Config
public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
public static boolean ALT_OLY_ANNOUNCE_GAMES;
public static List<Integer> LIST_OLY_RESTRICTED_SKILLS = new ArrayList<>();
public static boolean ALT_OLY_AUGMENT_ALLOW;
public static int ALT_OLY_TELEPORT_COUNTDOWN;
public static int ALT_OLY_START_TIME;
public static int ALT_OLY_MIN;
@@ -832,17 +809,6 @@ public class Config
public static boolean ENABLE_DWARF_ENCHANT_BONUS;
public static int DWARF_ENCHANT_MIN_LEVEL;
public static int DWARF_ENCHANT_BONUS;
public static int AUGMENTATION_NG_SKILL_CHANCE;
public static int AUGMENTATION_MID_SKILL_CHANCE;
public static int AUGMENTATION_HIGH_SKILL_CHANCE;
public static int AUGMENTATION_TOP_SKILL_CHANCE;
public static int AUGMENTATION_BASESTAT_CHANCE;
public static int AUGMENTATION_NG_GLOW_CHANCE;
public static int AUGMENTATION_MID_GLOW_CHANCE;
public static int AUGMENTATION_HIGH_GLOW_CHANCE;
public static int AUGMENTATION_TOP_GLOW_CHANCE;
public static boolean DELETE_AUGM_PASSIVE_ON_CHANGE;
public static boolean DELETE_AUGM_ACTIVE_ON_CHANGE;
public static boolean ENCHANT_HERO_WEAPON;
public static int SOUL_CRYSTAL_BREAK_CHANCE;
public static int SOUL_CRYSTAL_LEVEL_CHANCE;
@@ -1013,7 +979,6 @@ public class Config
public static List<Integer> RAID_INFO_IDS_LIST = new ArrayList<>();
public static boolean AUTO_LOOT;
public static boolean AUTO_LOOT_HERBS;
public static boolean AUTO_LOOT_BOSS;
public static boolean AUTO_LEARN_SKILLS;
public static boolean AUTO_LEARN_DIVINE_INSPIRATION;
@@ -1245,11 +1210,6 @@ public class Config
RATE_DROP_QUEST = ratesConfig.getFloat("RateDropQuest", 1f);
RATE_KARMA_EXP_LOST = ratesConfig.getFloat("RateKarmaExpLost", 1f);
RATE_SIEGE_GUARDS_PRICE = ratesConfig.getFloat("RateSiegeGuardsPrice", 1f);
RATE_DROP_COMMON_HERBS = ratesConfig.getFloat("RateCommonHerbs", 15f);
RATE_DROP_MP_HP_HERBS = ratesConfig.getFloat("RateHpMpHerbs", 10f);
RATE_DROP_GREATER_HERBS = ratesConfig.getFloat("RateGreaterHerbs", 4f);
RATE_DROP_SUPERIOR_HERBS = ratesConfig.getFloat("RateSuperiorHerbs", 0.80f) * 10;
RATE_DROP_SPECIAL_HERBS = ratesConfig.getFloat("RateSpecialHerbs", 0.20f) * 10;
PLAYER_DROP_LIMIT = ratesConfig.getInt("PlayerDropLimit", 3);
PLAYER_RATE_DROP = ratesConfig.getInt("PlayerRateDrop", 5);
PLAYER_RATE_DROP_ITEM = ratesConfig.getInt("PlayerRateDropItem", 70);
@@ -1314,13 +1274,6 @@ public class Config
ALT_LOTTERY_4_NUMBER_RATE = generalConfig.getFloat("AltLottery4NumberRate", 0.2f);
ALT_LOTTERY_3_NUMBER_RATE = generalConfig.getFloat("AltLottery3NumberRate", 0.2f);
ALT_LOTTERY_2_AND_1_NUMBER_PRIZE = generalConfig.getInt("AltLottery2and1NumberPrize", 200);
ALT_FISH_CHAMPIONSHIP_ENABLED = generalConfig.getBoolean("AltFishChampionshipEnabled", true);
ALT_FISH_CHAMPIONSHIP_REWARD_ITEM = generalConfig.getInt("AltFishChampionshipRewardItemId", 57);
ALT_FISH_CHAMPIONSHIP_REWARD_1 = generalConfig.getInt("AltFishChampionshipReward1", 800000);
ALT_FISH_CHAMPIONSHIP_REWARD_2 = generalConfig.getInt("AltFishChampionshipReward2", 500000);
ALT_FISH_CHAMPIONSHIP_REWARD_3 = generalConfig.getInt("AltFishChampionshipReward3", 300000);
ALT_FISH_CHAMPIONSHIP_REWARD_4 = generalConfig.getInt("AltFishChampionshipReward4", 200000);
ALT_FISH_CHAMPIONSHIP_REWARD_5 = generalConfig.getInt("AltFishChampionshipReward5", 100000);
RIFT_MIN_PARTY_SIZE = generalConfig.getInt("RiftMinPartySize", 5);
RIFT_MAX_JUMPS = generalConfig.getInt("MaxRiftJumps", 4);
RIFT_SPAWN_DELAY = generalConfig.getInt("RiftSpawnDelay", 10000);
@@ -1352,7 +1305,6 @@ public class Config
LEVEL_TO_GET_PENALTY = generalConfig.getInt("LevelToGetPenalty", 20);
MASTERY_WEAPON_PENALTY = generalConfig.getBoolean("MasteryWeaponPenality", false);
LEVEL_TO_GET_WEAPON_PENALTY = generalConfig.getInt("LevelToGetWeaponPenalty", 20);
ACTIVE_AUGMENTS_START_REUSE_TIME = generalConfig.getInt("AugmStartReuseTime", 0);
INVUL_NPC_LIST = new ArrayList<>();
final String t = generalConfig.getString("InvulNpcList", "30001-32132,35092-35103,35142-35146,35176-35187,35218-35232,35261-35278,35308-35319,35352-35367,35382-35407,35417-35427,35433-35469,35497-35513,35544-35587,35600-35617,35623-35628,35638-35640,35644,35645,50007,70010,99999");
String as[];
@@ -1476,7 +1428,6 @@ public class Config
ANNOUNCE_MAMMON_SPAWN = generalConfig.getBoolean("AnnounceMammonSpawn", true);
ALLOW_GUARDS = generalConfig.getBoolean("AllowGuards", false);
AUTODESTROY_ITEM_AFTER = generalConfig.getInt("AutoDestroyDroppedItemAfter", 0);
HERB_AUTO_DESTROY_TIME = generalConfig.getInt("AutoDestroyHerbTime", 15) * 1000;
PROTECTED_ITEMS = generalConfig.getString("ListOfProtectedItems", "");
LIST_PROTECTED_ITEMS = new ArrayList<>();
for (String id : PROTECTED_ITEMS.split(","))
@@ -1506,7 +1457,6 @@ public class Config
ALLOW_MANOR = generalConfig.getBoolean("AllowManor", false);
ALLOW_BOAT = generalConfig.getBoolean("AllowBoat", false);
ALLOW_NPC_WALKERS = generalConfig.getBoolean("AllowNpcWalkers", true);
ALLOW_CURSED_WEAPONS = generalConfig.getBoolean("AllowCursedWeapons", false);
DEFAULT_GLOBAL_CHAT = generalConfig.getString("GlobalChat", "ON");
DEFAULT_TRADE_CHAT = generalConfig.getString("TradeChat", "ON");
MAX_CHAT_LENGTH = generalConfig.getInt("MaxChatLength", 100);
@@ -1686,7 +1636,6 @@ public class Config
TVT_ANNOUNCE_TEAM_STATS = tvtConfig.getBoolean("TvTAnnounceTeamStats", false);
TVT_ANNOUNCE_REWARD = tvtConfig.getBoolean("TvTAnnounceReward", false);
TVT_PRICE_NO_KILLS = tvtConfig.getBoolean("TvTPriceNoKills", false);
TVT_JOIN_CURSED = tvtConfig.getBoolean("TvTJoinWithCursedWeapon", true);
TVT_COMMAND = tvtConfig.getBoolean("TvTCommand", true);
TVT_REVIVE_DELAY = tvtConfig.getLong("TvTReviveDelay", 20000);
if (TVT_REVIVE_DELAY < 1000)
@@ -1795,7 +1744,6 @@ public class Config
DM_ALLOW_INTERFERENCE = dmConfig.getBoolean("DMAllowInterference", false);
DM_ALLOW_POTIONS = dmConfig.getBoolean("DMAllowPotions", false);
DM_ALLOW_SUMMON = dmConfig.getBoolean("DMAllowSummon", false);
DM_JOIN_CURSED = dmConfig.getBoolean("DMJoinWithCursedWeapon", false);
DM_ON_START_REMOVE_ALL_EFFECTS = dmConfig.getBoolean("DMOnStartRemoveAllEffects", true);
DM_ON_START_UNSUMMON_PET = dmConfig.getBoolean("DMOnStartUnsummonPet", true);
DM_REVIVE_DELAY = dmConfig.getLong("DMReviveDelay", 20000);
@@ -1826,7 +1774,6 @@ public class Config
CTF_ON_START_UNSUMMON_PET = ctfConfig.getBoolean("CTFOnStartUnsummonPet", true);
CTF_ANNOUNCE_TEAM_STATS = ctfConfig.getBoolean("CTFAnnounceTeamStats", false);
CTF_ANNOUNCE_REWARD = ctfConfig.getBoolean("CTFAnnounceReward", false);
CTF_JOIN_CURSED = ctfConfig.getBoolean("CTFJoinWithCursedWeapon", true);
CTF_REVIVE_RECOVERY = ctfConfig.getBoolean("CTFReviveRecovery", false);
CTF_COMMAND = ctfConfig.getBoolean("CTFCommand", true);
CTF_AURA = ctfConfig.getBoolean("CTFAura", true);
@@ -2065,7 +2012,6 @@ public class Config
{
LIST_OLY_RESTRICTED_SKILLS.add(Integer.parseInt(id));
}
ALT_OLY_AUGMENT_ALLOW = olympiadConfig.getBoolean("AltOlyAugmentAllow", true);
ALT_OLY_TELEPORT_COUNTDOWN = olympiadConfig.getInt("AltOlyTeleportCountDown", 120);
ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = olympiadConfig.getBoolean("AltOlyUseCustomPeriodSettings", false);
ALT_OLY_PERIOD = OlympiadPeriod.valueOf(olympiadConfig.getString("AltOlyPeriod", "MONTH"));
@@ -2297,17 +2243,6 @@ public class Config
ENABLE_DWARF_ENCHANT_BONUS = enchantConfig.getBoolean("EnableDwarfEnchantBonus", false);
DWARF_ENCHANT_MIN_LEVEL = enchantConfig.getInt("DwarfEnchantMinLevel", 80);
DWARF_ENCHANT_BONUS = enchantConfig.getInt("DwarfEnchantBonus", 15);
AUGMENTATION_NG_SKILL_CHANCE = enchantConfig.getInt("AugmentationNGSkillChance", 15);
AUGMENTATION_MID_SKILL_CHANCE = enchantConfig.getInt("AugmentationMidSkillChance", 30);
AUGMENTATION_HIGH_SKILL_CHANCE = enchantConfig.getInt("AugmentationHighSkillChance", 45);
AUGMENTATION_TOP_SKILL_CHANCE = enchantConfig.getInt("AugmentationTopSkillChance", 60);
AUGMENTATION_BASESTAT_CHANCE = enchantConfig.getInt("AugmentationBaseStatChance", 1);
AUGMENTATION_NG_GLOW_CHANCE = enchantConfig.getInt("AugmentationNGGlowChance", 0);
AUGMENTATION_MID_GLOW_CHANCE = enchantConfig.getInt("AugmentationMidGlowChance", 40);
AUGMENTATION_HIGH_GLOW_CHANCE = enchantConfig.getInt("AugmentationHighGlowChance", 70);
AUGMENTATION_TOP_GLOW_CHANCE = enchantConfig.getInt("AugmentationTopGlowChance", 100);
DELETE_AUGM_PASSIVE_ON_CHANGE = enchantConfig.getBoolean("DeleteAgmentPassiveEffectOnChangeWep", true);
DELETE_AUGM_ACTIVE_ON_CHANGE = enchantConfig.getBoolean("DeleteAgmentActiveEffectOnChangeWep", true);
ENCHANT_HERO_WEAPON = enchantConfig.getBoolean("EnableEnchantHeroWeapons", false);
SOUL_CRYSTAL_BREAK_CHANCE = enchantConfig.getInt("SoulCrystalBreakChance", 10);
SOUL_CRYSTAL_LEVEL_CHANCE = enchantConfig.getInt("SoulCrystalLevelChance", 32);
@@ -2622,7 +2557,6 @@ public class Config
{
final PropertiesParser characterConfig = new PropertiesParser(CHARACTER_CONFIG_FILE);
AUTO_LOOT = characterConfig.getBoolean("AutoLoot", true);
AUTO_LOOT_HERBS = characterConfig.getBoolean("AutoLootHerbs", true);
AUTO_LOOT_BOSS = characterConfig.getBoolean("AutoLootBoss", true);
AUTO_LEARN_SKILLS = characterConfig.getBoolean("AutoLearnSkills", false);
AUTO_LEARN_DIVINE_INSPIRATION = characterConfig.getBoolean("AutoLearnDivineInspiration", false);
@@ -2876,9 +2810,6 @@ public class Config
MYSQL_BIN_PATH = serverSettings.getString("MySqlBinLocation", "C:/xampp/mysql/bin/");
BACKUP_PATH = serverSettings.getString("BackupPath", "../backup/");
BACKUP_DAYS = serverSettings.getInt("BackupDays", 30);
BRUT_AVG_TIME = serverSettings.getInt("BrutAvgTime", 30); // in Seconds
BRUT_LOGON_ATTEMPTS = serverSettings.getInt("BrutLogonAttempts", 15);
BRUT_BAN_IP_TIME = serverSettings.getInt("BrutBanIpTime", 900); // in Seconds
SHOW_LICENCE = serverSettings.getBoolean("ShowLicence", false);
IP_UPDATE_TIME = serverSettings.getInt("IpUpdateTime", 15);
FORCE_GGAUTH = serverSettings.getBoolean("ForceGGAuth", false);
@@ -2946,7 +2877,7 @@ public class Config
{
LoginController.getInstance().addBanForAddress(address, duration);
}
catch (UnknownHostException e)
catch (Exception e)
{
LOGGER.warning("Skipped: Invalid address (" + parts[0] + ") on (" + file.getName() + "). Line: " + reader.getLineNumber());
}
@@ -1,91 +0,0 @@
/*
* 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.commons.crypt;
import java.io.IOException;
import org.l2jmobius.commons.util.Rnd;
/**
* @author KenM
*/
public class LoginCrypt
{
private static final byte[] STATIC_BLOWFISH_KEY =
{
(byte) 0x6b,
(byte) 0x60,
(byte) 0xcb,
(byte) 0x5b,
(byte) 0x82,
(byte) 0xce,
(byte) 0x90,
(byte) 0xb1,
(byte) 0xcc,
(byte) 0x2b,
(byte) 0x6c,
(byte) 0x55,
(byte) 0x6c,
(byte) 0x6c,
(byte) 0x6c,
(byte) 0x6c
};
private final NewCrypt _staticCrypt = new NewCrypt(STATIC_BLOWFISH_KEY);
private NewCrypt _crypt;
private boolean _static = true;
public void setKey(byte[] key)
{
_crypt = new NewCrypt(key);
}
public boolean decrypt(byte[] raw, int offset, int size) throws IOException
{
_crypt.decrypt(raw, offset, size);
return NewCrypt.verifyChecksum(raw, offset, size);
}
public int encrypt(byte[] raw, int offset, int size) throws IOException
{
int newSize = size;
// reserve checksum
newSize += 4;
if (_static)
{
// reserve for XOR "key"
newSize += 4;
// padding
newSize += 8 - (newSize % 8);
NewCrypt.encXORPass(raw, offset, newSize, Rnd.nextInt());
_staticCrypt.crypt(raw, offset, newSize);
_static = false;
}
else
{
// padding
newSize += 8 - (newSize % 8);
NewCrypt.appendChecksum(raw, offset, newSize);
_crypt.crypt(raw, offset, newSize);
}
return newSize;
}
}
@@ -84,7 +84,9 @@ public abstract class SendablePacket<T extends MMOClient<?>>extends AbstractPack
*/
protected final void writeQ(long value)
{
_buf.putLong(value);
// C4 adjustment.
// _buf.putLong(value);
_buf.putInt((int) value);
}
/**
@@ -56,7 +56,6 @@ import org.l2jmobius.gameserver.datatables.sql.SpawnTable;
import org.l2jmobius.gameserver.datatables.sql.TeleportLocationTable;
import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.datatables.xml.ArmorSetData;
import org.l2jmobius.gameserver.datatables.xml.AugmentationData;
import org.l2jmobius.gameserver.datatables.xml.BoatData;
import org.l2jmobius.gameserver.datatables.xml.DoorData;
import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
@@ -89,11 +88,8 @@ import org.l2jmobius.gameserver.instancemanager.ClanHallManager;
import org.l2jmobius.gameserver.instancemanager.ClassDamageManager;
import org.l2jmobius.gameserver.instancemanager.CoupleManager;
import org.l2jmobius.gameserver.instancemanager.CrownManager;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
import org.l2jmobius.gameserver.instancemanager.FourSepulchersManager;
@@ -206,7 +202,6 @@ public class GameServer
GameTimeController.getInstance();
CharNameTable.getInstance();
ExperienceData.getInstance();
DuelManager.getInstance();
Util.printSection("Players");
PlayerTemplateData.getInstance();
@@ -301,19 +296,17 @@ public class GameServer
RecipeData.getInstance();
RecipeController.getInstance();
EventDroplist.getInstance();
AugmentationData.getInstance();
MonsterRace.getInstance();
Lottery.getInstance();
MercTicketManager.getInstance();
PetitionManager.getInstance();
CursedWeaponsManager.getInstance();
TaskManager.getInstance();
PetDataTable.getInstance();
if (Config.SAVE_DROPPED_ITEM)
{
ItemsOnGroundManager.getInstance();
}
if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0))
if (Config.AUTODESTROY_ITEM_AFTER > 0)
{
ItemsAutoDestroy.getInstance();
}
@@ -379,11 +372,6 @@ public class GameServer
LOGGER.info("Script: disable load.");
}
if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
{
FishingChampionshipManager.getInstance();
}
/* QUESTS */
Util.printSection("Quests");
if (!Config.ALT_DEV_NO_QUESTS)
@@ -25,7 +25,6 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.EtcItemType;
public class ItemsAutoDestroy
{
@@ -58,20 +57,6 @@ public class ItemsAutoDestroy
{
_items.remove(item);
}
else if (item.getItemType() == EtcItemType.HERB)
{
if ((curtime - item.getDropTime()) > Config.HERB_AUTO_DESTROY_TIME)
{
World.getInstance().removeVisibleObject(item, item.getWorldRegion());
World.getInstance().removeObject(item);
_items.remove(item);
if (Config.SAVE_DROPPED_ITEM)
{
ItemsOnGroundManager.getInstance().removeObject(item);
}
}
}
else if ((curtime - item.getDropTime()) > (Config.AUTODESTROY_ITEM_AFTER * 1000))
{
World.getInstance().removeVisibleObject(item, item.getWorldRegion());
@@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import org.l2jmobius.Config;
@@ -62,33 +63,32 @@ public class LoginServerThread extends Thread
protected static final Logger LOGGER = Logger.getLogger(LoginServerThread.class.getName());
/** The LoginServerThread singleton */
private static LoginServerThread _instance;
private static final int REVISION = 0x0102;
private RSAPublicKey _publicKey;
private final String _hostname;
private final int _port;
private final int _gamePort;
private Socket _loginSocket;
private InputStream _in;
private OutputStream _out;
/**
* The BlowFish engine used to encrypt packets<br>
* It is first initialized with a unified key:<br>
* "_;v.]05-31!|+-%xT!^[$\00"<br>
* <br>
* and then after handshake, with a new key sent by<br>
* loginserver during the handshake. This new key is stored<br>
* in {@link #_blowfishKey}
* loginserver during the handshake.
*/
private NewCrypt _blowfish;
private byte[] _blowfishKey;
private byte[] _hexID;
private final boolean _acceptAlternate;
private int _requestID;
private final int _requestID;
private int _serverID;
private final boolean _reserveHost;
private int _maxPlayer;
private final List<WaitingClient> _waitingClients;
private final Map<String, GameClient> _accountsInGameServer;
private final List<WaitingClient> _waitingClients = new CopyOnWriteArrayList<>();
private final Map<String, GameClient> _accountsInGameServer = new ConcurrentHashMap<>();
private int _status;
private String _serverName;
private final String _gameExternalHost;
@@ -103,26 +103,29 @@ public class LoginServerThread extends Thread
_hexID = Config.HEX_ID;
if (_hexID == null)
{
_requestID = Config.REQUEST_ID;
_hexID = generateHex(16);
}
else
{
_requestID = Config.SERVER_ID;
}
_acceptAlternate = Config.ACCEPT_ALTERNATE_ID;
_requestID = Config.REQUEST_ID;
_reserveHost = Config.RESERVE_HOST_ON_LOGIN;
_gameExternalHost = Config.EXTERNAL_HOSTNAME;
_gameInternalHost = Config.INTERNAL_HOSTNAME;
_waitingClients = new ArrayList<>();
_accountsInGameServer = new ConcurrentHashMap<>();
_maxPlayer = Config.MAXIMUM_ONLINE_USERS;
}
public static LoginServerThread getInstance()
{
if (_instance == null)
{
_instance = new LoginServerThread();
}
return _instance;
}
@Override
public void run()
{
while (!_interrupted)
while (!isInterrupted())
{
int lengthHi = 0;
int lengthLo = 0;
@@ -133,42 +136,39 @@ public class LoginServerThread extends Thread
// Connection
LOGGER.info("Connecting to login on " + _hostname + ":" + _port);
_loginSocket = new Socket(_hostname, _port);
_in = _loginSocket.getInputStream();
if (_out != null)
{
synchronized (_out) // avoids tow threads writing in the mean time
{
_out = new BufferedOutputStream(_loginSocket.getOutputStream());
}
}
else
{
_out = new BufferedOutputStream(_loginSocket.getOutputStream());
}
final InputStream in = _loginSocket.getInputStream();
_out = new BufferedOutputStream(_loginSocket.getOutputStream());
// init Blowfish
_blowfishKey = generateHex(40);
_blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
while (!_interrupted)
final byte[] blowfishKey = generateHex(40);
// Protect the new blowfish key what cannot begin with zero
if (blowfishKey[0] == 0)
{
lengthLo = _in.read();
lengthHi = _in.read();
blowfishKey[0] = (byte) Rnd.get(32, 64);
}
_blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
while (!isInterrupted())
{
lengthLo = in.read();
lengthHi = in.read();
length = (lengthHi * 256) + lengthLo;
if (lengthHi < 0)
{
LOGGER.info("LoginServerThread: Login terminated the connection.");
LOGGER.finer("LoginServerThread: Login terminated the connection.");
break;
}
final byte[] incoming = new byte[length];
incoming[0] = (byte) lengthLo;
incoming[1] = (byte) lengthHi;
final byte[] incoming = new byte[length - 2];
int receivedBytes = 0;
int newBytes = 0;
int left = length - 2;
while ((newBytes != -1) && (receivedBytes < (length - 2)))
{
newBytes = _in.read(incoming, 2, length - 2);
newBytes = in.read(incoming, receivedBytes, left);
receivedBytes = receivedBytes + newBytes;
left -= newBytes;
}
if (receivedBytes != (length - 2))
@@ -177,35 +177,33 @@ public class LoginServerThread extends Thread
break;
}
byte[] decrypt = new byte[length - 2];
System.arraycopy(incoming, 2, decrypt, 0, decrypt.length);
// decrypt if we have a key
decrypt = _blowfish.decrypt(decrypt);
checksumOk = NewCrypt.verifyChecksum(decrypt);
_blowfish.decrypt(incoming, 0, incoming.length);
checksumOk = NewCrypt.verifyChecksum(incoming);
if (!checksumOk)
{
LOGGER.warning("Incorrect packet checksum, ignoring packet (LS)");
break;
}
final int packetType = decrypt[0] & 0xff;
switch (packetType)
switch (incoming[0] & 0xff)
{
case 0x00:
{
final InitLS init = new InitLS(decrypt);
final InitLS init = new InitLS(incoming);
if (init.getRevision() != REVISION)
{
// TODO: revision mismatch
LOGGER.warning("/!\\ Revision mismatch between LS and GS /!\\");
break;
}
RSAPublicKey publicKey;
try
{
final KeyFactory kfac = KeyFactory.getInstance("RSA");
final BigInteger modulus = new BigInteger(init.getRSAKey());
final RSAPublicKeySpec kspec1 = new RSAPublicKeySpec(modulus, RSAKeyGenParameterSpec.F4);
_publicKey = (RSAPublicKey) kfac.generatePublic(kspec1);
publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(init.getRSAKey()), RSAKeyGenParameterSpec.F4));
}
catch (GeneralSecurityException e)
{
@@ -213,26 +211,23 @@ public class LoginServerThread extends Thread
break;
}
// send the blowfish key through the rsa encryption
final BlowFishKey bfk = new BlowFishKey(_blowfishKey, _publicKey);
sendPacket(bfk);
// now, only accept paket with the new encryption
_blowfish = new NewCrypt(_blowfishKey);
sendPacket(new BlowFishKey(blowfishKey, publicKey));
// now, only accept packet with the new encryption
_blowfish = new NewCrypt(blowfishKey);
final AuthRequest ar = new AuthRequest(_requestID, _acceptAlternate, _hexID, _gameExternalHost, _gameInternalHost, _gamePort, _reserveHost, _maxPlayer);
sendPacket(ar);
break;
}
case 0x01:
{
final LoginServerFail lsf = new LoginServerFail(decrypt);
LOGGER.info("Damn! Registeration Failed: " + lsf.getReasonString());
final LoginServerFail lsf = new LoginServerFail(incoming);
LOGGER.info("Damn! Registration Failed: " + lsf.getReasonString());
// login will close the connection here
break;
}
case 0x02:
{
final AuthResponse aresp = new AuthResponse(decrypt);
final AuthResponse aresp = new AuthResponse(incoming);
_serverID = aresp.getServerId();
_serverName = aresp.getServerName();
Config.saveHexid(_serverID, hexToString(_hexID));
@@ -285,17 +280,14 @@ public class LoginServerThread extends Thread
}
case 0x03:
{
final PlayerAuthResponse par = new PlayerAuthResponse(decrypt);
final PlayerAuthResponse par = new PlayerAuthResponse(incoming);
final String account = par.getAccount();
WaitingClient wcToRemove = null;
synchronized (_waitingClients)
for (WaitingClient wc : _waitingClients)
{
for (WaitingClient wc : _waitingClients)
if (wc.account.equals(account))
{
if (wc.account.equals(account))
{
wcToRemove = wc;
}
wcToRemove = wc;
}
}
if (wcToRemove != null)
@@ -313,8 +305,9 @@ public class LoginServerThread extends Thread
else
{
LOGGER.warning("Session key is not correct. Closing connection for account " + wcToRemove.account + ".");
wcToRemove.gameClient.getConnection().sendPacket(new AuthLoginFail(1));
wcToRemove.gameClient.closeNow();
wcToRemove.gameClient.sendPacket(new AuthLoginFail(AuthLoginFail.SYSTEM_ERROR_LOGIN_LATER));
wcToRemove.gameClient.close(new AuthLoginFail(AuthLoginFail.SYSTEM_ERROR_LOGIN_LATER));
_accountsInGameServer.remove(wcToRemove.account);
}
_waitingClients.remove(wcToRemove);
}
@@ -322,7 +315,7 @@ public class LoginServerThread extends Thread
}
case 0x04:
{
final KickPlayer kp = new KickPlayer(decrypt);
final KickPlayer kp = new KickPlayer(incoming);
doKickPlayer(kp.getAccount());
break;
}
@@ -331,46 +324,32 @@ public class LoginServerThread extends Thread
}
catch (UnknownHostException e)
{
LOGGER.info("Deconnected from Login, Trying to reconnect:");
LOGGER.info("Disconnected from Login, Trying to reconnect:");
LOGGER.info(e.toString());
}
catch (IOException e)
{
LOGGER.info("Deconnected from Login, Trying to reconnect..");
LOGGER.info("Disconnected from Login, Trying to reconnect:");
LOGGER.info(e.toString());
}
finally
{
if (_out != null)
try
{
synchronized (_out) // avoids tow threads writing in the mean time
{
try
{
_loginSocket.close();
}
catch (Exception e)
{
}
}
_loginSocket.close();
}
else
catch (Exception e)
{
try
{
_loginSocket.close();
}
catch (Exception e)
{
}
}
}
try
{
Thread.sleep(5000); // 5 seconds
Thread.sleep(5000); // 5 seconds tempo.
}
catch (InterruptedException e)
{
return;
}
}
}
@@ -378,43 +357,32 @@ public class LoginServerThread extends Thread
public void addWaitingClientAndSendRequest(String acc, GameClient client, SessionKey key)
{
final WaitingClient wc = new WaitingClient(acc, client, key);
synchronized (_waitingClients)
{
_waitingClients.add(wc);
}
_waitingClients.add(wc);
final PlayerAuthRequest par = new PlayerAuthRequest(acc, key);
try
{
sendPacket(par);
}
catch (IOException e)
{
LOGGER.warning("Error while sending player auth request");
LOGGER.warning("Error while sending player auth request.");
}
}
public void removeWaitingClient(GameClient client)
{
WaitingClient toRemove = null;
synchronized (_waitingClients)
for (WaitingClient c : _waitingClients)
{
for (WaitingClient c : _waitingClients)
if (c.gameClient == client)
{
if (c.gameClient == client)
{
toRemove = c;
}
}
if (toRemove != null)
{
_waitingClients.remove(toRemove);
toRemove = c;
}
}
if (toRemove != null)
{
_waitingClients.remove(toRemove);
}
}
public void sendLogout(String account)
@@ -430,7 +398,11 @@ public class LoginServerThread extends Thread
}
catch (IOException e)
{
LOGGER.warning("Error while sending logout packet to login: " + e.getMessage());
LOGGER.warning("Error while sending logout packet to login.");
}
finally
{
_accountsInGameServer.remove(account);
}
}
@@ -493,29 +465,22 @@ public class LoginServerThread extends Thread
*/
private void sendPacket(GameServerBasePacket sl) throws IOException
{
if (_interrupted)
{
return;
}
byte[] data = sl.getContent();
NewCrypt.appendChecksum(data);
data = _blowfish.crypt(data);
_blowfish.crypt(data, 0, data.length);
final int len = data.length + 2;
if ((_out != null) && !_loginSocket.isClosed() && _loginSocket.isConnected())
synchronized (_out) // avoids two threads writing in the mean time
{
synchronized (_out) // avoids tow threads writing in the mean time
{
_out.write(len & 0xff);
_out.write((len >> 8) & 0xff);
_out.write(data);
_out.flush();
}
_out.write(len & 0xff);
_out.write((len >> 8) & 0xff);
_out.write(data);
_out.flush();
}
}
/**
* Sets the max player.
* @param maxPlayer The maxPlayer to set.
*/
public void setMaxPlayer(int maxPlayer)
@@ -525,6 +490,7 @@ public class LoginServerThread extends Thread
}
/**
* Gets the max player.
* @return Returns the maxPlayer.
*/
public int getMaxPlayer()
@@ -533,8 +499,9 @@ public class LoginServerThread extends Thread
}
/**
* @param id
* @param value
* Send server status.
* @param id the id
* @param value the value
*/
public void sendServerStatus(int id, int value)
{
@@ -574,13 +541,18 @@ public class LoginServerThread extends Thread
}
/**
* @return Returns the serverName.
* Gets the server name.
* @return the server name.
*/
public String getServerName()
{
return _serverName;
}
/**
* Sets the server status.
* @param status the new server status
*/
public void setServerStatus(int status)
{
switch (status)
@@ -634,8 +606,14 @@ public class LoginServerThread extends Thread
public int playOkID2;
public int loginOkID1;
public int loginOkID2;
public int clientKey = -1;
/**
* Instantiates a new session key.
* @param loginOK1 the login o k1
* @param loginOK2 the login o k2
* @param playOK1 the play o k1
* @param playOK2 the play o k2
*/
public SessionKey(int loginOK1, int loginOK2, int playOK1, int playOK2)
{
playOkID1 = playOK1;
@@ -651,12 +629,18 @@ public class LoginServerThread extends Thread
}
}
private class WaitingClient
private static class WaitingClient
{
public String account;
public GameClient gameClient;
public SessionKey session;
/**
* Instantiates a new waiting client.
* @param acc the acc
* @param client the client
* @param key the key
*/
public WaitingClient(String acc, GameClient client, SessionKey key)
{
account = acc;
@@ -664,33 +648,4 @@ public class LoginServerThread extends Thread
session = key;
}
}
private boolean _interrupted = false;
@Override
public void interrupt()
{
_interrupted = true;
super.interrupt();
}
@Override
public boolean isInterrupted()
{
return _interrupted;
}
/**
* Gets the single instance of LoginServerThread.
* @return single instance of LoginServerThread
*/
public static LoginServerThread getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final LoginServerThread INSTANCE = new LoginServerThread();
}
}
}
@@ -125,12 +125,6 @@ public class RecipeController
public synchronized void requestMakeItem(PlayerInstance player, int recipeListId)
{
if (player.isInDuel())
{
player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
return;
}
final RecipeList recipeList = getValidRecipeList(player, recipeListId);
if (recipeList == null)
{
@@ -25,8 +25,6 @@ import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.datatables.OfflineTradeTable;
import org.l2jmobius.gameserver.datatables.SchemeBufferTable;
import org.l2jmobius.gameserver.instancemanager.CastleManorManager;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
import org.l2jmobius.gameserver.instancemanager.GlobalVariablesManager;
import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
@@ -443,16 +441,9 @@ public class Shutdown extends Thread
}
LOGGER.info("Olympiad System: Data saved!!");
// Save Cursed Weapons data before closing.
CursedWeaponsManager.getInstance().saveData();
// Save all manor data
CastleManorManager.getInstance().save();
// Save Fishing tournament data
FishingChampionshipManager.getInstance().shutdown();
LOGGER.info("Fishing Championship data have been saved!!");
// Schemes save.
SchemeBufferTable.getInstance().saveSchemes();
LOGGER.info("BufferTable data has been saved!!");
@@ -1,660 +0,0 @@
/*
* 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.datatables.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.model.Augmentation;
import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.skills.Stat;
/**
* This class manages the augmentation data and can also create new augmentations.
* @author durgus
*/
public class AugmentationData
{
private static final Logger LOGGER = Logger.getLogger(AugmentationData.class.getName());
// stats
private static final int STAT_START = 1;
private static final int STAT_END = 14560;
private static final int STAT_BLOCKSIZE = 3640;
private static final int STAT_SUBBLOCKSIZE = 91;
// skills
private static final int BLUE_START = 14561;
private static final int SKILLS_BLOCKSIZE = 178;
// basestats
private static final int BASESTAT_STR = 16341;
private static final int BASESTAT_CON = 16342;
private static final int BASESTAT_INT = 16343;
private static final int BASESTAT_MEN = 16344;
private static List<augmentationStat>[] _augmentationStats = null;
private static Map<Integer, ArrayList<augmentationSkill>> _blueSkills = null;
private static Map<Integer, ArrayList<augmentationSkill>> _purpleSkills = null;
private static Map<Integer, ArrayList<augmentationSkill>> _redSkills = null;
private AugmentationData()
{
load();
}
@SuppressWarnings("unchecked")
public void load()
{
LOGGER.info("Initializing AugmentationData.");
_augmentationStats = new ArrayList[4];
_augmentationStats[0] = new ArrayList<>();
_augmentationStats[1] = new ArrayList<>();
_augmentationStats[2] = new ArrayList<>();
_augmentationStats[3] = new ArrayList<>();
_blueSkills = new HashMap<>();
_purpleSkills = new HashMap<>();
_redSkills = new HashMap<>();
for (int i = 1; i <= 10; i++)
{
_blueSkills.put(i, new ArrayList<augmentationSkill>());
_purpleSkills.put(i, new ArrayList<augmentationSkill>());
_redSkills.put(i, new ArrayList<augmentationSkill>());
}
// Load the skillmap
// Note: the skillmap data is only used when generating new augmentations the client expects a different id in order to display the skill in the items description.
try
{
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setIgnoringComments(true);
int badAugmantData = 0;
final File file = new File(Config.DATAPACK_ROOT + "/data/stats/augmentation/augmentation_skillmap.xml");
if (!file.exists())
{
return;
}
final Document doc = factory.newDocumentBuilder().parse(file);
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("augmentation".equalsIgnoreCase(d.getNodeName()))
{
NamedNodeMap attrs = d.getAttributes();
int skillId = 0;
final int augmentationId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
String type = "blue";
int skillLvL = 0;
for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
{
if ("skillId".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
skillId = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
}
else if ("skillLevel".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
skillLvL = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
}
else if ("type".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
type = attrs.getNamedItem("val").getNodeValue();
}
}
if (skillId == 0)
{
badAugmantData++;
continue;
}
if (skillLvL == 0)
{
badAugmantData++;
continue;
}
int k = 1;
while ((augmentationId - (k * SKILLS_BLOCKSIZE)) >= BLUE_START)
{
k++;
}
if (type.equalsIgnoreCase("blue"))
{
_blueSkills.get(k).add(new augmentationSkill(skillId, skillLvL, augmentationId));
}
else if (type.equalsIgnoreCase("purple"))
{
_purpleSkills.get(k).add(new augmentationSkill(skillId, skillLvL, augmentationId));
}
else
{
_redSkills.get(k).add(new augmentationSkill(skillId, skillLvL, augmentationId));
}
}
}
}
}
if (badAugmantData != 0)
{
LOGGER.info("AugmentationData: " + badAugmantData + " bad skill(s) were skipped.");
}
}
catch (Exception e)
{
LOGGER.warning("Error parsing augmentation_skillmap.xml. " + e);
return;
}
// Load the stats from xml
for (int i = 1; i < 5; i++)
{
try
{
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setIgnoringComments(true);
final File file = new File(Config.DATAPACK_ROOT + "/data/stats/augmentation/augmentation_stats" + i + ".xml");
if (!file.exists())
{
return;
}
final Document doc = factory.newDocumentBuilder().parse(file);
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("stat".equalsIgnoreCase(d.getNodeName()))
{
NamedNodeMap attrs = d.getAttributes();
final String statName = attrs.getNamedItem("name").getNodeValue();
float[] soloValues = null;
float[] combinedValues = null;
for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
{
if ("table".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
final String tableName = attrs.getNamedItem("name").getNodeValue();
final StringTokenizer data = new StringTokenizer(cd.getFirstChild().getNodeValue());
final List<Float> array = new ArrayList<>();
while (data.hasMoreTokens())
{
array.add(Float.parseFloat(data.nextToken()));
}
if (tableName.equalsIgnoreCase("#soloValues"))
{
soloValues = new float[array.size()];
int x = 0;
for (float value : array)
{
soloValues[x++] = value;
}
}
else
{
combinedValues = new float[array.size()];
int x = 0;
for (float value : array)
{
combinedValues[x++] = value;
}
}
}
}
// store this stat
_augmentationStats[(i - 1)].add(new augmentationStat(Stat.valueOfXml(statName), soloValues, combinedValues));
}
}
}
}
}
catch (Exception e)
{
LOGGER.warning("Error parsing augmentation_stats" + i + ".xml. " + e);
return;
}
}
// Use size*4: since theres 4 blocks of stat-data with equivalent size
LOGGER.info("AugmentationData: Loaded " + (_augmentationStats[0].size() * 4) + " augmentation stats.");
}
/**
* Generate a new random augmentation
* @param item
* @param lifeStoneLevel
* @param lifeStoneGrade
* @return Augmentation
*/
public Augmentation generateRandomAugmentation(ItemInstance item, int lifeStoneLevel, int lifeStoneGrade)
{
// Note: stat12 stands for stat 1 AND 2 (same for stat34 ;p ) this is because a value can contain up to 2 stat modifications (there are two short values packed in one integer value, meaning 4 stat modifications at max) for more info take a look at getAugStatsById(...)
// Note: lifeStoneGrade: (0 means low grade, 3 top grade)
// First: determine whether we will add a skill/baseStatModifier or not because this determine which color could be the result
int skillChance = 0;
int stat34 = 0;
boolean generateSkill = false;
int resultColor = 0;
boolean generateGlow = false;
switch (lifeStoneGrade)
{
case 0:
{
skillChance = Config.AUGMENTATION_NG_SKILL_CHANCE;
if (Rnd.get(1, 100) <= Config.AUGMENTATION_NG_GLOW_CHANCE)
{
generateGlow = true;
}
break;
}
case 1:
{
skillChance = Config.AUGMENTATION_MID_SKILL_CHANCE;
if (Rnd.get(1, 100) <= Config.AUGMENTATION_MID_GLOW_CHANCE)
{
generateGlow = true;
}
break;
}
case 2:
{
skillChance = Config.AUGMENTATION_HIGH_SKILL_CHANCE;
if (Rnd.get(1, 100) <= Config.AUGMENTATION_HIGH_GLOW_CHANCE)
{
generateGlow = true;
}
break;
}
case 3:
{
skillChance = Config.AUGMENTATION_TOP_SKILL_CHANCE;
if (Rnd.get(1, 100) <= Config.AUGMENTATION_TOP_GLOW_CHANCE)
{
generateGlow = true;
}
}
}
if (Rnd.get(1, 100) <= skillChance)
{
generateSkill = true;
}
else if (Rnd.get(1, 100) <= Config.AUGMENTATION_BASESTAT_CHANCE)
{
stat34 = Rnd.get(BASESTAT_STR, BASESTAT_MEN);
}
// Second: decide which grade the augmentation result is going to have:
// 0:yellow, 1:blue, 2:purple, 3:red
// The chances used here are most likely custom, whats known is: u can also get a red result from a normal grade lifeStone however I will make it so that a higher grade lifeStone will more likely result in a higher grade augmentation...
// and the augmentation result will at least have the grade of the life stone
// Second: Calculate the subblock offset for the choosen color, and the level of the lifeStone
// Whats is known: you cant have yellow with skill(or baseStatModifier) noGrade stone can not have glow, mid only with skill, high has a chance(custom), top allways glow
if ((stat34 == 0) && !generateSkill)
{
resultColor = Rnd.get(0, 100);
if (resultColor <= ((15 * lifeStoneGrade) + 40))
{
resultColor = 1;
}
else
{
resultColor = 0;
}
}
else
{
resultColor = Rnd.get(0, 100);
if ((resultColor <= ((10 * lifeStoneGrade) + 5)) || (stat34 != 0))
{
resultColor = 3;
}
else if (resultColor <= ((10 * lifeStoneGrade) + 10))
{
resultColor = 1;
}
else
{
resultColor = 2;
}
}
// is neither a skill nor basestat used for stat34? then generate a normal stat
int stat12 = 0;
if ((stat34 == 0) && !generateSkill)
{
final int temp = Rnd.get(2, 3);
final int colorOffset = (resultColor * 10 * STAT_SUBBLOCKSIZE) + (temp * STAT_BLOCKSIZE) + 1;
int offset = ((lifeStoneLevel - 1) * STAT_SUBBLOCKSIZE) + colorOffset;
stat34 = Rnd.get(offset, (offset + STAT_SUBBLOCKSIZE) - 1);
if (generateGlow && (lifeStoneGrade >= 2))
{
offset = ((lifeStoneLevel - 1) * STAT_SUBBLOCKSIZE) + ((temp - 2) * STAT_BLOCKSIZE) + (lifeStoneGrade * 10 * STAT_SUBBLOCKSIZE) + 1;
}
else
{
offset = ((lifeStoneLevel - 1) * STAT_SUBBLOCKSIZE) + ((temp - 2) * STAT_BLOCKSIZE) + (Rnd.get(0, 1) * 10 * STAT_SUBBLOCKSIZE) + 1;
}
stat12 = Rnd.get(offset, (offset + STAT_SUBBLOCKSIZE) - 1);
}
else
{
int offset;
if (!generateGlow)
{
offset = ((lifeStoneLevel - 1) * STAT_SUBBLOCKSIZE) + (Rnd.get(0, 1) * STAT_BLOCKSIZE) + 1;
}
else
{
offset = ((lifeStoneLevel - 1) * STAT_SUBBLOCKSIZE) + (Rnd.get(0, 1) * STAT_BLOCKSIZE) + (((lifeStoneGrade + resultColor) / 2) * 10 * STAT_SUBBLOCKSIZE) + 1;
}
stat12 = Rnd.get(offset, (offset + STAT_SUBBLOCKSIZE) - 1);
}
// generate a skill if neccessary
Skill skill = null;
if (generateSkill)
{
augmentationSkill temp = null;
switch (resultColor)
{
case 1: // blue skill
{
temp = _blueSkills.get(lifeStoneLevel).get(Rnd.get(0, _blueSkills.get(lifeStoneLevel).size() - 1));
skill = temp.getSkill(lifeStoneLevel);
stat34 = temp.getAugmentationSkillId();
break;
}
case 2: // purple skill
{
temp = _purpleSkills.get(lifeStoneLevel).get(Rnd.get(0, _purpleSkills.get(lifeStoneLevel).size() - 1));
skill = temp.getSkill(lifeStoneLevel);
stat34 = temp.getAugmentationSkillId();
break;
}
case 3: // red skill
{
temp = _redSkills.get(lifeStoneLevel).get(Rnd.get(0, _redSkills.get(lifeStoneLevel).size() - 1));
skill = temp.getSkill(lifeStoneLevel);
stat34 = temp.getAugmentationSkillId();
break;
}
}
}
return new Augmentation(item, ((stat34 << 16) + stat12), skill, true);
}
public class AugStat
{
private final Stat _stat;
private final float _value;
public AugStat(Stat stat, float value)
{
_stat = stat;
_value = value;
}
public Stat getStat()
{
return _stat;
}
public float getValue()
{
return _value;
}
}
/**
* Returns the stat and basestat boni for a given augmentation id
* @param augmentationId
* @return
*/
public List<AugStat> getAugStatsById(int augmentationId)
{
final List<AugStat> temp = new ArrayList<>();
// An augmentation id contains 2 short vaues so we gotta seperate them here
// both values contain a number from 1-16380, the first 14560 values are stats
// the 14560 stats are devided into 4 blocks each holding 3640 values
// each block contains 40 subblocks holding 91 stat values
// the first 13 values are so called Solo-stats and they have the highest stat increase possible
// after the 13 Solo-stats come 78 combined stats (thats every possible combination of the 13 solo stats)
// the first 12 combined stats (14-26) is the stat 1 combined with stat 2-13
// the next 11 combined stats then are stat 2 combined with stat 3-13 and so on...
// to get the idea have a look @ optiondata_client-e.dat - thats where the data came from :)
final int[] stats = new int[2];
stats[0] = 0x0000FFFF & augmentationId;
stats[1] = augmentationId >> 16;
for (int i = 0; i < 2; i++)
{
// its a stat
if ((stats[i] >= STAT_START) && (stats[i] <= STAT_END))
{
int block = 0;
while (stats[i] > STAT_BLOCKSIZE)
{
stats[i] -= STAT_BLOCKSIZE;
block++;
}
int subblock = 0;
while (stats[i] > STAT_SUBBLOCKSIZE)
{
stats[i] -= STAT_SUBBLOCKSIZE;
subblock++;
}
if (stats[i] < 14) // solo stat
{
final augmentationStat as = _augmentationStats[block].get((stats[i] - 1));
temp.add(new AugStat(as.getStat(), as.getSingleStatValue(subblock)));
}
else // twin stat
{
stats[i] -= 13; // rescale to 0 (if first of first combined block)
int x = 12; // next combi block has 12 stats
int rescales = 0; // number of rescales done
while (stats[i] > x)
{
stats[i] -= x;
x--;
rescales++;
}
// get first stat
augmentationStat as = _augmentationStats[block].get(rescales);
if (rescales == 0)
{
temp.add(new AugStat(as.getStat(), as.getCombinedStatValue(subblock)));
}
else
{
temp.add(new AugStat(as.getStat(), as.getCombinedStatValue((subblock * 2) + 1)));
}
// get 2nd stat
as = _augmentationStats[block].get(rescales + stats[i]);
if (as.getStat() == Stat.CRITICAL_DAMAGE)
{
temp.add(new AugStat(as.getStat(), as.getCombinedStatValue(subblock)));
}
else
{
temp.add(new AugStat(as.getStat(), as.getCombinedStatValue(subblock * 2)));
}
}
}
// its a base stat
else if ((stats[i] >= BASESTAT_STR) && (stats[i] <= BASESTAT_MEN))
{
switch (stats[i])
{
case BASESTAT_STR:
{
temp.add(new AugStat(Stat.STAT_STR, 1.0f));
break;
}
case BASESTAT_CON:
{
temp.add(new AugStat(Stat.STAT_CON, 1.0f));
break;
}
case BASESTAT_INT:
{
temp.add(new AugStat(Stat.STAT_INT, 1.0f));
break;
}
case BASESTAT_MEN:
{
temp.add(new AugStat(Stat.STAT_MEN, 1.0f));
break;
}
}
}
}
return temp;
}
public class augmentationSkill
{
private final int _skillId;
private final int _maxSkillLevel;
private final int _augmentationSkillId;
public augmentationSkill(int skillId, int maxSkillLevel, int augmentationSkillId)
{
_skillId = skillId;
_maxSkillLevel = maxSkillLevel;
_augmentationSkillId = augmentationSkillId;
}
public Skill getSkill(int level)
{
if (level > _maxSkillLevel)
{
return SkillTable.getInstance().getInfo(_skillId, _maxSkillLevel);
}
return SkillTable.getInstance().getInfo(_skillId, level);
}
public int getAugmentationSkillId()
{
return _augmentationSkillId;
}
}
public class augmentationStat
{
private final Stat _stat;
private final int _singleSize;
private final int _combinedSize;
private final float[] _singleValues;
private final float[] _combinedValues;
public augmentationStat(Stat stat, float[] sValues, float[] cValues)
{
_stat = stat;
_singleSize = sValues.length;
_singleValues = sValues;
_combinedSize = cValues.length;
_combinedValues = cValues;
}
public int getSingleStatSize()
{
return _singleSize;
}
public int getCombinedStatSize()
{
return _combinedSize;
}
public float getSingleStatValue(int i)
{
if ((i >= _singleSize) || (i < 0))
{
return _singleValues[_singleSize - 1];
}
return _singleValues[i];
}
public float getCombinedStatValue(int i)
{
if ((i >= _combinedSize) || (i < 0))
{
return _combinedValues[_combinedSize - 1];
}
return _combinedValues[i];
}
public Stat getStat()
{
return _stat;
}
}
public static AugmentationData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final AugmentationData INSTANCE = new AugmentationData();
}
}
@@ -136,7 +136,7 @@ public class ZoneData
return;
}
for (final File file : mainDir.listFiles())
for (File file : mainDir.listFiles())
{
if (file.isFile() && file.getName().endsWith(".xml"))
{
@@ -30,7 +30,6 @@ import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminCache;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminChangeAccessLevel;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminChristmas;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminCreateItem;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDMEngine;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDelete;
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminDestroyItems;
@@ -111,7 +110,6 @@ public class AdminCommandHandler
registerAdminCommandHandler(new AdminChristmas());
registerAdminCommandHandler(new AdminCreateItem());
registerAdminCommandHandler(new AdminCTFEngine());
registerAdminCommandHandler(new AdminCursedWeapons());
registerAdminCommandHandler(new AdminDelete());
registerAdminCommandHandler(new AdminDestroyItems());
registerAdminCommandHandler(new AdminDMEngine());
@@ -27,7 +27,6 @@ import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.util.BuilderUtil;
/**
@@ -184,7 +183,6 @@ public class AdminAio implements IAdminCommandHandler
player.rewardAioSkills();
player.broadcastUserInfo();
player.sendPacket(new EtcStatusUpdate(player));
player.sendSkillList();
AdminData.broadcastMessageToGMs("GM " + activeChar.getName() + " set Aio stat for player " + playerName + " for " + time + " day(s)");
player.sendMessage("You are now an Aio, Congratulations!");
@@ -217,7 +215,6 @@ public class AdminAio implements IAdminCommandHandler
player.getAppearance().setNameColor(0xFFFFFF);
player.getAppearance().setTitleColor(0xFFFFFF);
player.broadcastUserInfo();
player.sendPacket(new EtcStatusUpdate(player));
player.sendSkillList();
AdminData.broadcastMessageToGMs("GM " + activeChar.getName() + " remove Aio stat of player " + playerName);
player.sendMessage("Now You are not an Aio..");
@@ -1,268 +0,0 @@
/*
* 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.handler.admincommandhandlers;
import java.util.StringTokenizer;
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.CursedWeapon;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.util.BuilderUtil;
/**
* This class handles following admin commands:<br>
* - cw_info = displays cursed weapon status.<br>
* - cw_remove = removes a cursed weapon from the world, item id or name must be provided.<br>
* - cw_add = adds a cursed weapon into the world, item id or name must be provided, the target will be the wielder.<br>
* - cw_goto = teleports GM to the specified cursed weapon.<br>
* - cw_reload = reloads instance manager.
* @author ProGramMoS, Zoey76
*/
public class AdminCursedWeapons implements IAdminCommandHandler
{
private static final CursedWeaponsManager cursedWeaponsManager = CursedWeaponsManager.getInstance();
private static final String[] ADMIN_COMMANDS =
{
"admin_cw_info",
"admin_cw_remove",
"admin_cw_goto",
"admin_cw_reload",
"admin_cw_add",
"admin_cw_info_menu"
};
@Override
public boolean useAdminCommand(String command, PlayerInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
if (command.equalsIgnoreCase("admin_cw_info"))
{
BuilderUtil.sendSysMessage(activeChar, "====== Cursed Weapons: ======");
for (CursedWeapon cw : cursedWeaponsManager.getCursedWeapons())
{
BuilderUtil.sendSysMessage(activeChar, "> " + cw.getName() + " (" + cw.getItemId() + ")");
if (cw.isActivated())
{
final PlayerInstance pl = cw.getPlayer();
BuilderUtil.sendSysMessage(activeChar, " Player holding: " + (pl == null ? "null" : pl.getName()));
BuilderUtil.sendSysMessage(activeChar, " Player karma: " + cw.getPlayerKarma());
BuilderUtil.sendSysMessage(activeChar, " Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
BuilderUtil.sendSysMessage(activeChar, " Kills : " + cw.getNbKills());
}
else if (cw.isDropped())
{
BuilderUtil.sendSysMessage(activeChar, " Lying on the ground.");
BuilderUtil.sendSysMessage(activeChar, " Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
BuilderUtil.sendSysMessage(activeChar, " Kills : " + cw.getNbKills());
}
else
{
BuilderUtil.sendSysMessage(activeChar, " Don't exist in the world.");
}
activeChar.sendPacket(SystemMessageId.EMPTY_3);
}
}
else if (command.equalsIgnoreCase("admin_cw_info_menu"))
{
final StringBuilder replyMSG = new StringBuilder();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setFile("data/html/admin/cwinfo.htm");
for (CursedWeapon cw : cursedWeaponsManager.getCursedWeapons())
{
final int itemId = cw.getItemId();
replyMSG.append("<table width=270><tr><td>Name:</td><td>" + cw.getName() + "</td></tr>");
if (cw.isActivated())
{
final PlayerInstance pl = cw.getPlayer();
replyMSG.append("<tr><td>Weilder:</td><td>" + (pl == null ? "null" : pl.getName()) + "</td></tr>");
replyMSG.append("<tr><td>Karma:</td><td>" + cw.getPlayerKarma() + "</td></tr>");
replyMSG.append("<tr><td>Kills:</td><td>" + cw.getPlayerPkKills() + "/" + cw.getNbKills() + "</td></tr>");
replyMSG.append("<tr><td>Time remaining:</td><td>" + (cw.getTimeLeft() / 60000) + " min.</td></tr>");
replyMSG.append("<tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove " + itemId + "\" width=73 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Go\" action=\"bypass -h admin_cw_goto " + itemId + "\" width=73 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
}
else if (cw.isDropped())
{
replyMSG.append("<tr><td>Position:</td><td>Lying on the ground</td></tr>");
replyMSG.append("<tr><td>Time remaining:</td><td>" + (cw.getTimeLeft() / 60000) + " min.</td></tr>");
replyMSG.append("<tr><td>Kills:</td><td>" + cw.getNbKills() + "</td></tr>");
replyMSG.append("<tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove " + itemId + "\" width=73 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
replyMSG.append("<td><button value=\"Go\" action=\"bypass -h admin_cw_goto " + itemId + "\" width=73 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
}
else
{
replyMSG.append("<tr><td>Position:</td><td>Doesn't exist.</td></tr>");
replyMSG.append("<tr><td><button value=\"Give to Target\" action=\"bypass -h admin_cw_add " + itemId + "\" width=99 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td></td></tr>");
}
replyMSG.append("</table>");
replyMSG.append("<br>");
}
adminReply.replace("%cwinfo%", replyMSG.toString());
activeChar.sendPacket(adminReply);
}
else if (command.equalsIgnoreCase("admin_cw_reload"))
{
cursedWeaponsManager.reload();
}
else if (command.startsWith("admin_cw_remove"))
{
if (!st.hasMoreElements())
{
BuilderUtil.sendSysMessage(activeChar, "Not enough parameters!");
return false;
}
String parameter = st.nextToken();
int id = 0;
if (parameter.matches("[0-9]*"))
{
id = Integer.parseInt(parameter);
}
else
{
parameter = parameter.replace('_', ' ');
for (CursedWeapon cwp : cursedWeaponsManager.getCursedWeapons())
{
if (cwp.getName().toLowerCase().contains(parameter.toLowerCase()))
{
id = cwp.getItemId();
break;
}
}
}
if (cursedWeaponsManager.isCursed(id))
{
cursedWeaponsManager.getCursedWeapon(id).endOfLife();
}
else
{
BuilderUtil.sendSysMessage(activeChar, "Wrong Cursed Weapon Id!");
}
}
else if (command.startsWith("admin_cw_goto"))
{
if (!st.hasMoreElements())
{
BuilderUtil.sendSysMessage(activeChar, "Not enough parameters!");
return false;
}
String parameter = st.nextToken();
int id = 0;
if (parameter.matches("[0-9]*"))
{
id = Integer.parseInt(parameter);
}
else
{
parameter = parameter.replace('_', ' ');
for (CursedWeapon cwp : cursedWeaponsManager.getCursedWeapons())
{
if (cwp.getName().toLowerCase().contains(parameter.toLowerCase()))
{
id = cwp.getItemId();
break;
}
}
}
if (cursedWeaponsManager.isCursed(id))
{
cursedWeaponsManager.getCursedWeapon(id).goTo(activeChar);
}
else
{
BuilderUtil.sendSysMessage(activeChar, "Wrong Cursed Weapon Id!");
}
}
else if (command.startsWith("admin_cw_add"))
{
if (!st.hasMoreElements())
{
BuilderUtil.sendSysMessage(activeChar, "Not enough parameters!");
return false;
}
String parameter = st.nextToken();
int id = 0;
if (parameter.matches("[0-9]*"))
{
id = Integer.parseInt(parameter);
}
else
{
parameter = parameter.replace('_', ' ');
for (CursedWeapon cwp : cursedWeaponsManager.getCursedWeapons())
{
if (cwp.getName().toLowerCase().contains(parameter.toLowerCase()))
{
id = cwp.getItemId();
break;
}
}
}
if (cursedWeaponsManager.isCursed(id))
{
final CursedWeapon cursedWeapon = cursedWeaponsManager.getCursedWeapon(id);
if (cursedWeapon.isActive())
{
BuilderUtil.sendSysMessage(activeChar, "This Cursed Weapon is already active!");
}
else
{
// end time is equal to dropped one
final long endTime = System.currentTimeMillis() + (cursedWeapon.getDuration() * 60000);
cursedWeapon.setEndTime(endTime);
final WorldObject target = activeChar.getTarget();
if ((target != null) && (target instanceof PlayerInstance))
{
((PlayerInstance) target).addItem("AdminCursedWeaponAdd", id, 1, target, true);
}
else
{
activeChar.addItem("AdminCursedWeaponAdd", id, 1, activeChar, true);
}
}
}
else
{
BuilderUtil.sendSysMessage(activeChar, "Wrong Cursed Weapon Id!");
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}
@@ -27,7 +27,6 @@ import org.l2jmobius.gameserver.model.skills.effects.EffectCharge;
import org.l2jmobius.gameserver.model.skills.handlers.SkillCharge;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
@@ -110,7 +109,6 @@ public class EnergyStone implements IItemHandler
final MagicSkillUse msu = new MagicSkillUse(playable, player, skill.getId(), 1, 1, 0);
player.sendPacket(msu);
player.broadcastPacket(msu);
player.sendPacket(new EtcStatusUpdate(player));
player.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
@@ -238,7 +238,7 @@ public class Potions implements IItemHandler
return;
}
if (!Config.ALLOW_POTS_IN_PVP && (activeChar.isInDuel() || (activeChar.getPvpFlag() != 0)))
if (!Config.ALLOW_POTS_IN_PVP && (activeChar.getPvpFlag() != 0))
{
activeChar.sendMessage("You Cannot Use Potions In PvP!");
return;
@@ -152,13 +152,6 @@ public class ScrollOfEscape implements IItemHandler
return;
}
// Check to see if player is in a duel
if (player.isInDuel())
{
player.sendPacket(SystemMessage.sendString("You cannot use escape skills during a duel."));
return;
}
if (player.isParalyzed())
{
player.sendPacket(SystemMessage.sendString("You may not use an escape skill in a paralyzed."));
@@ -171,7 +164,12 @@ public class ScrollOfEscape implements IItemHandler
sm3.addItemName(itemId);
player.sendPacket(sm3);
final int escapeSkill = (itemId == 1538) || (itemId == 5858) || (itemId == 5859) || (itemId == 3958) || (itemId == 10130) ? 2036 : 2013;
int escapeSkill = (itemId == 1538) || (itemId == 5858) || (itemId == 5859) || (itemId == 3958) || (itemId == 10130) ? 2036 : 2013;
// C4 adjustment.
if ((escapeSkill == 2036) || (escapeSkill == 2177) || (escapeSkill == 2178))
{
escapeSkill = 2013;
}
if (!player.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
return;
@@ -188,16 +186,23 @@ public class ScrollOfEscape implements IItemHandler
player.abortCast(true);
player.disableAllSkills();
// Cast escape animation.
final Skill skill = SkillTable.getInstance().getInfo(escapeSkill, 1);
player.broadcastPacket(new MagicSkillUse(player, player, escapeSkill, 1, skill.getHitTime(), 0));
player.sendPacket(new SetupGauge(0, skill.getHitTime()));
int hitTime = skill.getHitTime();
// C4 adjustment.
if ((escapeSkill == 2036) || (escapeSkill == 2177) || (escapeSkill == 2178))
{
hitTime = 500;
}
// Cast escape animation.
player.broadcastPacket(new MagicSkillUse(player, player, escapeSkill, 1, hitTime, 0));
player.sendPacket(new SetupGauge(0, hitTime));
player.setTarget(null);
// Continue execution later.
final EscapeFinalizer escapeFinalizer = new EscapeFinalizer(player, itemId);
player.setSkillCast(ThreadPool.schedule(escapeFinalizer, skill.getHitTime()));
player.setSkillCastEndTime(10 + GameTimeController.getGameTicks() + (skill.getHitTime() / GameTimeController.MILLIS_IN_TICK));
player.setSkillCast(ThreadPool.schedule(escapeFinalizer, hitTime));
player.setSkillCastEndTime(10 + GameTimeController.getGameTicks() + (hitTime / GameTimeController.MILLIS_IN_TICK));
}
static class EscapeFinalizer implements Runnable
@@ -120,19 +120,13 @@ public class SummonItems implements IItemHandler
return;
}
if (player.isCursedWeaponEquiped() && sitem.isPetSummon())
{
player.sendPacket(SystemMessageId.A_STRIDER_CANNOT_BE_RIDDEN_WHILE_IN_BATTLE);
return;
}
final int npcID = sitem.getNpcId();
if (npcID == 0)
final int npcId = sitem.getNpcId();
if (npcId == 0)
{
return;
}
final NpcTemplate npcTemplate = NpcTable.getInstance().getTemplate(npcID);
final NpcTemplate npcTemplate = NpcTable.getInstance().getTemplate(npcId);
if (npcTemplate == null)
{
return;
@@ -23,7 +23,6 @@ import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.Skill.SkillType;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
/**
@@ -54,12 +53,6 @@ public class BalanceLife implements ISkillHandler
}
Creature target = null;
PlayerInstance player = null;
if (creature instanceof PlayerInstance)
{
player = (PlayerInstance) creature;
}
double fullHP = 0;
double currentHPs = 0;
for (WorldObject target2 : targets)
@@ -78,19 +71,6 @@ public class BalanceLife implements ISkillHandler
continue;
}
// Player holding a cursed weapon can't be healed and can't heal
if (target != creature)
{
if ((target instanceof PlayerInstance) && ((PlayerInstance) target).isCursedWeaponEquiped())
{
continue;
}
else if ((player != null) && player.isCursedWeaponEquiped())
{
continue;
}
}
fullHP += target.getMaxHp();
currentHPs += target.getCurrentHp();
}
@@ -182,29 +182,22 @@ public class Blow implements ISkillHandler
}
if (damage >= player.getCurrentHp())
{
if (player.isInDuel())
player.setCurrentHp(0);
if (player.isInOlympiadMode())
{
player.setCurrentHp(1);
player.abortAttack();
player.abortCast();
player.getStatus().stopHpMpRegeneration();
// player.setDead(true);
player.setIsPendingRevive(true);
if (player.getPet() != null)
{
player.getPet().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
}
}
else
{
player.setCurrentHp(0);
if (player.isInOlympiadMode())
{
player.abortAttack();
player.abortCast();
player.getStatus().stopHpMpRegeneration();
// player.setDead(true);
player.setIsPendingRevive(true);
if (player.getPet() != null)
{
player.getPet().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, null);
}
}
else
{
player.doDie(creature);
}
player.doDie(creature);
}
}
else
@@ -24,7 +24,6 @@ import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.handler.ISkillHandler;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.model.Effect;
import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.Skill.SkillType;
@@ -142,19 +141,6 @@ public class Continuous implements ISkillHandler
continue;
}
// Player holding a cursed weapon can't be buffed and can't buff
if ((skill.getSkillType() == SkillType.BUFF) && (target != creature))
{
if ((target instanceof PlayerInstance) && ((PlayerInstance) target).isCursedWeaponEquiped())
{
continue;
}
else if ((player != null) && player.isCursedWeaponEquiped())
{
continue;
}
}
// Possibility of a lethal strike
if (!target.isRaid() && (!(target instanceof NpcInstance) || (((NpcInstance) target).getNpcId() != 35062)))
{
@@ -229,29 +215,7 @@ public class Continuous implements ISkillHandler
continue;
}
// if this is a debuff let the duel manager know about it so the debuff can be removed after the duel (player & target must be in the same duel)
if ((target instanceof PlayerInstance) && (player != null) && ((PlayerInstance) target).isInDuel() && ((skill.getSkillType() == SkillType.DEBUFF) || (skill.getSkillType() == SkillType.BUFF)) && (player.getDuelId() == ((PlayerInstance) target).getDuelId()))
{
final DuelManager dm = DuelManager.getInstance();
if (dm != null)
{
final Effect[] effects = skill.getEffects(creature, target, ss, sps, bss);
if (effects != null)
{
for (Effect buff : effects)
{
if (buff != null)
{
dm.onBuff(((PlayerInstance) target), buff);
}
}
}
}
}
else
{
skill.getEffects(creature, target, ss, sps, bss);
}
skill.getEffects(creature, target, ss, sps, bss);
if (skill.getSkillType() == SkillType.AGGDEBUFF)
{
@@ -95,19 +95,6 @@ public class Heal implements ISkillHandler
continue;
}
// Player holding a cursed weapon can't be healed and can't heal
if (target != creature)
{
if ((target instanceof PlayerInstance) && ((PlayerInstance) target).isCursedWeaponEquiped())
{
continue;
}
else if ((player != null) && player.isCursedWeaponEquiped())
{
continue;
}
}
// Fixed about Infinity Rod skill on Raid Boss and BigBoss
if ((skill.getId() == 3598) && ((target instanceof RaidBossInstance) || (target instanceof GrandBossInstance)))
{
@@ -38,7 +38,6 @@ import org.l2jmobius.gameserver.model.skills.BaseStat;
import org.l2jmobius.gameserver.model.skills.Formulas;
import org.l2jmobius.gameserver.model.skills.effects.EffectCharge;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class Pdam implements ISkillHandler
@@ -227,23 +226,16 @@ public class Pdam implements ISkillHandler
{
if (damage >= player.getCurrentHp())
{
if (player.isInDuel())
player.setCurrentHp(0);
if (player.isInOlympiadMode())
{
player.setCurrentHp(1);
player.abortAttack();
player.abortCast();
player.getStatus().stopHpMpRegeneration();
}
else
{
player.setCurrentHp(0);
if (player.isInOlympiadMode())
{
player.abortAttack();
player.abortCast();
player.getStatus().stopHpMpRegeneration();
}
else
{
player.doDie(creature);
}
player.doDie(creature);
}
}
else
@@ -303,7 +295,6 @@ public class Pdam implements ISkillHandler
effectcharge++;
effect.addNumCharges(1);
creature.sendPacket(new EtcStatusUpdate((PlayerInstance) creature));
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_FORCE_HAS_INCREASED_TO_S1_LEVEL);
sm.addNumber(effectcharge);
creature.sendPacket(sm);
@@ -102,12 +102,6 @@ public class Recall implements ISkillHandler
continue;
}
if (targetChar.isInDuel())
{
targetChar.sendPacket(SystemMessage.sendString("You can't use escape skills during a duel."));
continue;
}
if (targetChar.isAlikeDead())
{
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_IS_DEAD_AT_THE_MOMENT_AND_CANNOT_BE_SUMMONED);
@@ -73,11 +73,6 @@ public class CTFCmd implements IVoicedCommandHandler
activeChar.sendMessage("You are already registered.");
return false;
}
else if (activeChar.isCursedWeaponEquipped())
{
activeChar.sendMessage("You are not allowed to participate to the event because you are holding a Cursed Weapon.");
return false;
}
else if (activeChar.isInOlympiadMode())
{
activeChar.sendMessage("You are not allowed to participate to the event because you are in Olympiad.");
@@ -73,11 +73,6 @@ public class DMCmd implements IVoicedCommandHandler
activeChar.sendMessage("You are already registered.");
return false;
}
else if (activeChar.isCursedWeaponEquipped())
{
activeChar.sendMessage("You are not allowed to participate to the event because you are holding a Cursed Weapon.");
return false;
}
else if (activeChar.isInOlympiadMode())
{
activeChar.sendMessage("You are not allowed to participate to the event because you are in Olympiad.");
@@ -88,11 +88,6 @@ public class FarmPvpCmd implements IVoicedCommandHandler
activeChar.sendMessage("Sorry, you are in an event.");
return false;
}
else if (activeChar.isInDuel())
{
activeChar.sendMessage("Sorry, you are in a duel!");
return false;
}
else if (activeChar.inObserverMode())
{
activeChar.sendMessage("Sorry, you are in the observation mode.");
@@ -73,11 +73,6 @@ public class TvTCmd implements IVoicedCommandHandler
activeChar.sendMessage("You are already registered.");
return false;
}
else if (activeChar.isCursedWeaponEquipped())
{
activeChar.sendMessage("You are not allowed to participate to the event because you are holding a Cursed Weapon.");
return false;
}
else if (activeChar.isInOlympiadMode())
{
activeChar.sendMessage("You are not allowed to participate to the event because you are in Olympiad.");
@@ -272,11 +272,6 @@ public class Wedding implements IVoicedCommandHandler
activeChar.sendMessage("Your partner is in an event.");
return false;
}
else if (partner.isInDuel())
{
activeChar.sendMessage("Your partner is in a duel.");
return false;
}
else if (partner.isFestivalParticipant())
{
activeChar.sendMessage("Your partner is in a festival.");
@@ -337,11 +332,6 @@ public class Wedding implements IVoicedCommandHandler
activeChar.sendMessage("You may not use go to love in VIP.");
return false;
}
else if (activeChar.isInDuel())
{
activeChar.sendMessage("You are in a duel!");
return false;
}
else if (activeChar.inObserverMode())
{
activeChar.sendMessage("You are in the observation.");
@@ -362,11 +352,6 @@ public class Wedding implements IVoicedCommandHandler
activeChar.sendMessage("You are in the dimensional rift.");
return false;
}
else if (activeChar.isCursedWeaponEquiped())
{
activeChar.sendMessage("You have a cursed weapon, you can't go to your partner.");
return false;
}
else if (activeChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND))
{
activeChar.sendMessage("You are in area which blocks summoning.");
@@ -1,445 +0,0 @@
/*
* 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.instancemanager;
import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.model.CursedWeapon;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.CommanderInstance;
import org.l2jmobius.gameserver.model.actor.instance.FestivalMonsterInstance;
import org.l2jmobius.gameserver.model.actor.instance.FortSiegeGuardInstance;
import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.RiftInvaderInstance;
import org.l2jmobius.gameserver.model.actor.instance.SiegeGuardInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* @author Micht
*/
public class CursedWeaponsManager
{
private static final Logger LOGGER = Logger.getLogger(CursedWeaponsManager.class.getName());
private static final Map<Integer, CursedWeapon> _cursedWeapons = new HashMap<>();
public static final CursedWeaponsManager getInstance()
{
return SingletonHolder.INSTANCE;
}
public CursedWeaponsManager()
{
if (!Config.ALLOW_CURSED_WEAPONS)
{
return;
}
load();
restore();
controlPlayers();
LOGGER.info("Loaded: " + _cursedWeapons.size() + " cursed weapon(s).");
}
public void reload()
{
if (!Config.ALLOW_CURSED_WEAPONS)
{
return;
}
_cursedWeapons.clear();
load();
restore();
controlPlayers();
LOGGER.info("Reloaded: " + _cursedWeapons.size() + " cursed weapon(s).");
}
private final void load()
{
LOGGER.info("Initializing CursedWeaponsManager.");
try
{
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setIgnoringComments(true);
final File file = new File(Config.DATAPACK_ROOT + "/data/CursedWeapons.xml");
if (!file.exists())
{
return;
}
final Document doc = factory.newDocumentBuilder().parse(file);
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
{
if ("list".equalsIgnoreCase(n.getNodeName()))
{
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
{
if ("item".equalsIgnoreCase(d.getNodeName()))
{
NamedNodeMap attrs = d.getAttributes();
final int id = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
final int skillId = Integer.parseInt(attrs.getNamedItem("skillId").getNodeValue());
final String name = attrs.getNamedItem("name").getNodeValue();
final CursedWeapon cw = new CursedWeapon(id, skillId, name);
int val;
for (Node cd = d.getFirstChild(); cd != null; cd = cd.getNextSibling())
{
if ("dropRate".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
val = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
cw.setDropRate(val);
}
else if ("duration".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
val = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
cw.setDuration(val);
}
else if ("durationLost".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
val = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
cw.setDurationLost(val);
}
else if ("disapearChance".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
val = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
cw.setDisapearChance(val);
}
else if ("stageKills".equalsIgnoreCase(cd.getNodeName()))
{
attrs = cd.getAttributes();
val = Integer.parseInt(attrs.getNamedItem("val").getNodeValue());
cw.setStageKills(val);
}
}
_cursedWeapons.put(id, cw);
}
}
}
}
}
catch (Exception e)
{
LOGGER.warning("Error parsing cursed weapons file. " + e);
}
}
private final void restore()
{
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("SELECT itemId, playerId, playerKarma, playerPkKills, nbKills, endTime FROM cursed_weapons");
final ResultSet rset = statement.executeQuery();
if (rset.next())
{
final int itemId = rset.getInt("itemId");
final int playerId = rset.getInt("playerId");
final int playerKarma = rset.getInt("playerKarma");
final int playerPkKills = rset.getInt("playerPkKills");
final int nbKills = rset.getInt("nbKills");
final long endTime = rset.getLong("endTime");
final CursedWeapon cw = _cursedWeapons.get(itemId);
cw.setPlayerId(playerId);
cw.setPlayerKarma(playerKarma);
cw.setPlayerPkKills(playerPkKills);
cw.setNbKills(nbKills);
cw.setEndTime(endTime);
cw.reActivate();
// clean up the cursed weapons table.
removeFromDb(itemId);
}
rset.close();
statement.close();
}
catch (Exception e)
{
LOGGER.warning("Could not restore CursedWeapons data: " + e);
}
}
private final void controlPlayers()
{
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = null;
ResultSet rset = null;
// TODO: See comments below...
// This entire for loop should NOT be necessary, since it is already handled by
// CursedWeapon.endOfLife(). However, if we indeed *need* to duplicate it for safety,
// then we'd better make sure that it FULLY cleans up inactive cursed weapons!
// Undesired effects result otherwise, such as player with no zariche but with karma
// or a lost-child entry in the cursed weapons table, without a corresponding one in items...
for (CursedWeapon cw : _cursedWeapons.values())
{
if (cw.isActivated())
{
continue;
}
// Do an item check to be sure that the cursed weapon isn't hold by someone
final int itemId = cw.getItemId();
try
{
statement = con.prepareStatement("SELECT owner_id FROM items WHERE item_id=?");
statement.setInt(1, itemId);
rset = statement.executeQuery();
if (rset.next())
{
// A player has the cursed weapon in his inventory ...
final int playerId = rset.getInt("owner_id");
LOGGER.info("PROBLEM : Player " + playerId + " owns the cursed weapon " + itemId + " but he shouldn't.");
// Delete the item
statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
statement.setInt(1, playerId);
statement.setInt(2, itemId);
if (statement.executeUpdate() != 1)
{
LOGGER.warning("Error while deleting cursed weapon " + itemId + " from userId " + playerId);
}
statement.close();
// Restore the player's old karma and pk count
statement = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE obj_id=?");
statement.setInt(1, cw.getPlayerKarma());
statement.setInt(2, cw.getPlayerPkKills());
statement.setInt(3, playerId);
if (statement.executeUpdate() != 1)
{
LOGGER.warning("Error while updating karma & pkkills for userId " + cw.getPlayerId());
}
}
rset.close();
statement.close();
}
catch (SQLException sqlE)
{
}
}
}
catch (Exception e)
{
LOGGER.warning("Could not check CursedWeapons data: " + e.getMessage());
}
}
public synchronized void checkDrop(Attackable attackable, PlayerInstance player)
{
if ((attackable instanceof SiegeGuardInstance) || (attackable instanceof RiftInvaderInstance) || (attackable instanceof FestivalMonsterInstance) || (attackable instanceof GrandBossInstance) || (attackable instanceof FortSiegeGuardInstance) || (attackable instanceof CommanderInstance))
{
return;
}
if (player.isCursedWeaponEquiped())
{
return;
}
for (CursedWeapon cw : _cursedWeapons.values())
{
if (cw.isActive())
{
continue;
}
if (cw.checkDrop(attackable, player))
{
break;
}
}
}
public void activate(PlayerInstance player, ItemInstance item)
{
final CursedWeapon cw = _cursedWeapons.get(item.getItemId());
if (player.isCursedWeaponEquiped()) // cannot own 2 cursed swords
{
final CursedWeapon cw2 = _cursedWeapons.get(player.getCursedWeaponEquipedId());
/*
* TODO: give the bonus level in a more appropriate manner. The following code adds "_stageKills" levels. This will also show in the char status. I do not have enough info to know if the bonus should be shown in the pk count, or if it should be a full "_stageKills" bonus or just the
* remaining from the current count till the of the current stage... This code is a TEMP fix, so that the cursed weapon's bonus level can be observed with as little change in the code as possible, until proper info arises.
*/
cw2.setNbKills(cw2.getStageKills() - 1);
cw2.increaseKills();
// erase the newly obtained cursed weapon
cw.setPlayer(player); // NECESSARY in order to find which inventory the weapon is in!
cw.endOfLife(); // expire the weapon and clean up.
}
else
{
cw.activate(player, item);
}
}
public void drop(int itemId, Creature killer)
{
final CursedWeapon cw = _cursedWeapons.get(itemId);
cw.dropIt(killer);
}
public void increaseKills(int itemId)
{
final CursedWeapon cw = _cursedWeapons.get(itemId);
cw.increaseKills();
}
public int getLevel(int itemId)
{
final CursedWeapon cw = _cursedWeapons.get(itemId);
return cw.getLevel();
}
public static void announce(SystemMessage sm)
{
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if (player == null)
{
continue;
}
player.sendPacket(sm);
}
}
public void checkPlayer(PlayerInstance player)
{
if (player == null)
{
return;
}
for (CursedWeapon cw : _cursedWeapons.values())
{
if (cw.isActive() && (player.getObjectId() == cw.getPlayerId()))
{
cw.setPlayer(player);
cw.setItem(player.getInventory().getItemByItemId(cw.getItemId()));
cw.giveSkill();
player.setCursedWeaponEquipedId(cw.getItemId());
SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_S2_MINUTE_S_OF_USAGE_TIME_REMAINING);
sm.addString(cw.getName());
// sm.addItemName(cw.getItemId());
sm.addNumber((int) ((cw.getEndTime() - System.currentTimeMillis()) / 60000));
player.sendPacket(sm);
sm = new SystemMessage(SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION);
sm.addZoneName(player.getX(), player.getY(), player.getZ()); // Region Name
sm.addItemName(cw.getItemId());
announce(sm);
}
}
}
public static void removeFromDb(int itemId)
{
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
statement.setInt(1, itemId);
statement.executeUpdate();
statement.close();
}
catch (SQLException e)
{
LOGGER.warning("CursedWeaponsManager: Failed to remove data. " + e);
}
}
public void saveData()
{
for (CursedWeapon cw : _cursedWeapons.values())
{
cw.saveData();
}
}
public boolean isCursed(int itemId)
{
return _cursedWeapons.containsKey(itemId);
}
public Collection<CursedWeapon> getCursedWeapons()
{
return _cursedWeapons.values();
}
public Set<Integer> getCursedWeaponsIds()
{
return _cursedWeapons.keySet();
}
public CursedWeapon getCursedWeapon(int itemId)
{
return _cursedWeapons.get(itemId);
}
public void givePassive(int itemId)
{
try
{
_cursedWeapons.get(itemId).giveSkill();
}
catch (Exception e)
{
}
}
private static class SingletonHolder
{
protected static final CursedWeaponsManager INSTANCE = new CursedWeaponsManager();
}
}
@@ -1,238 +0,0 @@
/*
* 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.instancemanager;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.model.Effect;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.entity.Duel;
import org.l2jmobius.gameserver.network.serverpackets.GameServerPacket;
public class DuelManager
{
private static final Logger LOGGER = Logger.getLogger(DuelManager.class.getName());
private final List<Duel> _duels;
private int _currentDuelId = 0x90;
private DuelManager()
{
LOGGER.info("Initializing DuelManager");
_duels = new ArrayList<>();
}
private int getNextDuelId()
{
_currentDuelId++;
// In case someone wants to run the server forever :)
if (_currentDuelId >= 2147483640)
{
_currentDuelId = 1;
}
return _currentDuelId;
}
public Duel getDuel(int duelId)
{
for (Duel duel : _duels)
{
if (duel.getId() == duelId)
{
return duel;
}
}
return null;
}
public void addDuel(PlayerInstance playerA, PlayerInstance playerB, int partyDuel)
{
if ((playerA == null) || (playerB == null))
{
return;
}
// return if a player has PvPFlag
final String engagedInPvP = "The duel was canceled because a duelist engaged in PvP combat.";
if (partyDuel == 1)
{
boolean playerInPvP = false;
for (PlayerInstance temp : playerA.getParty().getPartyMembers())
{
if (temp.getPvpFlag() != 0)
{
playerInPvP = true;
break;
}
}
if (!playerInPvP)
{
for (PlayerInstance temp : playerB.getParty().getPartyMembers())
{
if (temp.getPvpFlag() != 0)
{
playerInPvP = true;
break;
}
}
}
// A player has PvP flag
if (playerInPvP)
{
for (PlayerInstance temp : playerA.getParty().getPartyMembers())
{
temp.sendMessage(engagedInPvP);
}
for (PlayerInstance temp : playerB.getParty().getPartyMembers())
{
temp.sendMessage(engagedInPvP);
}
return;
}
}
else if ((playerA.getPvpFlag() != 0) || (playerB.getPvpFlag() != 0))
{
playerA.sendMessage(engagedInPvP);
playerB.sendMessage(engagedInPvP);
return;
}
final Duel duel = new Duel(playerA, playerB, partyDuel, getNextDuelId());
_duels.add(duel);
}
public void removeDuel(Duel duel)
{
_duels.remove(duel);
}
public void doSurrender(PlayerInstance player)
{
if ((player == null) || !player.isInDuel())
{
return;
}
final Duel duel = getDuel(player.getDuelId());
duel.doSurrender(player);
}
/**
* Updates player states.
* @param player - the dieing player
*/
public void onPlayerDefeat(PlayerInstance player)
{
if ((player == null) || !player.isInDuel())
{
return;
}
final Duel duel = getDuel(player.getDuelId());
if (duel != null)
{
duel.onPlayerDefeat(player);
}
}
/**
* Registers a debuff which will be removed if the duel ends
* @param player
* @param buff
*/
public void onBuff(PlayerInstance player, Effect buff)
{
if ((player == null) || !player.isInDuel() || (buff == null))
{
return;
}
final Duel duel = getDuel(player.getDuelId());
if (duel != null)
{
duel.onBuff(player, buff);
}
}
/**
* Removes player from duel.
* @param player - the removed player
*/
public void onRemoveFromParty(PlayerInstance player)
{
if ((player == null) || !player.isInDuel())
{
return;
}
final Duel duel = getDuel(player.getDuelId());
if (duel != null)
{
duel.onRemoveFromParty(player);
}
}
/**
* Broadcasts a packet to the team opposing the given player.
* @param player
* @param packet
*/
public void broadcastToOppositTeam(PlayerInstance player, GameServerPacket packet)
{
if ((player == null) || !player.isInDuel())
{
return;
}
final Duel duel = getDuel(player.getDuelId());
if (duel == null)
{
return;
}
if ((duel.getPlayerA() == null) || (duel.getPlayerB() == null))
{
return;
}
if (duel.getPlayerA() == player)
{
duel.broadcastToTeam2(packet);
}
else if (duel.getPlayerB() == player)
{
duel.broadcastToTeam1(packet);
}
else if (duel.isPartyDuel())
{
if ((duel.getPlayerA().getParty() != null) && duel.getPlayerA().getParty().getPartyMembers().contains(player))
{
duel.broadcastToTeam2(packet);
}
else if ((duel.getPlayerB().getParty() != null) && duel.getPlayerB().getParty().getPartyMembers().contains(player))
{
duel.broadcastToTeam1(packet);
}
}
}
public static DuelManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final DuelManager INSTANCE = new DuelManager();
}
}
@@ -1,540 +0,0 @@
/*
* 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.instancemanager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class FishingChampionshipManager
{
protected static final Logger LOGGER = Logger.getLogger(FishingChampionshipManager.class.getName());
private static final String INSERT = "INSERT INTO fishing_championship(player_name,fish_length,rewarded) VALUES (?,?,?)";
private static final String DELETE = "DELETE FROM fishing_championship";
private static final String SELECT = "SELECT `player_name`, `fish_length`, `rewarded` FROM fishing_championship";
protected long _enddate = 0;
protected final List<String> _playersName = new ArrayList<>();
protected final List<String> _fishLength = new ArrayList<>();
protected final List<String> _winPlayersName = new ArrayList<>();
protected final List<String> _winFishLength = new ArrayList<>();
protected final List<Fisher> _tmpPlayers = new ArrayList<>();
protected final List<Fisher> _winPlayers = new ArrayList<>();
protected double _minFishLength = 0;
protected boolean _needRefresh = true;
protected FishingChampionshipManager()
{
restoreData();
refreshWinResult();
recalculateMinLength();
if (_enddate <= System.currentTimeMillis())
{
_enddate = System.currentTimeMillis();
new finishChamp().run();
}
else
{
ThreadPool.schedule(new finishChamp(), _enddate - System.currentTimeMillis());
}
}
protected void setEndOfChamp()
{
final Calendar finishtime = Calendar.getInstance();
finishtime.setTimeInMillis(_enddate);
finishtime.set(Calendar.MINUTE, 0);
finishtime.set(Calendar.SECOND, 0);
finishtime.add(Calendar.DAY_OF_MONTH, 6);
finishtime.set(Calendar.DAY_OF_WEEK, 3);
finishtime.set(Calendar.HOUR_OF_DAY, 19);
_enddate = finishtime.getTimeInMillis();
}
private void restoreData()
{
_enddate = GlobalVariablesManager.getInstance().getLong("fishChampionshipEnd", 0);
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement(SELECT);
final ResultSet rs = statement.executeQuery();
while (rs.next())
{
final int rewarded = rs.getInt("rewarded");
if (rewarded == 0)
{
_tmpPlayers.add(new Fisher(rs.getString("player_name"), rs.getDouble("fish_length"), 0));
}
else if (rewarded > 0)
{
_winPlayers.add(new Fisher(rs.getString("player_name"), rs.getDouble("fish_length"), rewarded));
}
}
rs.close();
statement.close();
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "FishingChampionshipManager: can't restore fishing championship info: " + e.getMessage(), e);
}
}
public synchronized void newFish(PlayerInstance pl, int lureId)
{
if (!Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
{
return;
}
double len = Rnd.get(60, 89) + (Rnd.get(0, 1000) / 1000.);
if ((lureId >= 8484) && (lureId <= 8486))
{
len += Rnd.get(0, 3000) / 1000.;
}
pl.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CAUGHT_A_FISH_S1_IN_LENGTH).addString(String.valueOf(len)));
if (_tmpPlayers.size() < 5)
{
for (Fisher fisher : _tmpPlayers)
{
if (fisher.getName().equalsIgnoreCase(pl.getName()))
{
if (fisher.getLength() < len)
{
fisher.setLength(len);
pl.sendPacket(SystemMessageId.BECAUSE_OF_THE_SIZE_OF_FISH_CAUGHT_YOU_WILL_BE_REGISTERED_IN_THE_RANKING);
recalculateMinLength();
}
return;
}
}
_tmpPlayers.add(new Fisher(pl.getName(), len, 0));
pl.sendPacket(SystemMessageId.BECAUSE_OF_THE_SIZE_OF_FISH_CAUGHT_YOU_WILL_BE_REGISTERED_IN_THE_RANKING);
recalculateMinLength();
}
else if (_minFishLength < len)
{
for (Fisher fisher : _tmpPlayers)
{
if (fisher.getName().equalsIgnoreCase(pl.getName()))
{
if (fisher.getLength() < len)
{
fisher.setLength(len);
pl.sendPacket(SystemMessageId.BECAUSE_OF_THE_SIZE_OF_FISH_CAUGHT_YOU_WILL_BE_REGISTERED_IN_THE_RANKING);
recalculateMinLength();
}
return;
}
}
Fisher minFisher = null;
double minLen = 99999.;
for (Fisher fisher : _tmpPlayers)
{
if (fisher.getLength() < minLen)
{
minFisher = fisher;
minLen = minFisher.getLength();
}
}
_tmpPlayers.remove(minFisher);
_tmpPlayers.add(new Fisher(pl.getName(), len, 0));
pl.sendPacket(SystemMessageId.BECAUSE_OF_THE_SIZE_OF_FISH_CAUGHT_YOU_WILL_BE_REGISTERED_IN_THE_RANKING);
recalculateMinLength();
}
}
private void recalculateMinLength()
{
double minLen = 99999.;
for (Fisher fisher : _tmpPlayers)
{
if (fisher.getLength() < minLen)
{
minLen = fisher.getLength();
}
}
_minFishLength = minLen;
}
public long getTimeRemaining()
{
return (_enddate - System.currentTimeMillis()) / 60000;
}
public String getWinnerName(int par)
{
if (_winPlayersName.size() >= par)
{
return _winPlayersName.get(par - 1);
}
return "None";
}
public String getCurrentName(int par)
{
if (_playersName.size() >= par)
{
return _playersName.get(par - 1);
}
return "None";
}
public String getFishLength(int par)
{
if (_winFishLength.size() >= par)
{
return _winFishLength.get(par - 1);
}
return "0";
}
public String getCurrentFishLength(int par)
{
if (_fishLength.size() >= par)
{
return _fishLength.get(par - 1);
}
return "0";
}
public boolean isWinner(String playerName)
{
for (String name : _winPlayersName)
{
if (name.equals(playerName))
{
return true;
}
}
return false;
}
public void getReward(PlayerInstance pl)
{
for (Fisher fisher : _winPlayers)
{
if (fisher.getName().equalsIgnoreCase(pl.getName()) && (fisher.getRewardType() != 2))
{
int rewardCnt = 0;
for (int x = 0; x < _winPlayersName.size(); x++)
{
if (_winPlayersName.get(x).equalsIgnoreCase(pl.getName()))
{
switch (x)
{
case 0:
{
rewardCnt = Config.ALT_FISH_CHAMPIONSHIP_REWARD_1;
break;
}
case 1:
{
rewardCnt = Config.ALT_FISH_CHAMPIONSHIP_REWARD_2;
break;
}
case 2:
{
rewardCnt = Config.ALT_FISH_CHAMPIONSHIP_REWARD_3;
break;
}
case 3:
{
rewardCnt = Config.ALT_FISH_CHAMPIONSHIP_REWARD_4;
break;
}
case 4:
{
rewardCnt = Config.ALT_FISH_CHAMPIONSHIP_REWARD_5;
break;
}
}
}
}
fisher.setRewardType(2);
if (rewardCnt > 0)
{
pl.addItem("fishing_reward", Config.ALT_FISH_CHAMPIONSHIP_REWARD_ITEM, rewardCnt, null, true);
final NpcHtmlMessage html = new NpcHtmlMessage(0);
html.setFile("data/html/fisherman/championship/fish_event_reward001.htm");
pl.sendPacket(html);
}
}
}
}
public void showMidResult(PlayerInstance pl)
{
final NpcHtmlMessage html = new NpcHtmlMessage(0);
if (_needRefresh)
{
html.setFile("data/html/fisherman/championship/fish_event003.htm");
pl.sendPacket(html);
refreshResult();
ThreadPool.schedule(new needRefresh(), 60000);
return;
}
html.setFile("data/html/fisherman/championship/fish_event002.htm");
String str = "";
for (int x = 1; x <= 5; x++)
{
str += "<tr><td width=70 align=center>" + x + "</td>";
str += "<td width=110 align=center>" + getCurrentName(x) + "</td>";
str += "<td width=80 align=center>" + getCurrentFishLength(x) + "</td></tr>";
}
html.replace("%TABLE%", str);
html.replace("%prizeItem%", ItemTable.getInstance().getTemplate(Config.ALT_FISH_CHAMPIONSHIP_REWARD_ITEM).getName());
html.replace("%prizeFirst%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_1);
html.replace("%prizeTwo%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_2);
html.replace("%prizeThree%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_3);
html.replace("%prizeFour%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_4);
html.replace("%prizeFive%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_5);
pl.sendPacket(html);
}
public void showChampScreen(PlayerInstance pl, int objectId)
{
final NpcHtmlMessage html = new NpcHtmlMessage(objectId);
html.setFile("data/html/fisherman/championship/fish_event001.htm");
String str = "";
for (int x = 1; x <= 5; x++)
{
str += "<tr><td width=70 align=center>" + x + "</td>";
str += "<td width=110 align=center>" + getWinnerName(x) + "</td>";
str += "<td width=80 align=center>" + getFishLength(x) + "</td></tr>";
}
html.replace("%TABLE%", str);
html.replace("%prizeItem%", ItemTable.getInstance().getTemplate(Config.ALT_FISH_CHAMPIONSHIP_REWARD_ITEM).getName());
html.replace("%prizeFirst%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_1);
html.replace("%prizeTwo%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_2);
html.replace("%prizeThree%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_3);
html.replace("%prizeFour%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_4);
html.replace("%prizeFive%", Config.ALT_FISH_CHAMPIONSHIP_REWARD_5);
html.replace("%refresh%", getTimeRemaining());
html.replace("%objectId%", objectId);
pl.sendPacket(html);
}
public void shutdown()
{
GlobalVariablesManager.getInstance().set("fishChampionshipEnd", _enddate);
try (Connection con = DatabaseFactory.getConnection())
{
PreparedStatement statement = con.prepareStatement(DELETE);
statement.execute();
statement.close();
for (Fisher fisher : _winPlayers)
{
statement = con.prepareStatement(INSERT);
statement.setString(1, fisher.getName());
statement.setDouble(2, fisher.getLength());
statement.setInt(3, fisher.getRewardType());
statement.execute();
statement.close();
}
for (Fisher fisher : _tmpPlayers)
{
statement = con.prepareStatement(INSERT);
statement.setString(1, fisher.getName());
statement.setDouble(2, fisher.getLength());
statement.setInt(3, 0);
statement.execute();
statement.close();
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "FishingChampionshipManager: can't update infos: " + e.getMessage(), e);
}
}
private synchronized void refreshResult()
{
_needRefresh = false;
_playersName.clear();
_fishLength.clear();
Fisher fisher1;
Fisher fisher2;
for (int x = 0; x <= (_tmpPlayers.size() - 1); x++)
{
for (int y = 0; y <= (_tmpPlayers.size() - 2); y++)
{
fisher1 = _tmpPlayers.get(y);
fisher2 = _tmpPlayers.get(y + 1);
if (fisher1.getLength() < fisher2.getLength())
{
_tmpPlayers.set(y, fisher2);
_tmpPlayers.set(y + 1, fisher1);
}
}
}
for (int x = 0; x <= (_tmpPlayers.size() - 1); x++)
{
_playersName.add(_tmpPlayers.get(x).getName());
_fishLength.add(String.valueOf(_tmpPlayers.get(x).getLength()));
}
}
protected void refreshWinResult()
{
_winPlayersName.clear();
_winFishLength.clear();
Fisher fisher1;
Fisher fisher2;
for (int x = 0; x <= (_winPlayers.size() - 1); x++)
{
for (int y = 0; y <= (_winPlayers.size() - 2); y++)
{
fisher1 = _winPlayers.get(y);
fisher2 = _winPlayers.get(y + 1);
if (fisher1.getLength() < fisher2.getLength())
{
_winPlayers.set(y, fisher2);
_winPlayers.set(y + 1, fisher1);
}
}
}
for (int x = 0; x <= (_winPlayers.size() - 1); x++)
{
_winPlayersName.add(_winPlayers.get(x).getName());
_winFishLength.add(String.valueOf(_winPlayers.get(x).getLength()));
}
}
private class finishChamp implements Runnable
{
protected finishChamp()
{
// Do nothing
}
@Override
public void run()
{
_winPlayers.clear();
for (Fisher fisher : _tmpPlayers)
{
fisher.setRewardType(1);
_winPlayers.add(fisher);
}
_tmpPlayers.clear();
refreshWinResult();
setEndOfChamp();
shutdown();
LOGGER.info("FishingChampionshipManager: new event period start.");
ThreadPool.schedule(new finishChamp(), _enddate - System.currentTimeMillis());
}
}
private class needRefresh implements Runnable
{
protected needRefresh()
{
// Do nothing
}
@Override
public void run()
{
_needRefresh = true;
}
}
private class Fisher
{
private double _length;
private final String _name;
private int _reward;
public Fisher(String name, double length, int rewardType)
{
_name = name;
_length = length;
_reward = rewardType;
}
public void setLength(double value)
{
_length = value;
}
public void setRewardType(int value)
{
_reward = value;
}
public String getName()
{
return _name;
}
public int getRewardType()
{
return _reward;
}
public double getLength()
{
return _length;
}
}
public static final FishingChampionshipManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final FishingChampionshipManager INSTANCE = new FishingChampionshipManager();
}
}
@@ -136,7 +136,7 @@ public class ItemsOnGroundManager
_items.add(item);
count++;
// add to ItemsAutoDestroy only items not protected
if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && (result.getLong(8) > -1) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && (item.getItemType() != EtcItemType.HERB)) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && (item.getItemType() == EtcItemType.HERB))))
if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && (result.getLong(8) > -1) && ((Config.AUTODESTROY_ITEM_AFTER > 0) && (item.getItemType() != EtcItemType.HERB)))
{
ItemsAutoDestroy.getInstance().addItem(item);
}
@@ -233,11 +233,6 @@ public class ItemsOnGroundManager
continue;
}
if (CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
{
continue; // Cursed Items not saved to ground, prevent double save
}
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("insert into itemsonground(object_id,item_id,count,enchant_level,x,y,z,drop_time,equipable) values(?,?,?,?,?,?,?,?,?)");
@@ -1,240 +0,0 @@
/*
* 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.util.List;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.datatables.xml.AugmentationData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.skills.Stat;
import org.l2jmobius.gameserver.model.skills.funcs.FuncAdd;
import org.l2jmobius.gameserver.model.skills.funcs.LambdaConst;
/**
* Used to store an augmentation and its bonus
* @author durgus
*/
public class Augmentation
{
private static final Logger LOGGER = Logger.getLogger(Augmentation.class.getName());
private final ItemInstance _item;
private int _effectsId = 0;
private augmentationStatBonus _bonus = null;
private Skill _skill = null;
public Augmentation(ItemInstance item, int effects, Skill skill, boolean save)
{
_item = item;
_effectsId = effects;
_bonus = new augmentationStatBonus(_effectsId);
_skill = skill;
// write to DB if save is true
if (save)
{
saveAugmentationData();
}
}
public Augmentation(ItemInstance item, int effects, int skill, int skillLevel, boolean save)
{
this(item, effects, SkillTable.getInstance().getInfo(skill, skillLevel), save);
}
public class augmentationStatBonus
{
private final Stat[] _stats;
private final float[] _values;
private boolean _active;
public augmentationStatBonus(int augmentationId)
{
_active = false;
final List<AugmentationData.AugStat> as = AugmentationData.getInstance().getAugStatsById(augmentationId);
_stats = new Stat[as.size()];
_values = new float[as.size()];
int i = 0;
for (AugmentationData.AugStat aStat : as)
{
_stats[i] = aStat.getStat();
_values[i] = aStat.getValue();
i++;
}
}
public void applyBonus(PlayerInstance player)
{
// make sure the bonus are not applyed twice..
if (_active)
{
return;
}
for (int i = 0; i < _stats.length; i++)
{
player.addStatFunc(new FuncAdd(_stats[i], 0x40, this, new LambdaConst(_values[i])));
}
_active = true;
}
public void removeBonus(PlayerInstance player)
{
// make sure the bonus is not removed twice
if (!_active)
{
return;
}
player.removeStatsOwner(this);
_active = false;
}
}
private void saveAugmentationData()
{
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("INSERT INTO augmentations (item_id,attributes,skill,level) VALUES (?,?,?,?)");
statement.setInt(1, _item.getObjectId());
statement.setInt(2, _effectsId);
if (_skill != null)
{
statement.setInt(3, _skill.getId());
statement.setInt(4, _skill.getLevel());
}
else
{
statement.setInt(3, 0);
statement.setInt(4, 0);
}
statement.executeUpdate();
statement.close();
}
catch (Exception e)
{
LOGGER.warning("Could not save augmentation for item: " + _item.getObjectId() + " from DB: " + e);
}
}
public void deleteAugmentationData()
{
if (!_item.isAugmented())
{
return;
}
// delete the augmentation from the database
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("DELETE FROM augmentations WHERE item_id=?");
statement.setInt(1, _item.getObjectId());
statement.executeUpdate();
statement.close();
}
catch (Exception e)
{
LOGGER.warning("Could not delete augmentation for item: " + _item.getObjectId() + " from DB: " + e);
}
}
/**
* Get the augmentation "id" used in serverpackets.
* @return augmentationId
*/
public int getAugmentationId()
{
return _effectsId;
}
public Skill getSkill()
{
return _skill;
}
/**
* Applies the bonus to the player.
* @param player
*/
public void applyBonus(PlayerInstance player)
{
_bonus.applyBonus(player);
// add the skill if any
if (_skill != null)
{
player.addSkill(_skill);
if (_skill.isActive() && (Config.ACTIVE_AUGMENTS_START_REUSE_TIME > 0))
{
player.disableSkill(_skill, Config.ACTIVE_AUGMENTS_START_REUSE_TIME);
player.addTimestamp(_skill, Config.ACTIVE_AUGMENTS_START_REUSE_TIME);
}
player.sendSkillList();
}
}
/**
* Removes the augmentation bonus from the player.
* @param player
*/
public void removeBonus(PlayerInstance player)
{
_bonus.removeBonus(player);
// remove the skill if any
if (_skill != null)
{
if (_skill.isPassive())
{
player.removeSkill(_skill);
}
else
{
player.removeSkill(_skill, false);
}
if ((_skill.isPassive() && Config.DELETE_AUGM_PASSIVE_ON_CHANGE) || (_skill.isActive() && Config.DELETE_AUGM_ACTIVE_ON_CHANGE))
{
// Iterate through all effects currently on the character.
final Effect[] effects = player.getAllEffects();
for (Effect currenteffect : effects)
{
final Skill effectSkill = currenteffect.getSkill();
if (effectSkill.getId() == _skill.getId())
{
player.sendMessage("You feel the power of " + effectSkill.getName() + " leaving yourself.");
currenteffect.exit(false);
}
}
}
player.sendSkillList();
}
}
}
@@ -47,7 +47,6 @@ public class CharSelectInfoPackage
private double _currentMp = 0;
private final int[][] _paperdoll;
private int _karma = 0;
private int _augmentationId = 0;
private int _accessLevel;
/**
@@ -290,16 +289,6 @@ public class CharSelectInfoPackage
return _karma;
}
public void setAugmentationId(int augmentationId)
{
_augmentationId = augmentationId;
}
public int getAugmentationId()
{
return _augmentationId;
}
public int getAccessLevel()
{
return _accessLevel;
@@ -1,670 +0,0 @@
/*
* 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.SQLException;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.entity.event.CTF;
import org.l2jmobius.gameserver.model.entity.event.DM;
import org.l2jmobius.gameserver.model.entity.event.TvT;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.Earthquake;
import org.l2jmobius.gameserver.network.serverpackets.ExRedSky;
import org.l2jmobius.gameserver.network.serverpackets.ItemList;
import org.l2jmobius.gameserver.network.serverpackets.Ride;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class CursedWeapon
{
private static final Logger LOGGER = Logger.getLogger(CursedWeapon.class.getName());
private final String _name;
private final int _itemId;
private final int _skillId;
private final int _skillMaxLevel;
private int _dropRate;
private int _duration;
private int _durationLost;
private int _disapearChance;
private int _stageKills;
private boolean _isDropped = false;
private boolean _isActivated = false;
private ScheduledFuture<?> _removeTask;
private int _nbKills = 0;
long _endTime = 0;
private int _playerId = 0;
private PlayerInstance _player = null;
private ItemInstance _item = null;
private int _playerKarma = 0;
private int _playerPkKills = 0;
public CursedWeapon(int itemId, int skillId, String name)
{
_name = name;
_itemId = itemId;
_skillId = skillId;
_skillMaxLevel = SkillTable.getInstance().getMaxLevel(_skillId, 0);
}
public void endOfLife()
{
if (_isActivated)
{
if ((_player != null) && _player.isOnline())
{
// Remove from player
LOGGER.info(_name + " being removed online.");
_player.abortAttack();
_player.setKarma(_playerKarma);
_player.setPkKills(_playerPkKills);
_player.setCursedWeaponEquipedId(0);
removeSkill();
// Remove and destroy
_player.getInventory().unEquipItemInBodySlotAndRecord(Item.SLOT_LR_HAND);
_player.getInventory().destroyItemByItemId("", _itemId, 1, _player, null);
_player.store();
// update inventory and userInfo
_player.sendPacket(new ItemList(_player, true));
_player.broadcastUserInfo();
}
else
{
// Remove from Db
LOGGER.info(_name + " being removed offline.");
try (Connection con = DatabaseFactory.getConnection())
{
// Delete the item
PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
statement.setInt(1, _playerId);
statement.setInt(2, _itemId);
if (statement.executeUpdate() != 1)
{
LOGGER.warning("Error while deleting itemId " + _itemId + " from userId " + _playerId);
}
statement.close();
// Restore the karma
statement = con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE obj_id=?");
statement.setInt(1, _playerKarma);
statement.setInt(2, _playerPkKills);
statement.setInt(3, _playerId);
if (statement.executeUpdate() != 1)
{
LOGGER.warning("Error while updating karma & pkkills for userId " + _playerId);
}
statement.close();
}
catch (Exception e)
{
LOGGER.warning("Could not delete : " + e);
}
}
}
else if ((_player != null) && (_player.getInventory().getItemByItemId(_itemId) != null)) // either this cursed weapon is in the inventory of someone who has another cursed weapon equipped, OR this cursed weapon is on the ground.
{
final ItemInstance rhand = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if (rhand != null)
{
_player.getInventory().unEquipItemInSlotAndRecord(rhand.getEquipSlot());
}
// Destroy
_player.getInventory().destroyItemByItemId("", _itemId, 1, _player, null);
_player.store();
// update inventory and userInfo
_player.sendPacket(new ItemList(_player, true));
_player.broadcastUserInfo();
}
// is dropped on the ground
else if (_item != null)
{
_item.decayMe();
World.getInstance().removeObject(_item);
LOGGER.info(_name + " item has been removed from World.");
}
final SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_DISAPPEARED);
sm.addItemName(_itemId);
CursedWeaponsManager.announce(sm);
// Reset state
cancelTask();
_isActivated = false;
_isDropped = false;
_endTime = 0;
_player = null;
_playerId = 0;
_playerKarma = 0;
_playerPkKills = 0;
_item = null;
_nbKills = 0;
}
private void cancelTask()
{
if (_removeTask != null)
{
_removeTask.cancel(true);
_removeTask = null;
}
}
private class RemoveTask implements Runnable
{
protected RemoveTask()
{
}
@Override
public void run()
{
if (System.currentTimeMillis() >= _endTime)
{
endOfLife();
}
}
}
private void dropIt(Attackable attackable, PlayerInstance player)
{
dropIt(attackable, player, null, true);
}
public void dropIt(Attackable attackable, PlayerInstance player, Creature killer, boolean fromMonster)
{
_isActivated = false;
final SystemMessage sm = new SystemMessage(SystemMessageId.S2_WAS_DROPPED_IN_THE_S1_REGION);
if (fromMonster)
{
_item = attackable.dropItem(player, _itemId, 1);
_item.setDropTime(0); // Prevent item from being removed by ItemsAutoDestroy
// RedSky and Earthquake
final ExRedSky rs = new ExRedSky(10);
final Earthquake eq = new Earthquake(player.getX(), player.getY(), player.getZ(), 14, 3);
for (PlayerInstance aPlayer : World.getInstance().getAllPlayers())
{
aPlayer.sendPacket(rs);
aPlayer.sendPacket(eq);
}
sm.addZoneName(attackable.getX(), attackable.getY(), attackable.getZ()); // Region Name
// EndTime: if dropped from monster, the endTime is a new endTime
cancelTask();
_endTime = 0;
}
else
{
// Remove from player
_player.abortAttack();
_player.setKarma(_playerKarma);
_player.setPkKills(_playerPkKills);
_player.setCursedWeaponEquipedId(0);
removeSkill();
// Remove
_player.getInventory().unEquipItemInBodySlotAndRecord(Item.SLOT_LR_HAND);
// drop
_player.dropItem("DieDrop", _item, killer, true, true);
_player.store();
// update Inventory and UserInfo
_player.sendPacket(new ItemList(_player, false));
_player.broadcastUserInfo();
sm.addZoneName(_player.getX(), _player.getY(), _player.getZ()); // Region Name
}
sm.addItemName(_itemId);
// reset
_player = null;
_playerId = 0;
_playerKarma = 0;
_playerPkKills = 0;
_nbKills = 0;
_isDropped = true;
CursedWeaponsManager.announce(sm);
}
/**
* Rebind the passive skill belonging to the CursedWeapon. Invoke this method if the weapon owner switches to a subclass.
*/
public void giveSkill()
{
int level = 1 + (_nbKills / _stageKills);
if (level > _skillMaxLevel)
{
level = _skillMaxLevel;
}
Skill skill = SkillTable.getInstance().getInfo(_skillId, level);
// To properly support subclasses this skill can not be stored.
_player.addSkill(skill, false);
// Void Burst, Void Flow
skill = SkillTable.getInstance().getInfo(3630, 1);
_player.addSkill(skill, false);
skill = SkillTable.getInstance().getInfo(3631, 1);
_player.addSkill(skill, false);
_player.sendSkillList();
}
public void removeSkill()
{
_player.removeSkill(SkillTable.getInstance().getInfo(_skillId, _player.getSkillLevel(_skillId)), false);
_player.removeSkill(SkillTable.getInstance().getInfo(3630, 1), false);
_player.removeSkill(SkillTable.getInstance().getInfo(3631, 1), false);
_player.sendSkillList();
}
public void reActivate()
{
_isActivated = true;
if ((_endTime - System.currentTimeMillis()) <= 0)
{
endOfLife();
}
else
{
_removeTask = ThreadPool.scheduleAtFixedRate(new RemoveTask(), _durationLost * 12000, _durationLost * 12000);
}
}
public boolean checkDrop(Attackable attackable, PlayerInstance player)
{
if (Rnd.get(1000000) < _dropRate)
{
// Drop the item
dropIt(attackable, player);
// Start the Life Task
_endTime = System.currentTimeMillis() + (_duration * 60000);
_removeTask = ThreadPool.scheduleAtFixedRate(new RemoveTask(), _durationLost * 12000, _durationLost * 12000);
return true;
}
return false;
}
public void activate(PlayerInstance player, ItemInstance item)
{
_player = player;
// if the player is mounted, attempt to unmount first. Only allow picking up the zariche if unmounting is successful.
if (player.isMounted())
{
if (_player.setMountType(0))
{
_player.broadcastPacket(new Ride(_player.getObjectId(), Ride.ACTION_DISMOUNT, 0));
_player.setMountObjectID(0);
}
else
{
// TODO: correct this custom message.
player.sendMessage("You may not pick up this item while riding in this territory");
return;
}
}
if ((player._inEventTvT && !Config.TVT_JOIN_CURSED) && player._inEventTvT)
{
TvT.removePlayer(player);
}
if ((player._inEventCTF && !Config.CTF_JOIN_CURSED) && player._inEventCTF)
{
CTF.removePlayer(player);
}
if ((player._inEventDM && !Config.DM_JOIN_CURSED) && player._inEventDM)
{
DM.removePlayer(player);
}
_isActivated = true;
// Player holding it data
_playerId = _player.getObjectId();
_playerKarma = _player.getKarma();
_playerPkKills = _player.getPkKills();
saveData();
// Change player stats
_player.setCursedWeaponEquipedId(_itemId);
_player.setKarma(9999999);
_player.setPkKills(0);
if (_player.isInParty())
{
_player.getParty().removePartyMember(_player);
}
if (_player.isWearingFormalWear())
{
_player.getInventory().unEquipItemInSlot(10);
}
// Add skill
giveSkill();
// Equip with the weapon
_item = item;
// ItemInstance[] items =
_player.getInventory().equipItemAndRecord(_item);
SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EQUIPPED_YOUR_S1);
sm.addItemName(_item.getItemId());
_player.sendPacket(sm);
// Fully heal player
_player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
_player.setCurrentCp(_player.getMaxCp());
// Refresh inventory
_player.sendPacket(new ItemList(_player, false));
// Refresh player stats
_player.broadcastUserInfo();
_player.broadcastPacket(new SocialAction(_player.getObjectId(), 17));
sm = new SystemMessage(SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION);
sm.addZoneName(_player.getX(), _player.getY(), _player.getZ()); // Region Name
sm.addItemName(_item.getItemId());
CursedWeaponsManager.announce(sm);
}
public void saveData()
{
try (Connection con = DatabaseFactory.getConnection())
{
// Delete previous datas
PreparedStatement statement = con.prepareStatement("DELETE FROM cursed_weapons WHERE itemId = ?");
statement.setInt(1, _itemId);
statement.executeUpdate();
if (_isActivated)
{
statement = con.prepareStatement("INSERT INTO cursed_weapons (itemId, playerId, playerKarma, playerPkKills, nbKills, endTime) VALUES (?, ?, ?, ?, ?, ?)");
statement.setInt(1, _itemId);
statement.setInt(2, _playerId);
statement.setInt(3, _playerKarma);
statement.setInt(4, _playerPkKills);
statement.setInt(5, _nbKills);
statement.setLong(6, _endTime);
statement.executeUpdate();
}
statement.close();
}
catch (SQLException e)
{
LOGGER.warning("CursedWeapon: Failed to save data " + e);
}
}
public void dropIt(Creature killer)
{
if (Rnd.get(100) <= _disapearChance)
{
// Remove it
endOfLife();
}
else
{
// Unequip & Drop
dropIt(null, null, killer, false);
}
}
public void increaseKills()
{
_nbKills++;
_player.setPkKills(_nbKills);
_player.broadcastUserInfo();
if (((_nbKills % _stageKills) == 0) && (_nbKills <= (_stageKills * (_skillMaxLevel - 1))))
{
giveSkill();
}
// Reduce time-to-live
_endTime -= _durationLost * 60000;
saveData();
}
public void setDisapearChance(int disapearChance)
{
_disapearChance = disapearChance;
}
public void setDropRate(int dropRate)
{
_dropRate = dropRate;
}
public void setDuration(int duration)
{
_duration = duration;
}
public void setDurationLost(int durationLost)
{
_durationLost = durationLost;
}
public void setStageKills(int stageKills)
{
_stageKills = stageKills;
}
public void setNbKills(int nbKills)
{
_nbKills = nbKills;
}
public void setPlayerId(int playerId)
{
_playerId = playerId;
}
public void setPlayerKarma(int playerKarma)
{
_playerKarma = playerKarma;
}
public void setPlayerPkKills(int playerPkKills)
{
_playerPkKills = playerPkKills;
}
public void setActivated(boolean isActivated)
{
_isActivated = isActivated;
}
public void setDropped(boolean isDropped)
{
_isDropped = isDropped;
}
public void setEndTime(long endTime)
{
_endTime = endTime;
}
public void setPlayer(PlayerInstance player)
{
_player = player;
}
public void setItem(ItemInstance item)
{
_item = item;
}
public boolean isActivated()
{
return _isActivated;
}
public boolean isDropped()
{
return _isDropped;
}
public long getEndTime()
{
return _endTime;
}
public String getName()
{
return _name;
}
public int getItemId()
{
return _itemId;
}
public int getSkillId()
{
return _skillId;
}
public int getPlayerId()
{
return _playerId;
}
public PlayerInstance getPlayer()
{
return _player;
}
public int getPlayerKarma()
{
return _playerKarma;
}
public int getPlayerPkKills()
{
return _playerPkKills;
}
public int getNbKills()
{
return _nbKills;
}
public int getStageKills()
{
return _stageKills;
}
public boolean isActive()
{
return _isActivated || _isDropped;
}
public int getLevel()
{
if (_nbKills > (_stageKills * _skillMaxLevel))
{
return _skillMaxLevel;
}
return _nbKills / _stageKills;
}
public long getTimeLeft()
{
return _endTime - System.currentTimeMillis();
}
public int getDuration()
{
return _duration;
}
public void goTo(PlayerInstance player)
{
if (player == null)
{
return;
}
if (_isActivated)
{
// Go to player holding the weapon
player.teleToLocation(_player.getX(), _player.getY(), _player.getZ() + 20, true);
}
else if (_isDropped)
{
// Go to item on the ground
player.teleToLocation(_item.getX(), _item.getY(), _item.getZ() + 20, true);
}
else
{
player.sendMessage(_name + " isn't in the World.");
}
}
public Location getWorldPosition()
{
if (_isActivated && (_player != null))
{
return _player.getLocation();
}
if (_isDropped && (_item != null))
{
return _item.getLocation();
}
return null;
}
}
@@ -21,7 +21,6 @@ import java.util.concurrent.Future;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.datatables.sql.NpcTable;
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
import org.l2jmobius.gameserver.model.actor.instance.PenaltyMonsterInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
@@ -51,7 +50,8 @@ public class Fishing implements Runnable
private final double _regenHp;
private final boolean _isUpperGrade;
private int _lureType;
private final int _lureId;
@SuppressWarnings("unused")
private final int _lureId; // Used by fishing tournament.
@Override
public void run()
@@ -159,7 +159,6 @@ public class Fishing implements Runnable
{
_fisher.sendPacket(SystemMessageId.YOU_CAUGHT_SOMETHING);
_fisher.addItem("Fishing", _fishId, 1, null, true);
FishingChampionshipManager.getInstance().newFish(_fisher, _lureId);
}
}
_fisher.endFishing(win);
@@ -27,7 +27,6 @@ public class ItemInfo
private int _objectId;
private Item _item;
private int _enchant;
private int _augmentation;
private int _count;
private int _price;
private int _type1;
@@ -56,16 +55,6 @@ public class ItemInfo
// Get the enchant level of the ItemInstance
_enchant = item.getEnchantLevel();
// Get the augmentation bonus
if (item.isAugmented())
{
_augmentation = item.getAugmentation().getAugmentationId();
}
else
{
_augmentation = 0;
}
// Get the quantity of the ItemInstance
_count = item.getCount();
@@ -116,16 +105,6 @@ public class ItemInfo
// Get the enchant level of the ItemInstance
_enchant = item.getEnchantLevel();
// Get the augmentation bonus
if (item.isAugmented())
{
_augmentation = item.getAugmentation().getAugmentationId();
}
else
{
_augmentation = 0;
}
// Get the quantity of the ItemInstance
_count = item.getCount();
@@ -158,11 +137,6 @@ public class ItemInfo
return _enchant;
}
public int getAugemtationBonus()
{
return _augmentation;
}
public int getCount()
{
return _count;
@@ -26,7 +26,6 @@ import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.GameTimeController;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Playable;
@@ -432,11 +431,6 @@ public class Party
SevenSignsFestival.getInstance().updateParticipants(player, this);
}
if (player.isInDuel())
{
DuelManager.getInstance().onRemoveFromParty(player);
}
if (sendMessage)
{
player.sendPacket(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_THE_PARTY);
@@ -487,10 +481,6 @@ public class Party
if (leader != null)
{
leader.setParty(null);
if (leader.isInDuel())
{
DuelManager.getInstance().onRemoveFromParty(leader);
}
}
if (_positionBroadcastTask != null)
@@ -511,7 +501,7 @@ public class Party
public void changePartyLeader(String name)
{
final PlayerInstance player = getPlayerByName(name);
if ((player != null) && !player.isInDuel())
if (player != null)
{
if (_members.contains(player))
{
@@ -70,7 +70,6 @@ import org.l2jmobius.gameserver.model.skills.handlers.SkillSignetCasttime;
import org.l2jmobius.gameserver.model.skills.handlers.SkillSummon;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Util;
@@ -2248,10 +2247,7 @@ public abstract class Skill
{
continue;
}
if (player.isInDuel() && ((player.getDuelId() != newTarget.getDuelId()) || ((player.getParty() == null) && (player.getParty() != newTarget.getParty()))))
{
continue;
}
final PlayerInstance trg = newTarget;
final PlayerInstance src = player;
// if src is in event and trg not OR viceversa:
@@ -2672,7 +2668,7 @@ public abstract class Skill
if (target instanceof Summon)
{
final Summon targetSummon = (Summon) target;
if (((creature instanceof PlayerInstance) && (creature.getPet() != targetSummon) && !targetSummon.isDead() && ((targetSummon.getOwner().getPvpFlag() != 0) || (targetSummon.getOwner().getKarma() > 0) || targetSummon.getOwner().isInDuel())) || (targetSummon.getOwner().isInsideZone(ZoneId.PVP) && ((PlayerInstance) creature).isInsideZone(ZoneId.PVP)))
if (((creature instanceof PlayerInstance) && (creature.getPet() != targetSummon) && !targetSummon.isDead() && ((targetSummon.getOwner().getPvpFlag() != 0) || (targetSummon.getOwner().getKarma() > 0))) || (targetSummon.getOwner().isInsideZone(ZoneId.PVP) && ((PlayerInstance) creature).isInsideZone(ZoneId.PVP)))
{
return new Creature[]
{
@@ -2921,7 +2917,6 @@ public abstract class Skill
effect.addNumCharges(effectcharge);
if (env.target instanceof PlayerInstance)
{
env.target.sendPacket(new EtcStatusUpdate((PlayerInstance) env.target));
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_FORCE_HAS_INCREASED_TO_S1_LEVEL);
sm.addNumber(effectcharge);
env.target.sendPacket(sm);
@@ -3050,11 +3045,6 @@ public abstract class Skill
return false;
}
if (activeCh.isInDuel() && targetChar.isInDuel() && (activeCh.getDuelId() == targetChar.getDuelId()))
{
return false;
}
// if src is in event and trg not OR viceversa, the target must be not attackable
// to be fixed for mixed events status (in TvT joining phase, someone can attack a partecipating CTF player with area attack)
if (((activeCh._inEvent || activeCh._inEventCTF || activeCh._inEventDM || activeCh._inEventTvT || activeCh._inEventVIP) && (!targetChar._inEvent && !targetChar._inEventCTF && !targetChar._inEventDM && !targetChar._inEventTvT && !targetChar._inEventVIP)) || ((targetChar._inEvent || targetChar._inEventCTF || targetChar._inEventDM || targetChar._inEventTvT || targetChar._inEventVIP) && (!activeCh._inEvent && !activeCh._inEventCTF && !activeCh._inEventDM && !activeCh._inEventTvT && !activeCh._inEventVIP)))
@@ -72,7 +72,7 @@ public class StoreTradeList
public void replaceItem(int itemID, int priceValue)
{
int price = priceValue;
for (final ItemInstance item : _items)
for (ItemInstance item : _items)
{
if (item.getItemId() == itemID)
{
@@ -88,7 +88,7 @@ public class StoreTradeList
public synchronized boolean decreaseCount(int itemID, int count)
{
for (final ItemInstance item : _items)
for (ItemInstance item : _items)
{
if (item.getItemId() == itemID)
{
@@ -104,7 +104,7 @@ public class StoreTradeList
public void restoreCount(int time)
{
for (final ItemInstance item : _items)
for (ItemInstance item : _items)
{
if (item.getCountDecrease() && (item.getTime() == time))
{
@@ -168,7 +168,7 @@ public class StoreTradeList
public int getPriceForItemId(int itemId)
{
for (final ItemInstance item : _items)
for (ItemInstance item : _items)
{
if (item.getItemId() == itemId)
{
@@ -180,7 +180,7 @@ public class StoreTradeList
public boolean countDecrease(int itemId)
{
for (final ItemInstance item : _items)
for (ItemInstance item : _items)
{
if (item.getItemId() == itemId)
{
@@ -204,7 +204,7 @@ public class StoreTradeList
public ItemInstance getItem(int objectId)
{
for (final ItemInstance item : _items)
for (ItemInstance item : _items)
{
if (item.getObjectId() == objectId)
{
@@ -51,9 +51,6 @@ public class TradeList
private int _price;
private int _curcount;
/** Augmented Item */
private final Augmentation _augmentation = null;
public TradeItem(ItemInstance item, int count, int price)
{
_objectId = item.getObjectId();
@@ -135,15 +132,6 @@ public class TradeList
{
return _curcount;
}
/**
* Returns whether this item is augmented or not
* @return true if augmented
*/
public boolean isAugmented()
{
return _augmentation != null;
}
}
private final PlayerInstance _owner;
@@ -1153,14 +1141,6 @@ public class TradeList
player.sendMessage(msg);
return false;
}
if (oldItem.getAugmentation() != null)
{
final String msg = "Transaction failed. Augmented items may not be exchanged.";
_owner.sendMessage(msg);
player.sendMessage(msg);
return false;
}
}
// Transfer items
@@ -34,7 +34,6 @@ import org.l2jmobius.gameserver.ai.SiegeGuardAI;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.datatables.xml.ManorSeedData;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.CommandChannel;
import org.l2jmobius.gameserver.model.DropCategory;
import org.l2jmobius.gameserver.model.DropData;
@@ -1786,12 +1785,6 @@ public class Attackable extends NpcInstance
final int levelModifier = calculateLevelModifierForDrop(player); // level modifier in %'s (will be subtracted from drop chance)
// Check the drop of a cursed weapon
if ((levelModifier == 0) && (player.getLevel() > 20))
{
CursedWeaponsManager.getInstance().checkDrop(this, player);
}
// now throw all categorized drops and handle spoil.
for (DropCategory cat : npcTemplate.getDropData())
{
@@ -1900,351 +1893,6 @@ public class Attackable extends NpcInstance
dropItem(player, item);
}
}
// Instant Item Drop :>
final double rateHp = getStat().calcStat(Stat.MAX_HP, 1, this, null);
if ((rateHp < 2) && npcTemplate.getType().contentEquals("Monster")) // only Monster with <= 1x HP can drop herbs
{
boolean hp = false;
boolean mp = false;
boolean spec = false;
// ptk - patk type enhance
int random = Rnd.get(1000); // note *10
if ((random < Config.RATE_DROP_SPECIAL_HERBS) && !spec) // && !_spec useless yet
{
final RewardItem item = new RewardItem(8612, 1); // Herb of Warrior
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
spec = true;
}
else
{
for (int i = 0; i < 3; i++)
{
random = Rnd.get(100);
if (random < Config.RATE_DROP_COMMON_HERBS)
{
RewardItem item = null;
if (i == 0)
{
item = new RewardItem(8606, 1); // Herb of Power
}
if (i == 1)
{
item = new RewardItem(8608, 1); // Herb of Atk. Spd.
}
if (i == 2)
{
item = new RewardItem(8610, 1); // Herb of Critical Attack
}
if (item == null)
{
break;
}
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
break;
}
}
}
// mtk - matk type enhance
random = Rnd.get(1000); // note *10
if ((random < Config.RATE_DROP_SPECIAL_HERBS) && !spec)
{
final RewardItem item = new RewardItem(8613, 1); // Herb of Mystic
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
spec = true;
}
else
{
for (int i = 0; i < 2; i++)
{
random = Rnd.get(100);
if (random < Config.RATE_DROP_COMMON_HERBS)
{
RewardItem item = null;
if (i == 0)
{
item = new RewardItem(8607, 1); // Herb of Magic
}
if (i == 1)
{
item = new RewardItem(8609, 1); // Herb of Casting Speed
}
if (item == null)
{
break;
}
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
break;
}
}
}
// hp + mp type
random = Rnd.get(1000); // note *10
if ((random < Config.RATE_DROP_SPECIAL_HERBS) && !spec)
{
final RewardItem item = new RewardItem(8614, 1); // Herb of Recovery
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
mp = true;
hp = true;
spec = true;
}
// hp - restore hp type
if (!hp)
{
random = Rnd.get(100);
if (random < Config.RATE_DROP_MP_HP_HERBS)
{
final RewardItem item = new RewardItem(8600, 1); // Herb of Life
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
hp = true;
}
}
if (!hp)
{
random = Rnd.get(100);
if (random < Config.RATE_DROP_GREATER_HERBS)
{
final RewardItem item = new RewardItem(8601, 1); // Greater Herb of Life
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
hp = true;
}
}
if (!hp)
{
random = Rnd.get(1000); // note *10
if (random < Config.RATE_DROP_SUPERIOR_HERBS)
{
final RewardItem item = new RewardItem(8602, 1); // Superior Herb of Life
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
}
}
// mp - restore mp type
if (!mp)
{
random = Rnd.get(100);
if (random < Config.RATE_DROP_MP_HP_HERBS)
{
final RewardItem item = new RewardItem(8603, 1); // Herb of Mana
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
mp = true;
}
}
if (!mp)
{
random = Rnd.get(100);
if (random < Config.RATE_DROP_GREATER_HERBS)
{
final RewardItem item = new RewardItem(8604, 1); // Greater Herb of Mana
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
mp = true;
}
}
if (!mp)
{
random = Rnd.get(1000); // note *10
if (random < Config.RATE_DROP_SUPERIOR_HERBS)
{
final RewardItem item = new RewardItem(8605, 1); // Superior Herb of Mana
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
}
}
// speed enhance type
random = Rnd.get(100);
if (random < Config.RATE_DROP_COMMON_HERBS)
{
final RewardItem item = new RewardItem(8611, 1); // Herb of Speed
if (Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
dropItem(player, item);
}
else
{
player.addItem("AutoLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
dropItem(player, item);
}
}
}
}
/**
@@ -2339,7 +1987,7 @@ public class Attackable extends NpcInstance
ditem.dropMe(this, newX, newY, newZ);
// Add drop to auto destroy item task
if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && (((Config.AUTODESTROY_ITEM_AFTER > 0) && (ditem.getItemType() != EtcItemType.HERB)) || ((Config.HERB_AUTO_DESTROY_TIME > 0) && (ditem.getItemType() == EtcItemType.HERB))))
if (!Config.LIST_PROTECTED_ITEMS.contains(item.getItemId()) && ((Config.AUTODESTROY_ITEM_AFTER > 0) && (ditem.getItemType() != EtcItemType.HERB)))
{
ItemsAutoDestroy.getInstance().addItem(ditem);
}
@@ -47,7 +47,6 @@ import org.l2jmobius.gameserver.handler.ISkillHandler;
import org.l2jmobius.gameserver.handler.SkillHandler;
import org.l2jmobius.gameserver.handler.itemhandlers.Potions;
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
import org.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
import org.l2jmobius.gameserver.model.ChanceSkillList;
@@ -84,7 +83,6 @@ import org.l2jmobius.gameserver.model.actor.stat.CreatureStat;
import org.l2jmobius.gameserver.model.actor.status.CreatureStatus;
import org.l2jmobius.gameserver.model.actor.templates.CreatureTemplate;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.entity.Duel;
import org.l2jmobius.gameserver.model.entity.event.CTF;
import org.l2jmobius.gameserver.model.entity.event.DM;
import org.l2jmobius.gameserver.model.entity.event.GameEvent;
@@ -818,15 +816,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
return;
}
if ((target instanceof PlayerInstance) && (((PlayerInstance) target).getDuelState() == Duel.DUELSTATE_DEAD))
{
// If PlayerInstance is dead or the target is dead, the action is stoped
getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if ((target instanceof DoorInstance) && !((DoorInstance) target).isAttackable(this))
{
return;
@@ -846,23 +835,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
return;
}
if (target instanceof PlayerInstance)
{
if (((PlayerInstance) target).isCursedWeaponEquiped() && (((PlayerInstance) this).getLevel() <= Config.MAX_LEVEL_NEWBIE))
{
((PlayerInstance) this).sendMessage("Can't attack a cursed player when under level 21.");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (((PlayerInstance) this).isCursedWeaponEquiped() && (((PlayerInstance) target).getLevel() <= Config.MAX_LEVEL_NEWBIE))
{
((PlayerInstance) this).sendMessage("Can't attack a newbie player using a cursed weapon.");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
}
if (getObjectId() == target.getObjectId())
{
sendPacket(ActionFailed.STATIC_PACKET);
@@ -1094,23 +1066,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
{
weaponInst.setChargedSoulshot(ItemInstance.CHARGED_NONE);
}
if (player != null)
{
if (player.isCursedWeaponEquiped())
{
// If hitted by a cursed weapon, Cp is reduced to 0
if (!target.isInvul())
{
target.setCurrentCp(0);
}
}
else if (player.isHero() && (target instanceof PlayerInstance) && ((PlayerInstance) target).isCursedWeaponEquiped())
{
// If a cursed weapon is hitted by a Hero, Cp is reduced to 0
target.setCurrentCp(0);
}
}
}
// If the Server->Client packet Attack contains at least 1 hit, send the Server->Client packet Attack
@@ -3188,15 +3143,6 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if ((effect.getSkill().getId() == newEffect.getSkill().getId()) && (effect.getEffectType() == newEffect.getEffectType()) && (effect.getStackType().equals(newEffect.getStackType())))
{
if (this instanceof PlayerInstance)
{
final PlayerInstance player = (PlayerInstance) this;
if (player.isInDuel())
{
DuelManager.getInstance().getDuel(player.getDuelId()).onBuffStop(player, effect);
}
}
if (((newEffect.getSkill().getSkillType() == SkillType.BUFF) || (newEffect.getEffectType() == Effect.EffectType.BUFF) || (newEffect.getEffectType() == Effect.EffectType.HEAL_OVER_TIME)) && (newEffect.getStackOrder() >= effect.getStackOrder()))
{
effect.exit(false);
@@ -4063,6 +4009,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
continue;
}
// C4
if (!_effects.get(i).getShowIcon() && !_effects.get(i).getSkill().isPotion())
{
continue;
}
if ((_effects.get(i).getEffectType() == Effect.EffectType.CHARGE) && (player != null))
{
// handled by EtcStatusUpdate
@@ -27,7 +27,6 @@ import org.l2jmobius.gameserver.ai.CtrlEvent;
import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.handler.ISkillHandler;
import org.l2jmobius.gameserver.handler.SkillHandler;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.model.Effect;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.Skill;
@@ -358,76 +357,6 @@ public class CubicInstance
return;
}
// Duel targeting
if (_owner.isInDuel())
{
final PlayerInstance playerA = DuelManager.getInstance().getDuel(_owner.getDuelId()).getPlayerA();
final PlayerInstance playerB = DuelManager.getInstance().getDuel(_owner.getDuelId()).getPlayerB();
if (DuelManager.getInstance().getDuel(_owner.getDuelId()).isPartyDuel())
{
final Party partyA = playerA.getParty();
final Party partyB = playerB.getParty();
Party partyEnemy = null;
if (partyA != null)
{
if (partyA.getPartyMembers().contains(_owner))
{
if (partyB != null)
{
partyEnemy = partyB;
}
else
{
_target = playerB;
}
}
else
{
partyEnemy = partyA;
}
}
else if (playerA == _owner)
{
if (partyB != null)
{
partyEnemy = partyB;
}
else
{
_target = playerB;
}
}
else
{
_target = playerA;
}
if (((_target == playerA) || (_target == playerB)) && (_target == ownerTarget))
{
return;
}
if (partyEnemy != null)
{
if (partyEnemy.getPartyMembers().contains(ownerTarget))
{
_target = (Creature) ownerTarget;
}
return;
}
}
if ((playerA != _owner) && (ownerTarget == playerA))
{
_target = playerA;
return;
}
if ((playerB != _owner) && (ownerTarget == playerB))
{
_target = playerB;
return;
}
_target = null;
return;
}
// Olympiad targeting
if (_owner.isInOlympiadMode())
{
@@ -705,22 +634,7 @@ public class CubicInstance
}
}
// if this is a debuff let the duel manager know about it so the debuff can be removed after the duel (player & target must be in the same duel)
if ((target instanceof PlayerInstance) && ((PlayerInstance) target).isInDuel() && (skill.getSkillType() == SkillType.DEBUFF) && (activeCubic.getOwner().getDuelId() == ((PlayerInstance) target).getDuelId()))
{
final DuelManager dm = DuelManager.getInstance();
for (Effect debuff : skill.getEffects(activeCubic.getOwner(), target))
{
if (debuff != null)
{
dm.onBuff(((PlayerInstance) target), debuff);
}
}
}
else
{
skill.getEffects(activeCubic.getOwner(), target);
}
skill.getEffects(activeCubic.getOwner(), target);
}
}
@@ -804,22 +718,7 @@ public class CubicInstance
{
if (Formulas.calcCubicSkillSuccess(activeCubic, target, skill))
{
// if this is a debuff let the duel manager know about it so the debuff can be removed after the duel (player & target must be in the same duel)
if ((target instanceof PlayerInstance) && ((PlayerInstance) target).isInDuel() && (skill.getSkillType() == SkillType.DEBUFF) && (activeCubic.getOwner().getDuelId() == ((PlayerInstance) target).getDuelId()))
{
final DuelManager dm = DuelManager.getInstance();
for (Effect debuff : skill.getEffects(activeCubic.getOwner(), target))
{
if (debuff != null)
{
dm.onBuff(((PlayerInstance) target), debuff);
}
}
}
else
{
skill.getEffects(activeCubic.getOwner(), target);
}
skill.getEffects(activeCubic.getOwner(), target);
}
break;
}
@@ -827,22 +726,7 @@ public class CubicInstance
{
if (Formulas.calcCubicSkillSuccess(activeCubic, target, skill))
{
// if this is a debuff let the duel manager know about it so the debuff can be removed after the duel (player & target must be in the same duel)
if ((target instanceof PlayerInstance) && ((PlayerInstance) target).isInDuel() && (skill.getSkillType() == SkillType.DEBUFF) && (activeCubic.getOwner().getDuelId() == ((PlayerInstance) target).getDuelId()))
{
final DuelManager dm = DuelManager.getInstance();
for (Effect debuff : skill.getEffects(activeCubic.getOwner(), target))
{
if (debuff != null)
{
dm.onBuff(((PlayerInstance) target), debuff);
}
}
}
else
{
skill.getEffects(activeCubic.getOwner(), target);
}
skill.getEffects(activeCubic.getOwner(), target);
}
break;
}
@@ -873,22 +757,7 @@ public class CubicInstance
{
if (Formulas.calcCubicSkillSuccess(activeCubic, target, skill))
{
// if this is a debuff let the duel manager know about it so the debuff can be removed after the duel (player & target must be in the same duel)
if ((target instanceof PlayerInstance) && ((PlayerInstance) target).isInDuel() && (skill.getSkillType() == SkillType.DEBUFF) && (activeCubic.getOwner().getDuelId() == ((PlayerInstance) target).getDuelId()))
{
final DuelManager dm = DuelManager.getInstance();
for (Effect debuff : skill.getEffects(activeCubic.getOwner(), target))
{
if (debuff != null)
{
dm.onBuff(((PlayerInstance) target), debuff);
}
}
}
else
{
skill.getEffects(activeCubic.getOwner(), target);
}
skill.getEffects(activeCubic.getOwner(), target);
}
break;
}
@@ -941,12 +810,6 @@ public class CubicInstance
double percentleft = 100.0;
Party party = _owner.getParty();
// if owner is in a duel but not in a party duel, then it is the same as he does not have a party
if (_owner.isInDuel() && !DuelManager.getInstance().getDuel(_owner.getDuelId()).isPartyDuel())
{
party = null;
}
if ((party != null) && !_owner.isInOlympiadMode())
{
// Get all visible objects in a spheric area near the Creature
@@ -18,11 +18,9 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.util.StringTokenizer;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.TradeController;
import org.l2jmobius.gameserver.datatables.SkillTable;
import org.l2jmobius.gameserver.datatables.sql.SkillTreeTable;
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
import org.l2jmobius.gameserver.model.Skill;
import org.l2jmobius.gameserver.model.SkillLearn;
import org.l2jmobius.gameserver.model.StoreTradeList;
@@ -93,35 +91,6 @@ public class FishermanInstance extends FolkInstance
player.setSkillLearningClassId(player.getClassId());
showSkillList(player);
}
else if (command.startsWith("FishingChampionship"))
{
if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
{
FishingChampionshipManager.getInstance().showChampScreen(player, getObjectId());
}
else
{
sendHtml(player, this, "no_fish_event001.htm");
}
}
else if (command.startsWith("FishingReward"))
{
if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
{
if (FishingChampionshipManager.getInstance().isWinner(player.getName()))
{
FishingChampionshipManager.getInstance().getReward(player);
}
else
{
sendHtml(player, this, "no_fish_event_reward001.htm");
}
}
else
{
sendHtml(player, this, "no_fish_event001.htm");
}
}
final StringTokenizer st = new StringTokenizer(command, " ");
final String command2 = st.nextToken();
@@ -190,11 +159,4 @@ public class FishermanInstance extends FolkInstance
player.sendPacket(ActionFailed.STATIC_PACKET);
}
private void sendHtml(PlayerInstance player, FishermanInstance npc, String htmlName)
{
final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
html.setFile("data/html/fisherman/championship/" + htmlName);
player.sendPacket(html);
}
}
@@ -83,8 +83,6 @@ import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationCancelWindow;
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationMakeWindow;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.MyTargetSelected;
@@ -1301,10 +1299,6 @@ public class NpcInstance extends Creature
{
makeSupportMagic(player);
}
else if (command.startsWith("GiveBlessing"))
{
giveBlessingSupport(player);
}
else if (command.startsWith("multisell"))
{
MultisellData.getInstance().SeparateAndSend(Integer.parseInt(command.substring(9).trim()), player, false, getCastle().getTaxRate());
@@ -1313,25 +1307,6 @@ public class NpcInstance extends Creature
{
MultisellData.getInstance().SeparateAndSend(Integer.parseInt(command.substring(13).trim()), player, true, getCastle().getTaxRate());
}
else if (command.startsWith("Augment"))
{
final int cmdChoice = Integer.parseInt(command.substring(8, 9).trim());
switch (cmdChoice)
{
case 1:
{
player.sendPacket(SystemMessageId.SELECT_THE_ITEM_TO_BE_AUGMENTED);
player.sendPacket(new ExShowVariationMakeWindow());
break;
}
case 2:
{
player.sendPacket(SystemMessageId.SELECT_THE_ITEM_FROM_WHICH_YOU_WISH_TO_REMOVE_AUGMENTATION);
player.sendPacket(new ExShowVariationCancelWindow());
break;
}
}
}
else if (command.startsWith("npcfind_byid"))
{
try
@@ -1347,142 +1322,6 @@ public class NpcInstance extends Creature
player.sendMessage("Wrong command parameters");
}
}
else if (command.startsWith("newbie_give_coupon"))
{
try
{
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
if ((player.getLevel() > 25) || (player.getLevel() < 6) || !player.isNewbie())
{
html.setFile("data/html/adventurers_guide/31760-3.htm");
player.sendPacket(html);
}
else if (player.getCoupon(0))
{
html.setFile("data/html/adventurers_guide/31760-1.htm");
player.sendPacket(html);
}
else
{
player.getInventory().addItem("Weapon Coupon", 7832, 1, player, this);
player.addCoupon(1);
html.setFile("data/html/adventurers_guide/31760-2.htm");
player.sendPacket(html);
}
}
catch (NumberFormatException nfe)
{
player.sendMessage("Wrong command parameters");
}
}
else if (command.startsWith("newbie_give_weapon"))
{
try
{
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
if ((player.getLevel() > 25) || (player.getLevel() < 6) || !player.isNewbie())
{
html.setFile("data/html/adventurers_guide/31760-3.htm");
player.sendPacket(html);
}
else
{
MultisellData.getInstance().SeparateAndSend(10010, player, false, getCastle().getTaxRate());
}
}
catch (NumberFormatException nfe)
{
player.sendMessage("Wrong command parameters");
}
}
else if (command.startsWith("newbie_return_weapon"))
{
try
{
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
if ((player.getLevel() > 25) || (player.getLevel() < 6) || !player.isNewbie())
{
html.setFile("data/html/adventurers_guide/31760-3.htm");
player.sendPacket(html);
}
else
{
MultisellData.getInstance().SeparateAndSend(10011, player, false, getCastle().getTaxRate());
}
}
catch (NumberFormatException nfe)
{
player.sendMessage("Wrong command parameters");
}
}
else if (command.startsWith("traveller_give_coupon"))
{
try
{
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
if ((player.getLevel() > 25) || (player.getClassId().level() != 1) || !player.isNewbie())
{
html.setFile("data/html/adventurers_guide/31760-6.htm");
player.sendPacket(html);
}
else if (player.getCoupon(1))
{
html.setFile("data/html/adventurers_guide/31760-4.htm");
player.sendPacket(html);
}
else
{
player.getInventory().addItem("Weapon Coupon", 7833, 1, player, this);
player.addCoupon(2);
html.setFile("data/html/adventurers_guide/31760-5.htm");
player.sendPacket(html);
}
}
catch (NumberFormatException nfe)
{
player.sendMessage("Wrong command parameters");
}
}
else if (command.startsWith("traveller_give_weapon"))
{
try
{
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
if ((player.getLevel() > 25) || (player.getClassId().level() != 1) || !player.isNewbie())
{
html.setFile("data/html/adventurers_guide/31760-6.htm");
player.sendPacket(html);
}
else
{
MultisellData.getInstance().SeparateAndSend(10012, player, false, getCastle().getTaxRate());
}
}
catch (NumberFormatException nfe)
{
player.sendMessage("Wrong command parameters");
}
}
else if (command.startsWith("traveller_return_weapon"))
{
try
{
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
if ((player.getLevel() > 25) || (player.getClassId().level() != 1) || !player.isNewbie())
{
html.setFile("data/html/adventurers_guide/31760-6.htm");
player.sendPacket(html);
}
else
{
MultisellData.getInstance().SeparateAndSend(10013, player, false, getCastle().getTaxRate());
}
}
catch (NumberFormatException nfe)
{
player.sendMessage("Wrong command parameters");
}
}
else if (command.startsWith("EnterRift"))
{
try
@@ -1553,37 +1392,6 @@ public class NpcInstance extends Creature
return (Weapon) item;
}
/**
* Give blessing support.
* @param player the player
*/
public void giveBlessingSupport(PlayerInstance player)
{
if (player == null)
{
return;
}
// Blessing of protection - author eX1steam.
// Prevent a cursed weapon weilder of being buffed - I think no need of that becouse karma check > 0
if (player.isCursedWeaponEquiped())
{
return;
}
final int playerLevel = player.getLevel();
// If the player is too high level, display a message and return
if ((playerLevel > 39) || (player.getClassId().level() >= 2))
{
final String content = "<html><body>Newbie Guide:<br>I'm sorry, but you are not eligible to receive the protection blessing.<br1>It can only be bestowed on <font color=\"LEVEL\">characters below level 39 who have not made a seccond transfer.</font></body></html>";
insertObjectIdAndShowChatWindow(player, content);
return;
}
final Skill skill = SkillTable.getInstance().getInfo(5182, 1);
broadcastPacket(new MagicSkillUse(this, player, skill.getId(), skill.getLevel(), 0, 0));
skill.getEffects(this, player);
}
/**
* Return null (regular NPCs don't have weapons instancies).
* @return the secondary weapon instance
@@ -2137,11 +1945,6 @@ public class NpcInstance extends Creature
{
return;
}
if (player.isCursedWeaponEquiped())
{
player.sendMessage("Go away, you're not welcome here.");
return;
}
final int neededmoney = 100;
SystemMessage sm;
@@ -2182,12 +1985,6 @@ public class NpcInstance extends Creature
return;
}
// Prevent a cursed weapon weilder of being buffed
if (player.isCursedWeaponEquiped())
{
return;
}
final int playerLevel = player.getLevel();
int lowestLevel = 0;
int higestLevel = 0;
@@ -28,7 +28,6 @@ import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.datatables.sql.PetDataTable;
import org.l2jmobius.gameserver.idfactory.IdFactory;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.model.PetData;
import org.l2jmobius.gameserver.model.Skill;
@@ -474,14 +473,6 @@ public class PetInstance extends Summon
getOwner().sendPacket(smsg);
return;
}
// Cursed weapons
if (CursedWeaponsManager.getInstance().isCursed(target.getItemId()))
{
final SystemMessage smsg = new SystemMessage(SystemMessageId.YOU_HAVE_FAILED_TO_PICK_UP_S1);
smsg.addItemName(target.getItemId());
getOwner().sendPacket(smsg);
return;
}
synchronized (target)
{
@@ -77,9 +77,7 @@ import org.l2jmobius.gameserver.handler.skillhandlers.StrSiegeAssault;
import org.l2jmobius.gameserver.handler.skillhandlers.TakeCastle;
import org.l2jmobius.gameserver.instancemanager.CastleManager;
import org.l2jmobius.gameserver.instancemanager.CoupleManager;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.instancemanager.DimensionalRiftManager;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.instancemanager.QuestManager;
@@ -121,7 +119,6 @@ import org.l2jmobius.gameserver.model.base.SubClass;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.model.entity.Announcements;
import org.l2jmobius.gameserver.model.entity.Duel;
import org.l2jmobius.gameserver.model.entity.Hero;
import org.l2jmobius.gameserver.model.entity.Rebirth;
import org.l2jmobius.gameserver.model.entity.event.CTF;
@@ -176,15 +173,12 @@ import org.l2jmobius.gameserver.network.serverpackets.ChangeWaitType;
import org.l2jmobius.gameserver.network.serverpackets.CharInfo;
import org.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
import org.l2jmobius.gameserver.network.serverpackets.ExDuelUpdateUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.ExFishingEnd;
import org.l2jmobius.gameserver.network.serverpackets.ExFishingStart;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
import org.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
import org.l2jmobius.gameserver.network.serverpackets.ExSetCompassZoneCode;
import org.l2jmobius.gameserver.network.serverpackets.FriendList;
import org.l2jmobius.gameserver.network.serverpackets.GameServerPacket;
import org.l2jmobius.gameserver.network.serverpackets.HennaInfo;
@@ -211,9 +205,7 @@ import org.l2jmobius.gameserver.network.serverpackets.RelationChanged;
import org.l2jmobius.gameserver.network.serverpackets.Ride;
import org.l2jmobius.gameserver.network.serverpackets.SendTradeDone;
import org.l2jmobius.gameserver.network.serverpackets.SetupGauge;
import org.l2jmobius.gameserver.network.serverpackets.ShortBuffStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
import org.l2jmobius.gameserver.network.serverpackets.SkillList;
import org.l2jmobius.gameserver.network.serverpackets.Snoop;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
@@ -307,7 +299,6 @@ public class PlayerInstance extends Playable
private byte _pvpFlag;
private byte _siegeState = 0;
private int _curWeightPenalty = 0;
private int _lastCompassZone; // the last compass zone update send to the client
private byte _zoneValidateCounter = 4;
private boolean _isIn7sDungeon = false;
private int _heroConsecutiveKillCount = 0;
@@ -359,10 +350,6 @@ public class PlayerInstance extends Playable
private int[] _olympiadPosition;
private int _olympiadGameId = -1;
private int _olympiadSide = -1;
private boolean _isInDuel = false;
private int _duelState = Duel.DUELSTATE_NODUEL;
private int _duelId = 0;
private SystemMessageId _noDuelReason = SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL;
private BoatInstance _boat;
private Location _inBoatPosition;
private int _mountType;
@@ -480,7 +467,6 @@ public class PlayerInstance extends Playable
private SkillDat _queuedSkill;
private boolean _isWearingFormalWear = false;
private Location _currentSkillWorldPosition;
private int _cursedWeaponEquipedId = 0;
private int _reviveRequested = 0;
private double _revivePower = 0;
private boolean _revivePet = false;
@@ -1781,56 +1767,6 @@ public class PlayerInstance extends Playable
}
getWorldRegion().revalidateZones(this);
if (isInsideZone(ZoneId.SIEGE))
{
if (_lastCompassZone == ExSetCompassZoneCode.SIEGEWARZONE2)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.SIEGEWARZONE2;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.SIEGEWARZONE2));
}
else if (isInsideZone(ZoneId.PVP))
{
if (_lastCompassZone == ExSetCompassZoneCode.PVPZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.PVPZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PVPZONE));
}
else if (isIn7sDungeon())
{
if (_lastCompassZone == ExSetCompassZoneCode.SEVENSIGNSZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.SEVENSIGNSZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.SEVENSIGNSZONE));
}
else if (isInsideZone(ZoneId.PEACE))
{
if (_lastCompassZone == ExSetCompassZoneCode.PEACEZONE)
{
return;
}
_lastCompassZone = ExSetCompassZoneCode.PEACEZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.PEACEZONE));
}
else
{
if (_lastCompassZone == ExSetCompassZoneCode.GENERALZONE)
{
return;
}
if (_lastCompassZone == ExSetCompassZoneCode.SIEGEWARZONE2)
{
updatePvPStatus();
}
_lastCompassZone = ExSetCompassZoneCode.GENERALZONE;
sendPacket(new ExSetCompassZoneCode(ExSetCompassZoneCode.GENERALZONE));
}
}
/**
@@ -2170,7 +2106,6 @@ public class PlayerInstance extends Playable
setOverloaded(false);
_curWeightPenalty = 0;
super.removeSkill(getKnownSkill(4270));
sendPacket(new EtcStatusUpdate(this));
Broadcast.toKnownPlayers(this, new CharInfo(this));
}
else
@@ -2215,7 +2150,6 @@ public class PlayerInstance extends Playable
sendSkillList(); // Fix visual bug
}
sendPacket(new EtcStatusUpdate(this));
Broadcast.toKnownPlayers(this, new CharInfo(this));
}
}
@@ -2317,7 +2251,6 @@ public class PlayerInstance extends Playable
super.removeSkill(getKnownSkill(4267));
}
sendPacket(new EtcStatusUpdate(this));
_masteryPenalty = newMasteryPenalty;
}
}
@@ -2412,7 +2345,7 @@ public class PlayerInstance extends Playable
{
for (ItemInstance item : getInventory().getItems())
{
if ((item != null) && item.isEquipped() && (item.getItem() instanceof Weapon) && !isCursedWeaponEquiped())
if ((item != null) && item.isEquipped() && (item.getItem() instanceof Weapon))
{
// No penality for cupid's bow
if (item.isCupidBow())
@@ -2507,7 +2440,6 @@ public class PlayerInstance extends Playable
super.removeSkill(getKnownSkill(4267));
}
sendPacket(new EtcStatusUpdate(this));
_masteryWeapPenalty = newMasteryPenalty;
}
}
@@ -3587,10 +3519,6 @@ public class PlayerInstance extends Playable
{
dropItem("InvDrop", newitem, null, true, true);
}
else if (CursedWeaponsManager.getInstance().isCursed(newitem.getItemId()))
{
CursedWeaponsManager.getInstance().activate(this, newitem);
}
}
// If you pickup arrows.
@@ -3703,10 +3631,6 @@ public class PlayerInstance extends Playable
{
dropItem("InvDrop", item, null, true, true);
}
else if (CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
{
CursedWeaponsManager.getInstance().activate(this, item);
}
}
}
}
@@ -4572,13 +4496,7 @@ public class PlayerInstance extends Playable
}
}
// Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21
if ((isCursedWeaponEquiped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquiped() && (getLevel() < 21)))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
else if (Config.PATHFINDING)
if (Config.PATHFINDING)
{
if (GeoEngine.getInstance().canSeeTarget(player, this))
{
@@ -4757,13 +4675,7 @@ public class PlayerInstance extends Playable
}
}
// Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21
if ((isCursedWeaponEquiped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquiped() && (getLevel() < 21)))
{
player.sendPacket(ActionFailed.STATIC_PACKET);
}
else if (Config.PATHFINDING)
if (Config.PATHFINDING)
{
if (GeoEngine.getInstance().canSeeTarget(player, this))
{
@@ -5028,10 +4940,6 @@ public class PlayerInstance extends Playable
}
}
}
if (isInDuel())
{
DuelManager.getInstance().broadcastToOppositTeam(this, new ExDuelUpdateUserInfo(this));
}
}
/**
@@ -5364,11 +5272,6 @@ public class PlayerInstance extends Playable
}
ItemTable.getInstance().destroyItem("Consume", target, this, null);
}
// Cursed Weapons are not distributed
else if (CursedWeaponsManager.getInstance().isCursed(target.getItemId()))
{
addItem("Pickup", target, null, true);
}
else if (FortSiegeManager.getInstance().isCombat(target.getItemId()))
{
addItem("Pickup", target, null, true);
@@ -6030,42 +5933,35 @@ public class PlayerInstance extends Playable
// Clear resurrect xp calculation
setExpBeforeDeath(0);
if (isCursedWeaponEquiped())
onDieDropItem(killer); // Check if any item should be dropped
if ((!isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
{
CursedWeaponsManager.getInstance().drop(_cursedWeaponEquipedId, killer);
}
else if ((pk == null) || !pk.isCursedWeaponEquiped())
{
onDieDropItem(killer); // Check if any item should be dropped
if ((!isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
if ((pk != null) && (pk.getClan() != null) && (getClan() != null) && !isAcademyMember() && !pk.isAcademyMember() && _clan.isAtWarWith(pk.getClanId()) && pk.getClan().isAtWarWith(_clan.getClanId()))
{
if ((pk != null) && (pk.getClan() != null) && (getClan() != null) && !isAcademyMember() && !pk.isAcademyMember() && _clan.isAtWarWith(pk.getClanId()) && pk.getClan().isAtWarWith(_clan.getClanId()))
if (getClan().getReputationScore() > 0)
{
if (getClan().getReputationScore() > 0)
{
pk.getClan().setReputationScore(((PlayerInstance) killer).getClan().getReputationScore() + 2, true);
pk.getClan().broadcastToOnlineMembers(new PledgeShowInfoUpdate(pk.getClan())); // Update status to all members
}
if (pk.getClan().getReputationScore() > 0)
{
_clan.setReputationScore(_clan.getReputationScore() - 2, true);
_clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(_clan)); // Update status to all members
}
pk.getClan().setReputationScore(((PlayerInstance) killer).getClan().getReputationScore() + 2, true);
pk.getClan().broadcastToOnlineMembers(new PledgeShowInfoUpdate(pk.getClan())); // Update status to all members
}
if (Config.ALT_GAME_DELEVEL)
if (pk.getClan().getReputationScore() > 0)
{
// Reduce the Experience of the PlayerInstance in function of the calculated Death Penalty
// NOTE: deathPenalty +- Exp will update karma
if ((getSkillLevel(Skill.SKILL_LUCKY) <= 0) || (getStat().getLevel() > 9))
{
deathPenalty(((pk != null) && (getClan() != null) && (pk.getClan() != null) && pk.getClan().isAtWarWith(getClanId())));
}
_clan.setReputationScore(_clan.getReputationScore() - 2, true);
_clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(_clan)); // Update status to all members
}
else
}
if (Config.ALT_GAME_DELEVEL)
{
// Reduce the Experience of the PlayerInstance in function of the calculated Death Penalty
// NOTE: deathPenalty +- Exp will update karma
if ((getSkillLevel(Skill.SKILL_LUCKY) <= 0) || (getStat().getLevel() > 9))
{
onDieUpdateKarma(); // Update karma if delevel is not allowed
deathPenalty(((pk != null) && (getClan() != null) && (pk.getClan() != null) && pk.getClan().isAtWarWith(getClanId())));
}
}
else
{
onDieUpdateKarma(); // Update karma if delevel is not allowed
}
}
}
@@ -6105,8 +6001,6 @@ public class PlayerInstance extends Playable
sendMessage("You leaved War Legend State");
}
// Refresh focus force like L2OFF
sendPacket(new EtcStatusUpdate(this));
return true;
}
@@ -6174,8 +6068,7 @@ public class PlayerInstance extends Playable
for (ItemInstance itemDrop : getInventory().getItems())
{
// Don't drop
if (itemDrop.isAugmented() || // Dont drop augmented items
itemDrop.isShadowItem() || // Dont drop Shadow Items
if (itemDrop.isShadowItem() || // Dont drop Shadow Items
(itemDrop.getItemId() == 57) || // Adena
(itemDrop.getItem().getType2() == Item.TYPE2_QUEST) || // Quest Items
Config.KARMA_LIST_NONDROPPABLE_ITEMS.contains(itemDrop.getItemId()) || // Item listed in the non droppable item list
@@ -6255,19 +6148,6 @@ public class PlayerInstance extends Playable
return;
}
if (isCursedWeaponEquipped())
{
CursedWeaponsManager.getInstance().increaseKills(_cursedWeaponEquipedId);
// Custom message for time left
// CursedWeapon cw = CursedWeaponsManager.getInstance().getCursedWeapon(_cursedWeaponEquipedId);
// SystemMessage msg = SystemMessageId.THERE_IS_S1_HOUR_AND_S2_MINUTE_LEFT_OF_THE_FIXED_USAGE_TIME);
// int timeLeftInHours = (int)(((cw.getTimeLeft()/60000)/60));
// msg.addItemName(_cursedWeaponEquipedId);
// msg.addNumber(timeLeftInHours);
// sendPacket(msg);
return;
}
PlayerInstance targetPlayer = null;
if (target instanceof PlayerInstance)
{
@@ -6288,18 +6168,6 @@ public class PlayerInstance extends Playable
return; // Target player is self
}
if (isCursedWeaponEquiped())
{
CursedWeaponsManager.getInstance().increaseKills(_cursedWeaponEquipedId);
return;
}
// If in duel and you kill (only can kill l2summon), do nothing
if (isInDuel() && targetPlayer.isInDuel())
{
return;
}
// If in Arena, do nothing
if (isInsideZone(ZoneId.PVP) || targetPlayer.isInsideZone(ZoneId.PVP))
{
@@ -6976,11 +6844,6 @@ public class PlayerInstance extends Playable
return;
}
if (isInDuel() && (targetPlayer.getDuelId() == getDuelId()))
{
return;
}
if ((!isInsideZone(ZoneId.PVP) || !targetPlayer.isInsideZone(ZoneId.PVP)) && (targetPlayer.getKarma() == 0))
{
if (checkIfPvP(targetPlayer))
@@ -7583,12 +7446,6 @@ public class PlayerInstance extends Playable
*/
public boolean disarmWeapons()
{
// Don't allow disarming a cursed weapon
if (isCursedWeaponEquiped() && !getAccessLevel().isGm())
{
return false;
}
// Unequip the weapon
ItemInstance wpn = getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if (wpn == null)
@@ -7603,12 +7460,6 @@ public class PlayerInstance extends Playable
return false;
}
// Remove augementation boni on unequip
if (wpn.isAugmented())
{
wpn.getAugmentation().removeBonus(this);
}
final ItemInstance[] unequiped = getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance element : unequiped)
@@ -8358,8 +8209,6 @@ public class PlayerInstance extends Playable
player.setAccessLevel(rset.getInt("accesslevel"));
CursedWeaponsManager.getInstance().checkPlayer(player);
player.setAllianceWithVarkaKetra(rset.getInt("varka_ketra_ally"));
player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
@@ -9162,12 +9011,6 @@ public class PlayerInstance extends Playable
foundskill = true;
}
// exclude cursed weapon skills
if (isCursedWeaponEquiped() && (skillid == CursedWeaponsManager.getInstance().getCursedWeapon(_cursedWeaponEquipedId).getSkillId()))
{
foundskill = true;
}
// exclude clan skills
if ((getClan() != null) && (skillid >= 370) && (skillid <= 391))
{
@@ -9751,8 +9594,8 @@ public class PlayerInstance extends Playable
return true;
}
// Check if the attacker is not in the same party, excluding duels like L2OFF
if ((getParty() != null) && getParty().getPartyMembers().contains(attacker) && ((getDuelState() != Duel.DUELSTATE_DUELLING) || (getDuelId() != ((PlayerInstance) attacker).getDuelId())))
// Check if the attacker is not in the same party.
if ((getParty() != null) && getParty().getPartyMembers().contains(attacker))
{
return false;
}
@@ -9767,8 +9610,8 @@ public class PlayerInstance extends Playable
return false;
}
// Check if the attacker is not in the same clan, excluding duels like L2OFF
if ((getClan() != null) && (attacker != null) && getClan().isMember(attacker.getName()) && ((getDuelState() != Duel.DUELSTATE_DUELLING) || (getDuelId() != ((PlayerInstance) attacker).getDuelId())))
// Check if the attacker is not in the same clan.
if ((getClan() != null) && (attacker != null) && getClan().isMember(attacker.getName()))
{
return false;
}
@@ -9786,8 +9629,8 @@ public class PlayerInstance extends Playable
player = ((Summon) attacker).getOwner();
}
// Check if the attacker is not in the same ally, excluding duels like L2OFF
if ((player != null) && (getAllyId() != 0) && (player.getAllyId() != 0) && (getAllyId() == player.getAllyId()) && ((getDuelState() != Duel.DUELSTATE_DUELLING) || (getDuelId() != player.getDuelId())))
// Check if the attacker is not in the same ally.
if ((player != null) && (getAllyId() != 0) && (player.getAllyId() != 0) && (getAllyId() == player.getAllyId()))
{
return false;
}
@@ -9830,11 +9673,6 @@ public class PlayerInstance extends Playable
// Check if the attacker is a PlayerInstance
if (attacker instanceof PlayerInstance)
{
// is AutoAttackable if both players are in the same duel and the duel is still going on
if ((getDuelState() == Duel.DUELSTATE_DUELLING) && (getDuelId() == ((PlayerInstance) attacker).getDuelId()))
{
return true;
}
// Check if the PlayerInstance is in an arena or a siege area
if (isInsideZone(ZoneId.PVP) && ((PlayerInstance) attacker).isInsideZone(ZoneId.PVP))
{
@@ -10152,14 +9990,6 @@ public class PlayerInstance extends Playable
}
}
// Are the target and the player in the same duel?
if (isInDuel() && (!(target instanceof PlayerInstance) || (((PlayerInstance) target).getDuelId() != getDuelId())) && (!(target instanceof SummonInstance) || (((Summon) target).getOwner().getDuelId() != getDuelId())))
{
sendMessage("You cannot do this while duelling.");
sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Pk protection config
if (skill.isOffensive() && !isGM() && (target instanceof PlayerInstance) && (((PlayerInstance) target).getPvpFlag() == 0) && (((PlayerInstance) target).getKarma() == 0) && ((getLevel() < Config.ALT_PLAYER_PROTECTION_LEVEL) || (((PlayerInstance) target).getLevel() < Config.ALT_PLAYER_PROTECTION_LEVEL)))
{
@@ -10261,7 +10091,6 @@ public class PlayerInstance extends Playable
}
effect.numCharges -= skill.getNumCharges();
sendPacket(new EtcStatusUpdate(this));
if (effect.numCharges == 0)
{
effect.exit(false);
@@ -10577,7 +10406,6 @@ public class PlayerInstance extends Playable
if ((target != null) && // target not null and
(target != this) && // target is not self and
(target instanceof PlayerInstance) && // target is PlayerInstance and
(!isInDuel() || (((PlayerInstance) target).getDuelId() != getDuelId())) && // self is not in a duel and attacking opponent
!isInsideZone(ZoneId.PVP) && // Pc is not in PvP zone
!((PlayerInstance) target).isInsideZone(ZoneId.PVP) // target is not in PvP zone
)
@@ -11556,7 +11384,6 @@ public class PlayerInstance extends Playable
public void setInRefusalMode(boolean mode)
{
_messageRefusal = mode;
sendPacket(new EtcStatusUpdate(this));
}
/**
@@ -11743,42 +11570,6 @@ public class PlayerInstance extends Playable
return _inOlympiadMode;
}
/**
* Checks if is in duel.
* @return true, if is in duel
*/
public boolean isInDuel()
{
return _isInDuel;
}
/**
* Gets the duel id.
* @return the duel id
*/
public int getDuelId()
{
return _duelId;
}
/**
* Sets the duel state.
* @param mode the new duel state
*/
public void setDuelState(int mode)
{
_duelState = mode;
}
/**
* Gets the duel state.
* @return the duel state
*/
public int getDuelState()
{
return _duelState;
}
/**
* Sets the coupon.
* @param coupon the new coupon
@@ -11813,97 +11604,6 @@ public class PlayerInstance extends Playable
return (((_hasCoupon == 1) || (_hasCoupon == 3)) && (coupon == 0)) || (((_hasCoupon == 2) || (_hasCoupon == 3)) && (coupon == 1));
}
/**
* Sets up the duel state using a non 0 duelId.
* @param duelId 0=not in a duel
*/
public void setInDuel(int duelId)
{
if (duelId > 0)
{
_isInDuel = true;
_duelState = Duel.DUELSTATE_DUELLING;
_duelId = duelId;
}
else
{
if (_duelState == Duel.DUELSTATE_DEAD)
{
enableAllSkills();
getStatus().startHpMpRegeneration();
}
_isInDuel = false;
_duelState = Duel.DUELSTATE_NODUEL;
_duelId = 0;
}
}
/**
* This returns a SystemMessage stating why the player is not available for duelling.
* @return S1_CANNOT_DUEL... message
*/
public SystemMessage getNoDuelReason()
{
final SystemMessage sm = new SystemMessage(_noDuelReason);
sm.addString(getName());
_noDuelReason = SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL;
return sm;
}
/**
* Checks if this player might join / start a duel. To get the reason use getNoDuelReason() after calling this function.
* @return true if the player might join/start a duel.
*/
public boolean canDuel()
{
if (isInCombat() || isInJail())
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_CURRENTLY_ENGAGED_IN_BATTLE;
return false;
}
if (isDead() || isAlikeDead() || (getCurrentHp() < (getMaxHp() / 2)) || (getCurrentMp() < (getMaxMp() / 2)))
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_S_HP_OR_MP_IS_BELOW_50_PERCENT;
return false;
}
if (isInDuel())
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_ALREADY_ENGAGED_IN_A_DUEL;
return false;
}
if (isInOlympiadMode())
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_PARTICIPATING_IN_THE_OLYMPIAD;
return false;
}
if (isCursedWeaponEquiped())
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_IN_A_CHAOTIC_STATE;
return false;
}
if (getPrivateStoreType() != STORE_PRIVATE_NONE)
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_CURRENTLY_ENGAGED_IN_A_PRIVATE_STORE_OR_MANUFACTURE;
return false;
}
if (isMounted() || isInBoat())
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_CURRENTLY_RIDING_A_BOAT_WYVERN_OR_STRIDER;
return false;
}
if (isFishing())
{
_noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_CURRENTLY_FISHING;
return false;
}
if (isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.PEACE) || isInsideZone(ZoneId.SIEGE))
{
_noDuelReason = SystemMessageId.S1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_S1_IS_CURRENTLY_IN_A_DUEL_PROHIBITED_AREA_PEACEFUL_ZONE_SEVEN_SIGNS_ZONE_NEAR_WATER_RESTART_PROHIBITED_AREA;
return false;
}
return true;
}
/**
* Checks if is noble.
* @return true, if is noble
@@ -12449,12 +12149,6 @@ public class PlayerInstance extends Playable
}
}
// Rebind CursedWeapon passive.
if (isCursedWeaponEquiped())
{
CursedWeaponsManager.getInstance().givePassive(_cursedWeaponEquipedId);
}
stopAllEffects();
if (isSubClassActive())
@@ -12532,8 +12226,6 @@ public class PlayerInstance extends Playable
checkAllowedSkills();
}
sendPacket(new EtcStatusUpdate(this));
// if player has quest 422: Repent Your Sins, remove it
final QuestState st = getQuestState("422_RepentYourSins");
if (st != null)
@@ -12587,7 +12279,6 @@ public class PlayerInstance extends Playable
}
broadcastPacket(new SocialAction(getObjectId(), 15));
sendPacket(new SkillCoolTime(this));
if (getClan() != null)
{
getClan().broadcastToOnlineMembers(new PledgeShowMemberListUpdate(this));
@@ -12877,7 +12568,6 @@ public class PlayerInstance extends Playable
{
super.doRevive();
updateEffectIcons();
sendPacket(new EtcStatusUpdate(this));
_reviveRequested = 0;
_revivePower = 0;
if (isInParty() && getParty().isInDimensionalRift() && !DimensionalRiftManager.getInstance().checkIfInPeaceZone(getX(), getY(), getZ()))
@@ -13595,12 +13285,6 @@ public class PlayerInstance extends Playable
return false;
}
if (CursedWeaponsManager.getInstance().isCursed(itemId))
{
// can not trade a cursed weapon
return false;
}
if (item.isWear())
{
// cannot drop/trade wear-items
@@ -13636,12 +13320,6 @@ public class PlayerInstance extends Playable
return false;
}
if (CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
{
// can not trade a cursed weapon
return false;
}
if (item.isWear())
{
// cannot drop/trade wear-items
@@ -14073,7 +13751,6 @@ public class PlayerInstance extends Playable
return;
}
_player.sendPacket(new ShortBuffStatusUpdate(0, 0, 0));
}
}
@@ -14090,7 +13767,6 @@ public class PlayerInstance extends Playable
_shortBuffTask = null;
}
_shortBuffTask = ThreadPool.schedule(new ShortBuffTask(this), 15000);
sendPacket(new ShortBuffStatusUpdate(magicId, level, time));
}
public List<Integer> getFriendList()
@@ -14812,33 +14488,6 @@ public class PlayerInstance extends Playable
_powerGrade = power;
}
/**
* Checks if is cursed weapon equiped.
* @return true, if is cursed weapon equiped
*/
public boolean isCursedWeaponEquiped()
{
return _cursedWeaponEquipedId != 0;
}
/**
* Sets the cursed weapon equipped id.
* @param value the new cursed weapon equipped id
*/
public void setCursedWeaponEquipedId(int value)
{
_cursedWeaponEquipedId = value;
}
/**
* Gets the cursed weapon equipped id.
* @return the cursed weapon equipped id
*/
public int getCursedWeaponEquipedId()
{
return _cursedWeaponEquipedId;
}
/** The _charm of courage. */
private boolean _charmOfCourage = false;
@@ -14858,7 +14507,6 @@ public class PlayerInstance extends Playable
public void setCharmOfCourage(boolean value)
{
_charmOfCourage = value;
sendPacket(new EtcStatusUpdate(this));
}
/**
@@ -14913,7 +14561,6 @@ public class PlayerInstance extends Playable
_deathPenaltyBuffLevel++;
addSkill(SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel()), false);
sendPacket(new EtcStatusUpdate(this));
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_DEATH_PENALTY_IS_NOW_LEVEL_S1);
sm.addNumber(getDeathPenaltyBuffLevel());
sendPacket(sm);
@@ -14942,7 +14589,6 @@ public class PlayerInstance extends Playable
if (getDeathPenaltyBuffLevel() > 0)
{
addSkill(SkillTable.getInstance().getInfo(5076, getDeathPenaltyBuffLevel()), false);
sendPacket(new EtcStatusUpdate(this));
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_DEATH_PENALTY_IS_NOW_LEVEL_S1);
sm.addNumber(getDeathPenaltyBuffLevel());
sendPacket(sm);
@@ -14950,7 +14596,6 @@ public class PlayerInstance extends Playable
}
else
{
sendPacket(new EtcStatusUpdate(this));
sendPacket(SystemMessageId.YOUR_DEATH_PENALTY_HAS_BEEN_LIFTED);
}
}
@@ -14997,7 +14642,6 @@ public class PlayerInstance extends Playable
sm.addNumber(getDeathPenaltyBuffLevel());
sendPacket(sm);
}
sendPacket(new EtcStatusUpdate(this));
}
/**
@@ -15046,7 +14690,6 @@ public class PlayerInstance extends Playable
{
sendSkillList();
}
sendPacket(new SkillCoolTime(this));
}
@Override
@@ -15176,15 +14819,6 @@ public class PlayerInstance extends Playable
_currentSkillWorldPosition = location;
}
/**
* Checks if is cursed weapon equipped.
* @return true, if is cursed weapon equipped
*/
public boolean isCursedWeaponEquipped()
{
return _cursedWeaponEquipedId != 0;
}
/**
* Dismount.
* @return true, if successful
@@ -16161,7 +15795,6 @@ public class PlayerInstance extends Playable
{
_punishLevel = state;
stopPunishTask(true);
sendPacket(new EtcStatusUpdate(this));
sendMessage("Your Chat ban has been lifted");
break;
}
@@ -16196,7 +15829,6 @@ public class PlayerInstance extends Playable
}
_punishLevel = state;
_punishTimer = 0;
sendPacket(new EtcStatusUpdate(this));
// Remove the task if any
stopPunishTask(false);
@@ -16539,15 +16171,12 @@ public class PlayerInstance extends Playable
final ItemInstance equippedItem = getInventory().getPaperdollItem(i);
if ((equippedItem != null) && !equippedItem.checkOlympCondition())
{
if (equippedItem.isAugmented())
{
equippedItem.getAugmentation().removeBonus(this);
}
final ItemInstance[] items = getInventory().unEquipItemInSlotAndRecord(i);
if (equippedItem.isWear())
{
continue;
}
SystemMessage sm = null;
if (equippedItem.getEnchantLevel() > 0)
{
@@ -214,12 +214,6 @@ public class VillageMasterInstance extends FolkInstance
return;
}
if (player.isCursedWeaponEquiped())
{
player.sendMessage("You can`t change Subclass while Cursed weapon equiped!");
return;
}
final StringBuilder content = new StringBuilder("<html><body>");
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
Set<PlayerClass> subsAvailable;
@@ -64,7 +64,7 @@ public class PlayerStat extends PlayableStat
}
// Set new karma.
if (!player.isCursedWeaponEquiped() && (player.getKarma() > 0) && (player.isGM() || !player.isInsideZone(ZoneId.PVP)))
if ((player.getKarma() > 0) && (player.isGM() || !player.isInsideZone(ZoneId.PVP)))
{
final int karmaLost = player.calculateKarmaLost(value);
if (karmaLost > 0)
@@ -23,17 +23,12 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.SummonInstance;
import org.l2jmobius.gameserver.model.actor.stat.CreatureStat;
import org.l2jmobius.gameserver.model.entity.Duel;
import org.l2jmobius.gameserver.model.skills.Formulas;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class CreatureStatus
{
@@ -130,24 +125,6 @@ public class CreatureStatus
double value = amount;
if (_creature instanceof PlayerInstance)
{
if (((PlayerInstance) _creature).isInDuel())
{
// the duel is finishing - players do not recive damage
if (((PlayerInstance) _creature).getDuelState() == Duel.DUELSTATE_DEAD)
{
return;
}
else if (((PlayerInstance) _creature).getDuelState() == Duel.DUELSTATE_WINNER)
{
return;
}
// cancel duel if player got hit by another player, that is not part of the duel or a monster
if (!(attacker instanceof SummonInstance) && (!(attacker instanceof PlayerInstance) || (((PlayerInstance) attacker).getDuelId() != ((PlayerInstance) _creature).getDuelId())))
{
((PlayerInstance) _creature).setDuelState(Duel.DUELSTATE_INTERRUPTED);
}
}
if (_creature.isDead() && !_creature.isFakeDeath())
{
return; // Disabled == null check so skills like Body to Mind work again untill another solution is found
@@ -159,11 +136,6 @@ public class CreatureStatus
{
return; // Disabled == null check so skills like Body to Mind work again untill another solution is found
}
if ((attacker instanceof PlayerInstance) && ((PlayerInstance) attacker).isInDuel() && (!(_creature instanceof SummonInstance) || (((SummonInstance) _creature).getOwner().getDuelId() != ((PlayerInstance) attacker).getDuelId()))) // Duelling player attacks mob
{
((PlayerInstance) attacker).setDuelState(Duel.DUELSTATE_INTERRUPTED);
}
}
if (awake && _creature.isSleeping())
@@ -206,23 +178,8 @@ public class CreatureStatus
value = _currentHp - value; // Get diff of Hp vs value
if (value <= 0)
{
// is the dieing one a duelist? if so change his duel state to dead
if ((_creature instanceof PlayerInstance) && ((PlayerInstance) _creature).isInDuel())
{
_creature.disableAllSkills();
stopHpMpRegeneration();
attacker.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
attacker.sendPacket(ActionFailed.STATIC_PACKET);
// let the DuelManager know of his defeat
DuelManager.getInstance().onPlayerDefeat((PlayerInstance) getActiveChar());
value = 1;
}
else
{
// Set value to 0 if Hp < 0
value = 0;
}
// Set value to 0 if Hp < 0
value = 0;
}
setCurrentHp(value); // Set Hp
}
@@ -22,7 +22,6 @@ import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.SummonInstance;
import org.l2jmobius.gameserver.model.entity.Duel;
import org.l2jmobius.gameserver.model.skills.Stat;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
@@ -51,25 +50,6 @@ public class PlayerStatus extends PlayableStatus
if (attacker instanceof PlayerInstance)
{
if (getActiveChar().isInDuel())
{
// the duel is finishing - players do not recive damage
if (getActiveChar().getDuelState() == Duel.DUELSTATE_DEAD)
{
return;
}
else if (getActiveChar().getDuelState() == Duel.DUELSTATE_WINNER)
{
return;
}
// cancel duel if player got hit by another player, that is not part of the duel
if (((PlayerInstance) attacker).getDuelId() != getActiveChar().getDuelId())
{
getActiveChar().setDuelState(Duel.DUELSTATE_INTERRUPTED);
}
}
if (getActiveChar().isDead() && !getActiveChar().isFakeDeath())
{
return;
@@ -77,12 +57,6 @@ public class PlayerStatus extends PlayableStatus
}
else
{
// if attacked by a non PlayerInstance & non SummonInstance the duel gets canceled
if (getActiveChar().isInDuel() && !(attacker instanceof SummonInstance))
{
getActiveChar().setDuelState(Duel.DUELSTATE_INTERRUPTED);
}
if (getActiveChar().isDead())
{
return;
@@ -52,7 +52,6 @@ import org.l2jmobius.gameserver.network.serverpackets.PledgeShowInfoUpdate;
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListDeleteAll;
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillListAdd;
import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
@@ -1058,22 +1057,6 @@ public class Clan
{
LOGGER.warning("Error could not store char skills: " + e2);
}
for (ClanMember temp : _members.values())
{
try
{
if (temp.isOnline() && (newSkill.getMinPledgeClass() <= temp.getPlayerInstance().getPledgeClass()))
{
temp.getPlayerInstance().addSkill(newSkill, false); // Skill is not saved to player DB
temp.getPlayerInstance().sendPacket(new PledgeSkillListAdd(newSkill.getId(), newSkill.getLevel()));
}
}
catch (NullPointerException e)
{
LOGGER.warning(e.toString());
}
}
}
return oldSkill;
@@ -1919,10 +1919,6 @@ public class CTF implements EventTask
replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
}
}
else if (eventPlayer.isCursedWeaponEquiped() && !Config.CTF_JOIN_CURSED)
{
replyMSG.append("<font color=\"FFFF00\">You can't participate to this event with a cursed Weapon.</font><br>");
}
else if (!_started && _joining && (eventPlayer.getLevel() >= _minlvl) && (eventPlayer.getLevel() <= _maxlvl))
{
synchronized (_players)
@@ -1669,10 +1669,6 @@ public class DM implements EventTask
replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
}
}
else if (eventPlayer.isCursedWeaponEquiped() && !Config.DM_JOIN_CURSED)
{
replyMSG.append("<font color=\"FFFF00\">You can't participate to this event with a cursed Weapon.</font><br>");
}
else if (!_started && _joining && (eventPlayer.getLevel() >= _minlvl) && (eventPlayer.getLevel() <= _maxlvl))
{
if (_players.contains(eventPlayer))
@@ -1815,10 +1815,6 @@ public class TvT implements EventTask
replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
}
}
else if (eventPlayer.isCursedWeaponEquiped() && !Config.TVT_JOIN_CURSED)
{
replyMSG.append("<font color=\"FFFF00\">You can't participate to this event with a cursed Weapon.</font><br>");
}
else if (!_started && _joining && (eventPlayer.getLevel() >= _minlvl) && (eventPlayer.getLevel() <= _maxlvl))
{
synchronized (_players)
@@ -476,14 +476,6 @@ public class Olympiad
return false;
}
if (noble.isCursedWeaponEquiped())
{
sm = new SystemMessage(SystemMessageId.IF_YOU_POSSESS_S1_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
sm.addItemName(noble.getCursedWeaponEquipedId());
noble.sendPacket(sm);
return false;
}
if ((noble.getInventoryLimit() * 0.8) <= noble.getInventory().getSize())
{
sm = new SystemMessage(SystemMessageId.YOU_CAN_T_JOIN_A_GRAND_OLYMPIAD_GAME_MATCH_WITH_THAT_MUCH_STUFF_ON_YOU_REDUCE_YOUR_WEIGHT_TO_BELOW_80_PERCENT_FULL_AND_REQUEST_TO_JOIN_AGAIN);
@@ -1106,12 +1106,6 @@ class OlympiadGameTask implements Runnable
sm = new SystemMessage(SystemMessageId.YOU_HAVE_CHANGED_FROM_YOUR_MAIN_CLASS_TO_A_SUBCLASS_AND_THEREFORE_ARE_REMOVED_FROM_THE_GRAND_OLYMPIAD_GAMES_WAITING_LIST);
defaulted = true;
}
else if (player.isCursedWeaponEquiped())
{
sm = new SystemMessage(SystemMessageId.IF_YOU_POSSESS_S1_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
sm.addItemName(player.getCursedWeaponEquipedId());
defaulted = true;
}
else if ((player.getInventoryLimit() * 0.8) <= player.getInventory().getSize())
{
sm = new SystemMessage(SystemMessageId.YOU_CAN_T_JOIN_A_GRAND_OLYMPIAD_GAME_MATCH_WITH_THAT_MUCH_STUFF_ON_YOU_REDUCE_YOUR_WEIGHT_TO_BELOW_80_PERCENT_FULL_AND_REQUEST_TO_JOIN_AGAIN);
@@ -706,7 +706,7 @@ public class Castle
return null;
}
for (final DoorInstance door : _doors)
for (DoorInstance door : _doors)
{
if (door.getDoorId() == doorId)
{
@@ -807,20 +807,6 @@ public abstract class Inventory extends ItemContainer
return 0;
}
public int getPaperdollAugmentationId(int slot)
{
final ItemInstance item = _paperdoll[slot];
if (item != null)
{
if (item.getAugmentation() != null)
{
return item.getAugmentation().getAugmentationId();
}
return 0;
}
return 0;
}
/**
* Returns the objectID associated to the item in the paperdoll slot
* @param slot : int pointing out the slot
@@ -904,11 +890,6 @@ public abstract class Inventory extends ItemContainer
listener.notifyUnequiped(slot, old);
}
if (old.isAugmented() && (getOwner() != null) && (getOwner() instanceof PlayerInstance))
{
old.getAugmentation().removeBonus((PlayerInstance) getOwner());
}
old.updateDatabase();
}
@@ -377,10 +377,7 @@ public abstract class ItemContainer
{
targetitem.updateDatabase();
}
if (sourceitem.isAugmented())
{
sourceitem.getAugmentation().removeBonus(actor);
}
refreshWeight();
target.refreshWeight();
}
@@ -229,23 +229,6 @@ public class PlayerInventory extends Inventory
return list.toArray(new ItemInstance[list.size()]);
}
/**
* Get all augmented items
* @return
*/
public ItemInstance[] getAugmentedItems()
{
final List<ItemInstance> list = new ArrayList<>();
for (ItemInstance item : _items)
{
if ((item != null) && item.isAugmented())
{
list.add(item);
}
}
return list.toArray(new ItemInstance[list.size()]);
}
/**
* Returns the list of items in inventory available for transaction adjusted by tradeList
* @param tradeList
@@ -31,7 +31,6 @@ import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import org.l2jmobius.gameserver.model.Augmentation;
import org.l2jmobius.gameserver.model.DropProtection;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
@@ -91,7 +90,6 @@ public class ItemInstance extends WorldObject
private int _priceSell;
private int _priceBuy;
private boolean _wear;
private Augmentation _augmentation = null;
private int _mana = -1;
private boolean _consumingMana = false;
private static final int MANA_CONSUMPTION_RATE = 60000;
@@ -539,7 +537,7 @@ public class ItemInstance extends WorldObject
*/
public boolean isDropable()
{
return !isAugmented() && _item.isDropable();
return _item.isDropable();
}
/**
@@ -557,7 +555,7 @@ public class ItemInstance extends WorldObject
*/
public boolean isTradeable()
{
return !isAugmented() && _item.isTradeable();
return _item.isTradeable();
}
/**
@@ -655,53 +653,6 @@ public class ItemInstance extends WorldObject
return 0;
}
/**
* Returns whether this item is augmented or not.
* @return true if augmented
*/
public boolean isAugmented()
{
return _augmentation != null;
}
/**
* Returns the augmentation object for this item.
* @return augmentation
*/
public Augmentation getAugmentation()
{
return _augmentation;
}
/**
* Sets a new augmentation.
* @param augmentation the augmentation
* @return return true if sucessfull
*/
public boolean setAugmentation(Augmentation augmentation)
{
// there shall be no previous augmentation.
if (_augmentation != null)
{
return false;
}
_augmentation = augmentation;
return true;
}
/**
* Remove the augmentation.
*/
public void removeAugmentation()
{
if (_augmentation == null)
{
return;
}
_augmentation.deleteAugmentationData();
_augmentation = null;
}
/**
* Used to decrease mana (mana means life time for shadow items).
*/
@@ -1091,18 +1042,6 @@ public class ItemInstance extends WorldObject
rs.close();
statement.close();
// load augmentation
statement = con.prepareStatement("SELECT attributes,skill,level FROM augmentations WHERE item_id=?");
statement.setInt(1, objectId);
rs = statement.executeQuery();
if (rs.next())
{
inst._augmentation = new Augmentation(inst, rs.getInt("attributes"), rs.getInt("skill"), rs.getInt("level"), false);
}
rs.close();
statement.close();
}
catch (Exception e)
{
@@ -1256,12 +1195,6 @@ public class ItemInstance extends WorldObject
return;
}
// delete augmentation data
if (isAugmented())
{
_augmentation.deleteAugmentationData();
}
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("DELETE FROM items WHERE object_id=?");
@@ -1454,7 +1387,7 @@ public class ItemInstance extends WorldObject
public boolean checkOlympCondition()
{
return !isHeroItem() && !isOlyRestrictedItem() && !_wear && (Config.ALT_OLY_AUGMENT_ALLOW || !isAugmented());
return !isHeroItem() && !isOlyRestrictedItem() && !_wear;
}
/**
@@ -20,7 +20,6 @@ import org.l2jmobius.gameserver.model.Effect;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.Env;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class EffectCharge extends Effect
@@ -33,7 +32,6 @@ public class EffectCharge extends Effect
numCharges = 1;
if (env.target instanceof PlayerInstance)
{
env.target.sendPacket(new EtcStatusUpdate((PlayerInstance) env.target));
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_FORCE_HAS_INCREASED_TO_S1_LEVEL);
sm.addNumber(numCharges);
getEffected().sendPacket(sm);
@@ -23,7 +23,6 @@ import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.effects.EffectCharge;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class SkillCharge extends Skill
@@ -77,7 +76,6 @@ public class SkillCharge extends Skill
effect.numCharges++;
if (caster instanceof PlayerInstance)
{
caster.sendPacket(new EtcStatusUpdate((PlayerInstance) caster));
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_FORCE_HAS_INCREASED_TO_S1_LEVEL);
sm.addNumber(effect.numCharges);
caster.sendPacket(sm);
@@ -28,7 +28,6 @@ import org.l2jmobius.gameserver.model.skills.BaseStat;
import org.l2jmobius.gameserver.model.skills.Formulas;
import org.l2jmobius.gameserver.model.skills.effects.EffectCharge;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class SkillChargeDmg extends Skill
@@ -84,11 +83,6 @@ public class SkillChargeDmg extends Skill
effect.numCharges -= getNumCharges();
}
if (caster instanceof PlayerInstance)
{
caster.sendPacket(new EtcStatusUpdate((PlayerInstance) caster));
}
if (effect.numCharges == 0)
{
effect.exit(false);
@@ -23,7 +23,6 @@ import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.skills.effects.EffectCharge;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class SkillChargeEffect extends Skill
@@ -89,9 +88,5 @@ public class SkillChargeEffect extends Skill
getEffects(creature, (Creature) target, false, false, false);
}
}
if (creature instanceof PlayerInstance)
{
creature.sendPacket(new EtcStatusUpdate((PlayerInstance) creature));
}
}
}
@@ -32,7 +32,6 @@ import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.model.zone.ZoneType;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
/**
* another type of damage zone with skills
@@ -143,7 +142,6 @@ public class EffectZone extends ZoneType
if ((creature instanceof PlayerInstance) && _isShowDangerIcon)
{
creature.setInsideZone(ZoneId.DANGER_AREA, true);
creature.sendPacket(new EtcStatusUpdate((PlayerInstance) creature));
}
}
@@ -153,10 +151,6 @@ public class EffectZone extends ZoneType
if ((creature instanceof PlayerInstance) && _isShowDangerIcon)
{
creature.setInsideZone(ZoneId.DANGER_AREA, false);
if (!creature.isInsideZone(ZoneId.DANGER_AREA))
{
creature.sendPacket(new EtcStatusUpdate((PlayerInstance) creature));
}
}
if (getCharactersInside().isEmpty() && (_task != null))
@@ -62,6 +62,18 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
{
protected static final Logger LOGGER = Logger.getLogger(GameClient.class.getName());
private final static byte[] CRYPT_KEY =
{
(byte) 0x94,
(byte) 0x35,
(byte) 0x00,
(byte) 0x00,
(byte) 0xa1,
(byte) 0x6c,
(byte) 0x54,
(byte) 0x87 // The last 4 bytes are fixed.
};
private final FloodProtectors _floodProtectors = new FloodProtectors(this);
private final ReentrantLock _playerLock = new ReentrantLock();
private final List<Integer> _charSlotMapping = new ArrayList<>();
@@ -87,9 +99,8 @@ public class GameClient extends MMOClient<MMOConnection<GameClient>> implements
public byte[] enableCrypt()
{
final byte[] key = BlowFishKeygen.getRandomKey();
_crypt.setKey(key);
return key;
_crypt.setKey(CRYPT_KEY);
return CRYPT_KEY;
}
public ConnectionState getState()
@@ -21,14 +21,14 @@ package org.l2jmobius.gameserver.network;
*/
public class GameCrypt
{
private final byte[] _inKey = new byte[16];
private final byte[] _outKey = new byte[16];
private final byte[] _inKey = new byte[8];
private final byte[] _outKey = new byte[8];
private boolean _isEnabled;
public void setKey(byte[] key)
{
System.arraycopy(key, 0, _inKey, 0, 16);
System.arraycopy(key, 0, _outKey, 0, 16);
System.arraycopy(key, 0, _inKey, 0, 8);
System.arraycopy(key, 0, _outKey, 0, 8);
}
public void decrypt(byte[] raw, int offset, int size)
@@ -42,21 +42,21 @@ public class GameCrypt
for (int i = 0; i < size; i++)
{
final int temp2 = raw[offset + i] & 0xFF;
raw[offset + i] = (byte) (temp2 ^ _inKey[i & 15] ^ temp);
raw[offset + i] = (byte) (temp2 ^ _inKey[i & 7] ^ temp);
temp = temp2;
}
int old = _inKey[8] & 0xff;
old |= (_inKey[9] << 8) & 0xff00;
old |= (_inKey[10] << 0x10) & 0xff0000;
old |= (_inKey[11] << 0x18) & 0xff000000;
int old = _inKey[0] & 0xff;
old |= (_inKey[1] << 8) & 0xff00;
old |= (_inKey[2] << 0x10) & 0xff0000;
old |= (_inKey[3] << 0x18) & 0xff000000;
old += size;
_inKey[8] = (byte) (old & 0xff);
_inKey[9] = (byte) ((old >> 0x08) & 0xff);
_inKey[10] = (byte) ((old >> 0x10) & 0xff);
_inKey[11] = (byte) ((old >> 0x18) & 0xff);
_inKey[0] = (byte) (old & 0xff);
_inKey[1] = (byte) ((old >> 0x08) & 0xff);
_inKey[2] = (byte) ((old >> 0x10) & 0xff);
_inKey[3] = (byte) ((old >> 0x18) & 0xff);
}
public void encrypt(byte[] raw, int offset, int size)
@@ -71,20 +71,20 @@ public class GameCrypt
for (int i = 0; i < size; i++)
{
final int temp2 = raw[offset + i] & 0xFF;
temp = temp2 ^ _outKey[i & 15] ^ temp;
temp = temp2 ^ _outKey[i & 7] ^ temp;
raw[offset + i] = (byte) temp;
}
int old = _outKey[8] & 0xff;
old |= (_outKey[9] << 8) & 0xff00;
old |= (_outKey[10] << 0x10) & 0xff0000;
old |= (_outKey[11] << 0x18) & 0xff000000;
int old = _outKey[0] & 0xff;
old |= (_outKey[1] << 8) & 0xff00;
old |= (_outKey[2] << 0x10) & 0xff0000;
old |= (_outKey[3] << 0x18) & 0xff000000;
old += size;
_outKey[8] = (byte) (old & 0xff);
_outKey[9] = (byte) ((old >> 0x08) & 0xff);
_outKey[10] = (byte) ((old >> 0x10) & 0xff);
_outKey[11] = (byte) ((old >> 0x18) & 0xff);
_outKey[0] = (byte) (old & 0xff);
_outKey[1] = (byte) ((old >> 0x08) & 0xff);
_outKey[2] = (byte) ((old >> 0x10) & 0xff);
_outKey[3] = (byte) ((old >> 0x18) & 0xff);
}
}
@@ -812,7 +812,7 @@ public class GamePacketHandler implements IPacketHandler<GameClient>, IClientFac
}
case 0x9d:
{
msg = new RequestSkillCoolTime();
// msg = new RequestSkillCoolTime();
break;
}
case 0x9e:
@@ -1213,7 +1213,7 @@ public class GamePacketHandler implements IPacketHandler<GameClient>, IClientFac
}
case 0x1f:
{
msg = new RequestExFishRanking();
// msg = new RequestExFishRanking();
break;
}
case 0x20:
@@ -1224,12 +1224,12 @@ public class GamePacketHandler implements IPacketHandler<GameClient>, IClientFac
// couldnt find it 0x21 :S
case 0x22:
{
msg = new RequestCursedWeaponList();
// msg = new RequestCursedWeaponList();
break;
}
case 0x23:
{
msg = new RequestCursedWeaponLocation();
// msg = new RequestCursedWeaponLocation();
break;
}
case 0x24:
@@ -1245,42 +1245,42 @@ public class GamePacketHandler implements IPacketHandler<GameClient>, IClientFac
}
case 0x27:
{
msg = new RequestDuelStart();
// msg = new RequestDuelStart();
break;
}
case 0x28:
{
msg = new RequestDuelAnswerStart();
// msg = new RequestDuelAnswerStart();
break;
}
case 0x29:
{
msg = new RequestConfirmTargetItem();
// msg = new RequestConfirmTargetItem();
break;
}
case 0x2a:
{
msg = new RequestConfirmRefinerItem();
// msg = new RequestConfirmRefinerItem();
break;
}
case 0x2b:
{
msg = new RequestConfirmGemStone();
// msg = new RequestConfirmGemStone();
break;
}
case 0x2c:
{
msg = new RequestRefine();
// msg = new RequestRefine();
break;
}
case 0x2d:
{
msg = new RequestConfirmCancelItem();
// msg = new RequestConfirmCancelItem();
break;
}
case 0x2e:
{
msg = new RequestRefineCancel();
// msg = new RequestRefineCancel();
break;
}
case 0x2f:
@@ -1290,7 +1290,7 @@ public class GamePacketHandler implements IPacketHandler<GameClient>, IClientFac
}
case 0x30:
{
msg = new RequestDuelSurrender();
// msg = new RequestDuelSurrender();
break;
}
default:
@@ -105,11 +105,6 @@ public class AddTradeItem extends GameClientPacket
return;
}
if (item.isAugmented())
{
return;
}
player.sendPacket(new TradeOwnAdd(item));
player.sendPacket(new TradeUpdate(trade, player));
trade.getPartner().sendPacket(new TradeOtherAdd(item));
@@ -60,7 +60,6 @@ import org.l2jmobius.gameserver.model.entity.sevensigns.SevenSigns;
import org.l2jmobius.gameserver.model.entity.siege.Castle;
import org.l2jmobius.gameserver.model.entity.siege.FortSiege;
import org.l2jmobius.gameserver.model.entity.siege.Siege;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -71,7 +70,6 @@ import org.l2jmobius.gameserver.network.serverpackets.ClientSetTime;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import org.l2jmobius.gameserver.network.serverpackets.Die;
import org.l2jmobius.gameserver.network.serverpackets.Earthquake;
import org.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import org.l2jmobius.gameserver.network.serverpackets.ExMailArrived;
import org.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import org.l2jmobius.gameserver.network.serverpackets.ExStorageMaxCount;
@@ -83,7 +81,6 @@ import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillList;
import org.l2jmobius.gameserver.network.serverpackets.PledgeStatusChanged;
import org.l2jmobius.gameserver.network.serverpackets.QuestList;
import org.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
@@ -192,8 +189,6 @@ public class EnterWorld extends GameClientPacket
player.restoreEffects();
}
player.sendPacket(new EtcStatusUpdate(player));
final Effect[] effects = player.getAllEffects();
if (effects != null)
{
@@ -212,25 +207,6 @@ public class EnterWorld extends GameClientPacket
}
}
// Apply augmentation boni for equipped items
for (ItemInstance temp : player.getInventory().getAugmentedItems())
{
if ((temp != null) && temp.isEquipped())
{
temp.getAugmentation().applyBonus(player);
}
}
// Remove Demonic Weapon if character is not Cursed Weapon Equipped
if ((player.getInventory().getItemByItemId(8190) != null) && !player.isCursedWeaponEquipped())
{
player.destroyItem("Zariche", player.getInventory().getItemByItemId(8190), null, true);
}
if ((player.getInventory().getItemByItemId(8689) != null) && !player.isCursedWeaponEquipped())
{
player.destroyItem("Akamanah", player.getInventory().getItemByItemId(8689), null, true);
}
// Apply death penalty
player.restoreDeathPenaltyBuffLevel();
@@ -330,7 +306,6 @@ public class EnterWorld extends GameClientPacket
setPledgeClass(player);
notifyClanMembers(player);
notifySponsorOrApprentice(player);
player.setTarget(player);
@@ -364,7 +339,6 @@ public class EnterWorld extends GameClientPacket
if (player.getClan() != null)
{
player.sendPacket(new PledgeSkillList(player.getClan()));
for (Siege siege : SiegeManager.getInstance().getSieges())
{
if (!siege.isInProgress())
@@ -495,21 +469,6 @@ public class EnterWorld extends GameClientPacket
}
}
// Elrokian Trap like L2OFF
final ItemInstance rhand = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if ((rhand != null) && (rhand.getItemId() == 8763))
{
player.addSkill(SkillTable.getInstance().getInfo(3626, 1));
player.addSkill(SkillTable.getInstance().getInfo(3627, 1));
player.addSkill(SkillTable.getInstance().getInfo(3628, 1));
}
else
{
player.removeSkill(3626, true);
player.removeSkill(3627, true);
player.removeSkill(3628, true);
}
// Send all skills to char
player.sendSkillList();
@@ -742,7 +701,6 @@ public class EnterWorld extends GameClientPacket
sendPacket(new ItemList(player, false));
sendPacket(new ShortCutInit(player));
player.broadcastUserInfo();
player.sendPacket(new EtcStatusUpdate(player));
}
private void onEnterAio(PlayerInstance player)
@@ -831,26 +789,6 @@ public class EnterWorld extends GameClientPacket
}
}
private void notifySponsorOrApprentice(PlayerInstance player)
{
if (player.getSponsor() != 0)
{
final PlayerInstance sponsor = (PlayerInstance) World.getInstance().findObject(player.getSponsor());
if (sponsor != null)
{
sponsor.sendPacket(new SystemMessage(SystemMessageId.YOUR_APPRENTICE_S1_HAS_LOGGED_IN).addString(player.getName()));
}
}
else if (player.getApprentice() != 0)
{
final PlayerInstance apprentice = (PlayerInstance) World.getInstance().findObject(player.getApprentice());
if (apprentice != null)
{
apprentice.sendPacket(new SystemMessage(SystemMessageId.YOUR_SPONSOR_S1_HAS_LOGGED_IN).addString(player.getName()));
}
}
}
private void loadTutorial(PlayerInstance player)
{
final QuestState qs = player.getQuestState("Tutorial");
@@ -23,7 +23,6 @@ import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.datatables.xml.MultisellData;
import org.l2jmobius.gameserver.model.Augmentation;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
@@ -233,7 +232,7 @@ public class MultiSellChoose extends GameClientPacket
}
ingredientsList.clear();
final List<Augmentation> augmentation = new ArrayList<>();
/** All ok, remove items and add final product */
for (MultiSellIngredient e : entry.getIngredients())
{
@@ -284,16 +283,6 @@ public class MultiSellChoose extends GameClientPacket
final ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantmentLevel());
for (int i = 0; i < (e.getItemCount() * _amount); i++)
{
if (inventoryContents[i].isAugmented())
{
augmentation.add(inventoryContents[i].getAugmentation());
}
if (inventoryContents[i].isEquipped() && inventoryContents[i].isAugmented())
{
inventoryContents[i].getAugmentation().removeBonus(player);
}
if (!player.destroyItem("Multisell", inventoryContents[i].getObjectId(), 1, player.getTarget(), true))
{
return;
@@ -338,11 +327,6 @@ public class MultiSellChoose extends GameClientPacket
}
}
if (itemToTake.isEquipped() && itemToTake.isAugmented())
{
itemToTake.getAugmentation().removeBonus(player);
}
if (!player.destroyItem("Multisell", itemToTake.getObjectId(), 1, player.getTarget(), true))
{
return;
@@ -379,10 +363,6 @@ public class MultiSellChoose extends GameClientPacket
product = inv.addItem("Multisell[" + _listId + "]", e.getItemId(), 1, player, player.getTarget());
if (maintainEnchantment && (product != null))
{
if (i < augmentation.size())
{
product.setAugmentation(new Augmentation(product, augmentation.get(i).getAugmentationId(), augmentation.get(i).getSkill(), true));
}
product.setEnchantLevel(e.getEnchantmentLevel());
}
}
@@ -289,11 +289,6 @@ public class RequestActionUse extends GameClientPacket
// You can't mount, dismount, break and drop items while fishing
player.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_FISHING_2));
}
else if (player.isCursedWeaponEquiped())
{
// You can't mount, dismount, break and drop items while weilding a cursed weapon
player.sendPacket(new SystemMessage(SystemMessageId.A_STRIDER_CANNOT_BE_RIDDEN_WHILE_IN_BATTLE));
}
else if (!pet.isDead() && !player.isMounted())
{
if (!player.disarmWeapons())
@@ -52,12 +52,6 @@ public class RequestAnswerJoinParty extends GameClientPacket
return;
}
if (player.isCursedWeaponEquiped() || requestor.isCursedWeaponEquiped())
{
requestor.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
requestor.sendPacket(new JoinParty(_response));
if (_response == 1)
{
@@ -1,117 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExConfirmCancelItem;
/**
* Format(ch) d
* @author -Wooden-
*/
public class RequestConfirmCancelItem extends GameClientPacket
{
private int _itemId;
@Override
protected void readImpl()
{
_itemId = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
final ItemInstance item = (ItemInstance) World.getInstance().findObject(_itemId);
if ((player == null) || (item == null))
{
return;
}
if (!item.isAugmented())
{
player.sendPacket(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM);
return;
}
int price = 0;
switch (item.getItem().getItemGrade())
{
case Item.CRYSTAL_C:
{
if (item.getCrystalCount() < 1720)
{
price = 95000;
}
else if (item.getCrystalCount() < 2452)
{
price = 150000;
}
else
{
price = 210000;
}
break;
}
case Item.CRYSTAL_B:
{
if (item.getCrystalCount() < 1746)
{
price = 240000;
}
else
{
price = 270000;
}
break;
}
case Item.CRYSTAL_A:
{
if (item.getCrystalCount() < 2160)
{
price = 330000;
}
else if (item.getCrystalCount() < 2824)
{
price = 390000;
}
else
{
price = 420000;
}
break;
}
case Item.CRYSTAL_S:
{
price = 480000;
break;
}
// any other item type is not augmentable
default:
{
return;
}
}
player.sendPacket(new ExConfirmCancelItem(_itemId, price));
}
}
@@ -1,112 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExConfirmVariationGemstone;
/**
* Format:(ch) dddd
* @author -Wooden-
*/
public class RequestConfirmGemStone extends GameClientPacket
{
private int _targetItemObjId;
private int _refinerItemObjId;
private int _gemstoneItemObjId;
private int _gemstoneCount;
@Override
protected void readImpl()
{
_targetItemObjId = readD();
_refinerItemObjId = readD();
_gemstoneItemObjId = readD();
_gemstoneCount = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
final ItemInstance targetItem = (ItemInstance) World.getInstance().findObject(_targetItemObjId);
final ItemInstance refinerItem = (ItemInstance) World.getInstance().findObject(_refinerItemObjId);
final ItemInstance gemstoneItem = (ItemInstance) World.getInstance().findObject(_gemstoneItemObjId);
if ((targetItem == null) || (refinerItem == null) || (gemstoneItem == null))
{
return;
}
// Make sure the item is a gemstone
final int gemstoneItemId = gemstoneItem.getItem().getItemId();
if ((gemstoneItemId != 2130) && (gemstoneItemId != 2131))
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
return;
}
// Check if the gemstoneCount is sufficant
final int itemGrade = targetItem.getItem().getItemGrade();
switch (itemGrade)
{
case Item.CRYSTAL_C:
{
if ((_gemstoneCount != 20) || (gemstoneItemId != 2130))
{
player.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
return;
}
break;
}
case Item.CRYSTAL_B:
{
if ((_gemstoneCount != 30) || (gemstoneItemId != 2130))
{
player.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
return;
}
break;
}
case Item.CRYSTAL_A:
{
if ((_gemstoneCount != 20) || (gemstoneItemId != 2131))
{
player.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
return;
}
break;
}
case Item.CRYSTAL_S:
{
if ((_gemstoneCount != 25) || (gemstoneItemId != 2131))
{
player.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
return;
}
break;
}
}
player.sendPacket(new ExConfirmVariationGemstone(_gemstoneItemObjId, _gemstoneCount));
player.sendPacket(SystemMessageId.PRESS_THE_AUGMENT_BUTTON_TO_BEGIN);
}
}
@@ -1,140 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExConfirmVariationRefiner;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Fromat(ch) dd
* @author -Wooden-
*/
public class RequestConfirmRefinerItem extends GameClientPacket
{
private static final int GEMSTONE_D = 2130;
private static final int GEMSTONE_C = 2131;
private int _targetItemObjId;
private int _refinerItemObjId;
@Override
protected void readImpl()
{
_targetItemObjId = readD();
_refinerItemObjId = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
final ItemInstance targetItem = (ItemInstance) World.getInstance().findObject(_targetItemObjId);
final ItemInstance refinerItem = (ItemInstance) World.getInstance().findObject(_refinerItemObjId);
if ((targetItem == null) || (refinerItem == null))
{
return;
}
final int itemGrade = targetItem.getItem().getItemGrade();
final int refinerItemId = refinerItem.getItem().getItemId();
// is the item a life stone?
if ((refinerItemId < 8723) || (refinerItemId > 8762))
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
return;
}
int gemstoneCount = 0;
int gemstoneItemId = 0;
@SuppressWarnings("unused")
final int lifeStoneLevel = getLifeStoneLevel(refinerItemId);
final SystemMessage sm = new SystemMessage(SystemMessageId.REQUIRES_S2_S1);
switch (itemGrade)
{
case Item.CRYSTAL_C:
{
gemstoneCount = 20;
gemstoneItemId = GEMSTONE_D;
sm.addNumber(gemstoneCount);
sm.addString("Gemstone D");
break;
}
case Item.CRYSTAL_B:
{
gemstoneCount = 30;
gemstoneItemId = GEMSTONE_D;
sm.addNumber(gemstoneCount);
sm.addString("Gemstone D");
break;
}
case Item.CRYSTAL_A:
{
gemstoneCount = 20;
gemstoneItemId = GEMSTONE_C;
sm.addNumber(gemstoneCount);
sm.addString("Gemstone C");
break;
}
case Item.CRYSTAL_S:
{
gemstoneCount = 25;
gemstoneItemId = GEMSTONE_C;
sm.addNumber(gemstoneCount);
sm.addString("Gemstone C");
break;
}
}
player.sendPacket(new ExConfirmVariationRefiner(_refinerItemObjId, refinerItemId, gemstoneItemId, gemstoneCount));
player.sendPacket(sm);
}
private int getLifeStoneGrade(int itemIdValue)
{
int itemId = itemIdValue - 8723;
if (itemId < 10)
{
return 0; // normal grade
}
if (itemId < 20)
{
return 1; // mid grade
}
if (itemId < 30)
{
return 2; // high grade
}
return 3; // top grade
}
private int getLifeStoneLevel(int itemIdValue)
{
int itemId = itemIdValue - (10 * getLifeStoneGrade(itemIdValue));
itemId -= 8722;
return itemId;
}
}
@@ -1,105 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExConfirmVariationItem;
/**
* Format:(ch) d
* @author -Wooden-
*/
public class RequestConfirmTargetItem extends GameClientPacket
{
private int _itemObjId;
@Override
protected void readImpl()
{
_itemObjId = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
final ItemInstance item = (ItemInstance) World.getInstance().findObject(_itemObjId);
if (item == null)
{
return;
}
if (player.getLevel() < 46)
{
player.sendMessage("You have to be level 46 in order to augment an item");
return;
}
// check if the item is augmentable
final int itemGrade = item.getItem().getItemGrade();
final int itemType = item.getItem().getType2();
if (item.isAugmented())
{
player.sendPacket(SystemMessageId.ONCE_AN_ITEM_IS_AUGMENTED_IT_CANNOT_BE_AUGMENTED_AGAIN);
return;
}
// TODO: can do better? : currently: using isdestroyable() as a check for hero / cursed weapons
else if ((itemGrade < Item.CRYSTAL_C) || (itemType != Item.TYPE2_WEAPON) || !item.isDestroyable() || item.isShadowItem())
{
player.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
return;
}
// check if the player can augment
if (player.getPrivateStoreType() != PlayerInstance.STORE_PRIVATE_NONE)
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP_IS_IN_OPERATION);
return;
}
if (player.isDead())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_DEAD);
return;
}
if (player.isParalyzed())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_PARALYZED);
return;
}
if (player.isFishing())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_FISHING);
return;
}
if (player.isSitting())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_SITTING_DOWN);
return;
}
player.sendPacket(new ExConfirmVariationItem(_itemObjId));
player.sendPacket(SystemMessageId.SELECT_THE_CATALYST_FOR_AUGMENTATION);
}
}
@@ -161,11 +161,6 @@ public class RequestCrystallizeItem extends GameClientPacket
// unequip if needed
if (itemToRemove.isEquipped())
{
if (itemToRemove.isAugmented())
{
itemToRemove.getAugmentation().removeBonus(player);
}
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance element : unequiped)
@@ -1,56 +0,0 @@
/*
* 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;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.ExCursedWeaponList;
/**
* Format: (ch)
* @author -Wooden-
*/
public class RequestCursedWeaponList extends GameClientPacket
{
@Override
protected void readImpl()
{
// nothing to read it's just a trigger
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
if (player == null)
{
return;
}
// send a ExCursedWeaponList :p
final List<Integer> list = new ArrayList<>();
for (int id : CursedWeaponsManager.getInstance().getCursedWeaponsIds())
{
list.add(id);
}
player.sendPacket(new ExCursedWeaponList(list));
}
}
@@ -1,70 +0,0 @@
/*
* 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;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.CursedWeapon;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.ExCursedWeaponLocation;
import org.l2jmobius.gameserver.network.serverpackets.ExCursedWeaponLocation.CursedWeaponInfo;
/**
* Format: (ch)
* @author -Wooden-
*/
public class RequestCursedWeaponLocation extends GameClientPacket
{
@Override
protected void readImpl()
{
// ignore read packet
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
if (player == null)
{
return;
}
final List<CursedWeaponInfo> list = new ArrayList<>();
for (CursedWeapon cw : CursedWeaponsManager.getInstance().getCursedWeapons())
{
if (!cw.isActive())
{
continue;
}
final Location location = cw.getWorldPosition();
if (location != null)
{
list.add(new CursedWeaponInfo(location, cw.getItemId(), cw.isActivated() ? 1 : 0));
}
}
if (!list.isEmpty())
{
player.sendPacket(new ExCursedWeaponLocation(list));
}
}
}
@@ -23,7 +23,6 @@ import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.datatables.sql.PetDataTable;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
@@ -93,7 +92,7 @@ public class RequestDestroyItem extends GameClientPacket
}
final int itemId = itemToRemove.getItemId();
if (itemToRemove.isWear() || !itemToRemove.isDestroyable() || CursedWeaponsManager.getInstance().isCursed(itemId))
if (itemToRemove.isWear() || !itemToRemove.isDestroyable())
{
player.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DISCARDED);
return;
@@ -112,11 +111,6 @@ public class RequestDestroyItem extends GameClientPacket
if (itemToRemove.isEquipped())
{
if (itemToRemove.isAugmented())
{
itemToRemove.getAugmentation().removeBonus(player);
}
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(itemToRemove.getEquipSlot());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance element : unequiped)
@@ -20,7 +20,6 @@ import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.SkillDat;
import org.l2jmobius.gameserver.model.items.Item;
@@ -95,12 +94,6 @@ public class RequestDropItem extends GameClientPacket
return;
}
if (item.isAugmented())
{
player.sendPacket(SystemMessageId.THE_AUGMENTED_ITEM_CANNOT_BE_DISCARDED);
return;
}
if ((item.getItemType() == EtcItemType.QUEST) && !(player.isGM()))
{
return;
@@ -114,12 +107,6 @@ public class RequestDropItem extends GameClientPacket
return;
}
// Cursed Weapons cannot be dropped
if (CursedWeaponsManager.getInstance().isCursed(item.getItemId()))
{
return;
}
if (_count > item.getCount())
{
player.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_DISCARDED);
@@ -200,12 +187,6 @@ public class RequestDropItem extends GameClientPacket
if (item.isEquipped())
{
// Remove augementation boni on unequip
if (item.isAugmented())
{
item.getAugmentation().removeBonus(player);
}
final ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(item.getItem().getBodyPart());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance element : unequiped)
@@ -1,114 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Format:(ch) ddd
*/
public class RequestDuelAnswerStart extends GameClientPacket
{
private int _partyDuel;
@SuppressWarnings("unused")
private int _unk1;
private int _response;
@Override
protected void readImpl()
{
_partyDuel = readD();
_unk1 = readD();
_response = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
if (player == null)
{
return;
}
final PlayerInstance requestor = player.getActiveRequester();
if (requestor == null)
{
return;
}
if (_response == 1)
{
SystemMessage msg1 = null;
SystemMessage msg2 = null;
if (requestor.isInDuel())
{
msg1 = new SystemMessage(SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_ALREADY_ENGAGED_IN_A_DUEL);
msg1.addString(requestor.getName());
player.sendPacket(msg1);
return;
}
else if (player.isInDuel())
{
player.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
return;
}
if (_partyDuel == 1)
{
msg1 = new SystemMessage(SystemMessageId.YOU_HAVE_ACCEPTED_S1_S_CHALLENGE_TO_A_PARTY_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg1.addString(requestor.getName());
msg2 = new SystemMessage(SystemMessageId.S1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_DUEL_AGAINST_THEIR_PARTY_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg2.addString(player.getName());
}
else
{
msg1 = new SystemMessage(SystemMessageId.YOU_HAVE_ACCEPTED_S1_S_CHALLENGE_TO_A_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg1.addString(requestor.getName());
msg2 = new SystemMessage(SystemMessageId.S1_HAS_ACCEPTED_YOUR_CHALLENGE_TO_A_DUEL_THE_DUEL_WILL_BEGIN_IN_A_FEW_MOMENTS);
msg2.addString(player.getName());
}
player.sendPacket(msg1);
requestor.sendPacket(msg2);
DuelManager.getInstance().addDuel(requestor, player, _partyDuel);
}
else
{
SystemMessage msg = null;
if (_partyDuel == 1)
{
msg = new SystemMessage(SystemMessageId.THE_OPPOSING_PARTY_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
}
else
{
msg = new SystemMessage(SystemMessageId.S1_HAS_DECLINED_YOUR_CHALLENGE_TO_A_DUEL);
msg.addString(player.getName());
}
requestor.sendPacket(msg);
}
player.setActiveRequester(null);
requestor.onTransactionResponse();
}
}
@@ -1,170 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExDuelAskStart;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Format:(ch) Sd
*/
public class RequestDuelStart extends GameClientPacket
{
private String _player;
private int _partyDuel;
@Override
protected void readImpl()
{
_player = readS();
_partyDuel = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
final PlayerInstance targetChar = World.getInstance().getPlayer(_player);
if (player == null)
{
return;
}
if (targetChar == null)
{
player.sendPacket(SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
return;
}
if (player == targetChar)
{
player.sendPacket(SystemMessageId.THERE_IS_NO_OPPONENT_TO_RECEIVE_YOUR_CHALLENGE_FOR_A_DUEL);
return;
}
// Check if duel is possible
if (!player.canDuel())
{
player.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
return;
}
else if (!targetChar.canDuel())
{
player.sendPacket(targetChar.getNoDuelReason());
return;
}
// Players may not be too far apart
else if (!player.isInsideRadius(targetChar, 250, false, false))
{
final SystemMessage msg = new SystemMessage(SystemMessageId.S1_CANNOT_RECEIVE_A_DUEL_CHALLENGE_BECAUSE_S1_IS_TOO_FAR_AWAY);
msg.addString(targetChar.getName());
player.sendPacket(msg);
return;
}
// Duel is a party duel
if (_partyDuel == 1)
{
// Player must be in a party & the party leader
if (!player.isInParty() || (!player.isInParty() || !player.getParty().isLeader(player)))
{
player.sendMessage("You have to be the leader of a party in order to request a party duel.");
return;
}
// Target must be in a party
else if (!targetChar.isInParty())
{
player.sendPacket(SystemMessageId.SINCE_THE_PERSON_YOU_CHALLENGED_IS_NOT_CURRENTLY_IN_A_PARTY_THEY_CANNOT_DUEL_AGAINST_YOUR_PARTY);
return;
}
// Target may not be of the same party
else if (player.getParty().getPartyMembers().contains(targetChar))
{
player.sendMessage("This player is a member of your own party.");
return;
}
// Check if every player is ready for a duel
for (PlayerInstance temp : player.getParty().getPartyMembers())
{
if (!temp.canDuel())
{
player.sendMessage("Not all the members of your party are ready for a duel.");
return;
}
}
PlayerInstance partyLeader = null; // snatch party leader of targetChar's party
for (PlayerInstance temp : targetChar.getParty().getPartyMembers())
{
if (partyLeader == null)
{
partyLeader = temp;
}
if (!temp.canDuel())
{
player.sendPacket(SystemMessageId.THE_OPPOSING_PARTY_IS_CURRENTLY_UNABLE_TO_ACCEPT_A_CHALLENGE_TO_A_DUEL);
return;
}
}
if (partyLeader != null)
{
// Send request to targetChar's party leader
if (!partyLeader.isProcessingRequest())
{
player.onTransactionRequest(partyLeader);
partyLeader.sendPacket(new ExDuelAskStart(player.getName(), _partyDuel));
SystemMessage msg = new SystemMessage(SystemMessageId.S1_S_PARTY_HAS_BEEN_CHALLENGED_TO_A_DUEL);
msg.addString(partyLeader.getName());
player.sendPacket(msg);
msg = new SystemMessage(SystemMessageId.S1_S_PARTY_HAS_CHALLENGED_YOUR_PARTY_TO_A_DUEL);
msg.addString(player.getName());
targetChar.sendPacket(msg);
}
else
{
final SystemMessage msg = new SystemMessage(SystemMessageId.S1_IS_BUSY_PLEASE_TRY_AGAIN_LATER);
msg.addString(partyLeader.getName());
player.sendPacket(msg);
}
}
}
else if (!targetChar.isProcessingRequest())
{
player.onTransactionRequest(targetChar);
targetChar.sendPacket(new ExDuelAskStart(player.getName(), _partyDuel));
SystemMessage msg = new SystemMessage(SystemMessageId.S1_HAS_BEEN_CHALLENGED_TO_A_DUEL);
msg.addString(targetChar.getName());
player.sendPacket(msg);
msg = new SystemMessage(SystemMessageId.S1_HAS_CHALLENGED_YOU_TO_A_DUEL);
msg.addString(player.getName());
targetChar.sendPacket(msg);
}
else
{
final SystemMessage msg = new SystemMessage(SystemMessageId.S1_IS_BUSY_PLEASE_TRY_AGAIN_LATER);
msg.addString(targetChar.getName());
player.sendPacket(msg);
}
}
}
@@ -1,38 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.instancemanager.DuelManager;
/**
* Format:(ch) just a trigger
* @author -Wooden-
*/
public class RequestDuelSurrender extends GameClientPacket
{
@Override
protected void readImpl()
{
// trigger
}
@Override
protected void runImpl()
{
DuelManager.getInstance().doSurrender(getClient().getPlayer());
}
}
@@ -660,11 +660,6 @@ public class RequestEnchantItem extends GameClientPacket
if (item.isEquipped())
{
if (item.isAugmented())
{
item.getAugmentation().removeBonus(player);
}
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(item.getEquipSlot());
final InventoryUpdate iu = new InventoryUpdate();
for (ItemInstance element : unequiped)
@@ -1,49 +0,0 @@
/*
* 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;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.instancemanager.FishingChampionshipManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
/**
* Format: (ch) just a trigger
* @author -Wooden-
*/
public class RequestExFishRanking extends GameClientPacket
{
@Override
protected void readImpl()
{
// trigger
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
if (player == null)
{
return;
}
if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
{
FishingChampionshipManager.getInstance().showMidResult(player);
}
}
}
@@ -84,11 +84,6 @@ public class RequestGiveItemToPet extends GameClientPacket
return;
}
if (item.isAugmented())
{
return;
}
if (!item.isDropable() || !item.isDestroyable() || !item.isTradeable())
{
player.sendPacket(SystemMessageId.YOUR_PET_CANNOT_CARRY_THIS_ITEM);
@@ -87,12 +87,6 @@ public class RequestJoinParty extends GameClientPacket
return;
}
if (target.isCursedWeaponEquiped() || requestor.isCursedWeaponEquiped())
{
requestor.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
if (target.isGM() && target.getAppearance().isInvisible())
{
requestor.sendMessage("You can't invite GM in invisible mode.");
@@ -117,11 +111,6 @@ public class RequestJoinParty extends GameClientPacket
return;
}
if (target.isInDuel() || requestor.isInDuel())
{
return;
}
if (!requestor.isInParty()) // Asker has no party
{
createNewParty(target, requestor);
@@ -153,13 +153,6 @@ public class RequestPackageSend extends GameClientPacket
continue;
}
// Fix exploit for trade Augmented weapon with freight
if (item.isAugmented())
{
LOGGER.warning("Error depositing a warehouse object for char " + player.getName() + " (item is augmented)");
return;
}
if (!item.isTradeable() || (item.getItemType() == EtcItemType.QUEST))
{
return;
@@ -21,7 +21,6 @@ import org.l2jmobius.gameserver.model.ManufactureItem;
import org.l2jmobius.gameserver.model.ManufactureList;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.RecipeShopMsg;
@@ -58,13 +57,6 @@ public class RequestRecipeShopListSet extends GameClientPacket
return;
}
if (player.isInDuel())
{
player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (player.isTradeDisabled())
{
player.sendMessage("Private manufacture is disabled here. Try another place.");
@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.gameserver.RecipeController;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.util.Util;
public class RequestRecipeShopMakeItem extends GameClientPacket
@@ -75,12 +74,6 @@ public class RequestRecipeShopMakeItem extends GameClientPacket
return;
}
if (manufacturer.isInDuel() || player.isInDuel())
{
player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ENGAGED_IN_COMBAT_YOU_CANNOT_OPERATE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
return;
}
if (Util.checkIfInRange(150, player, manufacturer, true))
{
RecipeController.getInstance().requestManufactureItem(manufacturer, _recipeId, player);
@@ -1,365 +0,0 @@
/*
* 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;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.datatables.xml.AugmentationData;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExVariationResult;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
import org.l2jmobius.gameserver.util.Util;
/**
* Format:(ch) dddd
* @author -Wooden-
*/
public class RequestRefine extends GameClientPacket
{
private int _targetItemObjId;
private int _refinerItemObjId;
private int _gemstoneItemObjId;
private int _gemstoneCount;
@Override
protected void readImpl()
{
_targetItemObjId = readD();
_refinerItemObjId = readD();
_gemstoneItemObjId = readD();
_gemstoneCount = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
if (player == null)
{
return;
}
final ItemInstance targetItem = (ItemInstance) World.getInstance().findObject(_targetItemObjId);
final ItemInstance refinerItem = (ItemInstance) World.getInstance().findObject(_refinerItemObjId);
final ItemInstance gemstoneItem = (ItemInstance) World.getInstance().findObject(_gemstoneItemObjId);
if ((targetItem == null) || (refinerItem == null) || (gemstoneItem == null) || (targetItem.getOwnerId() != player.getObjectId()) || (refinerItem.getOwnerId() != player.getObjectId()) || (gemstoneItem.getOwnerId() != player.getObjectId()) || (player.getLevel() < 46)) // must
// be
// lvl
// 46
{
player.sendPacket(new ExVariationResult(0, 0, 0));
player.sendPacket(SystemMessageId.AUGMENTATION_FAILED_DUE_TO_INAPPROPRIATE_CONDITIONS);
return;
}
// unequip item
if (targetItem.isEquipped())
{
player.disarmWeapons();
}
if (TryAugmentItem(player, targetItem, refinerItem, gemstoneItem))
{
final int stat12 = 0x0000FFFF & targetItem.getAugmentation().getAugmentationId();
final int stat34 = targetItem.getAugmentation().getAugmentationId() >> 16;
player.sendPacket(new ExVariationResult(stat12, stat34, 1));
player.sendPacket(SystemMessageId.THE_ITEM_WAS_SUCCESSFULLY_AUGMENTED);
}
else
{
player.sendPacket(new ExVariationResult(0, 0, 0));
player.sendPacket(SystemMessageId.AUGMENTATION_FAILED_DUE_TO_INAPPROPRIATE_CONDITIONS);
}
}
boolean TryAugmentItem(PlayerInstance player, ItemInstance targetItem, ItemInstance refinerItem, ItemInstance gemstoneItem)
{
if (targetItem.isAugmented() || targetItem.isWear())
{
player.sendMessage("You can't augment items while you wear it");
return false;
}
if (player.isDead())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_DEAD);
return false;
}
if (player.isSitting())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_SITTING_DOWN);
return false;
}
if (player.isFishing())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_FISHING);
return false;
}
if (player.isParalyzed())
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_PARALYZED);
return false;
}
if (player.getActiveTradeList() != null)
{
player.sendMessage("You cannot augment while trading");
return false;
}
if (player.getPrivateStoreType() != PlayerInstance.STORE_PRIVATE_NONE)
{
player.sendPacket(SystemMessageId.YOU_CANNOT_AUGMENT_ITEMS_WHILE_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP_IS_IN_OPERATION);
return false;
}
// check for the items to be in the inventory of the owner
if (player.getInventory().getItemByObjectId(refinerItem.getObjectId()) == null)
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to refine an item with wrong LifeStone-id.", Config.DEFAULT_PUNISH);
return false;
}
if (player.getInventory().getItemByObjectId(targetItem.getObjectId()) == null)
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to refine an item with wrong Weapon-id.", Config.DEFAULT_PUNISH);
return false;
}
if (player.getInventory().getItemByObjectId(gemstoneItem.getObjectId()) == null)
{
Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to refine an item with wrong Gemstone-id.", Config.DEFAULT_PUNISH);
return false;
}
final int itemGrade = targetItem.getItem().getItemGrade();
final int itemType = targetItem.getItem().getType2();
final int lifeStoneId = refinerItem.getItemId();
final int gemstoneItemId = gemstoneItem.getItemId();
// is the refiner Item a life stone?
if ((lifeStoneId < 8723) || (lifeStoneId > 8762))
{
return false;
}
// must be a weapon, must be > d grade
// TODO: can do better? : currently: using isdestroyable() as a check for hero / cursed weapons
if ((itemGrade < Item.CRYSTAL_C) || (itemType != Item.TYPE2_WEAPON) || !targetItem.isDestroyable())
{
return false;
}
// player must be able to use augmentation
if ((player.getPrivateStoreType() != PlayerInstance.STORE_PRIVATE_NONE) || player.isDead() || player.isParalyzed() || player.isFishing() || player.isSitting())
{
return false;
}
int modifyGemstoneCount = _gemstoneCount;
final int lifeStoneLevel = getLifeStoneLevel(lifeStoneId);
final int lifeStoneGrade = getLifeStoneGrade(lifeStoneId);
switch (itemGrade)
{
case Item.CRYSTAL_C:
{
if ((player.getLevel() < 46) || (gemstoneItemId != 2130))
{
return false;
}
modifyGemstoneCount = 20;
break;
}
case Item.CRYSTAL_B:
{
if ((player.getLevel() < 52) || (gemstoneItemId != 2130))
{
return false;
}
modifyGemstoneCount = 30;
break;
}
case Item.CRYSTAL_A:
{
if ((player.getLevel() < 61) || (gemstoneItemId != 2131))
{
return false;
}
modifyGemstoneCount = 20;
break;
}
case Item.CRYSTAL_S:
{
if ((player.getLevel() < 76) || (gemstoneItemId != 2131))
{
return false;
}
modifyGemstoneCount = 25;
break;
}
}
// check if the lifestone is appropriate for this player
switch (lifeStoneLevel)
{
case 1:
{
if (player.getLevel() < 46)
{
return false;
}
break;
}
case 2:
{
if (player.getLevel() < 49)
{
return false;
}
break;
}
case 3:
{
if (player.getLevel() < 52)
{
return false;
}
break;
}
case 4:
{
if (player.getLevel() < 55)
{
return false;
}
break;
}
case 5:
{
if (player.getLevel() < 58)
{
return false;
}
break;
}
case 6:
{
if (player.getLevel() < 61)
{
return false;
}
break;
}
case 7:
{
if (player.getLevel() < 64)
{
return false;
}
break;
}
case 8:
{
if (player.getLevel() < 67)
{
return false;
}
break;
}
case 9:
{
if (player.getLevel() < 70)
{
return false;
}
break;
}
case 10:
{
if (player.getLevel() < 76)
{
return false;
}
break;
}
}
// Check if player has all gemstorne on inventory
if ((gemstoneItem.getCount() - modifyGemstoneCount) < 0)
{
return false;
}
// consume the life stone
if (!player.destroyItem("RequestRefine", refinerItem, null, false))
{
return false;
}
// consume the gemstones
player.destroyItem("RequestRefine", _gemstoneItemObjId, modifyGemstoneCount, null, false);
// generate augmentation
targetItem.setAugmentation(AugmentationData.getInstance().generateRandomAugmentation(targetItem, lifeStoneLevel, lifeStoneGrade));
// finish and send the inventory update packet
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(targetItem);
player.sendPacket(iu);
final StatusUpdate su = new StatusUpdate(player.getObjectId());
su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
player.sendPacket(su);
return true;
}
private int getLifeStoneGrade(int itemIdValue)
{
int itemId = itemIdValue - 8723;
if (itemId < 10)
{
return 0; // normal grade
}
if (itemId < 20)
{
return 1; // mid grade
}
if (itemId < 30)
{
return 2; // high grade
}
return 3; // top grade
}
private int getLifeStoneLevel(int itemIdValue)
{
int itemId = itemIdValue - (10 * getLifeStoneGrade(itemIdValue));
itemId -= 8722;
return itemId;
}
}
@@ -1,159 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExVariationCancelResult;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* Format(ch) d
* @author -Wooden-
*/
public class RequestRefineCancel extends GameClientPacket
{
private int _targetItemObjId;
@Override
protected void readImpl()
{
_targetItemObjId = readD();
}
@Override
protected void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
final ItemInstance targetItem = (ItemInstance) World.getInstance().findObject(_targetItemObjId);
if (player == null)
{
return;
}
if (targetItem == null)
{
player.sendPacket(new ExVariationCancelResult(0));
return;
}
// cannot remove augmentation from a not augmented item
if (!targetItem.isAugmented())
{
player.sendPacket(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM);
player.sendPacket(new ExVariationCancelResult(0));
return;
}
// get the price
int price = 0;
switch (targetItem.getItem().getItemGrade())
{
case Item.CRYSTAL_C:
{
if (targetItem.getCrystalCount() < 1720)
{
price = 95000;
}
else if (targetItem.getCrystalCount() < 2452)
{
price = 150000;
}
else
{
price = 210000;
}
break;
}
case Item.CRYSTAL_B:
{
if (targetItem.getCrystalCount() < 1746)
{
price = 240000;
}
else
{
price = 270000;
}
break;
}
case Item.CRYSTAL_A:
{
if (targetItem.getCrystalCount() < 2160)
{
price = 330000;
}
else if (targetItem.getCrystalCount() < 2824)
{
price = 390000;
}
else
{
price = 420000;
}
break;
}
case Item.CRYSTAL_S:
{
price = 480000;
break;
}
// any other item type is not augmentable
default:
{
player.sendPacket(new ExVariationCancelResult(0));
return;
}
}
// try to reduce the players adena
if (!player.reduceAdena("RequestRefineCancel", price, null, true))
{
return;
}
// unequip item
final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped())
{
final ItemInstance[] unequiped = player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
for (ItemInstance itm : unequiped)
{
iu.addModifiedItem(itm);
}
}
// remove the augmentation
targetItem.removeAugmentation();
// send ExVariationCancelResult
player.sendPacket(new ExVariationCancelResult(1));
// send inventory update
iu.addModifiedItem(targetItem);
player.sendPacket(iu);
// send system message
final SystemMessage sm = new SystemMessage(SystemMessageId.AUGMENTATION_HAS_BEEN_SUCCESSFULLY_REMOVED_FROM_YOUR_S1);
sm.addString(targetItem.getItemName());
player.sendPacket(sm);
}
}
@@ -24,7 +24,6 @@ import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.entity.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.entity.sevensigns.SevenSignsFestival;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.ConnectionState;
import org.l2jmobius.gameserver.network.GameClient;
@@ -157,11 +156,6 @@ public class RequestRestart extends GameClientPacket
player.removeSkill(SkillTable.getInstance().getInfo(4289, 1));
}
if ((player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != null) && player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).isAugmented())
{
player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getAugmentation().removeBonus(player);
}
// delete box from the world
if (player._activeBoxes != -1)
{
@@ -1,38 +0,0 @@
/*
* 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;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
public class RequestSkillCoolTime extends GameClientPacket
{
@Override
public void readImpl()
{
}
@Override
public void runImpl()
{
final PlayerInstance player = getClient().getPlayer();
if (player != null)
{
player.sendPacket(new SkillCoolTime(player));
}
}
}

Some files were not shown because too many files have changed in this diff Show More