This commit is contained in:
120
trunk/java/com/l2jserver/gameserver/model/items/L2Armor.java
Normal file
120
trunk/java/com/l2jserver/gameserver/model/items/L2Armor.java
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items;
|
||||
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.items.type.ArmorType;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class is dedicated to the management of armors.
|
||||
*/
|
||||
public final class L2Armor extends L2Item
|
||||
{
|
||||
/**
|
||||
* Skill that activates when armor is enchanted +4.
|
||||
*/
|
||||
private SkillHolder _enchant4Skill = null;
|
||||
private ArmorType _type;
|
||||
|
||||
/**
|
||||
* Constructor for Armor.
|
||||
* @param set the StatsSet designating the set of couples (key,value) characterizing the armor.
|
||||
*/
|
||||
public L2Armor(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_type = set.getEnum("armor_type", ArmorType.class, ArmorType.NONE);
|
||||
|
||||
int _bodyPart = getBodyPart();
|
||||
if ((_bodyPart == L2Item.SLOT_NECK) || ((_bodyPart & L2Item.SLOT_L_EAR) != 0) || ((_bodyPart & L2Item.SLOT_L_FINGER) != 0) || ((_bodyPart & L2Item.SLOT_R_BRACELET) != 0) || ((_bodyPart & L2Item.SLOT_L_BRACELET) != 0))
|
||||
{
|
||||
_type1 = L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE;
|
||||
_type2 = L2Item.TYPE2_ACCESSORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_type == ArmorType.NONE) && (getBodyPart() == L2Item.SLOT_L_HAND))
|
||||
{
|
||||
_type = ArmorType.SHIELD;
|
||||
}
|
||||
_type1 = L2Item.TYPE1_SHIELD_ARMOR;
|
||||
_type2 = L2Item.TYPE2_SHIELD_ARMOR;
|
||||
}
|
||||
|
||||
String skill = set.getString("enchant4_skill", null);
|
||||
if (skill != null)
|
||||
{
|
||||
String[] info = skill.split("-");
|
||||
|
||||
if ((info != null) && (info.length == 2))
|
||||
{
|
||||
int id = 0;
|
||||
int level = 0;
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(info[0]);
|
||||
level = Integer.parseInt(info[1]);
|
||||
}
|
||||
catch (Exception nfe)
|
||||
{
|
||||
// Incorrect syntax, don't add new skill
|
||||
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in armor enchant skills! item ", toString()));
|
||||
}
|
||||
if ((id > 0) && (level > 0))
|
||||
{
|
||||
_enchant4Skill = new SkillHolder(id, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of the armor.
|
||||
*/
|
||||
@Override
|
||||
public ArmorType getItemType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the item after applying the mask.
|
||||
*/
|
||||
@Override
|
||||
public final int getItemMask()
|
||||
{
|
||||
return getItemType().mask();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return skill that player get when has equipped armor +4 or more
|
||||
*/
|
||||
@Override
|
||||
public Skill getEnchant4Skill()
|
||||
{
|
||||
if (_enchant4Skill == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _enchant4Skill.getSkill();
|
||||
}
|
||||
}
|
163
trunk/java/com/l2jserver/gameserver/model/items/L2EtcItem.java
Normal file
163
trunk/java/com/l2jserver/gameserver/model/items/L2EtcItem.java
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.model.L2ExtractableProduct;
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class is dedicated to the management of EtcItem.
|
||||
*/
|
||||
public final class L2EtcItem extends L2Item
|
||||
{
|
||||
private String _handler;
|
||||
private EtcItemType _type;
|
||||
private final boolean _isBlessed;
|
||||
private final List<L2ExtractableProduct> _extractableItems;
|
||||
|
||||
/**
|
||||
* Constructor for EtcItem.
|
||||
* @param set StatsSet designating the set of couples (key,value) for description of the Etc
|
||||
*/
|
||||
public L2EtcItem(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_type = set.getEnum("etcitem_type", EtcItemType.class, EtcItemType.NONE);
|
||||
|
||||
// l2j custom - L2EtcItemType.SHOT
|
||||
switch (getDefaultAction())
|
||||
{
|
||||
case SOULSHOT:
|
||||
case SUMMON_SOULSHOT:
|
||||
case SUMMON_SPIRITSHOT:
|
||||
case SPIRITSHOT:
|
||||
{
|
||||
_type = EtcItemType.SHOT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_type1 = L2Item.TYPE1_ITEM_QUESTITEM_ADENA;
|
||||
_type2 = L2Item.TYPE2_OTHER; // default is other
|
||||
|
||||
if (isQuestItem())
|
||||
{
|
||||
_type2 = L2Item.TYPE2_QUEST;
|
||||
}
|
||||
else if ((getId() == Inventory.ADENA_ID) || (getId() == Inventory.ANCIENT_ADENA_ID))
|
||||
{
|
||||
_type2 = L2Item.TYPE2_MONEY;
|
||||
}
|
||||
|
||||
_handler = set.getString("handler", null); // ! null !
|
||||
_isBlessed = set.getBoolean("blessed", false);
|
||||
|
||||
// Extractable
|
||||
String capsuled_items = set.getString("capsuled_items", null);
|
||||
if (capsuled_items != null)
|
||||
{
|
||||
String[] split = capsuled_items.split(";");
|
||||
_extractableItems = new ArrayList<>(split.length);
|
||||
for (String part : split)
|
||||
{
|
||||
if (part.trim().isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String[] data = part.split(",");
|
||||
if (data.length != 4)
|
||||
{
|
||||
_log.info(StringUtil.concat("> Couldnt parse ", part, " in capsuled_items! item ", toString()));
|
||||
continue;
|
||||
}
|
||||
int itemId = Integer.parseInt(data[0]);
|
||||
int min = Integer.parseInt(data[1]);
|
||||
int max = Integer.parseInt(data[2]);
|
||||
double chance = Double.parseDouble(data[3]);
|
||||
if (max < min)
|
||||
{
|
||||
_log.info(StringUtil.concat("> Max amount < Min amount in ", part, ", item ", toString()));
|
||||
continue;
|
||||
}
|
||||
L2ExtractableProduct product = new L2ExtractableProduct(itemId, min, max, chance);
|
||||
_extractableItems.add(product);
|
||||
}
|
||||
((ArrayList<?>) _extractableItems).trimToSize();
|
||||
|
||||
// check for handler
|
||||
if (_handler == null)
|
||||
{
|
||||
_log.warning("Item " + this + " define capsuled_items but missing handler.");
|
||||
_handler = "ExtractableItems";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_extractableItems = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of Etc Item.
|
||||
*/
|
||||
@Override
|
||||
public EtcItemType getItemType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the Etc item after applying the mask.
|
||||
*/
|
||||
@Override
|
||||
public int getItemMask()
|
||||
{
|
||||
return getItemType().mask();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the handler name, null if no handler for item.
|
||||
*/
|
||||
public String getHandlerName()
|
||||
{
|
||||
return _handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item is blessed, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isBlessed()
|
||||
{
|
||||
return _isBlessed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the extractable items list.
|
||||
*/
|
||||
public List<L2ExtractableProduct> getExtractableItems()
|
||||
{
|
||||
return _extractableItems;
|
||||
}
|
||||
}
|
194
trunk/java/com/l2jserver/gameserver/model/items/L2Henna.java
Normal file
194
trunk/java/com/l2jserver/gameserver/model/items/L2Henna.java
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.base.ClassId;
|
||||
|
||||
/**
|
||||
* Class for the Henna object.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class L2Henna
|
||||
{
|
||||
private final int _dyeId;
|
||||
private final String _dyeName;
|
||||
private final int _dyeItemId;
|
||||
private final int _str;
|
||||
private final int _con;
|
||||
private final int _dex;
|
||||
private final int _int;
|
||||
private final int _men;
|
||||
private final int _wit;
|
||||
private final int _wear_fee;
|
||||
private final int _wear_count;
|
||||
private final int _cancel_fee;
|
||||
private final int _cancel_count;
|
||||
private final List<ClassId> _wear_class;
|
||||
|
||||
public L2Henna(StatsSet set)
|
||||
{
|
||||
_dyeId = set.getInt("dyeId");
|
||||
_dyeName = set.getString("dyeName");
|
||||
_dyeItemId = set.getInt("dyeItemId");
|
||||
_str = set.getInt("str");
|
||||
_con = set.getInt("con");
|
||||
_dex = set.getInt("dex");
|
||||
_int = set.getInt("int");
|
||||
_men = set.getInt("men");
|
||||
_wit = set.getInt("wit");
|
||||
_wear_fee = set.getInt("wear_fee");
|
||||
_wear_count = set.getInt("wear_count");
|
||||
_cancel_fee = set.getInt("cancel_fee");
|
||||
_cancel_count = set.getInt("cancel_count");
|
||||
_wear_class = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dye Id.
|
||||
*/
|
||||
public int getDyeId()
|
||||
{
|
||||
return _dyeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dye server-side name.
|
||||
*/
|
||||
public String getDyeName()
|
||||
{
|
||||
return _dyeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item Id, required for this dye.
|
||||
*/
|
||||
public int getDyeItemId()
|
||||
{
|
||||
return _dyeItemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the STR stat.
|
||||
*/
|
||||
public int getStatSTR()
|
||||
{
|
||||
return _str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the CON stat.
|
||||
*/
|
||||
public int getStatCON()
|
||||
{
|
||||
return _con;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the DEX stat.
|
||||
*/
|
||||
public int getStatDEX()
|
||||
{
|
||||
return _dex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the INT stat.
|
||||
*/
|
||||
public int getStatINT()
|
||||
{
|
||||
return _int;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the MEN stat.
|
||||
*/
|
||||
public int getStatMEN()
|
||||
{
|
||||
return _men;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the WIT stat.
|
||||
*/
|
||||
public int getStatWIT()
|
||||
{
|
||||
return _wit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the wear fee, cost for adding this dye to the player.
|
||||
*/
|
||||
public int getWearFee()
|
||||
{
|
||||
return _wear_fee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the wear count, the required count to add this dye to the player.
|
||||
*/
|
||||
public int getWearCount()
|
||||
{
|
||||
return _wear_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cancel fee, cost for removing this dye from the player.
|
||||
*/
|
||||
public int getCancelFee()
|
||||
{
|
||||
return _cancel_fee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cancel count, the retrieved amount of dye items after removing the dye.
|
||||
*/
|
||||
public int getCancelCount()
|
||||
{
|
||||
return _cancel_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list with the allowed classes to wear this dye.
|
||||
*/
|
||||
public List<ClassId> getAllowedWearClass()
|
||||
{
|
||||
return _wear_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param c the class trying to wear this dye.
|
||||
* @return {@code true} if the player is allowed to wear this dye, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isAllowedClass(ClassId c)
|
||||
{
|
||||
return _wear_class.contains(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wearClassIds the list of classes that can wear this dye.
|
||||
*/
|
||||
public void setWearClassIds(List<ClassId> wearClassIds)
|
||||
{
|
||||
_wear_class.addAll(wearClassIds);
|
||||
}
|
||||
}
|
953
trunk/java/com/l2jserver/gameserver/model/items/L2Item.java
Normal file
953
trunk/java/com/l2jserver/gameserver/model/items/L2Item.java
Normal file
@ -0,0 +1,953 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.model.Elementals;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.conditions.Condition;
|
||||
import com.l2jserver.gameserver.model.events.ListenersContainer;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.ActionType;
|
||||
import com.l2jserver.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.model.items.type.ItemType;
|
||||
import com.l2jserver.gameserver.model.items.type.MaterialType;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.model.stats.functions.AbstractFunction;
|
||||
import com.l2jserver.gameserver.model.stats.functions.FuncTemplate;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class contains all informations concerning the item (weapon, armor, etc).<BR>
|
||||
* Mother class of :
|
||||
* <ul>
|
||||
* <li>L2Armor</li>
|
||||
* <li>L2EtcItem</li>
|
||||
* <li>L2Weapon</li>
|
||||
* </ul>
|
||||
*/
|
||||
public abstract class L2Item extends ListenersContainer implements IIdentifiable
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(L2Item.class.getName());
|
||||
|
||||
public static final int TYPE1_WEAPON_RING_EARRING_NECKLACE = 0;
|
||||
public static final int TYPE1_SHIELD_ARMOR = 1;
|
||||
public static final int TYPE1_ITEM_QUESTITEM_ADENA = 4;
|
||||
|
||||
public static final int TYPE2_WEAPON = 0;
|
||||
public static final int TYPE2_SHIELD_ARMOR = 1;
|
||||
public static final int TYPE2_ACCESSORY = 2;
|
||||
public static final int TYPE2_QUEST = 3;
|
||||
public static final int TYPE2_MONEY = 4;
|
||||
public static final int TYPE2_OTHER = 5;
|
||||
|
||||
public static final int SLOT_NONE = 0x0000;
|
||||
public static final int SLOT_UNDERWEAR = 0x0001;
|
||||
public static final int SLOT_R_EAR = 0x0002;
|
||||
public static final int SLOT_L_EAR = 0x0004;
|
||||
public static final int SLOT_LR_EAR = 0x00006;
|
||||
public static final int SLOT_NECK = 0x0008;
|
||||
public static final int SLOT_R_FINGER = 0x0010;
|
||||
public static final int SLOT_L_FINGER = 0x0020;
|
||||
public static final int SLOT_LR_FINGER = 0x0030;
|
||||
public static final int SLOT_HEAD = 0x0040;
|
||||
public static final int SLOT_R_HAND = 0x0080;
|
||||
public static final int SLOT_L_HAND = 0x0100;
|
||||
public static final int SLOT_GLOVES = 0x0200;
|
||||
public static final int SLOT_CHEST = 0x0400;
|
||||
public static final int SLOT_LEGS = 0x0800;
|
||||
public static final int SLOT_FEET = 0x1000;
|
||||
public static final int SLOT_BACK = 0x2000;
|
||||
public static final int SLOT_LR_HAND = 0x4000;
|
||||
public static final int SLOT_FULL_ARMOR = 0x8000;
|
||||
public static final int SLOT_HAIR = 0x010000;
|
||||
public static final int SLOT_ALLDRESS = 0x020000;
|
||||
public static final int SLOT_HAIR2 = 0x040000;
|
||||
public static final int SLOT_HAIRALL = 0x080000;
|
||||
public static final int SLOT_R_BRACELET = 0x100000;
|
||||
public static final int SLOT_L_BRACELET = 0x200000;
|
||||
public static final int SLOT_DECO = 0x400000;
|
||||
public static final int SLOT_BELT = 0x10000000;
|
||||
public static final int SLOT_WOLF = -100;
|
||||
public static final int SLOT_HATCHLING = -101;
|
||||
public static final int SLOT_STRIDER = -102;
|
||||
public static final int SLOT_BABYPET = -103;
|
||||
public static final int SLOT_GREATWOLF = -104;
|
||||
|
||||
public static final int SLOT_MULTI_ALLWEAPON = SLOT_LR_HAND | SLOT_R_HAND;
|
||||
|
||||
private final int _itemId;
|
||||
private final int _displayId;
|
||||
private final String _name;
|
||||
private final String _icon;
|
||||
private final int _weight;
|
||||
private final boolean _stackable;
|
||||
private final MaterialType _materialType;
|
||||
private final CrystalType _crystalType;
|
||||
private final int _equipReuseDelay;
|
||||
private final int _duration;
|
||||
private final int _time;
|
||||
private final int _autoDestroyTime;
|
||||
private final int _bodyPart;
|
||||
private final int _referencePrice;
|
||||
private final int _crystalCount;
|
||||
private final boolean _sellable;
|
||||
private final boolean _dropable;
|
||||
private final boolean _destroyable;
|
||||
private final boolean _tradeable;
|
||||
private final boolean _depositable;
|
||||
private final int _enchantable;
|
||||
private final boolean _elementable;
|
||||
private final boolean _questItem;
|
||||
private final boolean _freightable;
|
||||
private final boolean _allow_self_resurrection;
|
||||
private final boolean _is_oly_restricted;
|
||||
private final boolean _for_npc;
|
||||
private final boolean _common;
|
||||
private final boolean _heroItem;
|
||||
private final boolean _pvpItem;
|
||||
private final boolean _immediate_effect;
|
||||
private final boolean _ex_immediate_effect;
|
||||
private final int _defaultEnchantLevel;
|
||||
private final ActionType _defaultAction;
|
||||
|
||||
protected int _type1; // needed for item list (inventory)
|
||||
protected int _type2; // different lists for armor, weapon, etc
|
||||
protected Elementals[] _elementals = null;
|
||||
protected List<FuncTemplate> _funcTemplates;
|
||||
protected List<Condition> _preConditions;
|
||||
private SkillHolder[] _skillHolder;
|
||||
private SkillHolder _unequipSkill = null;
|
||||
|
||||
private final int _useSkillDisTime;
|
||||
private final int _reuseDelay;
|
||||
private final int _sharedReuseGroup;
|
||||
|
||||
/**
|
||||
* Constructor of the L2Item that fill class variables.<BR>
|
||||
* <BR>
|
||||
* @param set : StatsSet corresponding to a set of couples (key,value) for description of the item
|
||||
*/
|
||||
protected L2Item(StatsSet set)
|
||||
{
|
||||
_itemId = set.getInt("item_id");
|
||||
_displayId = set.getInt("displayId", _itemId);
|
||||
_name = set.getString("name");
|
||||
_icon = set.getString("icon", null);
|
||||
_weight = set.getInt("weight", 0);
|
||||
_materialType = set.getEnum("material", MaterialType.class, MaterialType.STEEL);
|
||||
_equipReuseDelay = set.getInt("equip_reuse_delay", 0) * 1000;
|
||||
_duration = set.getInt("duration", -1);
|
||||
_time = set.getInt("time", -1);
|
||||
_autoDestroyTime = set.getInt("auto_destroy_time", -1) * 1000;
|
||||
_bodyPart = ItemTable._slots.get(set.getString("bodypart", "none"));
|
||||
_referencePrice = set.getInt("price", 0);
|
||||
_crystalType = set.getEnum("crystal_type", CrystalType.class, CrystalType.NONE);
|
||||
_crystalCount = set.getInt("crystal_count", 0);
|
||||
|
||||
_stackable = set.getBoolean("is_stackable", false);
|
||||
_sellable = set.getBoolean("is_sellable", true);
|
||||
_dropable = set.getBoolean("is_dropable", true);
|
||||
_destroyable = set.getBoolean("is_destroyable", true);
|
||||
_tradeable = set.getBoolean("is_tradable", true);
|
||||
_depositable = set.getBoolean("is_depositable", true);
|
||||
_elementable = set.getBoolean("element_enabled", false);
|
||||
_enchantable = set.getInt("enchant_enabled", 0);
|
||||
_questItem = set.getBoolean("is_questitem", false);
|
||||
_freightable = set.getBoolean("is_freightable", false);
|
||||
_allow_self_resurrection = set.getBoolean("allow_self_resurrection", false);
|
||||
_is_oly_restricted = set.getBoolean("is_oly_restricted", false);
|
||||
_for_npc = set.getBoolean("for_npc", false);
|
||||
|
||||
_immediate_effect = set.getBoolean("immediate_effect", false);
|
||||
_ex_immediate_effect = set.getBoolean("ex_immediate_effect", false);
|
||||
|
||||
_defaultAction = set.getEnum("default_action", ActionType.class, ActionType.NONE);
|
||||
_useSkillDisTime = set.getInt("useSkillDisTime", 0);
|
||||
_defaultEnchantLevel = set.getInt("enchanted", 0);
|
||||
_reuseDelay = set.getInt("reuse_delay", 0);
|
||||
_sharedReuseGroup = set.getInt("shared_reuse_group", 0);
|
||||
|
||||
String skills = set.getString("item_skill", null);
|
||||
if (skills != null)
|
||||
{
|
||||
String[] skillsSplit = skills.split(";");
|
||||
_skillHolder = new SkillHolder[skillsSplit.length];
|
||||
int used = 0;
|
||||
|
||||
for (String element : skillsSplit)
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] skillSplit = element.split("-");
|
||||
int id = Integer.parseInt(skillSplit[0]);
|
||||
int level = Integer.parseInt(skillSplit[1]);
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
_log.info(StringUtil.concat("Ignoring item_skill(", element, ") for item ", toString(), ". Skill id is 0!"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (level == 0)
|
||||
{
|
||||
_log.info(StringUtil.concat("Ignoring item_skill(", element, ") for item ", toString(), ". Skill level is 0!"));
|
||||
continue;
|
||||
}
|
||||
|
||||
_skillHolder[used] = new SkillHolder(id, level);
|
||||
++used;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning(StringUtil.concat("Failed to parse item_skill(", element, ") for item ", toString(), "! Format: SkillId0-SkillLevel0[;SkillIdN-SkillLevelN]"));
|
||||
}
|
||||
}
|
||||
|
||||
// this is only loading? just don't leave a null or use a collection?
|
||||
if (used != _skillHolder.length)
|
||||
{
|
||||
SkillHolder[] skillHolder = new SkillHolder[used];
|
||||
System.arraycopy(_skillHolder, 0, skillHolder, 0, used);
|
||||
_skillHolder = skillHolder;
|
||||
}
|
||||
}
|
||||
|
||||
skills = set.getString("unequip_skill", null);
|
||||
if (skills != null)
|
||||
{
|
||||
String[] info = skills.split("-");
|
||||
if ((info != null) && (info.length == 2))
|
||||
{
|
||||
int id = 0;
|
||||
int level = 0;
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(info[0]);
|
||||
level = Integer.parseInt(info[1]);
|
||||
}
|
||||
catch (Exception nfe)
|
||||
{
|
||||
// Incorrect syntax, don't add new skill
|
||||
_log.info(StringUtil.concat("Couldnt parse ", skills, " in weapon unequip skills! item ", toString()));
|
||||
}
|
||||
if ((id > 0) && (level > 0))
|
||||
{
|
||||
_unequipSkill = new SkillHolder(id, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_common = ((_itemId >= 11605) && (_itemId <= 12361));
|
||||
_heroItem = ((_itemId >= 6611) && (_itemId <= 6621)) || ((_itemId >= 9388) && (_itemId <= 9390)) || (_itemId == 6842);
|
||||
_pvpItem = ((_itemId >= 10667) && (_itemId <= 10835)) || ((_itemId >= 12852) && (_itemId <= 12977)) || ((_itemId >= 14363) && (_itemId <= 14525)) || (_itemId == 14528) || (_itemId == 14529) || (_itemId == 14558) || ((_itemId >= 15913) && (_itemId <= 16024)) || ((_itemId >= 16134) && (_itemId <= 16147)) || (_itemId == 16149) || (_itemId == 16151) || (_itemId == 16153) || (_itemId == 16155) || (_itemId == 16157) || (_itemId == 16159) || ((_itemId >= 16168) && (_itemId <= 16176)) || ((_itemId >= 16179) && (_itemId <= 16220));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the itemType.
|
||||
* @return Enum
|
||||
*/
|
||||
public abstract ItemType getItemType();
|
||||
|
||||
/**
|
||||
* Verifies if the item is a magic weapon.
|
||||
* @return {@code true} if the weapon is magic, {@code false} otherwise
|
||||
*/
|
||||
public boolean isMagicWeapon()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _equipReuseDelay
|
||||
*/
|
||||
public int getEquipReuseDelay()
|
||||
{
|
||||
return _equipReuseDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the duration of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int getDuration()
|
||||
{
|
||||
return _duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int getTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the auto destroy time of the item in seconds: 0 or less - default
|
||||
*/
|
||||
public final int getAutoDestroyTime()
|
||||
{
|
||||
return _autoDestroyTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the item
|
||||
* @return int
|
||||
*/
|
||||
@Override
|
||||
public final int getId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int getDisplayId()
|
||||
{
|
||||
return _displayId;
|
||||
}
|
||||
|
||||
public abstract int getItemMask();
|
||||
|
||||
/**
|
||||
* Return the type of material of the item
|
||||
* @return MaterialType
|
||||
*/
|
||||
public final MaterialType getMaterialType()
|
||||
{
|
||||
return _materialType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type 2 of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int getType2()
|
||||
{
|
||||
return _type2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the weight of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int getWeight()
|
||||
{
|
||||
return _weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item is crystallizable
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isCrystallizable()
|
||||
{
|
||||
return (_crystalType != CrystalType.NONE) && (_crystalCount > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of crystal if item is crystallizable
|
||||
* @return CrystalType
|
||||
*/
|
||||
public final CrystalType getCrystalType()
|
||||
{
|
||||
return _crystalType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ID of crystal if item is crystallizable
|
||||
* @return int
|
||||
*/
|
||||
public final int getCrystalItemId()
|
||||
{
|
||||
return _crystalType.getCrystalId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grade of the item.<BR>
|
||||
* <BR>
|
||||
* <U><I>Concept :</I></U><BR>
|
||||
* In fact, this function returns the type of crystal of the item.
|
||||
* @return CrystalType
|
||||
*/
|
||||
public final CrystalType getItemGrade()
|
||||
{
|
||||
return getCrystalType();
|
||||
}
|
||||
|
||||
/**
|
||||
* For grades S80 and S84 return S
|
||||
* @return the grade of the item.
|
||||
*/
|
||||
public final CrystalType getItemGradeSPlus()
|
||||
{
|
||||
switch (getItemGrade())
|
||||
{
|
||||
case S80:
|
||||
case S84:
|
||||
return CrystalType.S;
|
||||
default:
|
||||
return getItemGrade();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of crystals for crystallization.
|
||||
*/
|
||||
public final int getCrystalCount()
|
||||
{
|
||||
return _crystalCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enchantLevel
|
||||
* @return the quantity of crystals for crystallization on specific enchant level
|
||||
*/
|
||||
public final int getCrystalCount(int enchantLevel)
|
||||
{
|
||||
if (enchantLevel > 3)
|
||||
{
|
||||
switch (_type2)
|
||||
{
|
||||
case TYPE2_SHIELD_ARMOR:
|
||||
case TYPE2_ACCESSORY:
|
||||
return _crystalCount + (getCrystalType().getCrystalEnchantBonusArmor() * ((3 * enchantLevel) - 6));
|
||||
case TYPE2_WEAPON:
|
||||
return _crystalCount + (getCrystalType().getCrystalEnchantBonusWeapon() * ((2 * enchantLevel) - 3));
|
||||
default:
|
||||
return _crystalCount;
|
||||
}
|
||||
}
|
||||
else if (enchantLevel > 0)
|
||||
{
|
||||
switch (_type2)
|
||||
{
|
||||
case TYPE2_SHIELD_ARMOR:
|
||||
case TYPE2_ACCESSORY:
|
||||
return _crystalCount + (getCrystalType().getCrystalEnchantBonusArmor() * enchantLevel);
|
||||
case TYPE2_WEAPON:
|
||||
return _crystalCount + (getCrystalType().getCrystalEnchantBonusWeapon() * enchantLevel);
|
||||
default:
|
||||
return _crystalCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _crystalCount;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the item.
|
||||
*/
|
||||
public final String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the base elemental of the item.
|
||||
*/
|
||||
public final Elementals[] getElementals()
|
||||
{
|
||||
return _elementals;
|
||||
}
|
||||
|
||||
public Elementals getElemental(byte attribute)
|
||||
{
|
||||
for (Elementals elm : _elementals)
|
||||
{
|
||||
if (elm.getElement() == attribute)
|
||||
{
|
||||
return elm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base elemental of the item.
|
||||
* @param element the element to set.
|
||||
*/
|
||||
public void setElementals(Elementals element)
|
||||
{
|
||||
if (_elementals == null)
|
||||
{
|
||||
_elementals = new Elementals[1];
|
||||
_elementals[0] = element;
|
||||
}
|
||||
else
|
||||
{
|
||||
Elementals elm = getElemental(element.getElement());
|
||||
if (elm != null)
|
||||
{
|
||||
elm.setValue(element.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
elm = element;
|
||||
Elementals[] array = new Elementals[_elementals.length + 1];
|
||||
System.arraycopy(_elementals, 0, array, 0, _elementals.length);
|
||||
array[_elementals.length] = elm;
|
||||
_elementals = array;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the part of the body used with the item.
|
||||
*/
|
||||
public final int getBodyPart()
|
||||
{
|
||||
return _bodyPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type 1 of the item.
|
||||
*/
|
||||
public final int getType1()
|
||||
{
|
||||
return _type1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item is stackable, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isStackable()
|
||||
{
|
||||
return _stackable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item can be equipped, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isEquipable()
|
||||
{
|
||||
return (getBodyPart() != 0) && !(getItemType() instanceof EtcItemType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the price of reference of the item.
|
||||
*/
|
||||
public final int getReferencePrice()
|
||||
{
|
||||
return _referencePrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item can be sold, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isSellable()
|
||||
{
|
||||
return _sellable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item can be dropped, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isDropable()
|
||||
{
|
||||
return _dropable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item can be destroyed, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isDestroyable()
|
||||
{
|
||||
return _destroyable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item can be traded, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isTradeable()
|
||||
{
|
||||
return _tradeable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item can be put into warehouse, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isDepositable()
|
||||
{
|
||||
return _depositable;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method also check the enchant blacklist.
|
||||
* @return {@code true} if the item can be enchanted, {@code false} otherwise.
|
||||
*/
|
||||
public final int isEnchantable()
|
||||
{
|
||||
return Arrays.binarySearch(Config.ENCHANT_BLACKLIST, getId()) < 0 ? _enchantable : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item can be elemented, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isElementable()
|
||||
{
|
||||
return _elementable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if item is common
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isCommon()
|
||||
{
|
||||
return _common;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if item is hero-only
|
||||
* @return
|
||||
*/
|
||||
public final boolean isHeroItem()
|
||||
{
|
||||
return _heroItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if item is pvp
|
||||
* @return
|
||||
*/
|
||||
public final boolean isPvpItem()
|
||||
{
|
||||
return _pvpItem;
|
||||
}
|
||||
|
||||
public boolean isPotion()
|
||||
{
|
||||
return (getItemType() == EtcItemType.POTION);
|
||||
}
|
||||
|
||||
public boolean isElixir()
|
||||
{
|
||||
return (getItemType() == EtcItemType.ELIXIR);
|
||||
}
|
||||
|
||||
public boolean isScroll()
|
||||
{
|
||||
return (getItemType() == EtcItemType.SCROLL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the functions used by this item.
|
||||
* @param item : L2ItemInstance pointing out the item
|
||||
* @param player : L2Character pointing out the player
|
||||
* @return the list of functions
|
||||
*/
|
||||
public final List<AbstractFunction> getStatFuncs(L2ItemInstance item, L2Character player)
|
||||
{
|
||||
if ((_funcTemplates == null) || _funcTemplates.isEmpty())
|
||||
{
|
||||
return Collections.<AbstractFunction> emptyList();
|
||||
}
|
||||
|
||||
final List<AbstractFunction> funcs = new ArrayList<>(_funcTemplates.size());
|
||||
for (FuncTemplate t : _funcTemplates)
|
||||
{
|
||||
AbstractFunction f = t.getFunc(player, player, item, item);
|
||||
if (f != null)
|
||||
{
|
||||
funcs.add(f);
|
||||
}
|
||||
}
|
||||
return funcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the FuncTemplate f to the list of functions used with the item
|
||||
* @param f : FuncTemplate to add
|
||||
*/
|
||||
public void attach(FuncTemplate f)
|
||||
{
|
||||
switch (f.getStat())
|
||||
{
|
||||
case FIRE_RES:
|
||||
case FIRE_POWER:
|
||||
setElementals(new Elementals(Elementals.FIRE, (int) f.getValue()));
|
||||
break;
|
||||
case WATER_RES:
|
||||
case WATER_POWER:
|
||||
setElementals(new Elementals(Elementals.WATER, (int) f.getValue()));
|
||||
break;
|
||||
case WIND_RES:
|
||||
case WIND_POWER:
|
||||
setElementals(new Elementals(Elementals.WIND, (int) f.getValue()));
|
||||
break;
|
||||
case EARTH_RES:
|
||||
case EARTH_POWER:
|
||||
setElementals(new Elementals(Elementals.EARTH, (int) f.getValue()));
|
||||
break;
|
||||
case HOLY_RES:
|
||||
case HOLY_POWER:
|
||||
setElementals(new Elementals(Elementals.HOLY, (int) f.getValue()));
|
||||
break;
|
||||
case DARK_RES:
|
||||
case DARK_POWER:
|
||||
setElementals(new Elementals(Elementals.DARK, (int) f.getValue()));
|
||||
break;
|
||||
}
|
||||
|
||||
if (_funcTemplates == null)
|
||||
{
|
||||
_funcTemplates = new ArrayList<>(1);
|
||||
}
|
||||
_funcTemplates.add(f);
|
||||
}
|
||||
|
||||
public final void attach(Condition c)
|
||||
{
|
||||
if (_preConditions == null)
|
||||
{
|
||||
_preConditions = new ArrayList<>(1);
|
||||
}
|
||||
if (!_preConditions.contains(c))
|
||||
{
|
||||
_preConditions.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasSkills()
|
||||
{
|
||||
return _skillHolder != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to retrieve skills linked to this item armor and weapon: passive skills etcitem: skills used on item use <-- ???
|
||||
* @return Skills linked to this item as SkillHolder[]
|
||||
*/
|
||||
public final SkillHolder[] getSkills()
|
||||
{
|
||||
return _skillHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return skill that activates, when player unequip this weapon or armor
|
||||
*/
|
||||
public final Skill getUnequipSkill()
|
||||
{
|
||||
return _unequipSkill == null ? null : _unequipSkill.getSkill();
|
||||
}
|
||||
|
||||
public boolean checkCondition(L2Character activeChar, L2Object object, boolean sendMessage)
|
||||
{
|
||||
if (activeChar.canOverrideCond(PcCondOverride.ITEM_CONDITIONS) && !Config.GM_ITEM_RESTRICTION)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't allow hero equipment and restricted items during Olympiad
|
||||
if ((isOlyRestrictedItem() || isHeroItem()) && ((activeChar instanceof L2PcInstance) && activeChar.getActingPlayer().isInOlympiadMode()))
|
||||
{
|
||||
if (isEquipable())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_EQUIP_THAT_ITEM_IN_A_OLYMPIAD_MATCH);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THAT_ITEM_IN_A_OLYMPIAD_MATCH);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isConditionAttached())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
final L2Character target = (object instanceof L2Character) ? (L2Character) object : null;
|
||||
for (Condition preCondition : _preConditions)
|
||||
{
|
||||
if (preCondition == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!preCondition.test(activeChar, target, null, null))
|
||||
{
|
||||
if (activeChar instanceof L2Summon)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THIS_PET_CANNOT_USE_THIS_ITEM);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sendMessage)
|
||||
{
|
||||
String msg = preCondition.getMessage();
|
||||
int msgId = preCondition.getMessageId();
|
||||
if (msg != null)
|
||||
{
|
||||
activeChar.sendMessage(msg);
|
||||
}
|
||||
else if (msgId != 0)
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(msgId);
|
||||
if (preCondition.isAddName())
|
||||
{
|
||||
sm.addItemName(_itemId);
|
||||
}
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isConditionAttached()
|
||||
{
|
||||
return (_preConditions != null) && !_preConditions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean isQuestItem()
|
||||
{
|
||||
return _questItem;
|
||||
}
|
||||
|
||||
public boolean isFreightable()
|
||||
{
|
||||
return _freightable;
|
||||
}
|
||||
|
||||
public boolean isAllowSelfResurrection()
|
||||
{
|
||||
return _allow_self_resurrection;
|
||||
}
|
||||
|
||||
public boolean isOlyRestrictedItem()
|
||||
{
|
||||
return _is_oly_restricted || Config.LIST_OLY_RESTRICTED_ITEMS.contains(_itemId);
|
||||
}
|
||||
|
||||
public boolean isForNpc()
|
||||
{
|
||||
return _for_npc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the item followed by the item ID.
|
||||
* @return the name and the ID of the item
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _name + "(" + _itemId + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the item has effects immediately.<br>
|
||||
* <i>Used for herbs mostly.</i>
|
||||
* @return {@code true} if the item applies effects immediately, {@code false} otherwise
|
||||
*/
|
||||
public boolean hasExImmediateEffect()
|
||||
{
|
||||
return _ex_immediate_effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the item has effects immediately.
|
||||
* @return {@code true} if the item applies effects immediately, {@code false} otherwise
|
||||
*/
|
||||
public boolean hasImmediateEffect()
|
||||
{
|
||||
return _immediate_effect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _default_action
|
||||
*/
|
||||
public ActionType getDefaultAction()
|
||||
{
|
||||
return _defaultAction;
|
||||
}
|
||||
|
||||
public int useSkillDisTime()
|
||||
{
|
||||
return _useSkillDisTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item reuse delay time in seconds.
|
||||
* @return the reuse delay time
|
||||
*/
|
||||
public int getReuseDelay()
|
||||
{
|
||||
return _reuseDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shared reuse group.<br>
|
||||
* Items with the same reuse group will render reuse delay upon those items when used.
|
||||
* @return the shared reuse group
|
||||
*/
|
||||
public int getSharedReuseGroup()
|
||||
{
|
||||
return _sharedReuseGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Usable in HTML windows.
|
||||
* @return the icon link in client files
|
||||
*/
|
||||
public String getIcon()
|
||||
{
|
||||
return _icon;
|
||||
}
|
||||
|
||||
public int getDefaultEnchantLevel()
|
||||
{
|
||||
return _defaultEnchantLevel;
|
||||
}
|
||||
|
||||
public boolean isPetItem()
|
||||
{
|
||||
return getItemType() == EtcItemType.PET_COLLAR;
|
||||
}
|
||||
|
||||
public Skill getEnchant4Skill()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items;
|
||||
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jserver.gameserver.model.items.type.ItemType;
|
||||
|
||||
/**
|
||||
* This class contains L2ItemInstance<BR>
|
||||
* Use to sort L2ItemInstance of :
|
||||
* <ul>
|
||||
* <li>L2Armor</li>
|
||||
* <li>L2EtcItem</li>
|
||||
* <li>L2Weapon</li>
|
||||
* </ul>
|
||||
* @version $Revision: 1.7.2.2.2.5 $ $Date: 2005/04/06 18:25:18 $
|
||||
*/
|
||||
public class L2WarehouseItem
|
||||
{
|
||||
private final L2Item _item;
|
||||
private final int _object;
|
||||
private final long _count;
|
||||
private final int _owner;
|
||||
private final int _locationSlot;
|
||||
private final int _enchant;
|
||||
private final CrystalType _grade;
|
||||
private boolean _isAugmented;
|
||||
private int _augmentationId;
|
||||
private final int _customType1;
|
||||
private final int _customType2;
|
||||
private final int _mana;
|
||||
|
||||
private int _elemAtkType = -2;
|
||||
private int _elemAtkPower = 0;
|
||||
|
||||
private final int[] _elemDefAttr =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
private final int[] _enchantOptions;
|
||||
|
||||
private final int _time;
|
||||
|
||||
public L2WarehouseItem(L2ItemInstance item)
|
||||
{
|
||||
_item = item.getItem();
|
||||
_object = item.getObjectId();
|
||||
_count = item.getCount();
|
||||
_owner = item.getOwnerId();
|
||||
_locationSlot = item.getLocationSlot();
|
||||
_enchant = item.getEnchantLevel();
|
||||
_customType1 = item.getCustomType1();
|
||||
_customType2 = item.getCustomType2();
|
||||
_grade = item.getItem().getItemGrade();
|
||||
if (item.isAugmented())
|
||||
{
|
||||
_isAugmented = true;
|
||||
_augmentationId = item.getAugmentation().getAugmentationId();
|
||||
}
|
||||
else
|
||||
{
|
||||
_isAugmented = false;
|
||||
}
|
||||
_mana = item.getMana();
|
||||
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -1;
|
||||
|
||||
_elemAtkType = item.getAttackElementType();
|
||||
_elemAtkPower = item.getAttackElementPower();
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
_elemDefAttr[i] = item.getElementDefAttr(i);
|
||||
}
|
||||
_enchantOptions = item.getEnchantOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item.
|
||||
*/
|
||||
public L2Item getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unique objectId.
|
||||
*/
|
||||
public final int getObjectId()
|
||||
{
|
||||
return _object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owner.
|
||||
*/
|
||||
public final int getOwnerId()
|
||||
{
|
||||
return _owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location slot.
|
||||
*/
|
||||
public final int getLocationSlot()
|
||||
{
|
||||
return _locationSlot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the count.
|
||||
*/
|
||||
public final long getCount()
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the first type.
|
||||
*/
|
||||
public final int getType1()
|
||||
{
|
||||
return _item.getType1();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the second type.
|
||||
*/
|
||||
public final int getType2()
|
||||
{
|
||||
return _item.getType2();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the second type.
|
||||
*/
|
||||
public final ItemType getItemType()
|
||||
{
|
||||
return _item.getItemType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ItemId.
|
||||
*/
|
||||
public final int getItemId()
|
||||
{
|
||||
return _item.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the part of body used with this item.
|
||||
*/
|
||||
public final int getBodyPart()
|
||||
{
|
||||
return _item.getBodyPart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the enchant level.
|
||||
*/
|
||||
public final int getEnchantLevel()
|
||||
{
|
||||
return _enchant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item grade
|
||||
*/
|
||||
public final CrystalType getItemGrade()
|
||||
{
|
||||
return _grade;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item is a weapon, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isWeapon()
|
||||
{
|
||||
return (_item instanceof L2Weapon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item is an armor, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isArmor()
|
||||
{
|
||||
return (_item instanceof L2Armor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item is an etc item, {@code false} otherwise.
|
||||
*/
|
||||
public final boolean isEtcItem()
|
||||
{
|
||||
return (_item instanceof L2EtcItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the item
|
||||
*/
|
||||
public String getItemName()
|
||||
{
|
||||
return _item.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the item is augmented, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isAugmented()
|
||||
{
|
||||
return _isAugmented;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the augmentation If.
|
||||
*/
|
||||
public int getAugmentationId()
|
||||
{
|
||||
return _augmentationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the item
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _item.getName();
|
||||
}
|
||||
|
||||
public final int getCustomType1()
|
||||
{
|
||||
return _customType1;
|
||||
}
|
||||
|
||||
public final int getCustomType2()
|
||||
{
|
||||
return _customType2;
|
||||
}
|
||||
|
||||
public final int getMana()
|
||||
{
|
||||
return _mana;
|
||||
}
|
||||
|
||||
public int getAttackElementType()
|
||||
{
|
||||
return _elemAtkType;
|
||||
}
|
||||
|
||||
public int getAttackElementPower()
|
||||
{
|
||||
return _elemAtkPower;
|
||||
}
|
||||
|
||||
public int getElementDefAttr(byte i)
|
||||
{
|
||||
return _elemDefAttr[i];
|
||||
}
|
||||
|
||||
public int[] getEnchantOptions()
|
||||
{
|
||||
return _enchantOptions;
|
||||
}
|
||||
|
||||
public int getTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the item
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _item.toString();
|
||||
}
|
||||
}
|
452
trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java
Normal file
452
trunk/java/com/l2jserver/gameserver/model/items/L2Weapon.java
Normal file
@ -0,0 +1,452 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.conditions.Condition;
|
||||
import com.l2jserver.gameserver.model.conditions.ConditionGameChance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcSkillSee;
|
||||
import com.l2jserver.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jserver.gameserver.model.items.type.WeaponType;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.model.stats.Formulas;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class is dedicated to the management of weapons.
|
||||
*/
|
||||
public final class L2Weapon extends L2Item
|
||||
{
|
||||
private final WeaponType _type;
|
||||
private final boolean _isMagicWeapon;
|
||||
private final int _rndDam;
|
||||
private final int _soulShotCount;
|
||||
private final int _spiritShotCount;
|
||||
private final int _mpConsume;
|
||||
private final int _baseAttackRange;
|
||||
private final int _baseAttackAngle;
|
||||
/**
|
||||
* Skill that activates when item is enchanted +4 (for duals).
|
||||
*/
|
||||
private SkillHolder _enchant4Skill = null;
|
||||
private final int _changeWeaponId;
|
||||
|
||||
// Attached skills for Special Abilities
|
||||
private SkillHolder _skillsOnMagic;
|
||||
private Condition _skillsOnMagicCondition = null;
|
||||
private SkillHolder _skillsOnCrit;
|
||||
private Condition _skillsOnCritCondition = null;
|
||||
|
||||
private final int _reducedSoulshot;
|
||||
private final int _reducedSoulshotChance;
|
||||
|
||||
private final int _reducedMpConsume;
|
||||
private final int _reducedMpConsumeChance;
|
||||
|
||||
private final boolean _isForceEquip;
|
||||
private final boolean _isAttackWeapon;
|
||||
private final boolean _useWeaponSkillsOnly;
|
||||
|
||||
/**
|
||||
* Constructor for Weapon.
|
||||
* @param set the StatsSet designating the set of couples (key,value) characterizing the weapon.
|
||||
*/
|
||||
public L2Weapon(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_type = WeaponType.valueOf(set.getString("weapon_type", "none").toUpperCase());
|
||||
_type1 = L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE;
|
||||
_type2 = L2Item.TYPE2_WEAPON;
|
||||
_isMagicWeapon = set.getBoolean("is_magic_weapon", false);
|
||||
_soulShotCount = set.getInt("soulshots", 0);
|
||||
_spiritShotCount = set.getInt("spiritshots", 0);
|
||||
_rndDam = set.getInt("random_damage", 0);
|
||||
_mpConsume = set.getInt("mp_consume", 0);
|
||||
_baseAttackRange = set.getInt("attack_range", 40);
|
||||
String[] damgeRange = set.getString("damage_range", "").split(";"); // 0?;0?;fan sector;base attack angle
|
||||
if ((damgeRange.length > 1) && Util.isDigit(damgeRange[3]))
|
||||
{
|
||||
_baseAttackAngle = Integer.parseInt(damgeRange[3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
_baseAttackAngle = 120;
|
||||
}
|
||||
|
||||
String[] reduced_soulshots = set.getString("reduced_soulshot", "").split(",");
|
||||
_reducedSoulshotChance = (reduced_soulshots.length == 2) ? Integer.parseInt(reduced_soulshots[0]) : 0;
|
||||
_reducedSoulshot = (reduced_soulshots.length == 2) ? Integer.parseInt(reduced_soulshots[1]) : 0;
|
||||
|
||||
String[] reduced_mpconsume = set.getString("reduced_mp_consume", "").split(",");
|
||||
_reducedMpConsumeChance = (reduced_mpconsume.length == 2) ? Integer.parseInt(reduced_mpconsume[0]) : 0;
|
||||
_reducedMpConsume = (reduced_mpconsume.length == 2) ? Integer.parseInt(reduced_mpconsume[1]) : 0;
|
||||
|
||||
String skill = set.getString("enchant4_skill", null);
|
||||
if (skill != null)
|
||||
{
|
||||
String[] info = skill.split("-");
|
||||
|
||||
if ((info != null) && (info.length == 2))
|
||||
{
|
||||
int id = 0;
|
||||
int level = 0;
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(info[0]);
|
||||
level = Integer.parseInt(info[1]);
|
||||
}
|
||||
catch (Exception nfe)
|
||||
{
|
||||
// Incorrect syntax, dont add new skill
|
||||
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon enchant skills! item ", toString()));
|
||||
}
|
||||
if ((id > 0) && (level > 0))
|
||||
{
|
||||
_enchant4Skill = new SkillHolder(id, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skill = set.getString("onmagic_skill", null);
|
||||
if (skill != null)
|
||||
{
|
||||
String[] info = skill.split("-");
|
||||
final int chance = set.getInt("onmagic_chance", 100);
|
||||
if ((info != null) && (info.length == 2))
|
||||
{
|
||||
int id = 0;
|
||||
int level = 0;
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(info[0]);
|
||||
level = Integer.parseInt(info[1]);
|
||||
}
|
||||
catch (Exception nfe)
|
||||
{
|
||||
// Incorrect syntax, don't add new skill
|
||||
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon onmagic skills! item ", toString()));
|
||||
}
|
||||
if ((id > 0) && (level > 0) && (chance > 0))
|
||||
{
|
||||
_skillsOnMagic = new SkillHolder(id, level);
|
||||
_skillsOnMagicCondition = new ConditionGameChance(chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skill = set.getString("oncrit_skill", null);
|
||||
if (skill != null)
|
||||
{
|
||||
String[] info = skill.split("-");
|
||||
final int chance = set.getInt("oncrit_chance", 100);
|
||||
if ((info != null) && (info.length == 2))
|
||||
{
|
||||
int id = 0;
|
||||
int level = 0;
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(info[0]);
|
||||
level = Integer.parseInt(info[1]);
|
||||
}
|
||||
catch (Exception nfe)
|
||||
{
|
||||
// Incorrect syntax, don't add new skill
|
||||
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon oncrit skills! item ", toString()));
|
||||
}
|
||||
if ((id > 0) && (level > 0) && (chance > 0))
|
||||
{
|
||||
_skillsOnCrit = new SkillHolder(id, level);
|
||||
_skillsOnCritCondition = new ConditionGameChance(chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_changeWeaponId = set.getInt("change_weaponId", 0);
|
||||
_isForceEquip = set.getBoolean("isForceEquip", false);
|
||||
_isAttackWeapon = set.getBoolean("isAttackWeapon", true);
|
||||
_useWeaponSkillsOnly = set.getBoolean("useWeaponSkillsOnly", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of Weapon
|
||||
*/
|
||||
@Override
|
||||
public WeaponType getItemType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the Etc item after applying the mask.
|
||||
*/
|
||||
@Override
|
||||
public int getItemMask()
|
||||
{
|
||||
return getItemType().mask();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the weapon is magic, {@code false} otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean isMagicWeapon()
|
||||
{
|
||||
return _isMagicWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of SoulShot used.
|
||||
*/
|
||||
public int getSoulShotCount()
|
||||
{
|
||||
return _soulShotCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of SpiritShot used.
|
||||
*/
|
||||
public int getSpiritShotCount()
|
||||
{
|
||||
return _spiritShotCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the reduced quantity of SoultShot used.
|
||||
*/
|
||||
public int getReducedSoulShot()
|
||||
{
|
||||
return _reducedSoulshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance to use Reduced SoultShot.
|
||||
*/
|
||||
public int getReducedSoulShotChance()
|
||||
{
|
||||
return _reducedSoulshotChance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the random damage inflicted by the weapon.
|
||||
*/
|
||||
public int getRandomDamage()
|
||||
{
|
||||
return _rndDam;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the MP consumption with the weapon.
|
||||
*/
|
||||
public int getMpConsume()
|
||||
{
|
||||
return _mpConsume;
|
||||
}
|
||||
|
||||
public int getBaseAttackRange()
|
||||
{
|
||||
return _baseAttackRange;
|
||||
}
|
||||
|
||||
public int getBaseAttackAngle()
|
||||
{
|
||||
return _baseAttackAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the reduced MP consumption with the weapon.
|
||||
*/
|
||||
public int getReducedMpConsume()
|
||||
{
|
||||
return _reducedMpConsume;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance to use getReducedMpConsume()
|
||||
*/
|
||||
public int getReducedMpConsumeChance()
|
||||
{
|
||||
return _reducedMpConsumeChance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the skill that player get when has equipped weapon +4 or more (for duals SA).
|
||||
*/
|
||||
@Override
|
||||
public Skill getEnchant4Skill()
|
||||
{
|
||||
if (_enchant4Skill == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _enchant4Skill.getSkill();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Id in which weapon this weapon can be changed.
|
||||
*/
|
||||
public int getChangeWeaponId()
|
||||
{
|
||||
return _changeWeaponId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the weapon is force equip, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isForceEquip()
|
||||
{
|
||||
return _isForceEquip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the weapon is attack weapon, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isAttackWeapon()
|
||||
{
|
||||
return _isAttackWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the weapon is skills only, {@code false} otherwise.
|
||||
*/
|
||||
public boolean useWeaponSkillsOnly()
|
||||
{
|
||||
return _useWeaponSkillsOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param caster the L2Character pointing out the caster
|
||||
* @param target the L2Character pointing out the target
|
||||
*/
|
||||
public void castOnCriticalSkill(L2Character caster, L2Character target)
|
||||
{
|
||||
if ((_skillsOnCrit == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill onCritSkill = _skillsOnCrit.getSkill();
|
||||
if (_skillsOnCritCondition != null)
|
||||
{
|
||||
if (!_skillsOnCritCondition.test(caster, target, onCritSkill))
|
||||
{
|
||||
// Chance not met
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!onCritSkill.checkCondition(caster, target, false))
|
||||
{
|
||||
// Skill condition not met
|
||||
return;
|
||||
}
|
||||
|
||||
L2Character[] targets =
|
||||
{
|
||||
target
|
||||
};
|
||||
|
||||
onCritSkill.activateSkill(caster, targets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param caster the L2Character pointing out the caster
|
||||
* @param target the L2Character pointing out the target
|
||||
* @param trigger the L2Skill pointing out the skill triggering this action
|
||||
*/
|
||||
public void castOnMagicSkill(L2Character caster, L2Character target, Skill trigger)
|
||||
{
|
||||
if (_skillsOnMagic == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Skill onMagicSkill = _skillsOnMagic.getSkill();
|
||||
|
||||
// Trigger only if both are good or bad magic.
|
||||
if (trigger.isBad() != onMagicSkill.isBad())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// No Trigger if not Magic Skill
|
||||
if (!trigger.isMagic() && !onMagicSkill.isMagic())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_skillsOnMagicCondition != null)
|
||||
{
|
||||
if (!_skillsOnMagicCondition.test(caster, target, onMagicSkill))
|
||||
{
|
||||
// Chance not met
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!onMagicSkill.checkCondition(caster, target, false))
|
||||
{
|
||||
// Skill condition not met
|
||||
return;
|
||||
}
|
||||
|
||||
if (onMagicSkill.isBad() && (Formulas.calcShldUse(caster, target, onMagicSkill) == Formulas.SHIELD_DEFENSE_PERFECT_BLOCK))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
L2Character[] targets =
|
||||
{
|
||||
target
|
||||
};
|
||||
|
||||
// Launch the magic skill and calculate its effects
|
||||
// Get the skill handler corresponding to the skill type
|
||||
onMagicSkill.activateSkill(caster, targets);
|
||||
|
||||
// notify quests of a skill use
|
||||
if (caster instanceof L2PcInstance)
|
||||
{
|
||||
//@formatter:off
|
||||
caster.getKnownList().getKnownObjects().values().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(npc -> npc.isNpc())
|
||||
.filter(npc -> Util.checkIfInRange(1000, npc, caster, false))
|
||||
.forEach(npc ->
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcSkillSee((L2Npc) npc, caster.getActingPlayer(), onMagicSkill, targets, false), npc);
|
||||
});
|
||||
//@formatter:on
|
||||
}
|
||||
if (caster.isPlayer())
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_BEEN_ACTIVATED);
|
||||
sm.addSkillName(onMagicSkill);
|
||||
caster.sendPacket(sm);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items;
|
||||
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public final class PcItemTemplate extends ItemHolder
|
||||
{
|
||||
private final boolean _equipped;
|
||||
|
||||
/**
|
||||
* @param set the set containing the values for this object
|
||||
*/
|
||||
public PcItemTemplate(StatsSet set)
|
||||
{
|
||||
super(set.getInt("id"), set.getInt("count"));
|
||||
_equipped = set.getBoolean("equipped", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the items is equipped upon character creation, {@code false} otherwise
|
||||
*/
|
||||
public boolean isEquipped()
|
||||
{
|
||||
return _equipped;
|
||||
}
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.enchant;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.model.items.type.ItemType;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public abstract class AbstractEnchantItem
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(AbstractEnchantItem.class.getName());
|
||||
|
||||
private static final ItemType[] ENCHANT_TYPES = new ItemType[]
|
||||
{
|
||||
EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM,
|
||||
EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP,
|
||||
EtcItemType.BLESS_SCRL_ENCHANT_AM,
|
||||
EtcItemType.BLESS_SCRL_ENCHANT_WP,
|
||||
EtcItemType.SCRL_ENCHANT_AM,
|
||||
EtcItemType.SCRL_ENCHANT_WP,
|
||||
EtcItemType.SCRL_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.SCRL_INC_ENCHANT_PROP_WP,
|
||||
};
|
||||
|
||||
private final int _id;
|
||||
private final CrystalType _grade;
|
||||
private final int _maxEnchantLevel;
|
||||
private final double _bonusRate;
|
||||
|
||||
public AbstractEnchantItem(StatsSet set)
|
||||
{
|
||||
_id = set.getInt("id");
|
||||
if (getItem() == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
else if (!Util.contains(ENCHANT_TYPES, getItem().getItemType()))
|
||||
{
|
||||
throw new IllegalAccessError();
|
||||
}
|
||||
_grade = set.getEnum("targetGrade", CrystalType.class, CrystalType.NONE);
|
||||
_maxEnchantLevel = set.getInt("maxEnchant", 65535);
|
||||
_bonusRate = set.getDouble("bonusRate", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id of current item
|
||||
*/
|
||||
public final int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bonus chance that would be added
|
||||
*/
|
||||
public final double getBonusRate()
|
||||
{
|
||||
return _bonusRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link L2Item} current item/scroll
|
||||
*/
|
||||
public final L2Item getItem()
|
||||
{
|
||||
return ItemTable.getInstance().getTemplate(_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return grade of the item/scroll.
|
||||
*/
|
||||
public final CrystalType getGrade()
|
||||
{
|
||||
return _grade;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if scroll is for weapon, {@code false} for armor
|
||||
*/
|
||||
public abstract boolean isWeapon();
|
||||
|
||||
/**
|
||||
* @return the maximum enchant level that this scroll/item can be used with
|
||||
*/
|
||||
public int getMaxEnchantLevel()
|
||||
{
|
||||
return _maxEnchantLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemToEnchant the item to be enchanted
|
||||
* @param supportItem
|
||||
* @return {@code true} if this support item can be used with the item to be enchanted, {@code false} otherwise
|
||||
*/
|
||||
public boolean isValid(L2ItemInstance itemToEnchant, EnchantSupportItem supportItem)
|
||||
{
|
||||
if (itemToEnchant == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (itemToEnchant.isEnchantable() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!isValidItemType(itemToEnchant.getItem().getType2()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((_maxEnchantLevel != 0) && (itemToEnchant.getEnchantLevel() >= _maxEnchantLevel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (_grade != itemToEnchant.getItem().getItemGradeSPlus())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type2
|
||||
* @return {@code true} if current type2 is valid to be enchanted, {@code false} otherwise
|
||||
*/
|
||||
private final boolean isValidItemType(int type2)
|
||||
{
|
||||
if (type2 == L2Item.TYPE2_WEAPON)
|
||||
{
|
||||
return isWeapon();
|
||||
}
|
||||
else if ((type2 == L2Item.TYPE2_SHIELD_ARMOR) || (type2 == L2Item.TYPE2_ACCESSORY))
|
||||
{
|
||||
return !isWeapon();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.enchant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.model.holders.RangeChanceHolder;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class EnchantItemGroup
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(EnchantItemGroup.class.getName());
|
||||
private final List<RangeChanceHolder> _chances = new ArrayList<>();
|
||||
private final String _name;
|
||||
|
||||
public EnchantItemGroup(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of current enchant item group.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param holder
|
||||
*/
|
||||
public void addChance(RangeChanceHolder holder)
|
||||
{
|
||||
_chances.add(holder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param index
|
||||
* @return chance for success rate for current enchant item group.
|
||||
*/
|
||||
public double getChance(int index)
|
||||
{
|
||||
if (!_chances.isEmpty())
|
||||
{
|
||||
for (RangeChanceHolder holder : _chances)
|
||||
{
|
||||
if ((holder.getMin() <= index) && (holder.getMax() >= index))
|
||||
{
|
||||
return holder.getChance();
|
||||
}
|
||||
}
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't match proper chance for item group: " + _name, new IllegalStateException());
|
||||
return _chances.get(_chances.size() - 1).getChance();
|
||||
}
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": item group: " + _name + " doesn't have any chances!");
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.enchant;
|
||||
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class EnchantRateItem
|
||||
{
|
||||
private final String _name;
|
||||
private int _itemId;
|
||||
private int _slot;
|
||||
private Boolean _isMagicWeapon = null;
|
||||
|
||||
public EnchantRateItem(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of enchant group.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds item id verification.
|
||||
* @param id
|
||||
*/
|
||||
public void setItemId(int id)
|
||||
{
|
||||
_itemId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds body slot verification.
|
||||
* @param slot
|
||||
*/
|
||||
public void addSlot(int slot)
|
||||
{
|
||||
_slot |= slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds magic weapon verification.
|
||||
* @param magicWeapon
|
||||
*/
|
||||
public void setMagicWeapon(boolean magicWeapon)
|
||||
{
|
||||
_isMagicWeapon = magicWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @return {@code true} if item can be used with this rate group, {@code false} otherwise.
|
||||
*/
|
||||
public boolean validate(L2Item item)
|
||||
{
|
||||
if ((_itemId != 0) && (_itemId != item.getId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((_slot != 0) && ((item.getBodyPart() & _slot) == 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((_isMagicWeapon != null) && (item.isMagicWeapon() != _isMagicWeapon))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.enchant;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum EnchantResultType
|
||||
{
|
||||
ERROR,
|
||||
SUCCESS,
|
||||
FAILURE
|
||||
}
|
@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.enchant;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.EnchantItemGroupsData;
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.model.items.type.ItemType;
|
||||
import com.l2jserver.gameserver.network.Debug;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class EnchantScroll extends AbstractEnchantItem
|
||||
{
|
||||
private final boolean _isWeapon;
|
||||
private final boolean _isBlessed;
|
||||
private final boolean _isSafe;
|
||||
private final int _scrollGroupId;
|
||||
private Set<Integer> _items;
|
||||
|
||||
public EnchantScroll(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_scrollGroupId = set.getInt("scrollGroupId", 0);
|
||||
|
||||
final ItemType type = getItem().getItemType();
|
||||
_isWeapon = (type == EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP) || (type == EtcItemType.BLESS_SCRL_ENCHANT_WP) || (type == EtcItemType.SCRL_ENCHANT_WP);
|
||||
_isBlessed = (type == EtcItemType.BLESS_SCRL_ENCHANT_AM) || (type == EtcItemType.BLESS_SCRL_ENCHANT_WP);
|
||||
_isSafe = (type == EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM) || (type == EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWeapon()
|
||||
{
|
||||
return _isWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} for blessed scrolls (enchanted item will remain on failure), {@code false} otherwise
|
||||
*/
|
||||
public boolean isBlessed()
|
||||
{
|
||||
return _isBlessed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} for safe-enchant scrolls (enchant level will remain on failure), {@code false} otherwise
|
||||
*/
|
||||
public boolean isSafe()
|
||||
{
|
||||
return _isSafe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id of scroll group that should be used
|
||||
*/
|
||||
public int getScrollGroupId()
|
||||
{
|
||||
return _scrollGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enforces current scroll to use only those items as possible items to enchant
|
||||
* @param itemId
|
||||
*/
|
||||
public void addItem(int itemId)
|
||||
{
|
||||
if (_items == null)
|
||||
{
|
||||
_items = new HashSet<>();
|
||||
}
|
||||
_items.add(itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemToEnchant the item to be enchanted
|
||||
* @param supportItem the support item used when enchanting (can be null)
|
||||
* @return {@code true} if this scroll can be used with the specified support item and the item to be enchanted, {@code false} otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(L2ItemInstance itemToEnchant, EnchantSupportItem supportItem)
|
||||
{
|
||||
if ((_items != null) && !_items.contains(itemToEnchant.getId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((supportItem != null))
|
||||
{
|
||||
if (isBlessed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!supportItem.isValid(itemToEnchant, supportItem))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (supportItem.isWeapon() != isWeapon())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.isValid(itemToEnchant, supportItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param enchantItem
|
||||
* @return the chance of current scroll's group.
|
||||
*/
|
||||
public double getChance(L2PcInstance player, L2ItemInstance enchantItem)
|
||||
{
|
||||
if (EnchantItemGroupsData.getInstance().getScrollGroup(_scrollGroupId) == null)
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": Unexistent enchant scroll group specified for enchant scroll: " + getId());
|
||||
return -1;
|
||||
}
|
||||
|
||||
final EnchantItemGroup group = EnchantItemGroupsData.getInstance().getItemGroup(enchantItem.getItem(), _scrollGroupId);
|
||||
if (group == null)
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't find enchant item group for scroll: " + getId() + " requested by: " + player);
|
||||
return -1;
|
||||
}
|
||||
return group.getChance(enchantItem.getEnchantLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param enchantItem
|
||||
* @param supportItem
|
||||
* @return the total chance for success rate of this scroll
|
||||
*/
|
||||
public EnchantResultType calculateSuccess(L2PcInstance player, L2ItemInstance enchantItem, EnchantSupportItem supportItem)
|
||||
{
|
||||
if (!isValid(enchantItem, supportItem))
|
||||
{
|
||||
return EnchantResultType.ERROR;
|
||||
}
|
||||
|
||||
final double chance = getChance(player, enchantItem);
|
||||
if (chance == -1)
|
||||
{
|
||||
return EnchantResultType.ERROR;
|
||||
}
|
||||
|
||||
final double bonusRate = getBonusRate();
|
||||
final double supportBonusRate = (supportItem != null) ? supportItem.getBonusRate() : 0;
|
||||
final double finalChance = Math.min(chance + bonusRate + supportBonusRate, 100);
|
||||
|
||||
final double random = 100 * Rnd.nextDouble();
|
||||
final boolean success = (random < finalChance);
|
||||
|
||||
if (player.isDebug())
|
||||
{
|
||||
final EnchantItemGroup group = EnchantItemGroupsData.getInstance().getItemGroup(enchantItem.getItem(), _scrollGroupId);
|
||||
final StatsSet set = new StatsSet();
|
||||
if (isBlessed())
|
||||
{
|
||||
set.set("isBlessed", isBlessed());
|
||||
}
|
||||
if (isSafe())
|
||||
{
|
||||
set.set("isSafe", isSafe());
|
||||
}
|
||||
set.set("chance", Util.formatDouble(chance, "#.##"));
|
||||
if (bonusRate > 0)
|
||||
{
|
||||
set.set("bonusRate", Util.formatDouble(bonusRate, "#.##"));
|
||||
}
|
||||
if (supportBonusRate > 0)
|
||||
{
|
||||
set.set("supportBonusRate", Util.formatDouble(supportBonusRate, "#.##"));
|
||||
}
|
||||
set.set("finalChance", Util.formatDouble(finalChance, "#.##"));
|
||||
set.set("random", Util.formatDouble(random, "#.##"));
|
||||
set.set("success", success);
|
||||
set.set("item group", group.getName());
|
||||
set.set("scroll group", _scrollGroupId);
|
||||
Debug.sendItemDebug(player, enchantItem, set);
|
||||
}
|
||||
return success ? EnchantResultType.SUCCESS : EnchantResultType.FAILURE;
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.enchant;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class EnchantScrollGroup
|
||||
{
|
||||
private final int _id;
|
||||
private List<EnchantRateItem> _rateGroups;
|
||||
|
||||
public EnchantScrollGroup(int id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id of current enchant scroll group.
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new rate group.
|
||||
* @param group
|
||||
*/
|
||||
public void addRateGroup(EnchantRateItem group)
|
||||
{
|
||||
if (_rateGroups == null)
|
||||
{
|
||||
_rateGroups = new ArrayList<>();
|
||||
}
|
||||
_rateGroups.add(group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code List} of all enchant rate items, Empty list if none.
|
||||
*/
|
||||
public List<EnchantRateItem> getRateGroups()
|
||||
{
|
||||
return _rateGroups != null ? _rateGroups : Collections.<EnchantRateItem> emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @return {@link EnchantRateItem}, {@code NULL} in case non of rate items can be used with.
|
||||
*/
|
||||
public EnchantRateItem getRateGroup(L2Item item)
|
||||
{
|
||||
for (EnchantRateItem group : getRateGroups())
|
||||
{
|
||||
if (group.validate(item))
|
||||
{
|
||||
return group;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.enchant;
|
||||
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class EnchantSupportItem extends AbstractEnchantItem
|
||||
{
|
||||
private final boolean _isWeapon;
|
||||
|
||||
public EnchantSupportItem(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_isWeapon = getItem().getItemType() == EtcItemType.SCRL_INC_ENCHANT_PROP_WP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWeapon()
|
||||
{
|
||||
return _isWeapon;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.type;
|
||||
|
||||
/**
|
||||
* Action Type enumerated.
|
||||
* @author nBd
|
||||
*/
|
||||
public enum ActionType
|
||||
{
|
||||
CALC,
|
||||
CALL_SKILL,
|
||||
CAPSULE,
|
||||
CREATE_MPCC,
|
||||
DICE,
|
||||
EQUIP,
|
||||
FISHINGSHOT,
|
||||
HARVEST,
|
||||
HIDE_NAME,
|
||||
KEEP_EXP,
|
||||
NICK_COLOR,
|
||||
NONE,
|
||||
PEEL,
|
||||
RECIPE,
|
||||
SEED,
|
||||
SHOW_ADVENTURER_GUIDE_BOOK,
|
||||
SHOW_HTML,
|
||||
SHOW_SSQ_STATUS,
|
||||
SKILL_MAINTAIN,
|
||||
SKILL_REDUCE,
|
||||
SOULSHOT,
|
||||
SPIRITSHOT,
|
||||
START_QUEST,
|
||||
SUMMON_SOULSHOT,
|
||||
SUMMON_SPIRITSHOT,
|
||||
XMAS_OPEN,
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.type;
|
||||
|
||||
/**
|
||||
* Armor Type enumerated.
|
||||
*/
|
||||
public enum ArmorType implements ItemType
|
||||
{
|
||||
NONE,
|
||||
LIGHT,
|
||||
HEAVY,
|
||||
MAGIC,
|
||||
SIGIL,
|
||||
|
||||
// L2J CUSTOM
|
||||
SHIELD;
|
||||
|
||||
final int _mask;
|
||||
|
||||
/**
|
||||
* Constructor of the ArmorType.
|
||||
*/
|
||||
private ArmorType()
|
||||
{
|
||||
_mask = 1 << (ordinal() + WeaponType.values().length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the ArmorType after applying a mask.
|
||||
*/
|
||||
@Override
|
||||
public int mask()
|
||||
{
|
||||
return _mask;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.type;
|
||||
|
||||
/**
|
||||
* Crystal Type enumerated.
|
||||
* @author Adry_85
|
||||
*/
|
||||
public enum CrystalType
|
||||
{
|
||||
NONE(0, 0, 0, 0),
|
||||
D(1, 1458, 11, 90),
|
||||
C(2, 1459, 6, 45),
|
||||
B(3, 1460, 11, 67),
|
||||
A(4, 1461, 20, 145),
|
||||
S(5, 1462, 25, 250),
|
||||
S80(6, 1462, 25, 250),
|
||||
S84(7, 1462, 25, 250),
|
||||
R(8, 17371, 30, 500),
|
||||
R95(9, 17371, 30, 500),
|
||||
R99(10, 17371, 30, 500),
|
||||
EVENT(0, 0, 0, 0);
|
||||
|
||||
private final int _id;
|
||||
private final int _crystalId;
|
||||
private final int _crystalEnchantBonusArmor;
|
||||
private final int _crystalEnchantBonusWeapon;
|
||||
|
||||
private CrystalType(int id, int crystalId, int crystalEnchantBonusArmor, int crystalEnchantBonusWeapon)
|
||||
{
|
||||
_id = id;
|
||||
_crystalId = crystalId;
|
||||
_crystalEnchantBonusArmor = crystalEnchantBonusArmor;
|
||||
_crystalEnchantBonusWeapon = crystalEnchantBonusWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the crystal type ID.
|
||||
* @return the crystal type ID
|
||||
*/
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item ID of the crystal.
|
||||
* @return the item ID of the crystal
|
||||
*/
|
||||
public int getCrystalId()
|
||||
{
|
||||
return _crystalId;
|
||||
}
|
||||
|
||||
public int getCrystalEnchantBonusArmor()
|
||||
{
|
||||
return _crystalEnchantBonusArmor;
|
||||
}
|
||||
|
||||
public int getCrystalEnchantBonusWeapon()
|
||||
{
|
||||
return _crystalEnchantBonusWeapon;
|
||||
}
|
||||
|
||||
public boolean isGreater(CrystalType crystalType)
|
||||
{
|
||||
return getId() > crystalType.getId();
|
||||
}
|
||||
|
||||
public boolean isLesser(CrystalType crystalType)
|
||||
{
|
||||
return getId() < crystalType.getId();
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.type;
|
||||
|
||||
/**
|
||||
* EtcItem Type enumerated.
|
||||
*/
|
||||
public enum EtcItemType implements ItemType
|
||||
{
|
||||
NONE,
|
||||
ARROW,
|
||||
POTION,
|
||||
SCRL_ENCHANT_WP,
|
||||
SCRL_ENCHANT_AM,
|
||||
SCROLL,
|
||||
RECIPE,
|
||||
MATERIAL,
|
||||
PET_COLLAR,
|
||||
CASTLE_GUARD,
|
||||
LOTTO,
|
||||
RACE_TICKET,
|
||||
DYE,
|
||||
SEED,
|
||||
CROP,
|
||||
MATURECROP,
|
||||
HARVEST,
|
||||
SEED2,
|
||||
TICKET_OF_LORD,
|
||||
LURE,
|
||||
BLESS_SCRL_ENCHANT_WP,
|
||||
BLESS_SCRL_ENCHANT_AM,
|
||||
COUPON,
|
||||
ELIXIR,
|
||||
SCRL_ENCHANT_ATTR,
|
||||
BOLT,
|
||||
SCRL_INC_ENCHANT_PROP_WP,
|
||||
SCRL_INC_ENCHANT_PROP_AM,
|
||||
ANCIENT_CRYSTAL_ENCHANT_WP,
|
||||
ANCIENT_CRYSTAL_ENCHANT_AM,
|
||||
RUNE_SELECT,
|
||||
RUNE,
|
||||
|
||||
// L2J CUSTOM, BACKWARD COMPATIBILITY
|
||||
SHOT;
|
||||
|
||||
/**
|
||||
* @return the ID of the item after applying the mask.
|
||||
*/
|
||||
@Override
|
||||
public int mask()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.type;
|
||||
|
||||
/**
|
||||
* Created for allow comparing different item types
|
||||
* @author DS
|
||||
*/
|
||||
public interface ItemType
|
||||
{
|
||||
public int mask();
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.type;
|
||||
|
||||
/**
|
||||
* Material Type enumerated.
|
||||
* @author Adry_85
|
||||
*/
|
||||
public enum MaterialType
|
||||
{
|
||||
STEEL,
|
||||
FINE_STEEL,
|
||||
COTTON,
|
||||
BLOOD_STEEL,
|
||||
BRONZE,
|
||||
SILVER,
|
||||
GOLD,
|
||||
MITHRIL,
|
||||
ORIHARUKON,
|
||||
PAPER,
|
||||
WOOD,
|
||||
CLOTH,
|
||||
LEATHER,
|
||||
BONE,
|
||||
HORN,
|
||||
DAMASCUS,
|
||||
ADAMANTAITE,
|
||||
CHRYSOLITE,
|
||||
CRYSTAL,
|
||||
LIQUID,
|
||||
SCALE_OF_DRAGON,
|
||||
DYESTUFF,
|
||||
COBWEB,
|
||||
SEED,
|
||||
FISH,
|
||||
RUNE_XP,
|
||||
RUNE_SP,
|
||||
RUNE_REMOVE_PENALTY;
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2014 L2J Server
|
||||
*
|
||||
* This file is part of L2J Server.
|
||||
*
|
||||
* L2J Server 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.
|
||||
*
|
||||
* L2J Server 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 com.l2jserver.gameserver.model.items.type;
|
||||
|
||||
import com.l2jserver.gameserver.model.stats.TraitType;
|
||||
|
||||
/**
|
||||
* Weapon Type enumerated.
|
||||
* @author mkizub
|
||||
*/
|
||||
public enum WeaponType implements ItemType
|
||||
{
|
||||
SWORD(TraitType.SWORD),
|
||||
BLUNT(TraitType.BLUNT),
|
||||
DAGGER(TraitType.DAGGER),
|
||||
BOW(TraitType.BOW),
|
||||
POLE(TraitType.POLE),
|
||||
NONE(TraitType.NONE),
|
||||
DUAL(TraitType.DUAL),
|
||||
ETC(TraitType.ETC),
|
||||
FIST(TraitType.FIST),
|
||||
DUALFIST(TraitType.DUALFIST),
|
||||
FISHINGROD(TraitType.NONE),
|
||||
RAPIER(TraitType.RAPIER),
|
||||
ANCIENTSWORD(TraitType.ANCIENTSWORD),
|
||||
CROSSBOW(TraitType.CROSSBOW),
|
||||
FLAG(TraitType.NONE),
|
||||
OWNTHING(TraitType.NONE),
|
||||
DUALDAGGER(TraitType.DUALDAGGER),
|
||||
DUALBLUNT(TraitType.DUALBLUNT);
|
||||
|
||||
private final int _mask;
|
||||
private final TraitType _traitType;
|
||||
|
||||
/**
|
||||
* Constructor of the L2WeaponType.
|
||||
* @param traitType
|
||||
*/
|
||||
private WeaponType(TraitType traitType)
|
||||
{
|
||||
_mask = 1 << ordinal();
|
||||
_traitType = traitType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the item after applying the mask.
|
||||
*/
|
||||
@Override
|
||||
public int mask()
|
||||
{
|
||||
return _mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return L2TraitType the type of the WeaponType
|
||||
*/
|
||||
public TraitType getTraitType()
|
||||
{
|
||||
return _traitType;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user