actual freya branch

This commit is contained in:
2026-09-12 15:41:31 +00:00
parent 8049e0a882
commit 68c1cd27d4
3510 changed files with 336689 additions and 302906 deletions
@@ -0,0 +1,119 @@
/*
* 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.l2jserver.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 final int _lowerLevel;
/** Max level that the player mustn't exceed if it want to obtain this buff from Newbie Helper */
private final int _upperLevel;
/** Identifier of the skill (buff) that the Newbie Helper must cast */
private final int _skillID;
/** Level of the skill (buff) that the Newbie Helper must cast */
private final int _skillLevel;
/**
* If True only Magus class will obtain this Buff <BR>
* If False only Fighter class will obtain this Buff
*/
private boolean _isMagicClass;
private boolean _forSummon = false;
/**
* Constructor of L2HelperBuff.<BR>
* <BR>
*/
public L2HelperBuff(StatsSet set)
{
_lowerLevel = set.getInteger("lowerLevel");
_upperLevel = set.getInteger("upperLevel");
_skillID = set.getInteger("skillID");
_skillLevel = set.getInteger("skillLevel");
if ("true".equals(set.getString("forSummon")))
{
_forSummon = true;
}
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;
}
/**
* Returns the upper level that the L2PcInstance mustn't exceed in order to obtain this buff
* @return int
*/
public int getUpperLevel()
{
return _upperLevel;
}
/**
* Returns the ID of the buff that the L2PcInstance will receive
* @return int
*/
public int getSkillID()
{
return _skillID;
}
/**
* Returns the Level of the buff that the L2PcInstance will receive
* @return int
*/
public int getSkillLevel()
{
return _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;
}
public boolean isForSummon()
{
return _forSummon;
}
}
@@ -0,0 +1,631 @@
/*
* 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.l2jserver.gameserver.templates;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
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 static final Logger _log = Logger.getLogger(StatsSet.class.getName());
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)
{
Map<String, Object> newMap = newSet.getSet();
for (Entry<String, Object> entry : newMap.entrySet())
{
_set.put(entry.getKey(), entry.getValue());
}
}
/**
* 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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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
* @return int[] : value associated to the key
*/
public int[] getIntegerArray(String name)
{
Object val = _set.get(name);
if (val == null)
{
throw new IllegalArgumentException("Integer value required, but not specified");
}
if (val instanceof Number)
{
int[] result =
{
((Number) val).intValue()
};
return result;
}
int c = 0;
String[] vals = ((String) val).split(";");
int[] result = new int[vals.length];
for (String v : vals)
{
try
{
result[c++] = Integer.parseInt(v);
}
catch (Exception e)
{
throw new IllegalArgumentException("Integer value required, but found: " + val);
}
}
return result;
}
/**
* 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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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 (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)
{
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)
{
Object val = _set.get(name);
if (val == null)
{
return deflt;
}
return String.valueOf(val);
}
/**
* Returns an enumeration of &lt;T&gt; 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)
{
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 (Exception e)
{
throw new IllegalArgumentException("Enum value of type " + enumClass.getName() + " required, but found: " + val);
}
}
/**
* Returns an enumeration of &lt;T&gt; 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)
{
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 (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);
}
/**
* Safe version of "set". Expected values are within [min, max[<br>
* 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 safeSet(String name, int value, int min, int max, String reference)
{
assert !(((min <= max) && ((value < min) || (value >= max))));
if ((min <= max) && ((value < min) || (value >= max)))
{
_log.log(Level.SEVERE, "Incorrect value: " + value + "for: " + name + "Ref: " + reference);
}
set(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);
}
}
@@ -0,0 +1,177 @@
/*
* 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.l2jserver.gameserver.templates.chars;
import com.l2jserver.gameserver.templates.StatsSet;
/**
* 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 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 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 baseSleepVuln;
public int baseFire;
public int baseWind;
public int baseWater;
public int baseEarth;
public int baseHoly;
public int baseDark;
public double baseFireRes;
public double baseWindRes;
public double baseWaterRes;
public double baseEarthRes;
public double baseHolyRes;
public double baseDarkRes;
public final double baseCritVuln;
// C4 Stats
public final int baseMpConsumeRate;
public final int baseHpConsumeRate;
/**
* <FONT COLOR=#FF0000><B> <U>Caution</U> : For client info use {@link fCollisionRadius} </B></FONT><BR>
* <BR>
*/
public final int collisionRadius;
/**
* <FONT COLOR=#FF0000><B> <U>Caution</U> : For client info use {@link fCollisionHeight} </B></FONT><BR>
* <BR>
*/
public final int collisionHeight;
public final double fCollisionRadius;
public final double fCollisionHeight;
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", 80); // CT2: The magic critical rate has been increased to 10 times.
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("baseAggressionVuln", 0);
baseBleedVuln = set.getInteger("baseBleedVuln", 0);
basePoisonVuln = set.getInteger("basePoisonVuln", 0);
baseStunVuln = set.getInteger("baseStunVuln", 0);
baseRootVuln = set.getInteger("baseRootVuln", 0);
baseMovementVuln = set.getInteger("baseMovementVuln", 0);
baseSleepVuln = set.getInteger("baseSleepVuln", 0);
baseFireRes = set.getInteger("baseFireRes", 0);
baseWindRes = set.getInteger("baseWindRes", 0);
baseWaterRes = set.getInteger("baseWaterRes", 0);
baseEarthRes = set.getInteger("baseEarthRes", 0);
baseHolyRes = set.getInteger("baseHolyRes", 0);
baseDarkRes = set.getInteger("baseDarkRes", 0);
baseCritVuln = set.getInteger("baseCritVuln", 1);
// C4 Stats
baseMpConsumeRate = set.getInteger("baseMpConsumeRate", 0);
baseHpConsumeRate = set.getInteger("baseHpConsumeRate", 0);
// Geometry
fCollisionHeight = set.getDouble("collision_height");
fCollisionRadius = set.getDouble("collision_radius");
collisionRadius = (int) fCollisionRadius;
collisionHeight = (int) fCollisionHeight;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,139 @@
/*
* 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.l2jserver.gameserver.templates.chars;
import java.util.List;
import javolution.util.FastList;
import com.l2jserver.gameserver.model.base.ClassId;
import com.l2jserver.gameserver.model.base.Race;
import com.l2jserver.gameserver.templates.StatsSet;
/**
* @author mkizub
*/
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 fCollisionHeight_female;
public final double fCollisionRadius_female;
private final List<PcTemplateItem> _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");
fCollisionRadius_female = set.getDouble("collision_radius_female");
fCollisionHeight_female = set.getDouble("collision_height_female");
}
/**
* Adds starter equipment
* @param i
*/
public void addItem(int itemId, int amount, boolean equipped)
{
_items.add(new PcTemplateItem(itemId, amount, equipped));
}
/**
* @return itemIds of all the starter equipment
*/
public List<PcTemplateItem> getItems()
{
return _items;
}
public static final class PcTemplateItem
{
private final int _itemId;
private final int _amount;
private final boolean _equipped;
/**
* @param amount
* @param itemId
*/
public PcTemplateItem(int itemId, int amount, boolean equipped)
{
_itemId = itemId;
_amount = amount;
_equipped = equipped;
}
/**
* @return Returns the itemId.
*/
public int getItemId()
{
return _itemId;
}
/**
* @return Returns the amount.
*/
public int getAmount()
{
return _amount;
}
/**
* @return Returns the if the item should be equipped after char creation.
*/
public boolean isEquipped()
{
return _equipped;
}
}
public final int getFallHeight()
{
return 333; // TODO: unhardcode it
}
}
@@ -0,0 +1,197 @@
/*
* 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.l2jserver.gameserver.templates.effects;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.ChanceCondition;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.skills.AbnormalEffect;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.conditions.Condition;
import com.l2jserver.gameserver.skills.funcs.FuncTemplate;
import com.l2jserver.gameserver.skills.funcs.Lambda;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* @author mkizub
*/
public class EffectTemplate
{
static Logger _log = Logger.getLogger(EffectTemplate.class.getName());
private final Class<?> _func;
private final Constructor<?> _constructor;
public final Condition attachCond;
public final Condition applayCond;
public final Lambda lambda;
public final int counter;
public final int abnormalTime; // in seconds
public final AbnormalEffect abnormalEffect;
public final AbnormalEffect specialEffect;
public final AbnormalEffect eventEffect;
public FuncTemplate[] funcTemplates;
public final String abnormalType;
public final byte abnormalLvl;
public final boolean icon;
public final String funcName;
public final double effectPower; // to thandle chance
public final L2SkillType effectType; // to handle resistences etc...
public final int triggeredId;
public final int triggeredLevel;
public final ChanceCondition chanceCondition;
public EffectTemplate(Condition pAttachCond, Condition pApplayCond, String func, Lambda pLambda, int pCounter, int pAbnormalTime, AbnormalEffect pAbnormalEffect, AbnormalEffect pSpecialEffect, AbnormalEffect pEventEffect, String pAbnormalType, byte pAbnormalLvl, boolean showicon, double ePower, L2SkillType eType, int trigId, int trigLvl, ChanceCondition chanceCond)
{
attachCond = pAttachCond;
applayCond = pApplayCond;
lambda = pLambda;
counter = pCounter;
abnormalTime = pAbnormalTime;
abnormalEffect = pAbnormalEffect;
specialEffect = pSpecialEffect;
eventEffect = pEventEffect;
abnormalType = pAbnormalType;
abnormalLvl = pAbnormalLvl;
icon = showicon;
funcName = func;
effectPower = ePower;
effectType = eType;
triggeredId = trigId;
triggeredLevel = trigLvl;
chanceCondition = chanceCond;
try
{
_func = Class.forName("com.l2jserver.gameserver.skills.effects.Effect" + func);
}
catch (ClassNotFoundException e)
{
throw new RuntimeException(e);
}
try
{
_constructor = _func.getConstructor(Env.class, EffectTemplate.class);
}
catch (NoSuchMethodException e)
{
throw new RuntimeException(e);
}
}
public L2Effect getEffect(Env env)
{
if ((attachCond != null) && !attachCond.test(env))
{
return null;
}
try
{
L2Effect effect = (L2Effect) _constructor.newInstance(env, this);
return effect;
}
catch (IllegalAccessException e)
{
_log.log(Level.WARNING, "", e);
return null;
}
catch (InstantiationException e)
{
_log.log(Level.WARNING, "", e);
return null;
}
catch (InvocationTargetException e)
{
_log.log(Level.WARNING, "Error creating new instance of Class " + _func + " Exception was: " + e.getTargetException().getMessage(), e.getTargetException());
return null;
}
}
/**
* Creates an L2Effect instance from an existing one and an Env object.
* @param env
* @param stolen
* @return
*/
public L2Effect getStolenEffect(Env env, L2Effect stolen)
{
Class<?> func;
Constructor<?> stolenCons;
try
{
func = Class.forName("com.l2jserver.gameserver.skills.effects.Effect" + stolen.getEffectTemplate().funcName);
}
catch (ClassNotFoundException e)
{
throw new RuntimeException(e);
}
try
{
stolenCons = func.getConstructor(Env.class, L2Effect.class);
}
catch (NoSuchMethodException e)
{
throw new RuntimeException(e);
}
try
{
L2Effect effect = (L2Effect) stolenCons.newInstance(env, stolen);
// if (_applayCond != null)
// effect.setCondition(_applayCond);
return effect;
}
catch (IllegalAccessException e)
{
_log.log(Level.WARNING, "", e);
return null;
}
catch (InstantiationException e)
{
_log.log(Level.WARNING, "", e);
return null;
}
catch (InvocationTargetException e)
{
_log.log(Level.WARNING, "Error creating new instance of Class " + func + " Exception was: " + e.getTargetException().getMessage(), e.getTargetException());
return null;
}
}
public void attach(FuncTemplate f)
{
if (funcTemplates == null)
{
funcTemplates = new FuncTemplate[]
{
f
};
}
else
{
int len = funcTemplates.length;
FuncTemplate[] tmp = new FuncTemplate[len + 1];
System.arraycopy(funcTemplates, 0, tmp, 0, len);
tmp[len] = f;
funcTemplates = tmp;
}
}
}
@@ -0,0 +1,48 @@
/*
* 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.l2jserver.gameserver.templates.item;
/**
* @author nBd
*/
public enum L2ActionType
{
calc,
call_skill,
capsule,
create_mpcc,
dice,
equip,
fishingshot,
harvest,
hide_name,
keep_exp,
nick_color,
none,
peel,
recipe,
seed,
show_adventurer_guide_book,
show_html,
show_ssq_status,
skill_maintain,
skill_reduce,
soulshot,
spiritshot,
start_quest,
summon_soulshot,
summon_spiritshot,
xmas_open,
}
@@ -0,0 +1,163 @@
/*
* 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.l2jserver.gameserver.templates.item;
import java.util.ArrayList;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.SkillHolder;
import com.l2jserver.gameserver.skills.funcs.Func;
import com.l2jserver.gameserver.skills.funcs.FuncTemplate;
import com.l2jserver.gameserver.templates.StatsSet;
import com.l2jserver.util.StringUtil;
/**
* 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 SkillHolder _enchant4Skill = null; // skill that activates when armor is enchanted +4
// private final String[] _skill;
private L2ArmorType _type;
/**
* Constructor for Armor.<BR>
* <BR>
* <U><I>Variables filled :</I></U><BR>
* <LI>_avoidModifier</LI> <LI>_pDef & _mDef</LI> <LI>_mpBonus & _hpBonus</LI> <LI>enchant4Skill</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(StatsSet set)
{
super(set);
_type = L2ArmorType.valueOf(set.getString("armor_type", "none").toUpperCase());
int _bodyPart = getBodyPart();
if ((_bodyPart == L2Item.SLOT_NECK) || (_bodyPart == L2Item.SLOT_HAIR) || (_bodyPart == L2Item.SLOT_HAIR2) || (_bodyPart == L2Item.SLOT_HAIRALL) || ((_bodyPart & L2Item.SLOT_L_EAR) != 0) || ((_bodyPart & L2Item.SLOT_L_FINGER) != 0) || ((_bodyPart & L2Item.SLOT_R_BRACELET) != 0) || ((_bodyPart & L2Item.SLOT_L_BRACELET) != 0) || ((_bodyPart & L2Item.SLOT_BACK) != 0))
{
_type1 = L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE;
_type2 = L2Item.TYPE2_ACCESSORY;
}
else
{
if ((_type == L2ArmorType.NONE) && (getBodyPart() == L2Item.SLOT_L_HAND))
{
_type = L2ArmorType.SHIELD;
}
_type1 = L2Item.TYPE1_SHIELD_ARMOR;
_type2 = L2Item.TYPE2_SHIELD_ARMOR;
}
String skill = set.getString("enchant4_skill", null);
if (skill != null)
{
String[] info = skill.split("-");
if ((info != null) && (info.length == 2))
{
int id = 0;
int level = 0;
try
{
id = Integer.parseInt(info[0]);
level = Integer.parseInt(info[1]);
}
catch (Exception nfe)
{
// Incorrect syntax, dont add new skill
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in armor enchant skills! item ", toString()));
}
if ((id > 0) && (level > 0))
{
_enchant4Skill = new SkillHolder(id, level);
}
}
}
}
/**
* Returns the type of the armor.
* @return L2ArmorType
*/
@Override
public L2ArmorType getItemType()
{
return _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 skill that player get when has equiped armor +4 or more
* @return
*/
public L2Skill getEnchant4Skill()
{
if (_enchant4Skill == null)
{
return null;
}
return _enchant4Skill.getSkill();
}
/**
* 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)
{
if ((_funcTemplates == null) || (_funcTemplates.length == 0))
{
return _emptyFunctionSet;
}
ArrayList<Func> funcs = new ArrayList<>(_funcTemplates.length);
Env env = new Env();
env.player = player;
env.item = instance;
Func f;
for (FuncTemplate t : _funcTemplates)
{
f = t.getFunc(env, instance);
if (f != null)
{
funcs.add(f);
}
}
return funcs.toArray(new Func[funcs.size()]);
}
}
@@ -0,0 +1,65 @@
/*
* 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.l2jserver.gameserver.templates.item;
/**
* Description of Armor Type
*/
public enum L2ArmorType implements L2ItemType
{
NONE("None"),
LIGHT("Light"),
HEAVY("Heavy"),
MAGIC("Magic"),
SIGIL("Sigil"),
// L2J CUSTOM
SHIELD("Shield");
final int _mask;
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(String name)
{
_mask = 1 << (ordinal() + L2WeaponType.values().length);
_name = name;
}
/**
* Returns the ID of the ArmorType after applying a mask.
* @return int : ID of the ArmorType after mask
*/
@Override
public int mask()
{
return _mask;
}
/**
* Returns the name of the ArmorType
* @return String
*/
@Override
public String toString()
{
return _name;
}
}
@@ -0,0 +1,190 @@
/*
* 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.l2jserver.gameserver.templates.item;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.model.L2ExtractableProduct;
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
import com.l2jserver.gameserver.templates.StatsSet;
import com.l2jserver.util.StringUtil;
/**
* 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
{
// private final String[] _skill;
private String _handler;
private final int _sharedReuseGroup;
private L2EtcItemType _type;
private final boolean _isBlessed;
private final List<L2ExtractableProduct> _extractableItems;
/**
* 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(StatsSet set)
{
super(set);
_type = L2EtcItemType.valueOf(set.getString("etcitem_type", "none").toUpperCase());
// l2j custom - L2EtcItemType.SHOT
switch (getDefaultAction())
{
case soulshot:
case summon_soulshot:
case summon_spiritshot:
case spiritshot:
{
_type = L2EtcItemType.SHOT;
break;
}
}
if (is_ex_immediate_effect())
{
_type = L2EtcItemType.HERB;
}
_type1 = L2Item.TYPE1_ITEM_QUESTITEM_ADENA;
_type2 = L2Item.TYPE2_OTHER; // default is other
if (isQuestItem())
{
_type2 = L2Item.TYPE2_QUEST;
}
else if ((getItemId() == PcInventory.ADENA_ID) || (getItemId() == PcInventory.ANCIENT_ADENA_ID))
{
_type2 = L2Item.TYPE2_MONEY;
}
_handler = set.getString("handler", null); // ! null !
_sharedReuseGroup = set.getInteger("shared_reuse_group", -1);
_isBlessed = set.getBool("blessed", false);
// extractable
String capsuled_items = set.getString("capsuled_items", null);
if (capsuled_items != null)
{
String[] split = capsuled_items.split(";");
_extractableItems = new ArrayList<>(split.length);
for (String part : split)
{
if (part.trim().isEmpty())
{
continue;
}
String[] data = part.split(",");
if (data.length != 4)
{
_log.info(StringUtil.concat("> Couldnt parse ", part, " in capsuled_items! item ", toString()));
continue;
}
int itemId = Integer.parseInt(data[0]);
int min = Integer.parseInt(data[1]);
int max = Integer.parseInt(data[2]);
double chance = Double.parseDouble(data[3]);
if (max < min)
{
_log.info(StringUtil.concat("> Max amount < Min amount in ", part, ", item ", toString()));
continue;
}
L2ExtractableProduct product = new L2ExtractableProduct(itemId, min, max, chance);
_extractableItems.add(product);
}
((ArrayList<?>) _extractableItems).trimToSize();
// check for handler
if (_handler == null)
{
// _log.warning("Item "+this+ " define capsuled_items but missing handler.");
_handler = "ExtractableItems";
}
}
else
{
_extractableItems = null;
}
}
/**
* Returns the type of Etc Item
* @return L2EtcItemType
*/
@Override
public L2EtcItemType getItemType()
{
return _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();
}
/**
* Return handler name. null if no handler for item
* @return String
*/
public String getHandlerName()
{
return _handler;
}
/**
* @return
*/
public int getSharedReuseGroup()
{
return _sharedReuseGroup;
}
/**
* @return
*/
public final boolean isBlessed()
{
return _isBlessed;
}
/**
* @return the _extractable_items
*/
public List<L2ExtractableProduct> getExtractableItems()
{
return _extractableItems;
}
}
@@ -0,0 +1,93 @@
/*
* 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.l2jserver.gameserver.templates.item;
/**
* Description of EtcItem Type
*/
public enum L2EtcItemType implements L2ItemType
{
NONE(1, "none"),
ARROW(2, "arrow"),
POTION(3, "potion"),
SCRL_ENCHANT_WP(4, "scrl_enchant_wp"),
SCRL_ENCHANT_AM(5, "scrl_enchant_am"),
SCROLL(6, "scroll"),
RECIPE(7, "recipe"),
MATERIAL(8, "material"),
PET_COLLAR(9, "pet_collar"),
CASTLE_GUARD(10, "castle_guard"),
LOTTO(11, "lotto"),
RACE_TICKET(12, "race_ticket"),
DYE(13, "dye"),
SEED(14, "seed"),
CROP(15, "crop"),
MATURECROP(16, "maturecrop"),
HARVEST(17, "harvest"),
SEED2(18, "seed2"),
TICKET_OF_LORD(19, "ticket_of_lord"),
LURE(20, "lure"),
BLESS_SCRL_ENCHANT_WP(21, "bless_scrl_enchant_wp"),
BLESS_SCRL_ENCHANT_AM(22, "bless_scrl_enchant_am"),
COUPON(23, "coupon"),
ELIXIR(24, "elixir"),
SCRL_ENCHANT_ATTR(25, "scrl_enchant_attr"),
BOLT(26, "bolt"),
SCRL_INC_ENCHANT_PROP_WP(27, "scrl_inc_enchant_prop_wp"),
SCRL_INC_ENCHANT_PROP_AM(28, "scrl_inc_enchant_prop_am"),
ANCIENT_CRYSTAL_ENCHANT_WP(29, "ancient_crystal_enchant_wp"),
ANCIENT_CRYSTAL_ENCHANT_AM(30, "ancient_crystal_enchant_am"),
RUNE_SELECT(31, "rune_select"),
RUNE(32, "rune"),
// L2J CUSTOM, BACKWARD COMPATIBILITY
SHOT(33, "Shot"),
HERB(34, "Herb");
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
*/
@Override
public int mask()
{
return 0;
}
/**
* Returns the name of the EtcItemType
* @return String
*/
@Override
public String toString()
{
return _name;
}
}
@@ -0,0 +1,126 @@
/*
* 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.l2jserver.gameserver.templates.item;
import com.l2jserver.gameserver.templates.StatsSet;
/**
* This class ...
* @version $Revision$ $Date$
*/
public class L2Henna
{
private final int symbolId;
private final int dye;
private final int price;
private final int amount;
private final int statINT;
private final int statSTR;
private final int statCON;
private final int statMEM;
private final int statDEX;
private final int statWIT;
public L2Henna(StatsSet set)
{
symbolId = set.getInteger("symbol_id");
dye = set.getInteger("dye");
price = set.getInteger("price");
amount = set.getInteger("amount");
statINT = set.getInteger("stat_INT");
statSTR = set.getInteger("stat_STR");
statCON = set.getInteger("stat_CON");
statMEM = set.getInteger("stat_MEM");
statDEX = set.getInteger("stat_DEX");
statWIT = set.getInteger("stat_WIT");
}
public int getSymbolId()
{
return symbolId;
}
/**
* @return
*/
public int getDyeId()
{
return dye;
}
/**
* @return
*/
public int getPrice()
{
return price;
}
/**
* @return
*/
public int getAmountDyeRequire()
{
return amount;
}
/**
* @return
*/
public int getStatINT()
{
return statINT;
}
/**
* @return
*/
public int getStatSTR()
{
return statSTR;
}
/**
* @return
*/
public int getStatCON()
{
return statCON;
}
/**
* @return
*/
public int getStatMEM()
{
return statMEM;
}
/**
* @return
*/
public int getStatDEX()
{
return statDEX;
}
/**
* @return
*/
public int getStatWIT()
{
return statWIT;
}
}
@@ -0,0 +1,985 @@
/*
* 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.l2jserver.gameserver.templates.item;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import javolution.util.FastList;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.Elementals;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.SkillHolder;
import com.l2jserver.gameserver.skills.conditions.Condition;
import com.l2jserver.gameserver.skills.conditions.ConditionLogicOr;
import com.l2jserver.gameserver.skills.conditions.ConditionPetType;
import com.l2jserver.gameserver.skills.funcs.Func;
import com.l2jserver.gameserver.skills.funcs.FuncTemplate;
import com.l2jserver.gameserver.templates.StatsSet;
import com.l2jserver.gameserver.templates.effects.EffectTemplate;
import com.l2jserver.util.StringUtil;
/**
* 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 WOLF = 0x1;
public static final int HATCHLING = 0x2;
public static final int STRIDER = 0x4;
public static final int BABY = 0x8;
public static final int IMPROVED_BABY = 0x10;
public static final int GROWN_WOLF = 0x20;
public static final int ALL_WOLF = 0x21;
public static final int ALL_PET = 0x3F;
public static final int SLOT_NONE = 0x0000;
public static final int SLOT_UNDERWEAR = 0x0001;
public static final int SLOT_R_EAR = 0x0002;
public static final int SLOT_L_EAR = 0x0004;
public static final int SLOT_LR_EAR = 0x00006;
public static final int SLOT_NECK = 0x0008;
public static final int SLOT_R_FINGER = 0x0010;
public static final int SLOT_L_FINGER = 0x0020;
public static final int SLOT_LR_FINGER = 0x0030;
public static final int SLOT_HEAD = 0x0040;
public static final int SLOT_R_HAND = 0x0080;
public static final int SLOT_L_HAND = 0x0100;
public static final int SLOT_GLOVES = 0x0200;
public static final int SLOT_CHEST = 0x0400;
public static final int SLOT_LEGS = 0x0800;
public static final int SLOT_FEET = 0x1000;
public static final int SLOT_BACK = 0x2000;
public static final int SLOT_LR_HAND = 0x4000;
public static final int SLOT_FULL_ARMOR = 0x8000;
public static final int SLOT_HAIR = 0x010000;
public static final int SLOT_ALLDRESS = 0x020000;
public static final int SLOT_HAIR2 = 0x040000;
public static final int SLOT_HAIRALL = 0x080000;
public static final int SLOT_R_BRACELET = 0x100000;
public static final int SLOT_L_BRACELET = 0x200000;
public static final int SLOT_DECO = 0x400000;
public static final int SLOT_BELT = 0x10000000;
public static final int SLOT_WOLF = -100;
public static final int SLOT_HATCHLING = -101;
public static final int SLOT_STRIDER = -102;
public static final int SLOT_BABYPET = -103;
public static final int SLOT_GREATWOLF = -104;
public static final int SLOT_MULTI_ALLWEAPON = SLOT_LR_HAND | SLOT_R_HAND;
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 = 0x16; // ??
public static final int MATERIAL_FISH = 0x17; // ??
public static final int MATERIAL_RUNE_XP = 0x18; // ??
public static final int MATERIAL_RUNE_SP = 0x19; // ??
public static final int MATERIAL_RUNE_PENALTY = 0x20; // ??
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 CRYSTAL_S80 = 0x06; // ??
public static final int CRYSTAL_S84 = 0x07; // ??
private static final int[] crystalItemId =
{
0,
1458,
1459,
1460,
1461,
1462,
1462,
1462
};
private static final int[] crystalEnchantBonusArmor =
{
0,
11,
6,
11,
19,
25,
25,
25
};
private static final int[] crystalEnchantBonusWeapon =
{
0,
90,
45,
67,
144,
250,
250,
250
};
private final int _itemId;
private final String _name;
private final String _icon;
private final int _weight;
private final boolean _stackable;
private final int _materialType;
private final int _crystalType; // default to none-grade
private final int _duration;
private final int _time;
private final int _bodyPart;
private final int _referencePrice;
private final int _crystalCount;
private final boolean _sellable;
private final boolean _dropable;
private final boolean _destroyable;
private final boolean _tradeable;
private final boolean _depositable;
private final boolean _questItem;
private final boolean _common;
private final boolean _heroItem;
private final boolean _pvpItem;
private final boolean _ex_immediate_effect;
private final L2ActionType _defaultAction;
protected int _type1; // needed for item list (inventory)
protected int _type2; // different lists for armor, weapon, etc
protected Elementals[] _elementals = null;
protected FuncTemplate[] _funcTemplates;
protected EffectTemplate[] _effectTemplates;
protected List<Condition> _preConditions;
private SkillHolder[] _skillHolder;
protected static final Func[] _emptyFunctionSet = new Func[0];
protected static final L2Effect[] _emptyEffectSet = new L2Effect[0];
protected static final Logger _log = Logger.getLogger(L2Item.class.getName());
/**
* Constructor of the L2Item that fill class variables.<BR>
* <BR>
* @param set : StatsSet corresponding to a set of couples (key,value) for description of the item
*/
protected L2Item(StatsSet set)
{
_itemId = set.getInteger("item_id");
_name = set.getString("name");
_icon = set.getString("icon", null);
_weight = set.getInteger("weight", 0);
_materialType = ItemTable._materials.get(set.getString("material", "steel")); // default is steel, yeah and what?
_duration = set.getInteger("duration", -1);
_time = set.getInteger("time", -1);
_bodyPart = ItemTable._slots.get(set.getString("bodypart", "none"));
_referencePrice = set.getInteger("price", 0);
_crystalType = ItemTable._crystalTypes.get(set.getString("crystal_type", "none")); // default to none-grade
_crystalCount = set.getInteger("crystal_count", 0);
_stackable = set.getBool("is_stackable", false);
_sellable = set.getBool("is_sellable", true);
_dropable = set.getBool("is_dropable", true);
_destroyable = set.getBool("is_destroyable", true);
_tradeable = set.getBool("is_tradable", true);
_depositable = set.getBool("is_depositable", true);
_questItem = set.getBool("is_questitem", false);
// _immediate_effect - herb
_ex_immediate_effect = set.getInteger("ex_immediate_effect", 0) > 0;
// used for custom type select
_defaultAction = set.getEnum("default_action", L2ActionType.class, L2ActionType.none);
// TODO cleanup + finish
String equip_condition = set.getString("equip_condition", null);
if (equip_condition != null)
{
// pet conditions
ConditionLogicOr cond = new ConditionLogicOr();
if (equip_condition.contains("all_wolf_group"))
{
cond.add(new ConditionPetType(ALL_WOLF));
}
if (equip_condition.contains("hatchling_group"))
{
cond.add(new ConditionPetType(HATCHLING));
}
if (equip_condition.contains("strider"))
{
cond.add(new ConditionPetType(STRIDER));
}
if (equip_condition.contains("baby_pet_group"))
{
cond.add(new ConditionPetType(BABY));
}
if (equip_condition.contains("upgrade_baby_pet_group"))
{
cond.add(new ConditionPetType(IMPROVED_BABY));
}
if (equip_condition.contains("grown_up_wolf_group"))
{
cond.add(new ConditionPetType(GROWN_WOLF));
}
if (equip_condition.contains("item_equip_pet_group"))
{
cond.add(new ConditionPetType(ALL_PET));
}
if (cond.conditions.length > 0)
{
attach(cond);
}
}
String skills = set.getString("item_skill", null);
if (skills != null)
{
String[] skillsSplit = skills.split(";");
_skillHolder = new SkillHolder[skillsSplit.length];
int used = 0;
for (String element : skillsSplit)
{
try
{
String[] skillSplit = element.split("-");
int id = Integer.parseInt(skillSplit[0]);
int level = Integer.parseInt(skillSplit[1]);
if (id == 0)
{
_log.info(StringUtil.concat("Ignoring item_skill(", element, ") for item ", toString(), ". Skill id is 0!"));
continue;
}
if (level == 0)
{
_log.info(StringUtil.concat("Ignoring item_skill(", element, ") for item ", toString(), ". Skill level is 0!"));
continue;
}
_skillHolder[used] = new SkillHolder(id, level);
++used;
}
catch (Exception e)
{
_log.warning(StringUtil.concat("Failed to parse item_skill(", element, ") for item ", toString(), "! Format: SkillId0-SkillLevel0[;SkillIdN-SkillLevelN]"));
}
}
// this is only loading? just don't leave a null or use a collection?
if (used != _skillHolder.length)
{
SkillHolder[] skillHolder = new SkillHolder[used];
System.arraycopy(_skillHolder, 0, skillHolder, 0, used);
_skillHolder = skillHolder;
}
}
_common = ((_itemId >= 11605) && (_itemId <= 12361));
_heroItem = ((_itemId >= 6611) && (_itemId <= 6621)) || ((_itemId >= 9388) && (_itemId <= 9390)) || (_itemId == 6842);
_pvpItem = ((_itemId >= 10667) && (_itemId <= 10835)) || ((_itemId >= 12852) && (_itemId <= 12977)) || ((_itemId >= 14363) && (_itemId <= 14525)) || (_itemId == 14528) || (_itemId == 14529) || (_itemId == 14558) || ((_itemId >= 15913) && (_itemId <= 16024)) || ((_itemId >= 16134) && (_itemId <= 16147)) || (_itemId == 16149) || (_itemId == 16151) || (_itemId == 16153) || (_itemId == 16155) || (_itemId == 16157) || (_itemId == 16159) || ((_itemId >= 16168) && (_itemId <= 16176)) || ((_itemId >= 16179) && (_itemId <= 16220));
}
/**
* Returns the itemType.
* @return Enum
*/
public abstract L2ItemType getItemType();
/**
* Returns the duration of the item
* @return int
*/
public final int getDuration()
{
return _duration;
}
/**
* Returns the time of the item
* @return int
*/
public final int getTime()
{
return _time;
}
/**
* 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 (_crystalType != L2Item.CRYSTAL_NONE) && (_crystalCount > 0);
}
/**
* 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 fucntion returns the type of crystal of the item.
* @return int
*/
public final int getItemGrade()
{
return getCrystalType();
}
/**
* Returns the grade of the item.<BR>
* <BR>
* For grades S80 and S84 return S
* @return int
*/
public final int getItemGradeSPlus()
{
switch (getItemGrade())
{
case CRYSTAL_S80:
case CRYSTAL_S84:
return CRYSTAL_S;
default:
return getItemGrade();
}
}
/**
* 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
* @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;
}
/**
* Returns the base elemental of the item
* @return Elementals
*/
public final Elementals[] getElementals()
{
return _elementals;
}
public Elementals getElemental(byte attribute)
{
for (Elementals elm : _elementals)
{
if (elm.getElement() == attribute)
{
return elm;
}
}
return null;
}
/**
* Sets the base elemental of the item
*/
public void setElementals(Elementals element)
{
if (_elementals == null)
{
_elementals = new Elementals[1];
_elementals[0] = element;
}
else
{
Elementals elm = getElemental(element.getElement());
if (elm != null)
{
elm.setValue(element.getValue());
}
else
{
elm = element;
Elementals[] array = new Elementals[_elementals.length + 1];
System.arraycopy(_elementals, 0, array, 0, _elementals.length);
array[_elementals.length] = elm;
_elementals = array;
}
}
}
/**
* Return the part of the body used with the item.
* @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;
}
public boolean isEquipable()
{
return (getBodyPart() != 0) && !(getItemType() instanceof L2EtcItemType);
}
/**
* 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 dropped
* @return boolean
*/
public final boolean isDropable()
{
return _dropable;
}
/**
* Returns if the item can destroy
* @return boolean
*/
public final boolean isDestroyable()
{
return _destroyable;
}
/**
* Returns if the item can add to trade
* @return boolean
*/
public final boolean isTradeable()
{
return _tradeable;
}
/**
* Returns if the item can be put into warehouse
* @return boolean
*/
public final boolean isDepositable()
{
return _depositable;
}
/**
* Returns if item is common
* @return boolean
*/
public final boolean isCommon()
{
return _common;
}
/**
* Returns if item is hero-only
* @return
*/
public final boolean isHeroItem()
{
return _heroItem;
}
/**
* Returns if item is pvp
* @return
*/
public final boolean isPvpItem()
{
return _pvpItem;
}
public boolean isPotion()
{
return (getItemType() == L2EtcItemType.POTION);
}
public boolean isElixir()
{
return (getItemType() == L2EtcItemType.ELIXIR);
}
/**
* 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) || (_funcTemplates.length == 0))
{
return _emptyFunctionSet;
}
ArrayList<Func> funcs = new ArrayList<>(_funcTemplates.length);
Env env = new Env();
env.player = player;
env.target = player;
env.item = instance;
Func f;
for (FuncTemplate t : _funcTemplates)
{
f = t.getFunc(env, this); // skill is owner
if (f != null)
{
funcs.add(f);
}
}
if (funcs.isEmpty())
{
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) || (_effectTemplates.length == 0))
{
return _emptyEffectSet;
}
FastList<L2Effect> effects = FastList.newInstance();
Env env = new Env();
env.player = player;
env.target = player;
env.item = instance;
L2Effect e;
for (EffectTemplate et : _effectTemplates)
{
e = et.getEffect(env);
if (e != null)
{
e.scheduleEffect();
effects.add(e);
}
}
if (effects.isEmpty())
{
return _emptyEffectSet;
}
L2Effect[] result = effects.toArray(new L2Effect[effects.size()]);
FastList.recycle(effects);
return result;
}
/**
* 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; List<L2Effect> effects = new FastList<L2Effect>(); for (L2Skill skill : _skills) { if
* (!skill.checkCondition(caster, target, true)) continue; // Skill condition not met if (target.getFirstEffect(skill.getId()) != null) target.removeEffect(target.getFirstEffect(skill.getId())); for (L2Effect e : skill.getEffects(caster, target)) effects.add(e); } if (effects.isEmpty())
* 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)
{
switch (f.stat)
{
case FIRE_RES:
case FIRE_POWER:
setElementals(new Elementals(Elementals.FIRE, (int) f.lambda.calc(null)));
break;
case WATER_RES:
case WATER_POWER:
setElementals(new Elementals(Elementals.WATER, (int) f.lambda.calc(null)));
break;
case WIND_RES:
case WIND_POWER:
setElementals(new Elementals(Elementals.WIND, (int) f.lambda.calc(null)));
break;
case EARTH_RES:
case EARTH_POWER:
setElementals(new Elementals(Elementals.EARTH, (int) f.lambda.calc(null)));
break;
case HOLY_RES:
case HOLY_POWER:
setElementals(new Elementals(Elementals.HOLY, (int) f.lambda.calc(null)));
break;
case DARK_RES:
case DARK_POWER:
setElementals(new Elementals(Elementals.DARK, (int) f.lambda.calc(null)));
break;
}
// If _functTemplates is empty, create it and add the FuncTemplate f in it
if (_funcTemplates == null)
{
_funcTemplates = new FuncTemplate[]
{
f
};
}
else
{
int len = _funcTemplates.length;
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
{
int len = _effectTemplates.length;
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;
}
}
public final void attach(Condition c)
{
if (_preConditions == null)
{
_preConditions = new FastList<>();
}
if (!_preConditions.contains(c))
{
_preConditions.add(c);
}
}
/**
* Method to retrive skills linked to this item armor and weapon: passive skills etcitem: skills used on item use <-- ???
* @return Skills linked to this item as SkillHolder[]
*/
public final SkillHolder[] getSkills()
{
return _skillHolder;
}
public boolean checkCondition(L2Character activeChar, L2Object target, boolean sendMessage)
{
if (activeChar.isGM() && !Config.GM_ITEM_RESTRICTION)
{
return true;
}
if (_preConditions == null)
{
return true;
}
Env env = new Env();
env.player = activeChar;
if (target instanceof L2Character)
{
env.target = (L2Character) target;
}
for (Condition preCondition : _preConditions)
{
if (preCondition == null)
{
continue;
}
if (!preCondition.test(env))
{
if (activeChar instanceof L2Summon)
{
activeChar.getActingPlayer().sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PET_CANNOT_USE_ITEM));
return false;
}
if (sendMessage)
{
String msg = preCondition.getMessage();
int msgId = preCondition.getMessageId();
if (msg != null)
{
activeChar.sendMessage(msg);
}
else if (msgId != 0)
{
SystemMessage sm = SystemMessage.getSystemMessage(msgId);
if (preCondition.isAddName())
{
sm.addItemName(_itemId);
}
activeChar.getActingPlayer().sendPacket(sm);
}
}
return false;
}
}
return true;
}
public boolean isConditionAttached()
{
return (_preConditions != null) && !_preConditions.isEmpty();
}
public boolean isQuestItem()
{
return _questItem;
}
/**
* Returns the name of the item
* @return String
*/
@Override
public String toString()
{
return _name + "(" + _itemId + ")";
}
/**
* @return the _ex_immediate_effect
*/
public boolean is_ex_immediate_effect()
{
return _ex_immediate_effect;
}
/**
* @return the _default_action
*/
public L2ActionType getDefaultAction()
{
return _defaultAction;
}
/**
* Get the icon link in client files.<BR>
* Usable in HTML windows.
* @return the _icon
*/
public String getIcon()
{
return _icon;
}
}
@@ -0,0 +1,24 @@
/*
* 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.l2jserver.gameserver.templates.item;
/**
* Created for allow comparing different item types
* @author DS
*/
public interface L2ItemType
{
public int mask();
}
@@ -0,0 +1,292 @@
/*
* 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.l2jserver.gameserver.templates.item;
import com.l2jserver.gameserver.model.L2ItemInstance;
/**
* This class contains L2ItemInstance<BR>
* Use to sort L2ItemInstance 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 class L2WarehouseItem
{
private final L2Item _item;
private final int _object;
private final long _count;
private final int _owner;
private final int _locationSlot;
private final int _enchant;
private final int _grade;
private boolean _isAugmented;
private int _augmentationId;
private final int _customType1;
private final int _customType2;
private final int _mana;
private int _elemAtkType = -2;
private int _elemAtkPower = 0;
private final int[] _elemDefAttr =
{
0,
0,
0,
0,
0,
0
};
private final int _time;
public L2WarehouseItem(L2ItemInstance item)
{
_item = item.getItem();
_object = item.getObjectId();
_count = item.getCount();
_owner = item.getOwnerId();
_locationSlot = item.getLocationSlot();
_enchant = item.getEnchantLevel();
_customType1 = item.getCustomType1();
_customType2 = item.getCustomType2();
_grade = item.getItem().getItemGrade();
if (item.isAugmented())
{
_isAugmented = true;
_augmentationId = item.getAugmentation().getAugmentationId();
}
else
{
_isAugmented = false;
}
_mana = item.getMana();
_time = item.isTimeLimitedItem() ? (int) (item.getRemainingTime() / 1000) : -1;
_elemAtkType = item.getAttackElementType();
_elemAtkPower = item.getAttackElementPower();
for (byte i = 0; i < 6; i++)
{
_elemDefAttr[i] = item.getElementDefAttr(i);
}
}
/**
* Returns the item.
* @return L2Item
*/
public L2Item getItem()
{
return _item;
}
/**
* Returns the unique objectId
* @return int
*/
public final int getObjectId()
{
return _object;
}
/**
* Returns the owner
* @return int
*/
public final int getOwnerId()
{
return _owner;
}
/**
* Returns the LocationSlot
* @return int
*/
public final int getLocationSlot()
{
return _locationSlot;
}
/**
* Returns the count
* @return int
*/
public final long getCount()
{
return _count;
}
/**
* Returns the first type
* @return int
*/
public final int getType1()
{
return _item.getType1();
}
/**
* Returns the second type
* @return int
*/
public final int getType2()
{
return _item.getType2();
}
/**
* Returns the second type
* @return int
*/
public final L2ItemType getItemType()
{
return _item.getItemType();
}
/**
* Returns the ItemId
* @return int
*/
public final int getItemId()
{
return _item.getItemId();
}
/**
* Returns the part of body used with this item
* @return int
*/
public final int getBodyPart()
{
return _item.getBodyPart();
}
/**
* Returns the enchant level
* @return int
*/
public final int getEnchantLevel()
{
return _enchant;
}
/**
* Returns the item grade
* @return int
*/
public final int getItemGrade()
{
return _grade;
}
/**
* Returns true if it is a weapon
* @return boolean
*/
public final boolean isWeapon()
{
return (_item instanceof L2Weapon);
}
/**
* Returns true if it is an armor
* @return boolean
*/
public final boolean isArmor()
{
return (_item instanceof L2Armor);
}
/**
* Returns true if it is an EtcItem
* @return boolean
*/
public final boolean isEtcItem()
{
return (_item instanceof L2EtcItem);
}
/**
* Returns the name of the item
* @return String
*/
public String getItemName()
{
return _item.getName();
}
public boolean isAugmented()
{
return _isAugmented;
}
public int getAugmentationId()
{
return _augmentationId;
}
/**
* Returns the name of the item
* @return String
* @deprecated beware to use getItemName() instead because getName() is final in L2Object and could not be overridden! Allover L2Object.getName() may return null!
*/
@Deprecated
public String getName()
{
return _item.getName();
}
public final int getCustomType1()
{
return _customType1;
}
public final int getCustomType2()
{
return _customType2;
}
public final int getMana()
{
return _mana;
}
public int getAttackElementType()
{
return _elemAtkType;
}
public int getAttackElementPower()
{
return _elemAtkPower;
}
public int getElementDefAttr(byte i)
{
return _elemDefAttr[i];
}
public int getTime()
{
return _time;
}
/**
* Returns the name of the item
* @return String
*/
@Override
public String toString()
{
return _item.toString();
}
}
@@ -0,0 +1,453 @@
/*
* 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.l2jserver.gameserver.templates.item;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javolution.util.FastList;
import com.l2jserver.gameserver.handler.ISkillHandler;
import com.l2jserver.gameserver.handler.SkillHandler;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.skills.Env;
import com.l2jserver.gameserver.skills.Formulas;
import com.l2jserver.gameserver.skills.SkillHolder;
import com.l2jserver.gameserver.skills.conditions.Condition;
import com.l2jserver.gameserver.skills.conditions.ConditionGameChance;
import com.l2jserver.gameserver.skills.funcs.Func;
import com.l2jserver.gameserver.skills.funcs.FuncTemplate;
import com.l2jserver.gameserver.templates.StatsSet;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
import com.l2jserver.util.StringUtil;
/**
* 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 L2WeaponType _type;
private final boolean _isMagicWeapon;
private final int _rndDam;
private final int _soulShotCount;
private final int _spiritShotCount;
private final int _mpConsume;
private SkillHolder _enchant4Skill = null; // skill that activates when item is enchanted +4 (for duals)
private final int _changeWeaponId;
// private final String[] _skill;
// Attached skills for Special Abilities
private SkillHolder _skillsOnCast;
private Condition _skillsOnCastCondition = null;
private SkillHolder _skillsOnCrit;
private Condition _skillsOnCritCondition = null;
private final int _reuseDelay;
/**
* 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(StatsSet set)
{
super(set);
_type = L2WeaponType.valueOf(set.getString("weapon_type", "none").toUpperCase());
_type1 = L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE;
_type2 = L2Item.TYPE2_WEAPON;
_isMagicWeapon = set.getBool("is_magic_weapon", false);
_soulShotCount = set.getInteger("soulshots", 0);
_spiritShotCount = set.getInteger("spiritshots", 0);
_rndDam = set.getInteger("random_damage", 0);
_mpConsume = set.getInteger("mp_consume", 0);
_reuseDelay = set.getInteger("reuse_delay", 0);
String skill = set.getString("enchant4_skill", null);
if (skill != null)
{
String[] info = skill.split("-");
if ((info != null) && (info.length == 2))
{
int id = 0;
int level = 0;
try
{
id = Integer.parseInt(info[0]);
level = Integer.parseInt(info[1]);
}
catch (Exception nfe)
{
// Incorrect syntax, dont add new skill
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon enchant skills! item ", toString()));
}
if ((id > 0) && (level > 0))
{
_enchant4Skill = new SkillHolder(id, level);
}
}
}
skill = set.getString("oncast_skill", null);
if (skill != null)
{
String[] info = skill.split("-");
String infochance = set.getString("oncast_chance", null);
if ((info != null) && (info.length == 2))
{
int id = 0;
int level = 0;
int chance = 0;
try
{
id = Integer.parseInt(info[0]);
level = Integer.parseInt(info[1]);
if (infochance != null)
{
chance = Integer.parseInt(infochance);
}
}
catch (Exception nfe)
{
// Incorrect syntax, dont add new skill
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon oncast skills! item ", toString()));
}
if ((id > 0) && (level > 0) && (chance > 0))
{
_skillsOnCast = new SkillHolder(id, level);
if (infochance != null)
{
_skillsOnCastCondition = new ConditionGameChance(chance);
}
}
}
}
skill = set.getString("oncrit_skill", null);
if (skill != null)
{
String[] info = skill.split("-");
String infochance = set.getString("oncrit_chance", null);
if ((info != null) && (info.length == 2))
{
int id = 0;
int level = 0;
int chance = 0;
try
{
id = Integer.parseInt(info[0]);
level = Integer.parseInt(info[1]);
if (infochance != null)
{
chance = Integer.parseInt(infochance);
}
}
catch (Exception nfe)
{
// Incorrect syntax, dont add new skill
_log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon oncrit skills! item ", toString()));
}
if ((id > 0) && (level > 0) && (chance > 0))
{
_skillsOnCrit = new SkillHolder(id, level);
if (infochance != null)
{
_skillsOnCritCondition = new ConditionGameChance(chance);
}
}
}
}
_changeWeaponId = set.getInteger("change_weaponId", 0);
}
/**
* Returns the type of Weapon
* @return L2WeaponType
*/
@Override
public L2WeaponType getItemType()
{
return _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 true if L2Weapon is magic type.
* @return boolean
*/
public boolean isMagicWeapon()
{
return _isMagicWeapon;
}
/**
* 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 random damage inflicted by the weapon
* @return int
*/
public int getRandomDamage()
{
return _rndDam;
}
/**
* Return the Reuse Delay of the L2Weapon.<BR>
* <BR>
* @return int
*/
public int getReuseDelay()
{
return _reuseDelay;
}
/**
* Returns the MP consumption with the weapon
* @return int
*/
public int getMpConsume()
{
return _mpConsume;
}
/**
* Returns skill that player get when has equiped weapon +4 or more (for duals SA)
* @return
*/
public L2Skill getEnchant4Skill()
{
if (_enchant4Skill == null)
{
return null;
}
return _enchant4Skill.getSkill();
}
/**
* Returns the Id in wich weapon this weapon can be changed
* @return
*/
public int getChangeWeaponId()
{
return _changeWeaponId;
}
/**
* 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)
{
if ((_funcTemplates == null) || (_funcTemplates.length == 0))
{
return _emptyFunctionSet;
}
ArrayList<Func> funcs = new ArrayList<>(_funcTemplates.length);
Env env = new Env();
env.player = player;
env.item = instance;
Func f;
for (FuncTemplate t : _funcTemplates)
{
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
* @param crit : boolean tells whether the hit was critical
* @return L2Effect[] : array of effects generated by the skill
*/
public L2Effect[] getSkillEffects(L2Character caster, L2Character target, boolean crit)
{
if ((_skillsOnCrit == null) || !crit)
{
return _emptyEffectSet;
}
List<L2Effect> effects = new FastList<>();
if (_skillsOnCritCondition != null)
{
Env env = new Env();
env.player = caster;
env.target = target;
env.skill = _skillsOnCrit.getSkill();
if (!_skillsOnCritCondition.test(env))
{
return _emptyEffectSet; // Skill condition not met
}
}
byte shld = Formulas.calcShldUse(caster, target, _skillsOnCrit.getSkill());
if (!Formulas.calcSkillSuccess(caster, target, _skillsOnCrit.getSkill(), shld, false, false, false))
{
return _emptyEffectSet; // These skills should not work on RaidBoss
}
if (target.getFirstEffect(_skillsOnCrit.getSkill().getId()) != null)
{
target.getFirstEffect(_skillsOnCrit.getSkill().getId()).exit();
}
for (L2Effect e : _skillsOnCrit.getSkill().getEffects(caster, target, new Env(shld, false, false, false)))
{
effects.add(e);
}
if (effects.isEmpty())
{
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;
}
if (trigger.isOffensive() != _skillsOnCast.getSkill().isOffensive())
{
return _emptyEffectSet; // Trigger only same type of skill
}
if (trigger.isToggle() && (_skillsOnCast.getSkill().getSkillType() == L2SkillType.BUFF))
{
return _emptyEffectSet; // No buffing with toggle skills
}
if (!trigger.isMagic() && (_skillsOnCast.getSkill().getSkillType() == L2SkillType.BUFF))
{
return _emptyEffectSet; // No buffing with not magic skills
}
if (_skillsOnCastCondition != null)
{
Env env = new Env();
env.player = caster;
env.target = target;
env.skill = _skillsOnCast.getSkill();
if (!_skillsOnCastCondition.test(env))
{
return _emptyEffectSet;
}
}
byte shld = Formulas.calcShldUse(caster, target, _skillsOnCast.getSkill());
if (_skillsOnCast.getSkill().isOffensive() && !Formulas.calcSkillSuccess(caster, target, _skillsOnCast.getSkill(), shld, false, false, false))
{
return _emptyEffectSet;
}
// Get the skill handler corresponding to the skill type
ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(_skillsOnCast.getSkill().getSkillType());
L2Character[] targets = new L2Character[1];
targets[0] = target;
// Launch the magic skill and calculate its effects
if (handler != null)
{
handler.useSkill(caster, _skillsOnCast.getSkill(), targets);
}
else
{
_skillsOnCast.getSkill().useSkill(caster, targets);
}
// notify quests of a skill use
if (caster instanceof L2PcInstance)
{
// Mobs in range 1000 see spell
Collection<L2Object> objs = caster.getKnownList().getKnownObjects().values();
// synchronized (caster.getKnownList().getKnownObjects())
{
for (L2Object spMob : objs)
{
if (spMob instanceof L2Npc)
{
L2Npc npcMob = (L2Npc) spMob;
if (npcMob.getTemplate().getEventQuests(Quest.QuestEventType.ON_SKILL_SEE) != null)
{
for (Quest quest : npcMob.getTemplate().getEventQuests(Quest.QuestEventType.ON_SKILL_SEE))
{
quest.notifySkillSee(npcMob, (L2PcInstance) caster, _skillsOnCast.getSkill(), targets, false);
}
}
}
}
}
}
return _emptyEffectSet;
}
}
@@ -0,0 +1,79 @@
/*
* 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.l2jserver.gameserver.templates.item;
/**
* @author mkizub <BR>
* Description of Weapon Type
*/
public enum L2WeaponType implements L2ItemType
{
SWORD("Sword"),
BLUNT("Blunt"),
DAGGER("Dagger"),
BOW("Bow"),
POLE("Pole"),
NONE("None"),
DUAL("Dual Sword"),
ETC("Etc"),
FIST("Fist"),
DUALFIST("Dual Fist"),
FISHINGROD("Rod"),
RAPIER("Rapier"),
ANCIENTSWORD("Ancient"),
CROSSBOW("Crossbow"),
FLAG("Flag"),
OWNTHING("Ownthing"),
DUALDAGGER("Dual Dagger"),
// L2J CUSTOM, BACKWARD COMPATIBILITY
BIGBLUNT("Big Blunt"),
BIGSWORD("Big Sword");
private final int _mask;
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(String name)
{
_mask = 1 << ordinal();
_name = name;
}
/**
* Returns the ID of the item after applying the mask.
* @return int : ID of the item
*/
@Override
public int mask()
{
return _mask;
}
/**
* Returns the name of the WeaponType
* @return String
*/
@Override
public String toString()
{
return _name;
}
}
@@ -0,0 +1,79 @@
/*
* 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.l2jserver.gameserver.templates.skills;
/**
* @author nBd
*/
public enum L2EffectType
{
BUFF,
DEBUFF,
CANCEL_DEBUFF,
CHARGE,
DMG_OVER_TIME,
HEAL_OVER_TIME,
COMBAT_POINT_HEAL,
COMBAT_POINT_HEAL_OVER_TIME,
CPDAMPERCENT,
MANA_DMG_OVER_TIME,
MANA_HEAL_OVER_TIME,
MP_CONSUME_PER_LEVEL,
RELAXING,
STUN,
ROOT,
SLEEP,
HATE,
FAKE_DEATH,
CONFUSION,
CONFUSE_MOB_ONLY,
MUTE,
FEAR,
SILENT_MOVE,
SEED,
PARALYZE,
STUN_SELF,
PHYSICAL_MUTE,
PHYSICAL_ATTACK_MUTE,
REMOVE_TARGET,
TARGET_ME,
SILENCE_MAGIC_PHYSICAL,
BETRAY,
NOBLESSE_BLESSING,
PHOENIX_BLESSING,
PETRIFICATION,
BLUFF,
CHARM_OF_LUCK,
LUCKY,
INVINCIBLE,
TRANSFORMATION,
DISARM,
CHARMOFCOURAGE,
SIGNET_EFFECT,
SIGNET_GROUND,
WARP,
SPOIL,
PROTECTION_BLESSING,
FUSION,
CHANCE_SKILL_TRIGGER,
CLAN_GATE,
CANCEL,
NEGATE,
THROW_UP,
HIDE,
ABORT_CAST,
INCREASE_CHARGES,
BLOCK_RESURRECTION
}
@@ -0,0 +1,229 @@
/*
* 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.l2jserver.gameserver.templates.skills;
import java.lang.reflect.Constructor;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.skills.l2skills.L2SkillAgathion;
import com.l2jserver.gameserver.skills.l2skills.L2SkillAppearance;
import com.l2jserver.gameserver.skills.l2skills.L2SkillChangeWeapon;
import com.l2jserver.gameserver.skills.l2skills.L2SkillChargeDmg;
import com.l2jserver.gameserver.skills.l2skills.L2SkillCreateItem;
import com.l2jserver.gameserver.skills.l2skills.L2SkillDecoy;
import com.l2jserver.gameserver.skills.l2skills.L2SkillDefault;
import com.l2jserver.gameserver.skills.l2skills.L2SkillDrain;
import com.l2jserver.gameserver.skills.l2skills.L2SkillLearnSkill;
import com.l2jserver.gameserver.skills.l2skills.L2SkillMount;
import com.l2jserver.gameserver.skills.l2skills.L2SkillSiegeFlag;
import com.l2jserver.gameserver.skills.l2skills.L2SkillSignet;
import com.l2jserver.gameserver.skills.l2skills.L2SkillSignetCasttime;
import com.l2jserver.gameserver.skills.l2skills.L2SkillSpawn;
import com.l2jserver.gameserver.skills.l2skills.L2SkillSummon;
import com.l2jserver.gameserver.skills.l2skills.L2SkillSweeper;
import com.l2jserver.gameserver.skills.l2skills.L2SkillTeleport;
import com.l2jserver.gameserver.skills.l2skills.L2SkillTrap;
import com.l2jserver.gameserver.templates.StatsSet;
/**
* @author nBd
*/
public enum L2SkillType
{
// Damage
PDAM,
MDAM,
CPDAM,
MANADAM,
CPDAMPERCENT,
DOT,
MDOT,
DRAIN_SOUL,
DRAIN(L2SkillDrain.class),
DEATHLINK,
FATAL,
BLOW,
SIGNET(L2SkillSignet.class),
SIGNET_CASTTIME(L2SkillSignetCasttime.class),
// Disablers
BLEED,
POISON,
STUN,
ROOT,
CONFUSION,
FEAR,
SLEEP,
CONFUSE_MOB_ONLY,
MUTE,
PARALYZE,
DISARM,
// hp, mp, cp
HEAL,
HOT,
BALANCE_LIFE,
HEAL_PERCENT,
HEAL_STATIC,
COMBATPOINTHEAL,
CPHEAL_PERCENT,
CPHOT,
MANAHEAL,
MANA_BY_LEVEL,
MANAHEAL_PERCENT,
MANARECHARGE,
MPHOT,
HPMPCPHEAL_PERCENT,
HPMPHEAL_PERCENT,
HPCPHEAL_PERCENT,
// sp
GIVE_SP,
// reco
GIVE_RECO,
// vitality
GIVE_VITALITY,
// Aggro
AGGDAMAGE,
AGGREDUCE,
AGGREMOVE,
AGGREDUCE_CHAR,
AGGDEBUFF,
// Fishing
FISHING,
PUMPING,
REELING,
// MISC
UNLOCK,
UNLOCK_SPECIAL,
ENCHANT_ARMOR,
ENCHANT_WEAPON,
ENCHANT_ATTRIBUTE,
SOULSHOT,
SPIRITSHOT,
SIEGEFLAG(L2SkillSiegeFlag.class),
TAKECASTLE,
TAKEFORT,
WEAPON_SA,
DELUXE_KEY_UNLOCK,
SOW,
HARVEST,
GET_PLAYER,
AGATHION(L2SkillAgathion.class),
MOUNT(L2SkillMount.class),
INSTANT_JUMP,
DETECTION,
DUMMY,
// Creation
COMMON_CRAFT,
DWARVEN_CRAFT,
CREATE_ITEM(L2SkillCreateItem.class),
EXTRACTABLE,
EXTRACTABLE_FISH,
LEARN_SKILL(L2SkillLearnSkill.class),
// Summons
SUMMON(L2SkillSummon.class),
FEED_PET,
DEATHLINK_PET,
STRSIEGEASSAULT,
ERASE,
BETRAY,
DECOY(L2SkillDecoy.class),
SPAWN(L2SkillSpawn.class),
// Cancel
CANCEL,
CANCEL_STATS,
CANCEL_DEBUFF,
NEGATE,
BUFF,
DEBUFF,
PASSIVE,
CONT,
FUSION,
RESURRECT,
CHARGEDAM(L2SkillChargeDmg.class),
MHOT,
DETECT_WEAKNESS,
RECALL(L2SkillTeleport.class),
TELEPORT(L2SkillTeleport.class),
SUMMON_FRIEND,
SPOIL,
SWEEP(L2SkillSweeper.class),
FAKE_DEATH,
UNDEAD_DEFENSE,
BEAST_FEED,
BEAST_RELEASE,
BEAST_RELEASE_ALL,
BEAST_SKILL,
BEAST_ACCOMPANY,
CHARGESOUL,
TRANSFORMDISPEL,
SUMMON_TRAP(L2SkillTrap.class),
DETECT_TRAP,
REMOVE_TRAP,
SHIFT_TARGET,
// Kamael WeaponChange
CHANGEWEAPON(L2SkillChangeWeapon.class),
STEAL_BUFF,
// Skill is done within the core.
COREDONE,
CHANGE_APPEARANCE(L2SkillAppearance.class),
// Refuel airship
REFUEL,
// Nornil's Power (Nornil's Garden instance)
NORNILS_POWER,
// unimplemented
NOTDONE,
BALLISTA;
private final Class<? extends L2Skill> _class;
public L2Skill makeSkill(StatsSet set)
{
try
{
Constructor<? extends L2Skill> c = _class.getConstructor(StatsSet.class);
return c.newInstance(set);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
private L2SkillType()
{
_class = L2SkillDefault.class;
}
private L2SkillType(Class<? extends L2Skill> classType)
{
_class = classType;
}
}