Chronicle 4 branch.
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.funcs.Func;
|
||||
import com.l2jmobius.gameserver.skills.funcs.FuncTemplate;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* This class is dedicated to the management of armors.
|
||||
* @version $Revision: 1.2.2.1.2.6 $ $Date: 2005/03/27 15:30:10 $
|
||||
*/
|
||||
public final class L2Armor extends L2Item
|
||||
{
|
||||
private final int _avoidModifier;
|
||||
private final int _pDef;
|
||||
private final int _mDef;
|
||||
private final int _mpBonus;
|
||||
private final int _hpBonus;
|
||||
private L2Skill _itemSkill = null; // for passive skill
|
||||
|
||||
/**
|
||||
* Constructor for Armor.<BR>
|
||||
* <BR>
|
||||
* <U><I>Variables filled :</I></U><BR>
|
||||
* <LI>_avoidModifier</LI>
|
||||
* <LI>_pDef & _mDef</LI>
|
||||
* <LI>_mpBonus & _hpBonus</LI>
|
||||
* @param type : L2ArmorType designating the type of armor
|
||||
* @param set : StatsSet designating the set of couples (key,value) caracterizing the armor
|
||||
* @see L2Item constructor
|
||||
*/
|
||||
public L2Armor(L2ArmorType type, StatsSet set)
|
||||
{
|
||||
super(type, set);
|
||||
_avoidModifier = set.getInteger("avoid_modify");
|
||||
_pDef = set.getInteger("p_def");
|
||||
_mDef = set.getInteger("m_def");
|
||||
_mpBonus = set.getInteger("mp_bonus", 0);
|
||||
_hpBonus = set.getInteger("hp_bonus", 0);
|
||||
|
||||
final int sId = set.getInteger("item_skill_id");
|
||||
final int sLv = set.getInteger("item_skill_lvl");
|
||||
if ((sId > 0) && (sLv > 0))
|
||||
{
|
||||
_itemSkill = SkillTable.getInstance().getInfo(sId, sLv);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the armor.
|
||||
* @return L2ArmorType
|
||||
*/
|
||||
@Override
|
||||
public L2ArmorType getItemType()
|
||||
{
|
||||
return (L2ArmorType) super._type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the item after applying the mask.
|
||||
* @return int : ID of the item
|
||||
*/
|
||||
@Override
|
||||
public final int getItemMask()
|
||||
{
|
||||
return getItemType().mask();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the magical defense of the armor
|
||||
* @return int : value of the magic defense
|
||||
*/
|
||||
public final int getMDef()
|
||||
{
|
||||
return _mDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the physical defense of the armor
|
||||
* @return int : value of the physical defense
|
||||
*/
|
||||
public final int getPDef()
|
||||
{
|
||||
return _pDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns avoid modifier given by the armor
|
||||
* @return int : avoid modifier
|
||||
*/
|
||||
public final int getAvoidModifier()
|
||||
{
|
||||
return _avoidModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns magical bonus given by the armor
|
||||
* @return int : value of the magical bonus
|
||||
*/
|
||||
public final int getMpBonus()
|
||||
{
|
||||
return _mpBonus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns physical bonus given by the armor
|
||||
* @return int : value of the physical bonus
|
||||
*/
|
||||
public final int getHpBonus()
|
||||
{
|
||||
return _hpBonus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns passive skill linked to that armor
|
||||
* @return
|
||||
*/
|
||||
public L2Skill getSkill()
|
||||
{
|
||||
return _itemSkill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of Func objects containing the list of functions used by the armor
|
||||
* @param instance : L2ItemInstance pointing out the armor
|
||||
* @param player : L2Character pointing out the player
|
||||
* @return Func[] : array of functions
|
||||
*/
|
||||
@Override
|
||||
public Func[] getStatFuncs(L2ItemInstance instance, L2Character player)
|
||||
{
|
||||
final List<Func> funcs = new FastList<>();
|
||||
if (_funcTemplates != null)
|
||||
{
|
||||
for (final FuncTemplate t : _funcTemplates)
|
||||
{
|
||||
final Env env = new Env();
|
||||
env.player = player;
|
||||
env.item = instance;
|
||||
final Func f = t.getFunc(env, instance);
|
||||
if (f != null)
|
||||
{
|
||||
funcs.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return funcs.toArray(new Func[funcs.size()]);
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
/**
|
||||
* Description of Armor Type
|
||||
*/
|
||||
public enum L2ArmorType
|
||||
{
|
||||
NONE(1, "None"),
|
||||
LIGHT(2, "Light"),
|
||||
HEAVY(3, "Heavy"),
|
||||
MAGIC(4, "Magic"),
|
||||
PET(5, "Pet");
|
||||
|
||||
final int _id;
|
||||
final String _name;
|
||||
|
||||
/**
|
||||
* Constructor of the L2ArmorType.
|
||||
* @param id : int designating the ID of the ArmorType
|
||||
* @param name : String designating the name of the ArmorType
|
||||
*/
|
||||
L2ArmorType(int id, String name)
|
||||
{
|
||||
_id = id;
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the ArmorType after applying a mask.
|
||||
* @return int : ID of the ArmorType after mask
|
||||
*/
|
||||
public int mask()
|
||||
{
|
||||
return 1 << (_id + 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the ArmorType
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision: 1.2.4.6 $ $Date: 2005/04/02 15:57:51 $
|
||||
*/
|
||||
public class L2CharTemplate
|
||||
{
|
||||
// BaseStats
|
||||
public final int baseSTR;
|
||||
public final int baseCON;
|
||||
public final int baseDEX;
|
||||
public final int baseINT;
|
||||
public final int baseWIT;
|
||||
public final int baseMEN;
|
||||
public final float baseHpMax;
|
||||
public final float baseCpMax;
|
||||
public final float baseMpMax;
|
||||
|
||||
/** HP Regen base */
|
||||
public final float baseHpReg;
|
||||
|
||||
/** MP Regen base */
|
||||
public final float baseMpReg;
|
||||
|
||||
public final int basePAtk;
|
||||
public final int baseMAtk;
|
||||
public final int basePDef;
|
||||
public final int baseMDef;
|
||||
public final int basePAtkSpd;
|
||||
public final int baseMAtkSpd;
|
||||
public final float baseMReuseRate;
|
||||
public final int baseShldDef;
|
||||
public final int baseAtkRange;
|
||||
public final int baseShldRate;
|
||||
public final int baseCritRate;
|
||||
public final int baseMCritRate;
|
||||
public final int baseWalkSpd;
|
||||
public final int baseRunSpd;
|
||||
|
||||
// SpecialStats
|
||||
public final int baseBreath;
|
||||
public final int baseAggression;
|
||||
public final int baseBleed;
|
||||
public final int basePoison;
|
||||
public final int baseStun;
|
||||
public final int baseRoot;
|
||||
public final int baseMovement;
|
||||
public final int baseConfusion;
|
||||
public final int baseSleep;
|
||||
public final int baseFire;
|
||||
public final int baseWind;
|
||||
public final int baseWater;
|
||||
public final int baseEarth;
|
||||
public final int baseHoly;
|
||||
public final int baseDark;
|
||||
public final double baseAggressionVuln;
|
||||
public final double baseBleedVuln;
|
||||
public final double basePoisonVuln;
|
||||
public final double baseStunVuln;
|
||||
public final double baseRootVuln;
|
||||
public final double baseMovementVuln;
|
||||
public final double baseConfusionVuln;
|
||||
public final double baseSleepVuln;
|
||||
public final double baseFireVuln;
|
||||
public final double baseWindVuln;
|
||||
public final double baseWaterVuln;
|
||||
public final double baseEarthVuln;
|
||||
public final double baseHolyVuln;
|
||||
public final double baseDarkVuln;
|
||||
|
||||
public final boolean isUndead;
|
||||
|
||||
// C4 Stats
|
||||
public final int baseMpConsumeRate;
|
||||
public final int baseHpConsumeRate;
|
||||
|
||||
public final double collisionRadius;
|
||||
public final double collisionHeight;
|
||||
|
||||
public L2CharTemplate(StatsSet set)
|
||||
{
|
||||
// Base stats
|
||||
baseSTR = set.getInteger("baseSTR");
|
||||
baseCON = set.getInteger("baseCON");
|
||||
baseDEX = set.getInteger("baseDEX");
|
||||
baseINT = set.getInteger("baseINT");
|
||||
baseWIT = set.getInteger("baseWIT");
|
||||
baseMEN = set.getInteger("baseMEN");
|
||||
baseHpMax = set.getFloat("baseHpMax");
|
||||
baseCpMax = set.getFloat("baseCpMax");
|
||||
baseMpMax = set.getFloat("baseMpMax");
|
||||
baseHpReg = set.getFloat("baseHpReg");
|
||||
baseMpReg = set.getFloat("baseMpReg");
|
||||
basePAtk = set.getInteger("basePAtk");
|
||||
baseMAtk = set.getInteger("baseMAtk");
|
||||
basePDef = set.getInteger("basePDef");
|
||||
baseMDef = set.getInteger("baseMDef");
|
||||
basePAtkSpd = set.getInteger("basePAtkSpd");
|
||||
baseMAtkSpd = set.getInteger("baseMAtkSpd");
|
||||
baseMReuseRate = set.getFloat("baseMReuseDelay", 1.f);
|
||||
baseShldDef = set.getInteger("baseShldDef");
|
||||
baseAtkRange = set.getInteger("baseAtkRange");
|
||||
baseShldRate = set.getInteger("baseShldRate");
|
||||
baseCritRate = set.getInteger("baseCritRate");
|
||||
baseMCritRate = set.getInteger("baseMCritRate", 8);
|
||||
baseWalkSpd = set.getInteger("baseWalkSpd");
|
||||
baseRunSpd = set.getInteger("baseRunSpd");
|
||||
|
||||
// SpecialStats
|
||||
baseBreath = set.getInteger("baseBreath", 100);
|
||||
baseAggression = set.getInteger("baseAggression", 0);
|
||||
baseBleed = set.getInteger("baseBleed", 0);
|
||||
basePoison = set.getInteger("basePoison", 0);
|
||||
baseStun = set.getInteger("baseStun", 0);
|
||||
baseRoot = set.getInteger("baseRoot", 0);
|
||||
baseMovement = set.getInteger("baseMovement", 0);
|
||||
baseConfusion = set.getInteger("baseConfusion", 0);
|
||||
baseSleep = set.getInteger("baseSleep", 0);
|
||||
baseFire = set.getInteger("baseFire", 0);
|
||||
baseWind = set.getInteger("baseWind", 0);
|
||||
baseWater = set.getInteger("baseWater", 0);
|
||||
baseEarth = set.getInteger("baseEarth", 0);
|
||||
baseHoly = set.getInteger("baseHoly", 0);
|
||||
baseDark = set.getInteger("baseDark", 0);
|
||||
baseAggressionVuln = set.getInteger("baseAaggressionVuln", 1);
|
||||
baseBleedVuln = set.getInteger("baseBleedVuln", 1);
|
||||
basePoisonVuln = set.getInteger("basePoisonVuln", 1);
|
||||
baseStunVuln = set.getInteger("baseStunVuln", 1);
|
||||
baseRootVuln = set.getInteger("baseRootVuln", 1);
|
||||
baseMovementVuln = set.getInteger("baseMovementVuln", 1);
|
||||
baseConfusionVuln = set.getInteger("baseConfusionVuln", 1);
|
||||
baseSleepVuln = set.getInteger("baseSleepVuln", 1);
|
||||
baseFireVuln = set.getInteger("baseFireVuln", 1);
|
||||
baseWindVuln = set.getInteger("baseWindVuln", 1);
|
||||
baseWaterVuln = set.getInteger("baseWaterVuln", 1);
|
||||
baseEarthVuln = set.getInteger("baseEarthVuln", 1);
|
||||
baseHolyVuln = set.getInteger("baseHolyVuln", 1);
|
||||
baseDarkVuln = set.getInteger("baseDarkVuln", 1);
|
||||
|
||||
isUndead = (set.getInteger("isUndead", 0) == 1);
|
||||
|
||||
// C4 Stats
|
||||
baseMpConsumeRate = set.getInteger("baseMpConsumeRate", 0);
|
||||
baseHpConsumeRate = set.getInteger("baseHpConsumeRate", 0);
|
||||
|
||||
// Geometry
|
||||
collisionRadius = set.getDouble("collision_radius");
|
||||
collisionHeight = set.getDouble("collision_height");
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
/**
|
||||
* This class is dedicated to the management of EtcItem.
|
||||
* @version $Revision: 1.2.2.1.2.3 $ $Date: 2005/03/27 15:30:10 $
|
||||
*/
|
||||
public final class L2EtcItem extends L2Item
|
||||
{
|
||||
/**
|
||||
* Constructor for EtcItem.
|
||||
* @see L2Item constructor
|
||||
* @param type : L2EtcItemType designating the type of object Etc
|
||||
* @param set : StatsSet designating the set of couples (key,value) for description of the Etc
|
||||
*/
|
||||
public L2EtcItem(L2EtcItemType type, StatsSet set)
|
||||
{
|
||||
super(type, set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of Etc Item
|
||||
* @return L2EtcItemType
|
||||
*/
|
||||
@Override
|
||||
public L2EtcItemType getItemType()
|
||||
{
|
||||
return (L2EtcItemType) super._type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item is consumable
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public final boolean isConsumable()
|
||||
{
|
||||
return ((getItemType() == L2EtcItemType.SHOT) || (getItemType() == L2EtcItemType.POTION)); // || (type == L2EtcItemType.SCROLL));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the Etc item after applying the mask.
|
||||
* @return int : ID of the EtcItem
|
||||
*/
|
||||
@Override
|
||||
public int getItemMask()
|
||||
{
|
||||
return getItemType().mask();
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
/**
|
||||
* Description of EtcItem Type
|
||||
*/
|
||||
public enum L2EtcItemType
|
||||
{
|
||||
ARROW(0, "Arrow"),
|
||||
MATERIAL(1, "Material"),
|
||||
PET_COLLAR(2, "PetCollar"),
|
||||
POTION(3, "Potion"),
|
||||
RECEIPE(4, "Receipe"),
|
||||
SCROLL(5, "Scroll"),
|
||||
QUEST(6, "Quest"),
|
||||
MONEY(7, "Money"),
|
||||
OTHER(8, "Other"),
|
||||
SPELLBOOK(9, "Spellbook"),
|
||||
SEED(10, "Seed"),
|
||||
SHOT(11, "Shot");
|
||||
|
||||
final int _id;
|
||||
final String _name;
|
||||
|
||||
/**
|
||||
* Constructor of the L2EtcItemType.
|
||||
* @param id : int designating the ID of the EtcItemType
|
||||
* @param name : String designating the name of the EtcItemType
|
||||
*/
|
||||
L2EtcItemType(int id, String name)
|
||||
{
|
||||
_id = id;
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the item after applying the mask.
|
||||
* @return int : ID of the item
|
||||
*/
|
||||
public int mask()
|
||||
{
|
||||
return 1 << (_id + 21);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the EtcItemType
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
/**
|
||||
* This class represents a Newbie Helper Buff Author: Ayor
|
||||
*/
|
||||
public class L2HelperBuff
|
||||
{
|
||||
/** Min level that the player must achieve to obtain this buff from Newbie Helper */
|
||||
private int _lowerLevel;
|
||||
|
||||
/** Max level that the player mustn't exceed if it want to obtain this buff from Newbie Helper */
|
||||
private int _upperLevel;
|
||||
|
||||
/** Identifier of the skill (buff) that the Newbie Helper must cast */
|
||||
private int _skillID;
|
||||
|
||||
/** Level of the skill (buff) that the Newbie Helper must cast */
|
||||
private int _skillLevel;
|
||||
|
||||
/**
|
||||
* If True only Magus class will obtain this Buff <BR>
|
||||
* If False only Fighter class will obtain this Buff
|
||||
*/
|
||||
private boolean _isMagicClass;
|
||||
|
||||
/**
|
||||
* Constructor of L2HelperBuff.<BR>
|
||||
* <BR>
|
||||
* @param set
|
||||
*/
|
||||
public L2HelperBuff(StatsSet set)
|
||||
{
|
||||
|
||||
_lowerLevel = set.getInteger("lowerLevel");
|
||||
_upperLevel = set.getInteger("upperLevel");
|
||||
_skillID = set.getInteger("skillID");
|
||||
_skillLevel = set.getInteger("skillLevel");
|
||||
|
||||
if ("false".equals(set.getString("isMagicClass")))
|
||||
{
|
||||
_isMagicClass = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isMagicClass = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lower level that the L2PcInstance must achieve in order to obtain this buff
|
||||
* @return int
|
||||
*/
|
||||
public int getLowerLevel()
|
||||
{
|
||||
return _lowerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the lower level that the L2PcInstance must achieve in order to obtain this buff
|
||||
* @param lowerLevel : int designating the lower level
|
||||
*/
|
||||
public void setLowerLevel(int lowerLevel)
|
||||
{
|
||||
_lowerLevel = lowerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the upper level that the L2PcInstance mustn't exceed in order to obtain this buff
|
||||
* @return int
|
||||
*/
|
||||
public int getUpperLevel()
|
||||
{
|
||||
return _upperLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the upper level that the L2PcInstance mustn't exceed in order to obtain this buff
|
||||
* @param upperLevel : int designating the upper level
|
||||
*/
|
||||
public void setUpperLevel(int upperLevel)
|
||||
{
|
||||
_upperLevel = upperLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the buff that the L2PcInstance will receive
|
||||
* @return int
|
||||
*/
|
||||
public int getSkillID()
|
||||
{
|
||||
return _skillID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the buff that the L2PcInstance will receive
|
||||
* @param skillID : int designating the skill Identifier
|
||||
*/
|
||||
public void setSkillID(int skillID)
|
||||
{
|
||||
_skillID = skillID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Level of the buff that the L2PcInstance will receive
|
||||
* @return int
|
||||
*/
|
||||
public int getSkillLevel()
|
||||
{
|
||||
return _skillLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Level of the buff that the L2PcInstance will receive
|
||||
* @param skillLevel : int designating the level of the skill
|
||||
*/
|
||||
public void setSkillLevel(int skillLevel)
|
||||
{
|
||||
_skillLevel = skillLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if this Buff can be cast on a fighter or a mystic
|
||||
* @return boolean : False if it's a fighter class Buff
|
||||
*/
|
||||
public boolean isMagicClassBuff()
|
||||
{
|
||||
return _isMagicClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this Buff can be cast on a fighter or a mystic
|
||||
* @param isMagicClass
|
||||
*/
|
||||
public void setIsMagicClass(boolean isMagicClass)
|
||||
{
|
||||
_isMagicClass = isMagicClass;
|
||||
}
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
public class L2Henna
|
||||
{
|
||||
public final int symbol_id;
|
||||
public final String symbol_name;
|
||||
public final int dye;
|
||||
public final int price;
|
||||
public final int amount;
|
||||
public final int stat_INT;
|
||||
public final int stat_STR;
|
||||
public final int stat_CON;
|
||||
public final int stat_MEN;
|
||||
public final int stat_DEX;
|
||||
public final int stat_WIT;
|
||||
|
||||
public L2Henna(StatsSet set)
|
||||
{
|
||||
|
||||
symbol_id = set.getInteger("symbol_id");
|
||||
symbol_name = ""; // set.getString("symbol_name");
|
||||
dye = set.getInteger("dye");
|
||||
price = set.getInteger("price");
|
||||
amount = set.getInteger("amount");
|
||||
stat_INT = set.getInteger("stat_INT");
|
||||
stat_STR = set.getInteger("stat_STR");
|
||||
stat_CON = set.getInteger("stat_CON");
|
||||
stat_MEN = set.getInteger("stat_MEN");
|
||||
stat_DEX = set.getInteger("stat_DEX");
|
||||
stat_WIT = set.getInteger("stat_WIT");
|
||||
|
||||
}
|
||||
|
||||
public int getSymbolId()
|
||||
{
|
||||
return symbol_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getDyeId()
|
||||
{
|
||||
return dye;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getPrice()
|
||||
{
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getAmountDyeRequire()
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getStatINT()
|
||||
{
|
||||
return stat_INT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getStatSTR()
|
||||
{
|
||||
return stat_STR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getStatCON()
|
||||
{
|
||||
return stat_CON;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getStatMEN()
|
||||
{
|
||||
return stat_MEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getStatDEX()
|
||||
{
|
||||
return stat_DEX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int getStatWIT()
|
||||
{
|
||||
return stat_WIT;
|
||||
}
|
||||
}
|
@@ -0,0 +1,641 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.effects.EffectTemplate;
|
||||
import com.l2jmobius.gameserver.skills.funcs.Func;
|
||||
import com.l2jmobius.gameserver.skills.funcs.FuncTemplate;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* This class contains all informations concerning the item (weapon, armor, etc).<BR>
|
||||
* Mother class of :
|
||||
* <LI>L2Armor</LI>
|
||||
* <LI>L2EtcItem</LI>
|
||||
* <LI>L2Weapon</LI>
|
||||
* @version $Revision: 1.7.2.2.2.5 $ $Date: 2005/04/06 18:25:18 $
|
||||
*/
|
||||
public abstract class L2Item
|
||||
{
|
||||
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 TYPE2_PET_WOLF = 6;
|
||||
public static final int TYPE2_PET_HATCHLING = 7;
|
||||
public static final int TYPE2_PET_STRIDER = 8;
|
||||
|
||||
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_NECK = 0x0008;
|
||||
public static final int SLOT_R_FINGER = 0x0010;
|
||||
public static final int SLOT_L_FINGER = 0x0020;
|
||||
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_WOLF = 0x020000;
|
||||
public static final int SLOT_HATCHLING = 0x040000;
|
||||
public static final int SLOT_STRIDER = 0x080000;
|
||||
|
||||
public static final int MATERIAL_STEEL = 0x00; // ??
|
||||
public static final int MATERIAL_FINE_STEEL = 0x01; // ??
|
||||
public static final int MATERIAL_BLOOD_STEEL = 0x02; // ??
|
||||
public static final int MATERIAL_BRONZE = 0x03; // ??
|
||||
public static final int MATERIAL_SILVER = 0x04; // ??
|
||||
public static final int MATERIAL_GOLD = 0x05; // ??
|
||||
public static final int MATERIAL_MITHRIL = 0x06; // ??
|
||||
public static final int MATERIAL_ORIHARUKON = 0x07; // ??
|
||||
public static final int MATERIAL_PAPER = 0x08; // ??
|
||||
public static final int MATERIAL_WOOD = 0x09; // ??
|
||||
public static final int MATERIAL_CLOTH = 0x0a; // ??
|
||||
public static final int MATERIAL_LEATHER = 0x0b; // ??
|
||||
public static final int MATERIAL_BONE = 0x0c; // ??
|
||||
public static final int MATERIAL_HORN = 0x0d; // ??
|
||||
public static final int MATERIAL_DAMASCUS = 0x0e; // ??
|
||||
public static final int MATERIAL_ADAMANTAITE = 0x0f; // ??
|
||||
public static final int MATERIAL_CHRYSOLITE = 0x10; // ??
|
||||
public static final int MATERIAL_CRYSTAL = 0x11; // ??
|
||||
public static final int MATERIAL_LIQUID = 0x12; // ??
|
||||
public static final int MATERIAL_SCALE_OF_DRAGON = 0x13; // ??
|
||||
public static final int MATERIAL_DYESTUFF = 0x14; // ??
|
||||
public static final int MATERIAL_COBWEB = 0x15; // ??
|
||||
public static final int MATERIAL_SEED = 0x15; // ??
|
||||
|
||||
public static final int CRYSTAL_NONE = 0x00; // ??
|
||||
public static final int CRYSTAL_D = 0x01; // ??
|
||||
public static final int CRYSTAL_C = 0x02; // ??
|
||||
public static final int CRYSTAL_B = 0x03; // ??
|
||||
public static final int CRYSTAL_A = 0x04; // ??
|
||||
public static final int CRYSTAL_S = 0x05; // ??
|
||||
|
||||
public static final int[] crystalItemId =
|
||||
{
|
||||
0,
|
||||
1458,
|
||||
1459,
|
||||
1460,
|
||||
1461,
|
||||
1462
|
||||
};
|
||||
public static final int[] crystalEnchantBonusArmor =
|
||||
{
|
||||
0,
|
||||
11,
|
||||
6,
|
||||
11,
|
||||
19,
|
||||
25
|
||||
};
|
||||
public static final int[] crystalEnchantBonusWeapon =
|
||||
{
|
||||
0,
|
||||
90,
|
||||
45,
|
||||
67,
|
||||
144,
|
||||
250
|
||||
};
|
||||
|
||||
private final int _itemId;
|
||||
private final String _name;
|
||||
private final int _type1; // needed for item list (inventory)
|
||||
private final int _type2; // different lists for armor, weapon, etc
|
||||
private final int _weight;
|
||||
private final boolean _crystallizable;
|
||||
private final boolean _stackable;
|
||||
private final int _materialType;
|
||||
private final int _crystalType; // default to none-grade
|
||||
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;
|
||||
|
||||
protected final Enum<?> _type;
|
||||
|
||||
protected FuncTemplate[] _funcTemplates;
|
||||
protected EffectTemplate[] _effectTemplates;
|
||||
protected L2Skill[] _skills;
|
||||
|
||||
private static final Func[] _emptyFunctionSet = new Func[0];
|
||||
protected static final L2Effect[] _emptyEffectSet = new L2Effect[0];
|
||||
|
||||
/**
|
||||
* Constructor of the L2Item that fill class variables.<BR>
|
||||
* <BR>
|
||||
* <U><I>Variables filled :</I></U><BR>
|
||||
* <LI>type</LI>
|
||||
* <LI>_itemId</LI>
|
||||
* <LI>_name</LI>
|
||||
* <LI>_type1 & _type2</LI>
|
||||
* <LI>_weight</LI>
|
||||
* <LI>_crystallizable</LI>
|
||||
* <LI>_stackable</LI>
|
||||
* <LI>_materialType & _crystalType & _crystlaCount</LI>
|
||||
* <LI>_durability</LI>
|
||||
* <LI>_bodypart</LI>
|
||||
* <LI>_referencePrice</LI>
|
||||
* <LI>_sellable</LI>
|
||||
* @param type : Enum designating the type of the item
|
||||
* @param set : StatsSet corresponding to a set of couples (key,value) for description of the item
|
||||
*/
|
||||
protected L2Item(Enum<?> type, StatsSet set)
|
||||
{
|
||||
_type = type;
|
||||
_itemId = set.getInteger("item_id");
|
||||
_name = set.getString("name");
|
||||
_type1 = set.getInteger("type1"); // needed for item list (inventory)
|
||||
_type2 = set.getInteger("type2"); // different lists for armor, weapon, etc
|
||||
_weight = set.getInteger("weight");
|
||||
_crystallizable = set.getBool("crystallizable");
|
||||
_stackable = set.getBool("stackable", false);
|
||||
_materialType = set.getInteger("material");
|
||||
_crystalType = set.getInteger("crystal_type", CRYSTAL_NONE); // default to none-grade
|
||||
_bodyPart = set.getInteger("bodypart");
|
||||
_referencePrice = set.getInteger("price");
|
||||
_crystalCount = set.getInteger("crystal_count", 0);
|
||||
_sellable = set.getBool("sellable", true);
|
||||
_dropable = set.getBool("dropable", true);
|
||||
_destroyable = set.getBool("destroyable", true);
|
||||
_tradeable = set.getBool("tradeable", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the itemType.
|
||||
* @return Enum
|
||||
*/
|
||||
public Enum<?> getItemType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the iden
|
||||
* @return int
|
||||
*/
|
||||
public final int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
public abstract int getItemMask();
|
||||
|
||||
/**
|
||||
* Return the type of material of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int 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 _crystallizable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of crystal if item is crystallizable
|
||||
* @return int
|
||||
*/
|
||||
public final int getCrystalType()
|
||||
{
|
||||
return _crystalType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of crystal if item is crystallizable
|
||||
* @return int
|
||||
*/
|
||||
public final int getCrystalItemId()
|
||||
{
|
||||
return crystalItemId[_crystalType];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 int
|
||||
*/
|
||||
public final int getItemGrade()
|
||||
{
|
||||
return getCrystalType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of crystals for crystallization
|
||||
* @return int
|
||||
*/
|
||||
public final int getCrystalCount()
|
||||
{
|
||||
return _crystalCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of crystals for crystallization on specific enchant level
|
||||
* @param enchantLevel
|
||||
* @return int
|
||||
*/
|
||||
public final int getCrystalCount(int enchantLevel)
|
||||
{
|
||||
if (enchantLevel > 3)
|
||||
{
|
||||
switch (_type2)
|
||||
{
|
||||
case TYPE2_SHIELD_ARMOR:
|
||||
case TYPE2_ACCESSORY:
|
||||
return _crystalCount + (crystalEnchantBonusArmor[getCrystalType()] * ((3 * enchantLevel) - 6));
|
||||
case TYPE2_WEAPON:
|
||||
return _crystalCount + (crystalEnchantBonusWeapon[getCrystalType()] * ((2 * enchantLevel) - 3));
|
||||
default:
|
||||
return _crystalCount;
|
||||
}
|
||||
}
|
||||
else if (enchantLevel > 0)
|
||||
{
|
||||
switch (_type2)
|
||||
{
|
||||
case TYPE2_SHIELD_ARMOR:
|
||||
case TYPE2_ACCESSORY:
|
||||
return _crystalCount + (crystalEnchantBonusArmor[getCrystalType()] * enchantLevel);
|
||||
case TYPE2_WEAPON:
|
||||
return _crystalCount + (crystalEnchantBonusWeapon[getCrystalType()] * enchantLevel);
|
||||
default:
|
||||
return _crystalCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return _crystalCount;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the item
|
||||
* @return String
|
||||
*/
|
||||
public final String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the part of the body used with the item.
|
||||
* @return int
|
||||
*/
|
||||
public final int getBodyPart()
|
||||
{
|
||||
return _bodyPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type 1 of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int getType1()
|
||||
{
|
||||
return _type1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item is stackable
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isStackable()
|
||||
{
|
||||
return _stackable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item is consumable
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isConsumable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the price of reference of the item
|
||||
* @return int
|
||||
*/
|
||||
public final int getReferencePrice()
|
||||
{
|
||||
return (isConsumable() ? (int) (_referencePrice * Config.RATE_CONSUMABLE_COST) : _referencePrice);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item can be sold
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isSellable()
|
||||
{
|
||||
return _sellable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item can be dropped
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isDropable()
|
||||
{
|
||||
return _dropable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item can be destroyed
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isDestroyable()
|
||||
{
|
||||
return _destroyable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the item can be traded
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isTradeable()
|
||||
{
|
||||
return _tradeable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if item is for hatchling
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isForHatchling()
|
||||
{
|
||||
return (_type2 == TYPE2_PET_HATCHLING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if item is for strider
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isForStrider()
|
||||
{
|
||||
return (_type2 == TYPE2_PET_STRIDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if item is for wolf
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isForWolf()
|
||||
{
|
||||
return (_type2 == TYPE2_PET_WOLF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of Func objects containing the list of functions used by the item
|
||||
* @param instance : L2ItemInstance pointing out the item
|
||||
* @param player : L2Character pointing out the player
|
||||
* @return Func[] : array of functions
|
||||
*/
|
||||
public Func[] getStatFuncs(L2ItemInstance instance, L2Character player)
|
||||
{
|
||||
if (_funcTemplates == null)
|
||||
{
|
||||
return _emptyFunctionSet;
|
||||
}
|
||||
final List<Func> funcs = new FastList<>();
|
||||
for (final FuncTemplate t : _funcTemplates)
|
||||
{
|
||||
final Env env = new Env();
|
||||
env.player = player;
|
||||
env.target = player;
|
||||
env.item = instance;
|
||||
final Func f = t.getFunc(env, this); // skill is owner
|
||||
if (f != null)
|
||||
{
|
||||
funcs.add(f);
|
||||
}
|
||||
}
|
||||
if (funcs.size() == 0)
|
||||
{
|
||||
return _emptyFunctionSet;
|
||||
}
|
||||
return funcs.toArray(new Func[funcs.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the effects associated with the item.
|
||||
* @param instance : L2ItemInstance pointing out the item
|
||||
* @param player : L2Character pointing out the player
|
||||
* @return L2Effect[] : array of effects generated by the item
|
||||
*/
|
||||
public L2Effect[] getEffects(L2ItemInstance instance, L2Character player)
|
||||
{
|
||||
if (_effectTemplates == null)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
final List<L2Effect> effects = new FastList<>();
|
||||
for (final EffectTemplate et : _effectTemplates)
|
||||
{
|
||||
final Env env = new Env();
|
||||
env.player = player;
|
||||
env.target = player;
|
||||
env.item = instance;
|
||||
final L2Effect e = et.getEffect(env);
|
||||
if (e != null)
|
||||
{
|
||||
effects.add(e);
|
||||
}
|
||||
}
|
||||
if (effects.size() == 0)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
return effects.toArray(new L2Effect[effects.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns effects of skills associated with the item.
|
||||
* @param caster : L2Character pointing out the caster
|
||||
* @param target : L2Character pointing out the target
|
||||
* @return L2Effect[] : array of effects generated by the skill
|
||||
*/
|
||||
public L2Effect[] getSkillEffects(L2Character caster, L2Character target)
|
||||
{
|
||||
if (_skills == null)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
final List<L2Effect> effects = new FastList<>();
|
||||
|
||||
for (final L2Skill skill : _skills)
|
||||
{
|
||||
if (!skill.checkCondition(caster, true))
|
||||
{
|
||||
continue; // Skill condition not met
|
||||
}
|
||||
|
||||
if (target.getFirstEffect(skill.getId()) != null)
|
||||
{
|
||||
target.removeEffect(target.getFirstEffect(skill.getId()));
|
||||
}
|
||||
for (final L2Effect e : skill.getEffects(caster, target))
|
||||
{
|
||||
effects.add(e);
|
||||
}
|
||||
}
|
||||
if (effects.size() == 0)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
return effects.toArray(new L2Effect[effects.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the FuncTemplate f to the list of functions used with the item
|
||||
* @param f : FuncTemplate to add
|
||||
*/
|
||||
public void attach(FuncTemplate f)
|
||||
{
|
||||
// If _functTemplates is empty, create it and add the FuncTemplate f in it
|
||||
if (_funcTemplates == null)
|
||||
{
|
||||
_funcTemplates = new FuncTemplate[]
|
||||
{
|
||||
f
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
final int len = _funcTemplates.length;
|
||||
final FuncTemplate[] tmp = new FuncTemplate[len + 1];
|
||||
// Definition : arraycopy(array source, begins copy at this position of source, array destination, begins copy at this position in dest,
|
||||
// number of components to be copied)
|
||||
System.arraycopy(_funcTemplates, 0, tmp, 0, len);
|
||||
tmp[len] = f;
|
||||
_funcTemplates = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the EffectTemplate effect to the list of effects generated by the item
|
||||
* @param effect : EffectTemplate
|
||||
*/
|
||||
public void attach(EffectTemplate effect)
|
||||
{
|
||||
if (_effectTemplates == null)
|
||||
{
|
||||
_effectTemplates = new EffectTemplate[]
|
||||
{
|
||||
effect
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
final int len = _effectTemplates.length;
|
||||
final EffectTemplate[] tmp = new EffectTemplate[len + 1];
|
||||
// Definition : arraycopy(array source, begins copy at this position of source, array destination, begins copy at this position in dest,
|
||||
// number of components to be copied)
|
||||
System.arraycopy(_effectTemplates, 0, tmp, 0, len);
|
||||
tmp[len] = effect;
|
||||
_effectTemplates = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the L2Skill skill to the list of skills generated by the item
|
||||
* @param skill : L2Skill
|
||||
*/
|
||||
public void attach(L2Skill skill)
|
||||
{
|
||||
if (_skills == null)
|
||||
{
|
||||
_skills = new L2Skill[]
|
||||
{
|
||||
skill
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
final int len = _skills.length;
|
||||
final L2Skill[] tmp = new L2Skill[len + 1];
|
||||
// Definition : arraycopy(array source, begins copy at this position of source, array destination, begins copy at this position in dest,
|
||||
// number of components to be copied)
|
||||
System.arraycopy(_skills, 0, tmp, 0, len);
|
||||
tmp[len] = skill;
|
||||
_skills = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the item
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2DropCategory;
|
||||
import com.l2jmobius.gameserver.model.L2DropData;
|
||||
import com.l2jmobius.gameserver.model.L2MinionData;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
/**
|
||||
* This cl contains all generic data of a L2Spawn object.<BR>
|
||||
* <BR>
|
||||
* <B><U> Data</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>npcId, type, name, sex</li>
|
||||
* <li>rewardExp, rewardSp</li>
|
||||
* <li>aggroRange, factionId, factionRange</li>
|
||||
* <li>rhand, lhand, armor</li>
|
||||
* <li>isUndead</li>
|
||||
* <li>_drops</li>
|
||||
* <li>_minions</li>
|
||||
* <li>_teachInfo</li>
|
||||
* <li>_skills</li>
|
||||
* <li>_questsStart</li><BR>
|
||||
* <BR>
|
||||
* @version $Revision: 1.1.2.4 $ $Date: 2005/04/02 15:57:51 $
|
||||
*/
|
||||
public final class L2NpcTemplate extends L2CharTemplate
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(L2NpcTemplate.class.getName());
|
||||
|
||||
public final int npcId;
|
||||
public final int idTemplate;
|
||||
public final String type;
|
||||
public final String name;
|
||||
public final boolean serverSideName;
|
||||
public final String title;
|
||||
public final boolean serverSideTitle;
|
||||
public final String sex;
|
||||
public final byte level;
|
||||
public final int rewardExp;
|
||||
public final int rewardSp;
|
||||
public final int aggroRange;
|
||||
public final int rhand;
|
||||
public final int lhand;
|
||||
public final int armor;
|
||||
public final String factionId;
|
||||
public final int factionRange;
|
||||
public final int absorb_level;
|
||||
public final short ss;
|
||||
public final short bss;
|
||||
public final short ssRate;
|
||||
|
||||
public boolean isQuestMonster = false;
|
||||
|
||||
public int race;
|
||||
public final String jClass;
|
||||
public final String AI;
|
||||
|
||||
/** The table containing all Item that can be dropped by L2NpcInstance using this L2NpcTemplate */
|
||||
private FastList<L2DropCategory> _categories = null;
|
||||
|
||||
/** The table containing all Minions that must be spawn with the L2NpcInstance using this L2NpcTemplate */
|
||||
private List<L2MinionData> _minions = null;
|
||||
|
||||
private List<ClassId> _teachInfo;
|
||||
private Map<Integer, L2Skill> _skills;
|
||||
private Map<Stats, Double> _vulnerabilities;
|
||||
// contains a list of quests for each event type (questStart, questAttack, questKill, etc)
|
||||
public Map<Quest.QuestEventType, Quest[]> questEvents;
|
||||
|
||||
/**
|
||||
* Constructor of L2Character.<BR>
|
||||
* <BR>
|
||||
* @param set The StatsSet object to transfer data to the method
|
||||
*/
|
||||
public L2NpcTemplate(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
npcId = set.getInteger("npcId");
|
||||
idTemplate = set.getInteger("idTemplate");
|
||||
type = set.getString("type");
|
||||
name = set.getString("name");
|
||||
serverSideName = set.getBool("serverSideName");
|
||||
title = set.getString("title");
|
||||
if (title.equalsIgnoreCase("Quest Monster"))
|
||||
{
|
||||
isQuestMonster = true;
|
||||
}
|
||||
serverSideTitle = set.getBool("serverSideTitle");
|
||||
sex = set.getString("sex");
|
||||
level = set.getByte("level");
|
||||
rewardExp = set.getInteger("rewardExp");
|
||||
rewardSp = set.getInteger("rewardSp");
|
||||
aggroRange = set.getInteger("aggroRange");
|
||||
rhand = set.getInteger("rhand");
|
||||
lhand = set.getInteger("lhand");
|
||||
armor = set.getInteger("armor");
|
||||
|
||||
final String f = set.getString("factionId", null);
|
||||
if (f == null)
|
||||
{
|
||||
factionId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
factionId = f.intern();
|
||||
}
|
||||
|
||||
factionRange = set.getInteger("factionRange");
|
||||
absorb_level = set.getInteger("absorb_level", 0);
|
||||
ss = (short) set.getInteger("ss", 0);
|
||||
bss = (short) set.getInteger("bss", 0);
|
||||
ssRate = (short) set.getInteger("ssRate", 0);
|
||||
race = 0;
|
||||
jClass = set.getString("jClass");
|
||||
AI = set.getString("AI");
|
||||
_teachInfo = null;
|
||||
}
|
||||
|
||||
public void addTeachInfo(ClassId classId)
|
||||
{
|
||||
if (_teachInfo == null)
|
||||
{
|
||||
_teachInfo = new FastList<>();
|
||||
}
|
||||
_teachInfo.add(classId);
|
||||
}
|
||||
|
||||
public ClassId[] getTeachInfo()
|
||||
{
|
||||
if (_teachInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _teachInfo.toArray(new ClassId[_teachInfo.size()]);
|
||||
}
|
||||
|
||||
public boolean canTeach(ClassId classId)
|
||||
{
|
||||
if (_teachInfo == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the player is on a third class, fetch the class teacher
|
||||
// information for its parent class.
|
||||
if (classId.getId() >= 88)
|
||||
{
|
||||
return _teachInfo.contains(classId.getParent());
|
||||
}
|
||||
|
||||
return _teachInfo.contains(classId);
|
||||
}
|
||||
|
||||
// add a drop to a given category. If the category does not exist, create it.
|
||||
public void addDropData(L2DropData drop, int categoryType)
|
||||
{
|
||||
if (!drop.isQuestDrop())
|
||||
{
|
||||
// if the category doesn't already exist, create it first
|
||||
if (_categories == null)
|
||||
{
|
||||
_categories = new FastList<>();
|
||||
}
|
||||
|
||||
synchronized (_categories)
|
||||
{
|
||||
boolean catExists = false;
|
||||
for (final L2DropCategory cat : _categories)
|
||||
{
|
||||
// if the category exists, add the drop to this category.
|
||||
if (cat.getCategoryType() == categoryType)
|
||||
{
|
||||
cat.addDropData(drop, type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss"));
|
||||
catExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if the category doesn't exit, create it and add the drop
|
||||
if (!catExists)
|
||||
{
|
||||
final L2DropCategory cat = new L2DropCategory(categoryType);
|
||||
cat.addDropData(drop, type.equalsIgnoreCase("L2RaidBoss") || type.equalsIgnoreCase("L2GrandBoss"));
|
||||
_categories.add(cat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addRaidData(L2MinionData minion)
|
||||
{
|
||||
if (_minions == null)
|
||||
{
|
||||
_minions = new FastList<>();
|
||||
}
|
||||
_minions.add(minion);
|
||||
}
|
||||
|
||||
public void addSkill(L2Skill skill)
|
||||
{
|
||||
if (_skills == null)
|
||||
{
|
||||
_skills = new FastMap<>();
|
||||
}
|
||||
_skills.put(skill.getId(), skill);
|
||||
}
|
||||
|
||||
public void addVulnerability(Stats id, double vuln)
|
||||
{
|
||||
if (_vulnerabilities == null)
|
||||
{
|
||||
_vulnerabilities = new FastMap<>();
|
||||
}
|
||||
_vulnerabilities.put(id, new Double(vuln));
|
||||
}
|
||||
|
||||
public double getVulnerability(Stats id)
|
||||
{
|
||||
if ((_vulnerabilities == null) || (_vulnerabilities.get(id) == null))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return _vulnerabilities.get(id);
|
||||
}
|
||||
|
||||
public double removeVulnerability(Stats id)
|
||||
{
|
||||
return _vulnerabilities.remove(id);
|
||||
}
|
||||
|
||||
public FastList<L2DropCategory> getDropData()
|
||||
{
|
||||
return _categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of all possible item drops of this L2NpcTemplate.<BR>
|
||||
* (ie full drops and part drops, mats, miscellaneous & UNCATEGORIZED)<BR>
|
||||
* <BR>
|
||||
* @return
|
||||
*/
|
||||
public List<L2DropData> getAllDropData()
|
||||
{
|
||||
if (_categories == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<L2DropData> lst = new FastList<>();
|
||||
for (final L2DropCategory tmp : _categories)
|
||||
{
|
||||
lst.addAll(tmp.getAllDrops());
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty all possible drops of this L2NpcTemplate.<BR>
|
||||
* <BR>
|
||||
*/
|
||||
public synchronized void clearAllDropData()
|
||||
{
|
||||
if (_categories == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (_categories.size() > 0)
|
||||
{
|
||||
_categories.getFirst().clearAllDrops();
|
||||
_categories.removeFirst();
|
||||
}
|
||||
_categories.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of all Minions that must be spawn with the L2NpcInstance using this L2NpcTemplate.<BR>
|
||||
* <BR>
|
||||
* @return
|
||||
*/
|
||||
public List<L2MinionData> getMinionData()
|
||||
{
|
||||
return _minions;
|
||||
}
|
||||
|
||||
public Map<Integer, L2Skill> getSkills()
|
||||
{
|
||||
return _skills;
|
||||
}
|
||||
|
||||
public void addQuestEvent(Quest.QuestEventType EventType, Quest q)
|
||||
{
|
||||
if (questEvents == null)
|
||||
{
|
||||
questEvents = new FastMap<>();
|
||||
}
|
||||
|
||||
if (questEvents.get(EventType) == null)
|
||||
{
|
||||
questEvents.put(EventType, new Quest[]
|
||||
{
|
||||
q
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
final Quest[] _quests = questEvents.get(EventType);
|
||||
final int len = _quests.length;
|
||||
|
||||
// if only one registration per npc is allowed for this event type
|
||||
// then only register this NPC if not already registered for the specified event.
|
||||
// if a quest allows multiple registrations, then register regardless of count
|
||||
// In all cases, check if this new registration is replacing an older copy of the SAME quest
|
||||
if (!EventType.isMultipleRegistrationAllowed())
|
||||
{
|
||||
if (_quests[0].getName().equals(q.getName()))
|
||||
{
|
||||
_quests[0] = q;
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Quest event not allowed in multiple quests. Skipped addition of Event Type \"" + EventType + "\" for NPC \"" + name + "\" and quest \"" + q.getName() + "\".");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// be ready to add a new quest to a new copy of the list, with larger size than previously.
|
||||
final Quest[] tmp = new Quest[len + 1];
|
||||
// loop through the existing quests and copy them to the new list. While doing so, also
|
||||
// check if this new quest happens to be just a replacement for a previously loaded quest.
|
||||
// If so, just save the updated reference and do NOT use the new list. Else, add the new
|
||||
// quest to the end of the new list
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (_quests[i].getName().equals(q.getName()))
|
||||
{
|
||||
_quests[i] = q;
|
||||
return;
|
||||
}
|
||||
tmp[i] = _quests[i];
|
||||
}
|
||||
tmp[len] = q;
|
||||
questEvents.put(EventType, tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Quest[] getEventQuests(Quest.QuestEventType EventType)
|
||||
{
|
||||
if (questEvents == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return questEvents.get(EventType);
|
||||
}
|
||||
|
||||
public void setRace(int newrace)
|
||||
{
|
||||
race = newrace;
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.base.ClassId;
|
||||
import com.l2jmobius.gameserver.model.base.Race;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class L2PcTemplate extends L2CharTemplate
|
||||
{
|
||||
/** The Class object of the L2PcInstance */
|
||||
public final ClassId classId;
|
||||
|
||||
public final Race race;
|
||||
public final String className;
|
||||
|
||||
public final int spawnX;
|
||||
public final int spawnY;
|
||||
public final int spawnZ;
|
||||
|
||||
public final int classBaseLevel;
|
||||
public final float lvlHpAdd;
|
||||
public final float lvlHpMod;
|
||||
public final float lvlCpAdd;
|
||||
public final float lvlCpMod;
|
||||
public final float lvlMpAdd;
|
||||
public final float lvlMpMod;
|
||||
|
||||
public final double collisionHeight_female;
|
||||
public final double collisionRadius_female;
|
||||
|
||||
private final List<L2Item> _items = new FastList<>();
|
||||
|
||||
public L2PcTemplate(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
classId = ClassId.values()[set.getInteger("classId")];
|
||||
race = Race.values()[set.getInteger("raceId")];
|
||||
className = set.getString("className");
|
||||
|
||||
spawnX = set.getInteger("spawnX");
|
||||
spawnY = set.getInteger("spawnY");
|
||||
spawnZ = set.getInteger("spawnZ");
|
||||
|
||||
classBaseLevel = set.getInteger("classBaseLevel");
|
||||
lvlHpAdd = set.getFloat("lvlHpAdd");
|
||||
lvlHpMod = set.getFloat("lvlHpMod");
|
||||
lvlCpAdd = set.getFloat("lvlCpAdd");
|
||||
lvlCpMod = set.getFloat("lvlCpMod");
|
||||
lvlMpAdd = set.getFloat("lvlMpAdd");
|
||||
lvlMpMod = set.getFloat("lvlMpMod");
|
||||
|
||||
collisionRadius_female = set.getDouble("collision_radius_female");
|
||||
collisionHeight_female = set.getDouble("collision_height_female");
|
||||
}
|
||||
|
||||
/**
|
||||
* add starter equipment
|
||||
* @param itemId
|
||||
*/
|
||||
public void addItem(int itemId)
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(itemId);
|
||||
if (item != null)
|
||||
{
|
||||
_items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return itemIds of all the starter equipment
|
||||
*/
|
||||
public L2Item[] getItems()
|
||||
{
|
||||
return _items.toArray(new L2Item[_items.size()]);
|
||||
}
|
||||
|
||||
public final int getFallHeight()
|
||||
{
|
||||
return 333;
|
||||
}
|
||||
}
|
@@ -0,0 +1,439 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Formulas;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionGameChance;
|
||||
import com.l2jmobius.gameserver.skills.funcs.Func;
|
||||
import com.l2jmobius.gameserver.skills.funcs.FuncTemplate;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* This class is dedicated to the management of weapons.
|
||||
* @version $Revision: 1.4.2.3.2.5 $ $Date: 2005/04/02 15:57:51 $
|
||||
*/
|
||||
public final class L2Weapon extends L2Item
|
||||
{
|
||||
private final int _soulShotCount;
|
||||
private final int _spiritShotCount;
|
||||
private final int _pDam;
|
||||
private final int _rndDam;
|
||||
private final int _critical;
|
||||
private final double _hitModifier;
|
||||
private final int _avoidModifier;
|
||||
private final int _shieldDef;
|
||||
private final double _shieldDefRate;
|
||||
private final int _atkSpeed;
|
||||
private final int _atkReuse;
|
||||
private final int _mpConsume;
|
||||
private final int _mDam;
|
||||
|
||||
private L2Skill _itemSkill = null; // for passive skill
|
||||
|
||||
// Attached skills for Special Abilities
|
||||
protected L2Skill[] _skillsOnCast;
|
||||
protected L2Skill[] _skillsOnCrit;
|
||||
|
||||
/**
|
||||
* Constructor for Weapon.<BR>
|
||||
* <BR>
|
||||
* <U><I>Variables filled :</I></U><BR>
|
||||
* <LI>_soulShotCount & _spiritShotCount</LI>
|
||||
* <LI>_pDam & _mDam & _rndDam</LI>
|
||||
* <LI>_critical</LI>
|
||||
* <LI>_hitModifier</LI>
|
||||
* <LI>_avoidModifier</LI>
|
||||
* <LI>_shieldDes & _shieldDefRate</LI>
|
||||
* <LI>_atkSpeed & _AtkReuse</LI>
|
||||
* <LI>_mpConsume</LI>
|
||||
* @param type : L2ArmorType designating the type of armor
|
||||
* @param set : StatsSet designating the set of couples (key,value) caracterizing the armor
|
||||
* @see L2Item constructor
|
||||
*/
|
||||
public L2Weapon(L2WeaponType type, StatsSet set)
|
||||
{
|
||||
super(type, set);
|
||||
_soulShotCount = set.getInteger("soulshots");
|
||||
_spiritShotCount = set.getInteger("spiritshots");
|
||||
_pDam = set.getInteger("p_dam");
|
||||
_rndDam = set.getInteger("rnd_dam");
|
||||
_critical = set.getInteger("critical");
|
||||
_hitModifier = set.getDouble("hit_modify");
|
||||
_avoidModifier = set.getInteger("avoid_modify");
|
||||
_shieldDef = set.getInteger("shield_def");
|
||||
_shieldDefRate = set.getDouble("shield_def_rate");
|
||||
_atkSpeed = set.getInteger("atk_speed");
|
||||
_atkReuse = set.getInteger("atk_reuse", type == L2WeaponType.BOW ? 1500 : 0);
|
||||
_mpConsume = set.getInteger("mp_consume");
|
||||
_mDam = set.getInteger("m_dam");
|
||||
|
||||
int sId = set.getInteger("item_skill_id");
|
||||
int sLv = set.getInteger("item_skill_lvl");
|
||||
if ((sId > 0) && (sLv > 0))
|
||||
{
|
||||
_itemSkill = SkillTable.getInstance().getInfo(sId, sLv);
|
||||
}
|
||||
|
||||
sId = set.getInteger("onCast_skill_id");
|
||||
sLv = set.getInteger("onCast_skill_lvl");
|
||||
int sCh = set.getInteger("onCast_skill_chance");
|
||||
if ((sId > 0) && (sLv > 0) && (sCh > 0))
|
||||
{
|
||||
final L2Skill skill = SkillTable.getInstance().getInfo(sId, sLv);
|
||||
skill.attach(new ConditionGameChance(sCh), true);
|
||||
attachOnCast(skill);
|
||||
}
|
||||
|
||||
sId = set.getInteger("onCrit_skill_id");
|
||||
sLv = set.getInteger("onCrit_skill_lvl");
|
||||
sCh = set.getInteger("onCrit_skill_chance");
|
||||
if ((sId > 0) && (sLv > 0) && (sCh > 0))
|
||||
{
|
||||
final L2Skill skill = SkillTable.getInstance().getInfo(sId, sLv);
|
||||
skill.attach(new ConditionGameChance(sCh), true);
|
||||
attachOnCrit(skill);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of Weapon
|
||||
* @return L2WeaponType
|
||||
*/
|
||||
@Override
|
||||
public L2WeaponType getItemType()
|
||||
{
|
||||
return (L2WeaponType) super._type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the Etc item after applying the mask.
|
||||
* @return int : ID of the Weapon
|
||||
*/
|
||||
@Override
|
||||
public int getItemMask()
|
||||
{
|
||||
return getItemType().mask();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of SoulShot used.
|
||||
* @return int
|
||||
*/
|
||||
public int getSoulShotCount()
|
||||
{
|
||||
return _soulShotCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quatity of SpiritShot used.
|
||||
* @return int
|
||||
*/
|
||||
public int getSpiritShotCount()
|
||||
{
|
||||
return _spiritShotCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the physical damage.
|
||||
* @return int
|
||||
*/
|
||||
public int getPDamage()
|
||||
{
|
||||
return _pDam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the random damage inflicted by the weapon
|
||||
* @return int
|
||||
*/
|
||||
public int getRandomDamage()
|
||||
{
|
||||
return _rndDam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attack speed of the weapon
|
||||
* @return int
|
||||
*/
|
||||
public int getAttackSpeed()
|
||||
{
|
||||
return _atkSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Attack Reuse Delay of the L2Weapon.<BR>
|
||||
* <BR>
|
||||
* @return int
|
||||
*/
|
||||
public int getAttackReuseDelay()
|
||||
{
|
||||
return _atkReuse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the avoid modifier of the weapon
|
||||
* @return int
|
||||
*/
|
||||
public int getAvoidModifier()
|
||||
{
|
||||
return _avoidModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rate of critical hit
|
||||
* @return int
|
||||
*/
|
||||
public int getCritical()
|
||||
{
|
||||
return _critical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hit modifier of the weapon
|
||||
* @return double
|
||||
*/
|
||||
public double getHitModifier()
|
||||
{
|
||||
return _hitModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the magical damage inflicted by the weapon
|
||||
* @return int
|
||||
*/
|
||||
public int getMDamage()
|
||||
{
|
||||
return _mDam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MP consumption with the weapon
|
||||
* @return int
|
||||
*/
|
||||
public int getMpConsume()
|
||||
{
|
||||
return _mpConsume;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shield defense of the weapon
|
||||
* @return int
|
||||
*/
|
||||
public int getShieldDef()
|
||||
{
|
||||
return _shieldDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rate of shield defense of the weapon
|
||||
* @return double
|
||||
*/
|
||||
public double getShieldDefRate()
|
||||
{
|
||||
return _shieldDefRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns passive skill linked to that weapon
|
||||
* @return
|
||||
*/
|
||||
public L2Skill getSkill()
|
||||
{
|
||||
return _itemSkill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of Func objects containing the list of functions used by the weapon
|
||||
* @param instance : L2ItemInstance pointing out the weapon
|
||||
* @param player : L2Character pointing out the player
|
||||
* @return Func[] : array of functions
|
||||
*/
|
||||
@Override
|
||||
public Func[] getStatFuncs(L2ItemInstance instance, L2Character player)
|
||||
{
|
||||
final List<Func> funcs = new FastList<>();
|
||||
if (_funcTemplates != null)
|
||||
{
|
||||
for (final FuncTemplate t : _funcTemplates)
|
||||
{
|
||||
final Env env = new Env();
|
||||
env.player = player;
|
||||
env.item = instance;
|
||||
final Func f = t.getFunc(env, instance);
|
||||
if (f != null)
|
||||
{
|
||||
funcs.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return funcs.toArray(new Func[funcs.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns effects of skills associated with the item to be triggered onHit.
|
||||
* @param caster : L2Character pointing out the caster
|
||||
* @param target : L2Character pointing out the target
|
||||
* @return L2Effect[] : array of effects generated by the skill
|
||||
*/
|
||||
@Override
|
||||
public L2Effect[] getSkillEffects(L2Character caster, L2Character target)
|
||||
{
|
||||
if (_skillsOnCrit == null)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
|
||||
final List<L2Effect> effects = new FastList<>();
|
||||
|
||||
for (final L2Skill skill : _skillsOnCrit)
|
||||
{
|
||||
if (!skill.checkCondition(caster, true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Formulas.getInstance().calcSkillSuccess(caster, target, skill, false, false, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (final L2Effect e : skill.getEffects(caster, target))
|
||||
{
|
||||
effects.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (effects.size() == 0)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
|
||||
return effects.toArray(new L2Effect[effects.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns effects of skills associated with the item to be triggered onCast.
|
||||
* @param caster : L2Character pointing out the caster
|
||||
* @param target : L2Character pointing out the target
|
||||
* @param trigger : L2Skill pointing out the skill triggering this action
|
||||
* @return L2Effect[] : array of effects generated by the skill
|
||||
*/
|
||||
public L2Effect[] getSkillEffects(L2Character caster, L2Character target, L2Skill trigger)
|
||||
{
|
||||
if (_skillsOnCast == null)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
|
||||
final List<L2Effect> effects = new FastList<>();
|
||||
|
||||
for (final L2Skill skill : _skillsOnCast)
|
||||
{
|
||||
if (!skill.checkCondition(caster, true))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trigger.isOffensive() != skill.isOffensive())
|
||||
{
|
||||
continue; // Trigger only same type of skill
|
||||
}
|
||||
|
||||
if (trigger.isToggle() && (skill.getSkillType() == SkillType.BUFF))
|
||||
{
|
||||
continue; // No buffing with toggle skills
|
||||
}
|
||||
|
||||
if (skill.isOffensive() && !Formulas.getInstance().calcSkillSuccess(caster, target, skill, false, false, false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (final L2Effect e : skill.getEffects(caster, target))
|
||||
{
|
||||
effects.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (effects.size() == 0)
|
||||
{
|
||||
return _emptyEffectSet;
|
||||
}
|
||||
|
||||
return effects.toArray(new L2Effect[effects.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the L2Skill skill to the list of skills generated by the item triggered by critical hit
|
||||
* @param skill : L2Skill
|
||||
*/
|
||||
public void attachOnCrit(L2Skill skill)
|
||||
{
|
||||
if (_skillsOnCrit == null)
|
||||
{
|
||||
_skillsOnCrit = new L2Skill[]
|
||||
{
|
||||
skill
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
final int len = _skillsOnCrit.length;
|
||||
final L2Skill[] tmp = new L2Skill[len + 1];
|
||||
// Definition : arraycopy(array source, begins copy at this position of source, array destination, begins copy at this position in dest,
|
||||
// number of components to be copied)
|
||||
System.arraycopy(_skillsOnCrit, 0, tmp, 0, len);
|
||||
tmp[len] = skill;
|
||||
_skillsOnCrit = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the L2Skill skill to the list of skills generated by the item triggered by casting spell
|
||||
* @param skill : L2Skill
|
||||
*/
|
||||
public void attachOnCast(L2Skill skill)
|
||||
{
|
||||
if (_skillsOnCast == null)
|
||||
{
|
||||
_skillsOnCast = new L2Skill[]
|
||||
{
|
||||
skill
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
final int len = _skillsOnCast.length;
|
||||
final L2Skill[] tmp = new L2Skill[len + 1];
|
||||
// Definition : arraycopy(array source, begins copy at this position of source, array destination, begins copy at this position in dest,
|
||||
// number of components to be copied)
|
||||
System.arraycopy(_skillsOnCast, 0, tmp, 0, len);
|
||||
tmp[len] = skill;
|
||||
_skillsOnCast = tmp;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
/**
|
||||
* @author mkizub <BR>
|
||||
* Description of Weapon Type
|
||||
*/
|
||||
public enum L2WeaponType
|
||||
{
|
||||
NONE(1, "Shield"), // Shields!!!
|
||||
SWORD(2, "Sword"),
|
||||
BLUNT(3, "Blunt"),
|
||||
DAGGER(4, "Dagger"),
|
||||
BOW(5, "Bow"),
|
||||
POLE(6, "Pole"),
|
||||
ETC(7, "Etc"),
|
||||
FIST(8, "Fist"),
|
||||
DUAL(9, "Dual Sword"),
|
||||
DUALFIST(10, "Dual Fist"),
|
||||
BIGSWORD(11, "Big Sword"), // Two Handed Sword
|
||||
PET(12, "Pet"),
|
||||
ROD(13, "Rod"),
|
||||
BIGBLUNT(14, "Big Blunt"); // Two Handed Blunt
|
||||
|
||||
private final int _id;
|
||||
private final String _name;
|
||||
|
||||
/**
|
||||
* Constructor of the L2WeaponType.
|
||||
* @param id : int designating the ID of the WeaponType
|
||||
* @param name : String designating the name of the WeaponType
|
||||
*/
|
||||
private L2WeaponType(int id, String name)
|
||||
{
|
||||
_id = id;
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the item after applying the mask.
|
||||
* @return int : ID of the item
|
||||
*/
|
||||
public int mask()
|
||||
{
|
||||
return 1 << _id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the WeaponType
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,575 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.templates;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javolution.util.FastMap;
|
||||
|
||||
/**
|
||||
* @author mkizub <BR>
|
||||
* This class is used in order to have a set of couples (key,value).<BR>
|
||||
* Methods deployed are accessors to the set (add/get value from its key) and addition of a whole set in the current one.
|
||||
*/
|
||||
public final class StatsSet
|
||||
{
|
||||
private final Map<String, Object> _set = new FastMap<>();
|
||||
|
||||
/**
|
||||
* Returns the set of values
|
||||
* @return HashMap
|
||||
*/
|
||||
public final Map<String, Object> getSet()
|
||||
{
|
||||
return _set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a set of couple values in the current set
|
||||
* @param newSet : StatsSet pointing out the list of couples to add in the current set
|
||||
*/
|
||||
public void add(StatsSet newSet)
|
||||
{
|
||||
final Map<String, Object> newMap = newSet.getSet();
|
||||
for (final String key : newMap.keySet())
|
||||
{
|
||||
final Object value = newMap.get(key);
|
||||
_set.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the boolean associated to the key put in parameter ("name")
|
||||
* @param name : String designating the key in the set
|
||||
* @return boolean : value associated to the key
|
||||
*/
|
||||
public boolean getBool(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Boolean value required, but not specified");
|
||||
}
|
||||
if (val instanceof Boolean)
|
||||
{
|
||||
return ((Boolean) val).booleanValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Boolean.parseBoolean((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Boolean value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the boolean associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : boolean designating the default value if value associated with the key is null
|
||||
* @return boolean : value of the key
|
||||
*/
|
||||
public boolean getBool(String name, boolean deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (val instanceof Boolean)
|
||||
{
|
||||
return ((Boolean) val).booleanValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Boolean.parseBoolean((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Boolean value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the int associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : byte designating the default value if value associated with the key is null
|
||||
* @return byte : value associated to the key
|
||||
*/
|
||||
public byte getByte(String name, byte deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).byteValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Byte.parseByte((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Byte value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the byte associated to the key put in parameter ("name").
|
||||
* @param name : String designating the key in the set
|
||||
* @return byte : value associated to the key
|
||||
*/
|
||||
public byte getByte(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Byte value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).byteValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Byte.parseByte((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Byte value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the short associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : short designating the default value if value associated with the key is null
|
||||
* @return short : value associated to the key
|
||||
*/
|
||||
public short getShort(String name, short deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).shortValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Short.parseShort((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Short value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the short associated to the key put in parameter ("name").
|
||||
* @param name : String designating the key in the set
|
||||
* @return short : value associated to the key
|
||||
*/
|
||||
public short getShort(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Short value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).shortValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Short.parseShort((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Short value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the int associated to the key put in parameter ("name").
|
||||
* @param name : String designating the key in the set
|
||||
* @return int : value associated to the key
|
||||
*/
|
||||
public int getInteger(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).intValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Integer.parseInt((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the int associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : int designating the default value if value associated with the key is null
|
||||
* @return int : value associated to the key
|
||||
*/
|
||||
public int getInteger(String name, int deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).intValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Integer.parseInt((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the long associated to the key put in parameter ("name").
|
||||
* @param name : String designating the key in the set
|
||||
* @return long : value associated to the key
|
||||
*/
|
||||
public long getLong(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).longValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Long.parseLong((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the long associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : long designating the default value if value associated with the key is null
|
||||
* @return long : value associated to the key
|
||||
*/
|
||||
public long getLong(String name, int deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).longValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Long.parseLong((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Integer value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the float associated to the key put in parameter ("name").
|
||||
* @param name : String designating the key in the set
|
||||
* @return float : value associated to the key
|
||||
*/
|
||||
public float getFloat(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).floatValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return (float) Double.parseDouble((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the float associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : float designating the default value if value associated with the key is null
|
||||
* @return float : value associated to the key
|
||||
*/
|
||||
public float getFloat(String name, float deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).floatValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return (float) Double.parseDouble((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the double associated to the key put in parameter ("name").
|
||||
* @param name : String designating the key in the set
|
||||
* @return double : value associated to the key
|
||||
*/
|
||||
public double getDouble(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but not specified");
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).doubleValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Double.parseDouble((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the double associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : float designating the default value if value associated with the key is null
|
||||
* @return double : value associated to the key
|
||||
*/
|
||||
public double getDouble(String name, float deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (val instanceof Number)
|
||||
{
|
||||
return ((Number) val).doubleValue();
|
||||
}
|
||||
try
|
||||
{
|
||||
return Double.parseDouble((String) val);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Float value required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the String associated to the key put in parameter ("name").
|
||||
* @param name : String designating the key in the set
|
||||
* @return String : value associated to the key
|
||||
*/
|
||||
public String getString(String name)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("String value required, but not specified");
|
||||
}
|
||||
return String.valueOf(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the String associated to the key put in parameter ("name"). If the value associated to the key is null, this method returns the value of the parameter deflt.
|
||||
* @param name : String designating the key in the set
|
||||
* @param deflt : String designating the default value if value associated with the key is null
|
||||
* @return String : value associated to the key
|
||||
*/
|
||||
public String getString(String name, String deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
return String.valueOf(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of <T> from the set
|
||||
* @param <T> : Class of the enumeration returned
|
||||
* @param name : String designating the key in the set
|
||||
* @param enumClass : Class designating the class of the value associated with the key in the set
|
||||
* @return Enum<T>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Enum<T>> T getEnum(String name, Class<T> enumClass)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Enum value of type " + enumClass.getName() + " required, but not specified");
|
||||
}
|
||||
if (enumClass.isInstance(val))
|
||||
{
|
||||
return (T) val;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Enum.valueOf(enumClass, String.valueOf(val));
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Enum value of type " + enumClass.getName() + "required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of <T> from the set. If the enumeration is empty, the method returns the value of the parameter "deflt".
|
||||
* @param <T> : Class of the enumeration returned
|
||||
* @param name : String designating the key in the set
|
||||
* @param enumClass : Class designating the class of the value associated with the key in the set
|
||||
* @param deflt : <T> designating the value by default
|
||||
* @return Enum<T>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Enum<T>> T getEnum(String name, Class<T> enumClass, T deflt)
|
||||
{
|
||||
final Object val = _set.get(name);
|
||||
if (val == null)
|
||||
{
|
||||
return deflt;
|
||||
}
|
||||
if (enumClass.isInstance(val))
|
||||
{
|
||||
return (T) val;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Enum.valueOf(enumClass, String.valueOf(val));
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Enum value of type " + enumClass.getName() + "required, but found: " + val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the String hold in param "value" for the key "name"
|
||||
* @param name : String designating the key in the set
|
||||
* @param value : String corresponding to the value associated with the key
|
||||
*/
|
||||
public void set(String name, String value)
|
||||
{
|
||||
_set.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the boolean hold in param "value" for the key "name"
|
||||
* @param name : String designating the key in the set
|
||||
* @param value : boolean corresponding to the value associated with the key
|
||||
*/
|
||||
public void set(String name, boolean value)
|
||||
{
|
||||
_set.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the int hold in param "value" for the key "name"
|
||||
* @param name : String designating the key in the set
|
||||
* @param value : int corresponding to the value associated with the key
|
||||
*/
|
||||
public void set(String name, int value)
|
||||
{
|
||||
_set.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the double hold in param "value" for the key "name"
|
||||
* @param name : String designating the key in the set
|
||||
* @param value : double corresponding to the value associated with the key
|
||||
*/
|
||||
public void set(String name, double value)
|
||||
{
|
||||
_set.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the long hold in param "value" for the key "name"
|
||||
* @param name : String designating the key in the set
|
||||
* @param value : double corresponding to the value associated with the key
|
||||
*/
|
||||
public void set(String name, long value)
|
||||
{
|
||||
_set.put(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Enum hold in param "value" for the key "name"
|
||||
* @param name : String designating the key in the set
|
||||
* @param value : Enum corresponding to the value associated with the key
|
||||
*/
|
||||
public void set(String name, Enum<?> value)
|
||||
{
|
||||
_set.put(name, value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user