Chronicle 4 branch.
This commit is contained in:
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
|
||||
/**
|
||||
* @author DS
|
||||
*/
|
||||
public enum BaseStats
|
||||
{
|
||||
STR(new STR()),
|
||||
INT(new INT()),
|
||||
DEX(new DEX()),
|
||||
WIT(new WIT()),
|
||||
CON(new CON()),
|
||||
MEN(new MEN()),
|
||||
NULL(new NULL());
|
||||
|
||||
private static final Logger _log = Logger.getLogger(BaseStats.class.getName());
|
||||
|
||||
public static final int MAX_STAT_VALUE = 100;
|
||||
|
||||
protected static final double[] STRbonus = new double[MAX_STAT_VALUE];
|
||||
protected static final double[] INTbonus = new double[MAX_STAT_VALUE];
|
||||
protected static final double[] DEXbonus = new double[MAX_STAT_VALUE];
|
||||
protected static final double[] WITbonus = new double[MAX_STAT_VALUE];
|
||||
protected static final double[] CONbonus = new double[MAX_STAT_VALUE];
|
||||
protected static final double[] MENbonus = new double[MAX_STAT_VALUE];
|
||||
|
||||
private final BaseStat _stat;
|
||||
|
||||
public final String getValue()
|
||||
{
|
||||
return _stat.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private BaseStats(BaseStat s)
|
||||
{
|
||||
_stat = s;
|
||||
}
|
||||
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
if (actor != null)
|
||||
{
|
||||
return _stat.calcBonus(actor);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static final BaseStats valueOfXml(String name)
|
||||
{
|
||||
name = name.intern();
|
||||
for (final BaseStats s : values())
|
||||
{
|
||||
if (s.getValue().equalsIgnoreCase(name))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
throw new NoSuchElementException("Unknown name '" + name + "' for enum BaseStats");
|
||||
}
|
||||
|
||||
private interface BaseStat
|
||||
{
|
||||
public double calcBonus(L2Character actor);
|
||||
}
|
||||
|
||||
protected static final class STR implements BaseStat
|
||||
{
|
||||
@Override
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
return STRbonus[actor.getSTR()];
|
||||
}
|
||||
}
|
||||
|
||||
protected static final class INT implements BaseStat
|
||||
{
|
||||
@Override
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
return INTbonus[actor.getINT()];
|
||||
}
|
||||
}
|
||||
|
||||
protected static final class DEX implements BaseStat
|
||||
{
|
||||
@Override
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
return DEXbonus[actor.getDEX()];
|
||||
}
|
||||
}
|
||||
|
||||
protected static final class WIT implements BaseStat
|
||||
{
|
||||
@Override
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
return WITbonus[actor.getWIT()];
|
||||
}
|
||||
}
|
||||
|
||||
protected static final class CON implements BaseStat
|
||||
{
|
||||
@Override
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
return CONbonus[actor.getCON()];
|
||||
}
|
||||
}
|
||||
|
||||
protected static final class MEN implements BaseStat
|
||||
{
|
||||
@Override
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
return MENbonus[actor.getMEN()];
|
||||
}
|
||||
}
|
||||
|
||||
protected static final class NULL implements BaseStat
|
||||
{
|
||||
@Override
|
||||
public final double calcBonus(L2Character actor)
|
||||
{
|
||||
return 1f;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
final File file = new File(Config.DATAPACK_ROOT, "data/stats/baseStats.xml");
|
||||
Document doc = null;
|
||||
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
doc = factory.newDocumentBuilder().parse(file);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "[BaseStats] Could not parse file: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (doc != null)
|
||||
{
|
||||
String statName;
|
||||
int val;
|
||||
double bonus;
|
||||
NamedNodeMap attrs;
|
||||
for (Node list = doc.getFirstChild(); list != null; list = list.getNextSibling())
|
||||
{
|
||||
if ("list".equalsIgnoreCase(list.getNodeName()))
|
||||
{
|
||||
for (Node stat = list.getFirstChild(); stat != null; stat = stat.getNextSibling())
|
||||
{
|
||||
statName = stat.getNodeName();
|
||||
for (Node value = stat.getFirstChild(); value != null; value = value.getNextSibling())
|
||||
{
|
||||
if ("stat".equalsIgnoreCase(value.getNodeName()))
|
||||
{
|
||||
attrs = value.getAttributes();
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(attrs.getNamedItem("value").getNodeValue());
|
||||
bonus = Double.parseDouble(attrs.getNamedItem("bonus").getNodeValue());
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
_log.severe("[BaseStats] Invalid stats value: " + value.getNodeValue() + ", skipping");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("STR".equalsIgnoreCase(statName))
|
||||
{
|
||||
STRbonus[val] = bonus;
|
||||
}
|
||||
else if ("INT".equalsIgnoreCase(statName))
|
||||
{
|
||||
INTbonus[val] = bonus;
|
||||
}
|
||||
else if ("DEX".equalsIgnoreCase(statName))
|
||||
{
|
||||
DEXbonus[val] = bonus;
|
||||
}
|
||||
else if ("WIT".equalsIgnoreCase(statName))
|
||||
{
|
||||
WITbonus[val] = bonus;
|
||||
}
|
||||
else if ("CON".equalsIgnoreCase(statName))
|
||||
{
|
||||
CONbonus[val] = bonus;
|
||||
}
|
||||
else if ("MEN".equalsIgnoreCase(statName))
|
||||
{
|
||||
MENbonus[val] = bonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.severe("[BaseStats] Invalid stats name: " + statName + ", skipping");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Error("[BaseStats] File not found: " + file.getName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.funcs.Func;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* A calculator is created to manage and dynamically calculate the effect of a character property (ex : MAX_HP, REGENERATE_HP_RATE...). In fact, each calculator is a table of Func object in which each Func represents a mathematic function : <BR>
|
||||
* <BR>
|
||||
* FuncAtkAccuracy -> Math.sqrt(_player.getDEX())*6+_player.getLevel()<BR>
|
||||
* <BR>
|
||||
* When the calc method of a calculator is launched, each mathematic function is called according to its priority <B>_order</B>. Indeed, Func with lowest priority order is executed first and Funcs with the same order are executed in unspecified order. The result of the calculation is stored in the
|
||||
* value property of an Env class instance.<BR>
|
||||
* <BR>
|
||||
* Method addFunc and removeFunc permit to add and remove a Func object from a Calculator.<BR>
|
||||
* <BR>
|
||||
*/
|
||||
public final class Calculator
|
||||
{
|
||||
/** Empty Func table definition */
|
||||
static final Func[] emptyFuncs = new Func[0];
|
||||
|
||||
/** Table of Func object */
|
||||
Func[] _functions;
|
||||
|
||||
/**
|
||||
* Constructor of Calculator (Init value : emptyFuncs).<BR>
|
||||
* <BR>
|
||||
*/
|
||||
public Calculator()
|
||||
{
|
||||
_functions = emptyFuncs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor of Calculator (Init value : Calculator c).<BR>
|
||||
* <BR>
|
||||
* @param c
|
||||
*/
|
||||
public Calculator(Calculator c)
|
||||
{
|
||||
_functions = c._functions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if 2 calculators are equals.<BR>
|
||||
* <BR>
|
||||
* @param c1
|
||||
* @param c2
|
||||
* @return
|
||||
*/
|
||||
public static boolean equalsCals(Calculator c1, Calculator c2)
|
||||
{
|
||||
if (c1 == c2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((c1 == null) || (c2 == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Func[] funcs1 = c1._functions;
|
||||
final Func[] funcs2 = c2._functions;
|
||||
|
||||
if (funcs1 == funcs2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (funcs1.length != funcs2.length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (funcs1.length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < funcs1.length; i++)
|
||||
{
|
||||
if (funcs1[i] != funcs2[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of Funcs in the Calculator.<BR>
|
||||
* <BR>
|
||||
* @return
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return _functions.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Func to the Calculator.<BR>
|
||||
* <BR>
|
||||
* @param f
|
||||
*/
|
||||
public synchronized void addFunc(Func f)
|
||||
{
|
||||
final Func[] funcs = _functions;
|
||||
final Func[] tmp = new Func[funcs.length + 1];
|
||||
|
||||
final int order = f._order;
|
||||
int i;
|
||||
|
||||
for (i = 0; (i < funcs.length) && (order >= funcs[i]._order); i++)
|
||||
{
|
||||
tmp[i] = funcs[i];
|
||||
}
|
||||
|
||||
tmp[i] = f;
|
||||
|
||||
for (; i < funcs.length; i++)
|
||||
{
|
||||
tmp[i + 1] = funcs[i];
|
||||
}
|
||||
|
||||
_functions = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a Func from the Calculator.<BR>
|
||||
* <BR>
|
||||
* @param f
|
||||
*/
|
||||
public synchronized void removeFunc(Func f)
|
||||
{
|
||||
final Func[] funcs = _functions;
|
||||
final Func[] tmp = new Func[funcs.length - 1];
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; (i < funcs.length) && (f != funcs[i]); i++)
|
||||
{
|
||||
tmp[i] = funcs[i];
|
||||
}
|
||||
|
||||
if (i == funcs.length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i++; i < funcs.length; i++)
|
||||
{
|
||||
tmp[i - 1] = funcs[i];
|
||||
}
|
||||
|
||||
if (tmp.length == 0)
|
||||
{
|
||||
_functions = emptyFuncs;
|
||||
}
|
||||
else
|
||||
{
|
||||
_functions = tmp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove each Func with the specified owner of the Calculator.<BR>
|
||||
* <BR>
|
||||
* @param owner
|
||||
* @return
|
||||
*/
|
||||
public synchronized FastList<Stats> removeOwner(Object owner)
|
||||
{
|
||||
final Func[] funcs = _functions;
|
||||
final FastList<Stats> modifiedStats = new FastList<>();
|
||||
|
||||
for (final Func func : funcs)
|
||||
{
|
||||
if (func._funcOwner == owner)
|
||||
{
|
||||
modifiedStats.add(func._stat);
|
||||
removeFunc(func);
|
||||
}
|
||||
}
|
||||
return modifiedStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run each Func of the Calculator.<BR>
|
||||
* <BR>
|
||||
* @param env
|
||||
*/
|
||||
public void calc(Env env)
|
||||
{
|
||||
final Func[] funcs = _functions;
|
||||
for (final Func func : funcs)
|
||||
{
|
||||
func.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,864 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.base.Race;
|
||||
import com.l2jmobius.gameserver.skills.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionElementSeed;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionGameChance;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionGameTime;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionGameTime.CheckGameTime;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionLogicAnd;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionLogicNot;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionLogicOr;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionPlayerHp;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionPlayerHpPercentage;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionPlayerLevel;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionPlayerRace;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionPlayerState;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionPlayerState.CheckPlayerState;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionSkillStats;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionSlotItemId;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionTargetAggro;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionTargetLevel;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionTargetUsesWeaponKind;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionUsingItemType;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionUsingSkill;
|
||||
import com.l2jmobius.gameserver.skills.conditions.ConditionWithSkill;
|
||||
import com.l2jmobius.gameserver.skills.effects.EffectTemplate;
|
||||
import com.l2jmobius.gameserver.skills.funcs.FuncTemplate;
|
||||
import com.l2jmobius.gameserver.skills.funcs.Lambda;
|
||||
import com.l2jmobius.gameserver.skills.funcs.LambdaCalc;
|
||||
import com.l2jmobius.gameserver.skills.funcs.LambdaConst;
|
||||
import com.l2jmobius.gameserver.skills.funcs.LambdaStats;
|
||||
import com.l2jmobius.gameserver.templates.L2ArmorType;
|
||||
import com.l2jmobius.gameserver.templates.L2Item;
|
||||
import com.l2jmobius.gameserver.templates.L2Weapon;
|
||||
import com.l2jmobius.gameserver.templates.L2WeaponType;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
import javolution.text.TextBuilder;
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
abstract class DocumentBase
|
||||
{
|
||||
static Logger _log = Logger.getLogger(DocumentBase.class.getName());
|
||||
|
||||
private final File file;
|
||||
protected Map<String, Number[]> tables;
|
||||
|
||||
DocumentBase(File pFile)
|
||||
{
|
||||
file = pFile;
|
||||
tables = new FastMap<>();
|
||||
}
|
||||
|
||||
Document parse()
|
||||
{
|
||||
Document doc;
|
||||
try
|
||||
{
|
||||
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
doc = factory.newDocumentBuilder().parse(file);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error loading file " + file, e);
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
parseDocument(doc);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Error in file " + file, e);
|
||||
return null;
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
protected abstract void parseDocument(Document doc);
|
||||
|
||||
protected abstract StatsSet getStatsSet();
|
||||
|
||||
protected abstract Number getTableValue(String name);
|
||||
|
||||
protected abstract Number getTableValue(String name, int idx);
|
||||
|
||||
protected void resetTable()
|
||||
{
|
||||
tables = new FastMap<>();
|
||||
}
|
||||
|
||||
protected void setTable(String name, Number[] table)
|
||||
{
|
||||
tables.put(name, table);
|
||||
}
|
||||
|
||||
protected void parseTemplate(Node n, Object template)
|
||||
{
|
||||
Condition condition = null;
|
||||
n = n.getFirstChild();
|
||||
if (n == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ("cond".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
condition = parseCondition(n.getFirstChild(), template);
|
||||
final Node msg = n.getAttributes().getNamedItem("msg");
|
||||
|
||||
if ((condition != null) && (msg != null))
|
||||
{
|
||||
condition.setMessage(msg.getNodeValue());
|
||||
}
|
||||
|
||||
n = n.getNextSibling();
|
||||
}
|
||||
for (; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("add".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
attachFunc(n, template, "Add", condition);
|
||||
}
|
||||
else if ("sub".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
attachFunc(n, template, "Sub", condition);
|
||||
}
|
||||
else if ("mul".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
attachFunc(n, template, "Mul", condition);
|
||||
}
|
||||
else if ("div".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
attachFunc(n, template, "Div", condition);
|
||||
}
|
||||
else if ("set".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
attachFunc(n, template, "Set", condition);
|
||||
}
|
||||
else if ("enchant".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
attachFunc(n, template, "Enchant", condition);
|
||||
}
|
||||
else if ("skill".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
attachSkill(n, template, condition);
|
||||
}
|
||||
else if ("effect".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
if (template instanceof EffectTemplate)
|
||||
{
|
||||
throw new RuntimeException("Nested effects");
|
||||
}
|
||||
attachEffect(n, template, condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void attachFunc(Node n, Object template, String name, Condition attachCond)
|
||||
{
|
||||
final Stats stat = Stats.valueOfXml(n.getAttributes().getNamedItem("stat").getNodeValue());
|
||||
final String order = n.getAttributes().getNamedItem("order").getNodeValue();
|
||||
final Lambda lambda = getLambda(n, template);
|
||||
final int ord = getNumber(order, template).intValue();
|
||||
|
||||
final Condition applyCond = parseCondition(n.getFirstChild(), template);
|
||||
final FuncTemplate ft = new FuncTemplate(attachCond, applyCond, name, stat, ord, lambda);
|
||||
if (template instanceof L2Item)
|
||||
{
|
||||
((L2Item) template).attach(ft);
|
||||
}
|
||||
else if (template instanceof L2Skill)
|
||||
{
|
||||
((L2Skill) template).attach(ft);
|
||||
}
|
||||
else if (template instanceof EffectTemplate)
|
||||
{
|
||||
((EffectTemplate) template).attach(ft);
|
||||
}
|
||||
}
|
||||
|
||||
protected void attachLambdaFunc(Node n, Object template, LambdaCalc calc)
|
||||
{
|
||||
String name = n.getNodeName();
|
||||
final TextBuilder sb = new TextBuilder(name);
|
||||
sb.setCharAt(0, Character.toUpperCase(name.charAt(0)));
|
||||
name = sb.toString();
|
||||
final Lambda lambda = getLambda(n, template);
|
||||
final FuncTemplate ft = new FuncTemplate(null, null, name, null, calc._funcs.length, lambda);
|
||||
calc.addFunc(ft.getFunc(new Env(), calc));
|
||||
}
|
||||
|
||||
protected void attachEffect(Node n, Object template, Condition attachCond)
|
||||
{
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
final String name = attrs.getNamedItem("name").getNodeValue();
|
||||
int time, count = 1;
|
||||
if (attrs.getNamedItem("count") != null)
|
||||
{
|
||||
count = getNumber(attrs.getNamedItem("count").getNodeValue(), template).intValue();
|
||||
}
|
||||
if (attrs.getNamedItem("time") != null)
|
||||
{
|
||||
time = getNumber(attrs.getNamedItem("time").getNodeValue(), template).intValue();
|
||||
if (Config.ENABLE_MODIFY_SKILL_DURATION)
|
||||
{
|
||||
if (Config.SKILL_DURATION_LIST.containsKey(((L2Skill) template).getId()))
|
||||
{
|
||||
if ((((L2Skill) template).getLevel() >= 100) && (((L2Skill) template).getLevel() < 140))
|
||||
{
|
||||
time += Config.SKILL_DURATION_LIST.get(((L2Skill) template).getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
time = Config.SKILL_DURATION_LIST.get(((L2Skill) template).getId());
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.info("*** Skill " + ((L2Skill) template).getName() + " (" + ((L2Skill) template).getLevel() + ") changed duration to " + time + " seconds.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
time = ((L2Skill) template).getBuffDuration() / 1000 / count;
|
||||
}
|
||||
|
||||
boolean self = false;
|
||||
if (attrs.getNamedItem("self") != null)
|
||||
{
|
||||
if (getNumber(attrs.getNamedItem("self").getNodeValue(), template).intValue() == 1)
|
||||
{
|
||||
self = true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean icon = true;
|
||||
if (attrs.getNamedItem("noicon") != null)
|
||||
{
|
||||
if (getNumber(attrs.getNamedItem("noicon").getNodeValue(), template).intValue() == 1)
|
||||
{
|
||||
icon = false;
|
||||
}
|
||||
}
|
||||
|
||||
final Lambda lambda = getLambda(n, template);
|
||||
final Condition applayCond = parseCondition(n.getFirstChild(), template);
|
||||
short abnormal = 0;
|
||||
if (attrs.getNamedItem("abnormal") != null)
|
||||
{
|
||||
final String abn = attrs.getNamedItem("abnormal").getNodeValue();
|
||||
if (abn.equals("poison"))
|
||||
{
|
||||
abnormal = L2Character.ABNORMAL_EFFECT_POISON;
|
||||
}
|
||||
if (abn.equals("bleeding"))
|
||||
{
|
||||
abnormal = L2Character.ABNORMAL_EFFECT_BLEEDING;
|
||||
}
|
||||
if (abn.equals("flame"))
|
||||
{
|
||||
abnormal = L2Character.ABNORMAL_EFFECT_FLAME;
|
||||
}
|
||||
if (abn.equals("bighead"))
|
||||
{
|
||||
abnormal = L2Character.ABNORMAL_EFFECT_BIG_HEAD;
|
||||
}
|
||||
}
|
||||
float stackOrder = 0;
|
||||
String stackType = "none";
|
||||
if (attrs.getNamedItem("stackType") != null)
|
||||
{
|
||||
stackType = attrs.getNamedItem("stackType").getNodeValue();
|
||||
}
|
||||
if (attrs.getNamedItem("stackOrder") != null)
|
||||
{
|
||||
stackOrder = getNumber(attrs.getNamedItem("stackOrder").getNodeValue(), template).floatValue();
|
||||
}
|
||||
final EffectTemplate lt = new EffectTemplate(attachCond, applayCond, name, lambda, count, time, abnormal, stackType, stackOrder, icon);
|
||||
parseTemplate(n, lt);
|
||||
if (template instanceof L2Item)
|
||||
{
|
||||
((L2Item) template).attach(lt);
|
||||
}
|
||||
else if ((template instanceof L2Skill) && !self)
|
||||
{
|
||||
((L2Skill) template).attach(lt);
|
||||
}
|
||||
else if ((template instanceof L2Skill) && self)
|
||||
{
|
||||
((L2Skill) template).attachSelf(lt);
|
||||
}
|
||||
}
|
||||
|
||||
protected void attachSkill(Node n, Object template, Condition attachCond)
|
||||
{
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
int id = 0, lvl = 1;
|
||||
if (attrs.getNamedItem("id") != null)
|
||||
{
|
||||
id = getNumber(attrs.getNamedItem("id").getNodeValue(), template).intValue();
|
||||
}
|
||||
if (attrs.getNamedItem("lvl") != null)
|
||||
{
|
||||
lvl = getNumber(attrs.getNamedItem("lvl").getNodeValue(), template).intValue();
|
||||
}
|
||||
|
||||
final L2Skill skill = SkillTable.getInstance().getInfo(id, lvl);
|
||||
if (attrs.getNamedItem("chance") != null)
|
||||
{
|
||||
if ((template instanceof L2Weapon) || (template instanceof L2Item))
|
||||
{
|
||||
skill.attach(new ConditionGameChance(getNumber(attrs.getNamedItem("chance").getNodeValue(), template).intValue()), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
skill.attach(new ConditionGameChance(getNumber(attrs.getNamedItem("chance").getNodeValue(), template).intValue()), false);
|
||||
}
|
||||
}
|
||||
if (template instanceof L2Weapon)
|
||||
{
|
||||
if ((attrs.getNamedItem("onUse") != null) || ((attrs.getNamedItem("onCrit") == null) && (attrs.getNamedItem("onCast") == null)))
|
||||
{
|
||||
((L2Weapon) template).attach(skill); // Attach as skill triggered on use
|
||||
}
|
||||
if (attrs.getNamedItem("onCrit") != null)
|
||||
{
|
||||
((L2Weapon) template).attachOnCrit(skill); // Attach as skill triggered on critical hit
|
||||
}
|
||||
if (attrs.getNamedItem("onCast") != null)
|
||||
{
|
||||
((L2Weapon) template).attachOnCast(skill); // Attach as skill triggered on cast
|
||||
}
|
||||
}
|
||||
else if (template instanceof L2Item)
|
||||
{
|
||||
((L2Item) template).attach(skill); // Attach as skill triggered on use
|
||||
}
|
||||
}
|
||||
|
||||
protected Condition parseCondition(Node n, Object template)
|
||||
{
|
||||
while ((n != null) && (n.getNodeType() != Node.ELEMENT_NODE))
|
||||
{
|
||||
n = n.getNextSibling();
|
||||
}
|
||||
if (n == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if ("and".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parseLogicAnd(n, template);
|
||||
}
|
||||
if ("or".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parseLogicOr(n, template);
|
||||
}
|
||||
if ("not".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parseLogicNot(n, template);
|
||||
}
|
||||
if ("player".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parsePlayerCondition(n);
|
||||
}
|
||||
if ("target".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parseTargetCondition(n, template);
|
||||
}
|
||||
if ("skill".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parseSkillCondition(n);
|
||||
}
|
||||
if ("using".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parseUsingCondition(n);
|
||||
}
|
||||
if ("game".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
return parseGameCondition(n);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Condition parseLogicAnd(Node n, Object template)
|
||||
{
|
||||
final ConditionLogicAnd cond = new ConditionLogicAnd();
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
cond.add(parseCondition(n, template));
|
||||
}
|
||||
}
|
||||
if ((cond._conditions == null) || (cond._conditions.length == 0))
|
||||
{
|
||||
_log.severe("Empty <and> condition in " + file);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected Condition parseLogicOr(Node n, Object template)
|
||||
{
|
||||
final ConditionLogicOr cond = new ConditionLogicOr();
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
cond.add(parseCondition(n, template));
|
||||
}
|
||||
}
|
||||
if ((cond._conditions == null) || (cond._conditions.length == 0))
|
||||
{
|
||||
_log.severe("Empty <or> condition in " + file);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected Condition parseLogicNot(Node n, Object template)
|
||||
{
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (n.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
return new ConditionLogicNot(parseCondition(n, template));
|
||||
}
|
||||
}
|
||||
_log.severe("Empty <not> condition in " + file);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Condition parsePlayerCondition(Node n)
|
||||
{
|
||||
Condition cond = null;
|
||||
final int[] ElementSeeds = new int[5];
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
final Node a = attrs.item(i);
|
||||
if ("race".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final Race race = Race.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionPlayerRace(race));
|
||||
}
|
||||
else if ("level".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final int lvl = getNumber(a.getNodeValue(), null).intValue();
|
||||
cond = joinAnd(cond, new ConditionPlayerLevel(lvl));
|
||||
}
|
||||
else if ("resting".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionPlayerState(CheckPlayerState.RESTING, val));
|
||||
}
|
||||
else if ("flying".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionPlayerState(CheckPlayerState.FLYING, val));
|
||||
}
|
||||
else if ("moving".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionPlayerState(CheckPlayerState.MOVING, val));
|
||||
}
|
||||
else if ("running".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionPlayerState(CheckPlayerState.RUNNING, val));
|
||||
}
|
||||
else if ("behind".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionPlayerState(CheckPlayerState.BEHIND, val));
|
||||
}
|
||||
else if ("front".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionPlayerState(CheckPlayerState.FRONT, val));
|
||||
}
|
||||
else if ("hp".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final int hp = getNumber(a.getNodeValue(), null).intValue();
|
||||
cond = joinAnd(cond, new ConditionPlayerHp(hp));
|
||||
}
|
||||
else if ("hprate".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final double rate = getNumber(a.getNodeValue(), null).doubleValue();
|
||||
cond = joinAnd(cond, new ConditionPlayerHpPercentage(rate));
|
||||
}
|
||||
else if ("seed_fire".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
ElementSeeds[0] = getNumber(a.getNodeValue(), null).intValue();
|
||||
}
|
||||
else if ("seed_water".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
ElementSeeds[1] = getNumber(a.getNodeValue(), null).intValue();
|
||||
}
|
||||
else if ("seed_wind".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
ElementSeeds[2] = getNumber(a.getNodeValue(), null).intValue();
|
||||
}
|
||||
else if ("seed_various".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
ElementSeeds[3] = getNumber(a.getNodeValue(), null).intValue();
|
||||
}
|
||||
else if ("seed_any".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
ElementSeeds[4] = getNumber(a.getNodeValue(), null).intValue();
|
||||
}
|
||||
}
|
||||
|
||||
// Elemental seed condition processing
|
||||
for (final int elementSeed : ElementSeeds)
|
||||
{
|
||||
if (elementSeed > 0)
|
||||
{
|
||||
cond = joinAnd(cond, new ConditionElementSeed(ElementSeeds));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cond == null)
|
||||
{
|
||||
_log.severe("Unrecognized <player> condition in " + file);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected Condition parseTargetCondition(Node n, Object template)
|
||||
{
|
||||
Condition cond = null;
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
final Node a = attrs.item(i);
|
||||
if ("aggro".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionTargetAggro(val));
|
||||
}
|
||||
else if ("level".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final int lvl = getNumber(a.getNodeValue(), template).intValue();
|
||||
cond = joinAnd(cond, new ConditionTargetLevel(lvl));
|
||||
}
|
||||
else if ("using".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
int mask = 0;
|
||||
final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
for (final L2WeaponType wt : L2WeaponType.values())
|
||||
{
|
||||
if (wt.toString().equals(item))
|
||||
{
|
||||
mask |= wt.mask();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (final L2ArmorType at : L2ArmorType.values())
|
||||
{
|
||||
if (at.toString().equals(item))
|
||||
{
|
||||
mask |= at.mask();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionTargetUsesWeaponKind(mask));
|
||||
}
|
||||
}
|
||||
if (cond == null)
|
||||
{
|
||||
_log.severe("Unrecognized <target> condition in " + file);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected Condition parseSkillCondition(Node n)
|
||||
{
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
final Stats stat = Stats.valueOfXml(attrs.getNamedItem("stat").getNodeValue());
|
||||
return new ConditionSkillStats(stat);
|
||||
}
|
||||
|
||||
protected Condition parseUsingCondition(Node n)
|
||||
{
|
||||
Condition cond = null;
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
final Node a = attrs.item(i);
|
||||
if ("kind".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
int mask = 0;
|
||||
final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String item = st.nextToken().trim();
|
||||
for (final L2WeaponType wt : L2WeaponType.values())
|
||||
{
|
||||
if (wt.toString().equals(item))
|
||||
{
|
||||
mask |= wt.mask();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (final L2ArmorType at : L2ArmorType.values())
|
||||
{
|
||||
if (at.toString().equals(item))
|
||||
{
|
||||
mask |= at.mask();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionUsingItemType(mask));
|
||||
}
|
||||
else if ("skill".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final int id = Integer.parseInt(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionUsingSkill(id));
|
||||
}
|
||||
else if ("slotitem".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ";");
|
||||
final int id = Integer.parseInt(st.nextToken().trim());
|
||||
final int slot = Integer.parseInt(st.nextToken().trim());
|
||||
int enchant = 0;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
enchant = Integer.parseInt(st.nextToken().trim());
|
||||
}
|
||||
cond = joinAnd(cond, new ConditionSlotItemId(slot, id, enchant));
|
||||
}
|
||||
}
|
||||
if (cond == null)
|
||||
{
|
||||
_log.severe("Unrecognized <using> condition in " + file);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected Condition parseGameCondition(Node n)
|
||||
{
|
||||
Condition cond = null;
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
final Node a = attrs.item(i);
|
||||
if ("skill".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionWithSkill(val));
|
||||
}
|
||||
if ("night".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final boolean val = Boolean.valueOf(a.getNodeValue());
|
||||
cond = joinAnd(cond, new ConditionGameTime(CheckGameTime.NIGHT, val));
|
||||
}
|
||||
if ("chance".equalsIgnoreCase(a.getNodeName()))
|
||||
{
|
||||
final int val = getNumber(a.getNodeValue(), null).intValue();
|
||||
cond = joinAnd(cond, new ConditionGameChance(val));
|
||||
}
|
||||
}
|
||||
if (cond == null)
|
||||
{
|
||||
_log.severe("Unrecognized <game> condition in " + file);
|
||||
}
|
||||
return cond;
|
||||
}
|
||||
|
||||
protected void parseTable(Node n)
|
||||
{
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
final String name = attrs.getNamedItem("name").getNodeValue();
|
||||
if (name.charAt(0) != '#')
|
||||
{
|
||||
throw new IllegalArgumentException("Table name must start with #");
|
||||
}
|
||||
final StringTokenizer data = new StringTokenizer(n.getFirstChild().getNodeValue());
|
||||
final List<String> array = new FastList<>();
|
||||
while (data.hasMoreTokens())
|
||||
{
|
||||
array.add(data.nextToken());
|
||||
}
|
||||
final Number[] res = new Number[array.size()];
|
||||
for (int i = 0; i < array.size(); i++)
|
||||
{
|
||||
res[i] = getNumber(array.get(i), null);
|
||||
}
|
||||
setTable(name, res);
|
||||
}
|
||||
|
||||
protected void parseBeanSet(Node n, StatsSet set, Integer level)
|
||||
{
|
||||
final String name = n.getAttributes().getNamedItem("name").getNodeValue().trim();
|
||||
final String value = n.getAttributes().getNamedItem("val").getNodeValue().trim();
|
||||
final char ch = value.length() == 0 ? ' ' : value.charAt(0);
|
||||
if ((ch == '#') || (ch == '-') || Character.isDigit(ch))
|
||||
{
|
||||
set.set(name, String.valueOf(getNumber(value, level)));
|
||||
}
|
||||
else
|
||||
{
|
||||
set.set(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected Lambda getLambda(Node n, Object template)
|
||||
{
|
||||
final Node nval = n.getAttributes().getNamedItem("val");
|
||||
if (nval != null)
|
||||
{
|
||||
final String val = nval.getNodeValue();
|
||||
if (val.charAt(0) == '#')
|
||||
{ // table by level
|
||||
return new LambdaConst(getTableValue(val).doubleValue());
|
||||
}
|
||||
else if (val.charAt(0) == '$')
|
||||
{
|
||||
if (val.equalsIgnoreCase("$player_level"))
|
||||
{
|
||||
return new LambdaStats(LambdaStats.StatsType.PLAYER_LEVEL);
|
||||
}
|
||||
if (val.equalsIgnoreCase("$target_level"))
|
||||
{
|
||||
return new LambdaStats(LambdaStats.StatsType.TARGET_LEVEL);
|
||||
}
|
||||
if (val.equalsIgnoreCase("$player_max_hp"))
|
||||
{
|
||||
return new LambdaStats(LambdaStats.StatsType.PLAYER_MAX_HP);
|
||||
}
|
||||
if (val.equalsIgnoreCase("$player_max_mp"))
|
||||
{
|
||||
return new LambdaStats(LambdaStats.StatsType.PLAYER_MAX_MP);
|
||||
}
|
||||
// try to find value out of item fields
|
||||
final StatsSet set = getStatsSet();
|
||||
final String field = set.getString(val.substring(1));
|
||||
if (field != null)
|
||||
{
|
||||
return new LambdaConst(getNumber(field, template).doubleValue());
|
||||
}
|
||||
// failed
|
||||
throw new IllegalArgumentException("Unknown value " + val);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new LambdaConst(Double.parseDouble(val));
|
||||
}
|
||||
}
|
||||
final LambdaCalc calc = new LambdaCalc();
|
||||
n = n.getFirstChild();
|
||||
while ((n != null) && (n.getNodeType() != Node.ELEMENT_NODE))
|
||||
{
|
||||
n = n.getNextSibling();
|
||||
}
|
||||
if ((n == null) || !"val".equals(n.getNodeName()))
|
||||
{
|
||||
throw new IllegalArgumentException("Value not specified");
|
||||
}
|
||||
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if (n.getNodeType() != Node.ELEMENT_NODE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
attachLambdaFunc(n, template, calc);
|
||||
}
|
||||
return calc;
|
||||
}
|
||||
|
||||
protected Number getNumber(String value, Object template)
|
||||
{
|
||||
if (value.charAt(0) == '#')
|
||||
{// table by level
|
||||
if (template instanceof L2Skill)
|
||||
{
|
||||
return getTableValue(value);
|
||||
}
|
||||
else if (template instanceof Integer)
|
||||
{
|
||||
return getTableValue(value, ((Integer) template).intValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
if (value.indexOf('.') == -1)
|
||||
{
|
||||
int radix = 10;
|
||||
if ((value.length() > 2) && value.substring(0, 2).equalsIgnoreCase("0x"))
|
||||
{
|
||||
value = value.substring(2);
|
||||
radix = 16;
|
||||
}
|
||||
return Integer.valueOf(value, radix);
|
||||
}
|
||||
return Double.valueOf(value);
|
||||
}
|
||||
|
||||
protected Condition joinAnd(Condition cond, Condition c)
|
||||
{
|
||||
if (cond == null)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
if (cond instanceof ConditionLogicAnd)
|
||||
{
|
||||
((ConditionLogicAnd) cond).add(c);
|
||||
return cond;
|
||||
}
|
||||
final ConditionLogicAnd and = new ConditionLogicAnd();
|
||||
and.add(cond);
|
||||
and.add(c);
|
||||
return and;
|
||||
}
|
||||
}
|
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.l2jmobius.gameserver.Item;
|
||||
import com.l2jmobius.gameserver.templates.L2Armor;
|
||||
import com.l2jmobius.gameserver.templates.L2ArmorType;
|
||||
import com.l2jmobius.gameserver.templates.L2EtcItem;
|
||||
import com.l2jmobius.gameserver.templates.L2EtcItemType;
|
||||
import com.l2jmobius.gameserver.templates.L2Item;
|
||||
import com.l2jmobius.gameserver.templates.L2Weapon;
|
||||
import com.l2jmobius.gameserver.templates.L2WeaponType;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
import javolution.util.FastList;
|
||||
import javolution.util.FastMap;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class DocumentItem extends DocumentBase
|
||||
{
|
||||
private Item currentItem = null;
|
||||
private final List<L2Item> itemsInFile = new FastList<>();
|
||||
private Map<Integer, Item> itemData = new FastMap<>();
|
||||
|
||||
/**
|
||||
* @param pItemData
|
||||
* @param file
|
||||
*/
|
||||
public DocumentItem(Map<Integer, Item> pItemData, File file)
|
||||
{
|
||||
super(file);
|
||||
itemData = pItemData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
*/
|
||||
private void setCurrentItem(Item item)
|
||||
{
|
||||
currentItem = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StatsSet getStatsSet()
|
||||
{
|
||||
return currentItem.set;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number getTableValue(String name)
|
||||
{
|
||||
return tables.get(name)[currentItem.currentLevel];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number getTableValue(String name, int idx)
|
||||
{
|
||||
return tables.get(name)[idx - 1];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseDocument(Document doc)
|
||||
{
|
||||
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("list".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
|
||||
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
|
||||
{
|
||||
if ("item".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
setCurrentItem(new Item());
|
||||
parseItem(d);
|
||||
itemsInFile.add(currentItem.item);
|
||||
resetTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("item".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
setCurrentItem(new Item());
|
||||
parseItem(n);
|
||||
itemsInFile.add(currentItem.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void parseItem(Node n)
|
||||
{
|
||||
final int itemId = Integer.parseInt(n.getAttributes().getNamedItem("id").getNodeValue());
|
||||
final String itemName = n.getAttributes().getNamedItem("name").getNodeValue();
|
||||
|
||||
currentItem.id = itemId;
|
||||
currentItem.name = itemName;
|
||||
currentItem.set = itemData.get(currentItem.id).set;
|
||||
currentItem.type = itemData.get(currentItem.id).type;
|
||||
|
||||
final Node first = n.getFirstChild();
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("table".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseTable(n);
|
||||
}
|
||||
}
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("set".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseBeanSet(n, itemData.get(currentItem.id).set, 1);
|
||||
}
|
||||
}
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("for".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
makeItem();
|
||||
parseTemplate(n, currentItem.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void makeItem()
|
||||
{
|
||||
if (currentItem.item != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (currentItem.type instanceof L2ArmorType)
|
||||
{
|
||||
currentItem.item = new L2Armor((L2ArmorType) currentItem.type, currentItem.set);
|
||||
}
|
||||
else if (currentItem.type instanceof L2WeaponType)
|
||||
{
|
||||
currentItem.item = new L2Weapon((L2WeaponType) currentItem.type, currentItem.set);
|
||||
}
|
||||
else if (currentItem.type instanceof L2EtcItemType)
|
||||
{
|
||||
currentItem.item = new L2EtcItem((L2EtcItemType) currentItem.type, currentItem.set);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Error("Unknown item type " + currentItem.type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public List<L2Item> getItemList()
|
||||
{
|
||||
return itemsInFile;
|
||||
}
|
||||
}
|
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
|
||||
import com.l2jmobius.gameserver.skills.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class DocumentSkill extends DocumentBase
|
||||
{
|
||||
public class Skill
|
||||
{
|
||||
public int id;
|
||||
public String name;
|
||||
public StatsSet[] sets;
|
||||
public StatsSet[] enchsets1;
|
||||
public StatsSet[] enchsets2;
|
||||
public int currentLevel;
|
||||
public List<L2Skill> skills = new FastList<>();
|
||||
public List<L2Skill> currentSkills = new FastList<>();
|
||||
}
|
||||
|
||||
private Skill currentSkill;
|
||||
private final List<L2Skill> skillsInFile = new FastList<>();
|
||||
|
||||
DocumentSkill(File file)
|
||||
{
|
||||
super(file);
|
||||
}
|
||||
|
||||
private void setCurrentSkill(Skill skill)
|
||||
{
|
||||
currentSkill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StatsSet getStatsSet()
|
||||
{
|
||||
return currentSkill.sets[currentSkill.currentLevel];
|
||||
}
|
||||
|
||||
protected List<L2Skill> getSkills()
|
||||
{
|
||||
return skillsInFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number getTableValue(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return tables.get(name)[currentSkill.currentLevel];
|
||||
}
|
||||
catch (final RuntimeException e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "error in table: " + name + " of skill Id " + currentSkill.id, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Number getTableValue(String name, int idx)
|
||||
{
|
||||
try
|
||||
{
|
||||
return tables.get(name)[idx - 1];
|
||||
}
|
||||
catch (final RuntimeException e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "wrong level count in skill Id " + currentSkill.id, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void parseDocument(Document doc)
|
||||
{
|
||||
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("list".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
|
||||
{
|
||||
if ("skill".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
setCurrentSkill(new Skill());
|
||||
parseSkill(d);
|
||||
skillsInFile.addAll(currentSkill.skills);
|
||||
resetTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("skill".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
setCurrentSkill(new Skill());
|
||||
parseSkill(n);
|
||||
skillsInFile.addAll(currentSkill.skills);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void parseSkill(Node n)
|
||||
{
|
||||
final NamedNodeMap attrs = n.getAttributes();
|
||||
int enchantLevels1 = 0;
|
||||
int enchantLevels2 = 0;
|
||||
final int skillId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
|
||||
final String skillName = attrs.getNamedItem("name").getNodeValue();
|
||||
final String levels = attrs.getNamedItem("levels").getNodeValue();
|
||||
final int lastLvl = Integer.parseInt(levels);
|
||||
|
||||
if (attrs.getNamedItem("enchantLevels1") != null)
|
||||
{
|
||||
enchantLevels1 = Integer.parseInt(attrs.getNamedItem("enchantLevels1").getNodeValue());
|
||||
}
|
||||
if (attrs.getNamedItem("enchantLevels2") != null)
|
||||
{
|
||||
enchantLevels2 = Integer.parseInt(attrs.getNamedItem("enchantLevels2").getNodeValue());
|
||||
}
|
||||
|
||||
currentSkill.id = skillId;
|
||||
currentSkill.name = skillName;
|
||||
currentSkill.sets = new StatsSet[lastLvl];
|
||||
currentSkill.enchsets1 = new StatsSet[enchantLevels1];
|
||||
currentSkill.enchsets2 = new StatsSet[enchantLevels2];
|
||||
|
||||
for (int i = 0; i < lastLvl; i++)
|
||||
{
|
||||
currentSkill.sets[i] = new StatsSet();
|
||||
currentSkill.sets[i].set("skill_id", currentSkill.id);
|
||||
currentSkill.sets[i].set("level", i + 1);
|
||||
currentSkill.sets[i].set("name", currentSkill.name);
|
||||
}
|
||||
|
||||
if (currentSkill.sets.length != lastLvl)
|
||||
{
|
||||
throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + lastLvl + " levels expected");
|
||||
}
|
||||
|
||||
final Node first = n.getFirstChild();
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("table".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseTable(n);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= lastLvl; i++)
|
||||
{
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("set".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseBeanSet(n, currentSkill.sets[i - 1], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < enchantLevels1; i++)
|
||||
{
|
||||
currentSkill.enchsets1[i] = new StatsSet();
|
||||
currentSkill.enchsets1[i].set("skill_id", currentSkill.id);
|
||||
|
||||
currentSkill.enchsets1[i].set("level", i + 101);
|
||||
currentSkill.enchsets1[i].set("name", currentSkill.name);
|
||||
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("set".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseBeanSet(n, currentSkill.enchsets1[i], currentSkill.sets.length);
|
||||
}
|
||||
}
|
||||
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("enchant1".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseBeanSet(n, currentSkill.enchsets1[i], i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSkill.enchsets1.length != enchantLevels1)
|
||||
{
|
||||
throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels1 + " levels expected");
|
||||
}
|
||||
|
||||
for (int i = 0; i < enchantLevels2; i++)
|
||||
{
|
||||
currentSkill.enchsets2[i] = new StatsSet();
|
||||
|
||||
currentSkill.enchsets2[i].set("skill_id", currentSkill.id);
|
||||
currentSkill.enchsets2[i].set("level", i + 141);
|
||||
currentSkill.enchsets2[i].set("name", currentSkill.name);
|
||||
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("set".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseBeanSet(n, currentSkill.enchsets2[i], currentSkill.sets.length);
|
||||
}
|
||||
}
|
||||
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("enchant2".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseBeanSet(n, currentSkill.enchsets2[i], i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentSkill.enchsets2.length != enchantLevels2)
|
||||
{
|
||||
throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + enchantLevels2 + " levels expected");
|
||||
}
|
||||
|
||||
makeSkills();
|
||||
|
||||
for (int i = 0; i < lastLvl; i++)
|
||||
{
|
||||
currentSkill.currentLevel = i;
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("cond".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
final Condition condition = parseCondition(n.getFirstChild(), currentSkill.currentSkills.get(i));
|
||||
final Node msg = n.getAttributes().getNamedItem("msg");
|
||||
|
||||
if ((condition != null) && (msg != null))
|
||||
{
|
||||
condition.setMessage(msg.getNodeValue());
|
||||
}
|
||||
|
||||
currentSkill.currentSkills.get(i).attach(condition, false);
|
||||
}
|
||||
|
||||
if ("for".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseTemplate(n, currentSkill.currentSkills.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = lastLvl; i < (lastLvl + enchantLevels1); i++)
|
||||
{
|
||||
currentSkill.currentLevel = i - lastLvl;
|
||||
boolean found = false;
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("enchant1cond".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
found = true;
|
||||
final Condition condition = parseCondition(n.getFirstChild(), currentSkill.currentSkills.get(i));
|
||||
final Node msg = n.getAttributes().getNamedItem("msg");
|
||||
if ((condition != null) && (msg != null))
|
||||
{
|
||||
condition.setMessage(msg.getNodeValue());
|
||||
}
|
||||
currentSkill.currentSkills.get(i).attach(condition, false);
|
||||
}
|
||||
|
||||
if ("enchant1for".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
found = true;
|
||||
parseTemplate(n, currentSkill.currentSkills.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
// If none found, the enchanted skill will take effects from maxLvL of norm skill
|
||||
if (!found)
|
||||
{
|
||||
currentSkill.currentLevel = lastLvl - 1;
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("cond".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
final Condition condition = parseCondition(n.getFirstChild(), currentSkill.currentSkills.get(i));
|
||||
final Node msg = n.getAttributes().getNamedItem("msg");
|
||||
if ((condition != null) && (msg != null))
|
||||
{
|
||||
condition.setMessage(msg.getNodeValue());
|
||||
}
|
||||
currentSkill.currentSkills.get(i).attach(condition, false);
|
||||
}
|
||||
|
||||
if ("for".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseTemplate(n, currentSkill.currentSkills.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = lastLvl + enchantLevels1; i < (lastLvl + enchantLevels1 + enchantLevels2); i++)
|
||||
{
|
||||
boolean found = false;
|
||||
currentSkill.currentLevel = i - lastLvl - enchantLevels1;
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("enchant2cond".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
found = true;
|
||||
final Condition condition = parseCondition(n.getFirstChild(), currentSkill.currentSkills.get(i));
|
||||
final Node msg = n.getAttributes().getNamedItem("msg");
|
||||
if ((condition != null) && (msg != null))
|
||||
{
|
||||
condition.setMessage(msg.getNodeValue());
|
||||
}
|
||||
currentSkill.currentSkills.get(i).attach(condition, false);
|
||||
}
|
||||
|
||||
if ("enchant2for".equalsIgnoreCase(n.getNodeName()))
|
||||
|
||||
{
|
||||
found = true;
|
||||
parseTemplate(n, currentSkill.currentSkills.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
// If none found, the enchanted skill will take effects from maxLvL of normal skill
|
||||
if (!found)
|
||||
{
|
||||
currentSkill.currentLevel = lastLvl - 1;
|
||||
for (n = first; n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("cond".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
final Condition condition = parseCondition(n.getFirstChild(), currentSkill.currentSkills.get(i));
|
||||
final Node msg = n.getAttributes().getNamedItem("msg");
|
||||
if ((condition != null) && (msg != null))
|
||||
{
|
||||
condition.setMessage(msg.getNodeValue());
|
||||
}
|
||||
currentSkill.currentSkills.get(i).attach(condition, false);
|
||||
}
|
||||
|
||||
if ("for".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
parseTemplate(n, currentSkill.currentSkills.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
currentSkill.skills.addAll(currentSkill.currentSkills);
|
||||
}
|
||||
|
||||
private void makeSkills()
|
||||
{
|
||||
int count = 0;
|
||||
currentSkill.currentSkills = new FastList<>(currentSkill.sets.length + currentSkill.enchsets1.length + currentSkill.enchsets2.length);
|
||||
|
||||
for (int i = 0; i < currentSkill.sets.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
currentSkill.currentSkills.add(i, currentSkill.sets[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.sets[i]));
|
||||
count++;
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Skill id=" + currentSkill.sets[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.sets[i]).getDisplayId() + "level" + currentSkill.sets[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.sets[i]).getLevel(), e);
|
||||
}
|
||||
}
|
||||
|
||||
int _count = count;
|
||||
for (int i = 0; i < currentSkill.enchsets1.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
currentSkill.currentSkills.add(_count + i, currentSkill.enchsets1[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.enchsets1[i]));
|
||||
count++;
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Skill id=" + currentSkill.enchsets1[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.enchsets1[i]).getDisplayId() + " level=" + currentSkill.enchsets1[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.enchsets1[i]).getLevel(), e);
|
||||
}
|
||||
}
|
||||
|
||||
_count = count;
|
||||
for (int i = 0; i < currentSkill.enchsets2.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
currentSkill.currentSkills.add(_count + i, currentSkill.enchsets2[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.enchsets2[i]));
|
||||
count++;
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "Skill id=" + currentSkill.enchsets2[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.enchsets2[i]).getDisplayId() + " level=" + currentSkill.enchsets2[i].getEnum("skillType", SkillType.class).makeSkill(currentSkill.enchsets2[i]).getLevel(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
L2J_Mobius_C4/java/com/l2jmobius/gameserver/skills/Env.java
Normal file
34
L2J_Mobius_C4/java/com/l2jmobius/gameserver/skills/Env.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
|
||||
/**
|
||||
* An Env object is just a class to pass parameters to a calculator such as L2PcInstance, L2ItemInstance, Initial value.
|
||||
*/
|
||||
public final class Env
|
||||
{
|
||||
public L2Character player;
|
||||
public L2Character target;
|
||||
public L2ItemInstance item;
|
||||
public L2Skill skill;
|
||||
public double value;
|
||||
public boolean skillMastery = false;
|
||||
}
|
2263
L2J_Mobius_C4/java/com/l2jmobius/gameserver/skills/Formulas.java
Normal file
2263
L2J_Mobius_C4/java/com/l2jmobius/gameserver/skills/Formulas.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.Item;
|
||||
import com.l2jmobius.gameserver.datatables.SkillTable;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.templates.L2Armor;
|
||||
import com.l2jmobius.gameserver.templates.L2EtcItem;
|
||||
import com.l2jmobius.gameserver.templates.L2EtcItemType;
|
||||
import com.l2jmobius.gameserver.templates.L2Item;
|
||||
import com.l2jmobius.gameserver.templates.L2Weapon;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class SkillsEngine
|
||||
{
|
||||
protected static Logger _log = Logger.getLogger(SkillsEngine.class.getName());
|
||||
|
||||
private static final SkillsEngine _instance = new SkillsEngine();
|
||||
|
||||
private final List<File> _armorFiles = new FastList<>();
|
||||
private final List<File> _weaponFiles = new FastList<>();
|
||||
private final List<File> _etcitemFiles = new FastList<>();
|
||||
private final List<File> _skillFiles = new FastList<>();
|
||||
|
||||
public static SkillsEngine getInstance()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
|
||||
private SkillsEngine()
|
||||
{
|
||||
hashFiles("data/stats/armor", _armorFiles);
|
||||
hashFiles("data/stats/weapon", _weaponFiles);
|
||||
hashFiles("data/stats/skills", _skillFiles);
|
||||
}
|
||||
|
||||
private void hashFiles(String dirname, List<File> hash)
|
||||
{
|
||||
final File dir = new File(Config.DATAPACK_ROOT, dirname);
|
||||
|
||||
if (!dir.exists())
|
||||
{
|
||||
_log.config("Dir " + dir.getAbsolutePath() + " not exists");
|
||||
return;
|
||||
}
|
||||
|
||||
final File[] files = dir.listFiles();
|
||||
for (final File f : files)
|
||||
{
|
||||
if (f.getName().endsWith(".xml"))
|
||||
{
|
||||
if (!f.getName().startsWith("custom"))
|
||||
{
|
||||
hash.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
final File customfile = new File(Config.DATAPACK_ROOT, dirname + "/custom.xml");
|
||||
if (customfile.exists())
|
||||
{
|
||||
hash.add(customfile);
|
||||
}
|
||||
}
|
||||
|
||||
public List<L2Skill> loadSkills(File file)
|
||||
{
|
||||
if (file == null)
|
||||
{
|
||||
_log.config("Skill file not found.");
|
||||
return null;
|
||||
}
|
||||
final DocumentSkill doc = new DocumentSkill(file);
|
||||
doc.parse();
|
||||
return doc.getSkills();
|
||||
}
|
||||
|
||||
public void loadAllSkills(Map<Integer, L2Skill> allSkills)
|
||||
{
|
||||
int count = 0;
|
||||
for (final File file : _skillFiles)
|
||||
{
|
||||
final List<L2Skill> s = loadSkills(file);
|
||||
if (s == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (final L2Skill skill : s)
|
||||
{
|
||||
allSkills.put(SkillTable.getSkillHashCode(skill), skill);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
_log.config("SkillsEngine: Loaded " + count + " Skill templates from XML files.");
|
||||
}
|
||||
|
||||
public List<L2Armor> loadArmors(Map<Integer, Item> armorData)
|
||||
{
|
||||
final List<L2Armor> list = new FastList<>();
|
||||
for (final L2Item item : loadData(armorData, _armorFiles))
|
||||
{
|
||||
list.add((L2Armor) item);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<L2Weapon> loadWeapons(Map<Integer, Item> weaponData)
|
||||
{
|
||||
final List<L2Weapon> list = new FastList<>();
|
||||
for (final L2Item item : loadData(weaponData, _weaponFiles))
|
||||
{
|
||||
list.add((L2Weapon) item);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<L2EtcItem> loadItems(Map<Integer, Item> itemData)
|
||||
{
|
||||
final List<L2EtcItem> list = new FastList<>();
|
||||
for (final L2Item item : loadData(itemData, _etcitemFiles))
|
||||
{
|
||||
list.add((L2EtcItem) item);
|
||||
}
|
||||
|
||||
if (list.size() == 0)
|
||||
{
|
||||
for (final Item item : itemData.values())
|
||||
{
|
||||
list.add(new L2EtcItem((L2EtcItemType) item.type, item.set));
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<L2Item> loadData(Map<Integer, Item> itemData, List<File> files)
|
||||
{
|
||||
final List<L2Item> list = new FastList<>();
|
||||
for (final File f : files)
|
||||
{
|
||||
final DocumentItem document = new DocumentItem(itemData, f);
|
||||
document.parse();
|
||||
list.addAll(document.getItemList());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
212
L2J_Mobius_C4/java/com/l2jmobius/gameserver/skills/Stats.java
Normal file
212
L2J_Mobius_C4/java/com/l2jmobius/gameserver/skills/Stats.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/**
|
||||
* Enum of basic stats.
|
||||
* @author mkizub
|
||||
*/
|
||||
public enum Stats
|
||||
{
|
||||
//
|
||||
// Base stats, for each in Calculator a slot is allocated
|
||||
//
|
||||
|
||||
// HP & MP
|
||||
MAX_HP("maxHp"),
|
||||
MAX_MP("maxMp"),
|
||||
MAX_CP("maxCp"),
|
||||
REGENERATE_HP_RATE("regHp"),
|
||||
REGENERATE_CP_RATE("regCp"),
|
||||
REGENERATE_MP_RATE("regMp"),
|
||||
RECHARGE_MP_RATE("gainMp"),
|
||||
HEAL_EFFECTIVNESS("gainHp"),
|
||||
|
||||
// Atk & Def
|
||||
POWER_DEFENCE("pDef"),
|
||||
MAGIC_DEFENCE("mDef"),
|
||||
POWER_ATTACK("pAtk"),
|
||||
MAGIC_ATTACK("mAtk"),
|
||||
POWER_ATTACK_SPEED("pAtkSpd"),
|
||||
MAGIC_ATTACK_SPEED("mAtkSpd"), // how fast a spell is casted (including animation)
|
||||
MAGIC_REUSE_RATE("mReuse"), // how fast spells becomes ready to reuse
|
||||
PHYSICAL_REUSE_RATE("pReuse"), // how fast physical skill becomes ready to reuse
|
||||
SHIELD_DEFENCE("sDef"),
|
||||
CRITICAL_DAMAGE("cAtk"),
|
||||
CRITICAL_DAMAGE_ADD("cAtkAdd"),
|
||||
PVP_PHYSICAL_DMG("pvpPhysDmg"),
|
||||
PVP_MAGICAL_DMG("pvpMagicalDmg"),
|
||||
PVP_PHYS_SKILL_DMG("pvpPhysSkillsDmg"),
|
||||
VALAKAS_PHYSICAL_DMG("valakasPhysDmg"),
|
||||
|
||||
// Atk & Def rates
|
||||
EVASION_RATE("rEvas"),
|
||||
SHIELD_RATE("rShld"),
|
||||
SHIELD_DEFENCE_ANGLE("shieldDefAngle"),
|
||||
CRITICAL_RATE("rCrit"),
|
||||
MCRITICAL_RATE("mCritRate"),
|
||||
EXPSP_RATE("rExp"),
|
||||
BLOW_RATE("blowRate"),
|
||||
ATTACK_CANCEL("cancel"),
|
||||
|
||||
// Accuracy and range
|
||||
ACCURACY_COMBAT("accCombat"),
|
||||
POWER_ATTACK_RANGE("pAtkRange"),
|
||||
MAGIC_ATTACK_RANGE("mAtkRange"),
|
||||
POWER_ATTACK_ANGLE("pAtkAngle"),
|
||||
ATTACK_COUNT_MAX("atkCountMax"),
|
||||
|
||||
WALK_SPEED("walkSpd"),
|
||||
RUN_SPEED("runSpd"),
|
||||
|
||||
//
|
||||
// Player-only stats
|
||||
//
|
||||
STAT_STR("STR"),
|
||||
STAT_CON("CON"),
|
||||
STAT_DEX("DEX"),
|
||||
STAT_INT("INT"),
|
||||
STAT_WIT("WIT"),
|
||||
STAT_MEN("MEN"),
|
||||
|
||||
//
|
||||
// Special stats, share one slot in Calculator
|
||||
//
|
||||
|
||||
// Water breath
|
||||
BREATH("breath"),
|
||||
|
||||
// Terrain damage
|
||||
FALL("fall"),
|
||||
|
||||
// Various stats
|
||||
AGGRESSION("aggression"), // locks a mob on tank caster
|
||||
BLEED("bleed"), // by daggers, like poison
|
||||
POISON("poison"), // by magic, hp dmg over time
|
||||
STUN("stun"), // disable move/ATTACK for a period of time
|
||||
ROOT("root"), // disable movement, but not ATTACK
|
||||
MOVEMENT("movement"), // slowdown movement, debuff
|
||||
CONFUSION("confusion"), // mob changes target, opposite to aggression/hate
|
||||
SLEEP("sleep"), // sleep (don't move/ATTACK) until attacked
|
||||
FIRE("fire"),
|
||||
WIND("wind"),
|
||||
WATER("water"),
|
||||
EARTH("earth"),
|
||||
HOLY("holy"),
|
||||
DARK("dark"),
|
||||
|
||||
// Resists
|
||||
AGGRESSION_VULN("aggressionVuln"),
|
||||
BLEED_VULN("bleedVuln"),
|
||||
POISON_VULN("poisonVuln"),
|
||||
STUN_VULN("stunVuln"),
|
||||
PARALYZE_VULN("paralyzeVuln"),
|
||||
ROOT_VULN("rootVuln"),
|
||||
SLEEP_VULN("sleepVuln"),
|
||||
CONFUSION_VULN("confusionVuln"),
|
||||
MOVEMENT_VULN("movementVuln"),
|
||||
FIRE_VULN("fireVuln"),
|
||||
WIND_VULN("windVuln"),
|
||||
WATER_VULN("waterVuln"),
|
||||
EARTH_VULN("earthVuln"),
|
||||
HOLY_VULN("holyVuln"),
|
||||
DARK_VULN("darkVuln"),
|
||||
CANCEL_VULN("cancelVuln"),
|
||||
DERANGEMENT_VULN("derangementVuln"),
|
||||
DEBUFF_VULN("debuffVuln"),
|
||||
VALAKAS_VULN("valakasVuln"),
|
||||
|
||||
NONE_WPN_VULN("noneWpnVuln"), // Shields!!!
|
||||
SWORD_WPN_VULN("swordWpnVuln"),
|
||||
BLUNT_WPN_VULN("bluntWpnVuln"),
|
||||
DAGGER_WPN_VULN("daggerWpnVuln"),
|
||||
BOW_WPN_VULN("bowWpnVuln"),
|
||||
POLE_WPN_VULN("poleWpnVuln"),
|
||||
ETC_WPN_VULN("etcWpnVuln"),
|
||||
FIST_WPN_VULN("fistWpnVuln"),
|
||||
DUAL_WPN_VULN("dualWpnVuln"),
|
||||
DUALFIST_WPN_VULN("dualFistWpnVuln"),
|
||||
|
||||
REFLECT_DAMAGE_PERCENT("reflectDam"),
|
||||
REFLECT_SKILL_MAGIC("reflectSkillMagic"),
|
||||
REFLECT_SKILL_PHYSIC("reflectSkillPhysic"),
|
||||
ABSORB_DAMAGE_PERCENT("absorbDam"),
|
||||
TRANSFER_DAMAGE_PERCENT("transDam"),
|
||||
|
||||
MAX_LOAD("maxLoad"),
|
||||
|
||||
PATK_PLANTS("pAtk-plants"),
|
||||
PATK_INSECTS("pAtk-insects"),
|
||||
PATK_ANIMALS("pAtk-animals"),
|
||||
PATK_MONSTERS("pAtk-monsters"),
|
||||
PATK_DRAGONS("pAtk-dragons"),
|
||||
PATK_UNDEAD("pAtk-undead"),
|
||||
PATK_GIANTS("pAtk-giants"),
|
||||
PATK_MCREATURES("pAtk-mcreatures"),
|
||||
PDEF_UNDEAD("pDef-undead"),
|
||||
|
||||
ATK_REUSE("atkReuse"),
|
||||
|
||||
// ExSkill :)
|
||||
INV_LIM("inventoryLimit"),
|
||||
WH_LIM("whLimit"),
|
||||
FREIGHT_LIM("FreightLimit"),
|
||||
P_SELL_LIM("PrivateSellLimit"),
|
||||
P_BUY_LIM("PrivateBuyLimit"),
|
||||
REC_D_LIM("DwarfRecipeLimit"),
|
||||
REC_C_LIM("CommonRecipeLimit"),
|
||||
|
||||
// C4 Stats
|
||||
PHYSICAL_MP_CONSUME_RATE("PhysicalMpConsumeRate"),
|
||||
MAGICAL_MP_CONSUME_RATE("MagicalMpConsumeRate"),
|
||||
HP_CONSUME_RATE("HpConsumeRate"),
|
||||
MP_CONSUME("MpConsume"),
|
||||
SOULSHOT_COUNT("soulShotCount"),
|
||||
|
||||
// Skill mastery
|
||||
SKILL_MASTERY("skillMastery");
|
||||
|
||||
public static final int NUM_STATS = values().length;
|
||||
|
||||
private String _value;
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
private Stats(String s)
|
||||
{
|
||||
_value = s;
|
||||
}
|
||||
|
||||
public static Stats valueOfXml(String name)
|
||||
{
|
||||
name = name.intern();
|
||||
for (final Stats s : values())
|
||||
{
|
||||
if (s.getValue().equals(name))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchElementException("Unknown name '" + name + "' for enum BaseStats");
|
||||
}
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public abstract class Condition implements ConditionListener
|
||||
{
|
||||
static final Logger _log = Logger.getLogger(Condition.class.getName());
|
||||
|
||||
private ConditionListener _listener;
|
||||
private String _msg;
|
||||
|
||||
private boolean _result;
|
||||
|
||||
public final void setMessage(String msg)
|
||||
{
|
||||
_msg = msg;
|
||||
}
|
||||
|
||||
public final String getMessage()
|
||||
{
|
||||
return _msg;
|
||||
}
|
||||
|
||||
void setListener(ConditionListener listener)
|
||||
{
|
||||
_listener = listener;
|
||||
notifyChanged();
|
||||
}
|
||||
|
||||
final ConditionListener getListener()
|
||||
{
|
||||
return _listener;
|
||||
}
|
||||
|
||||
public final boolean test(Env env)
|
||||
{
|
||||
final boolean res = testImpl(env);
|
||||
if ((_listener != null) && (res != _result))
|
||||
{
|
||||
_result = res;
|
||||
notifyChanged();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
abstract boolean testImpl(Env env);
|
||||
|
||||
@Override
|
||||
public void notifyChanged()
|
||||
{
|
||||
if (_listener != null)
|
||||
{
|
||||
_listener.notifyChanged();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.effects.EffectSeed;
|
||||
|
||||
/**
|
||||
* @author Advi
|
||||
*/
|
||||
public class ConditionElementSeed extends Condition
|
||||
{
|
||||
static int[] seedSkills =
|
||||
{
|
||||
1285,
|
||||
1286,
|
||||
1287
|
||||
};
|
||||
final int[] _requiredSeeds;
|
||||
|
||||
public ConditionElementSeed(int[] seeds)
|
||||
{
|
||||
_requiredSeeds = seeds;
|
||||
}
|
||||
|
||||
ConditionElementSeed(int fire, int water, int wind, int various, int any)
|
||||
{
|
||||
_requiredSeeds = new int[5];
|
||||
_requiredSeeds[0] = fire;
|
||||
_requiredSeeds[1] = water;
|
||||
_requiredSeeds[2] = wind;
|
||||
_requiredSeeds[3] = various;
|
||||
_requiredSeeds[4] = any;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
final int[] Seeds = new int[3];
|
||||
for (int i = 0; i < Seeds.length; i++)
|
||||
{
|
||||
final L2Effect effect = env.player.getFirstEffect(seedSkills[i]);
|
||||
Seeds[i] = (effect instanceof EffectSeed ? ((EffectSeed) effect).getPower() : 0);
|
||||
if (Seeds[i] >= _requiredSeeds[i])
|
||||
{
|
||||
Seeds[i] -= _requiredSeeds[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_requiredSeeds[3] > 0)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; (i < Seeds.length) && (count < _requiredSeeds[3]); i++)
|
||||
{
|
||||
if (Seeds[i] > 0)
|
||||
{
|
||||
Seeds[i]--;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < _requiredSeeds[3])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_requiredSeeds[4] > 0)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; (i < Seeds.length) && (count < _requiredSeeds[4]); i++)
|
||||
{
|
||||
count += Seeds[i];
|
||||
}
|
||||
if (count < _requiredSeeds[4])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Advi
|
||||
*/
|
||||
public class ConditionGameChance extends Condition
|
||||
{
|
||||
final int _chance;
|
||||
|
||||
public ConditionGameChance(int chance)
|
||||
{
|
||||
_chance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
return Rnd.get(100) < _chance;
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionGameTime extends Condition
|
||||
{
|
||||
|
||||
public enum CheckGameTime
|
||||
{
|
||||
NIGHT
|
||||
}
|
||||
|
||||
final CheckGameTime _check;
|
||||
final boolean _required;
|
||||
|
||||
public ConditionGameTime(CheckGameTime check, boolean required)
|
||||
{
|
||||
_check = check;
|
||||
_required = required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
switch (_check)
|
||||
{
|
||||
case NIGHT:
|
||||
return GameTimeController.getInstance().isNowNight() == _required;
|
||||
}
|
||||
return !_required;
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public abstract class ConditionInventory extends Condition
|
||||
{
|
||||
|
||||
final int _slot;
|
||||
|
||||
public ConditionInventory(int slot)
|
||||
{
|
||||
_slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean testImpl(Env env);
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class ConditionItemId extends Condition
|
||||
{
|
||||
final int _itemId;
|
||||
|
||||
public ConditionItemId(int itemId)
|
||||
{
|
||||
_itemId = itemId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (env.item == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return env.item.getItemId() == _itemId;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public interface ConditionListener
|
||||
{
|
||||
public void notifyChanged();
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionLogicAnd extends Condition
|
||||
{
|
||||
private static Condition[] emptyConditions = new Condition[0];
|
||||
public Condition[] _conditions = emptyConditions;
|
||||
|
||||
public ConditionLogicAnd()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public void add(Condition condition)
|
||||
{
|
||||
if (condition == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (getListener() != null)
|
||||
{
|
||||
condition.setListener(this);
|
||||
}
|
||||
final int len = _conditions.length;
|
||||
final Condition[] tmp = new Condition[len + 1];
|
||||
System.arraycopy(_conditions, 0, tmp, 0, len);
|
||||
tmp[len] = condition;
|
||||
_conditions = tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setListener(ConditionListener listener)
|
||||
{
|
||||
if (listener != null)
|
||||
{
|
||||
for (final Condition c : _conditions)
|
||||
{
|
||||
c.setListener(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (final Condition c : _conditions)
|
||||
{
|
||||
c.setListener(null);
|
||||
}
|
||||
}
|
||||
super.setListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
for (final Condition c : _conditions)
|
||||
{
|
||||
if (!c.test(env))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionLogicNot extends Condition
|
||||
{
|
||||
Condition _condition;
|
||||
|
||||
public ConditionLogicNot(Condition condition)
|
||||
{
|
||||
_condition = condition;
|
||||
if (getListener() != null)
|
||||
{
|
||||
_condition.setListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void setListener(ConditionListener listener)
|
||||
{
|
||||
if (listener != null)
|
||||
{
|
||||
_condition.setListener(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_condition.setListener(null);
|
||||
}
|
||||
super.setListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
return !_condition.test(env);
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionLogicOr extends Condition
|
||||
{
|
||||
private static Condition[] emptyConditions = new Condition[0];
|
||||
public Condition[] _conditions = emptyConditions;
|
||||
|
||||
public void add(Condition condition)
|
||||
{
|
||||
if (condition == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (getListener() != null)
|
||||
{
|
||||
condition.setListener(this);
|
||||
}
|
||||
final int len = _conditions.length;
|
||||
final Condition[] tmp = new Condition[len + 1];
|
||||
System.arraycopy(_conditions, 0, tmp, 0, len);
|
||||
tmp[len] = condition;
|
||||
_conditions = tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
void setListener(ConditionListener listener)
|
||||
{
|
||||
if (listener != null)
|
||||
{
|
||||
for (final Condition c : _conditions)
|
||||
{
|
||||
c.setListener(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (final Condition c : _conditions)
|
||||
{
|
||||
c.setListener(null);
|
||||
}
|
||||
}
|
||||
super.setListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
for (final Condition c : _conditions)
|
||||
{
|
||||
if (c.test(env))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionPlayerBaseStats extends Condition
|
||||
{
|
||||
final BaseStat _stat;
|
||||
final int _value;
|
||||
|
||||
public ConditionPlayerBaseStats(L2Character player, BaseStat stat, int value)
|
||||
{
|
||||
super();
|
||||
_stat = stat;
|
||||
_value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (!(env.player instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance player = (L2PcInstance) env.player;
|
||||
switch (_stat)
|
||||
{
|
||||
case Int:
|
||||
return player.getINT() >= _value;
|
||||
case Str:
|
||||
return player.getSTR() >= _value;
|
||||
case Con:
|
||||
return player.getCON() >= _value;
|
||||
case Dex:
|
||||
return player.getDEX() >= _value;
|
||||
case Men:
|
||||
return player.getMEN() >= _value;
|
||||
case Wit:
|
||||
return player.getWIT() >= _value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
enum BaseStat
|
||||
{
|
||||
Int,
|
||||
Str,
|
||||
Con,
|
||||
Dex,
|
||||
Men,
|
||||
Wit
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mr TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionPlayerHp extends Condition
|
||||
{
|
||||
final int _hp;
|
||||
|
||||
public ConditionPlayerHp(int hp)
|
||||
{
|
||||
_hp = hp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
|
||||
return ((env.player.getCurrentHp() * 100) / env.player.getMaxHp()) <= _hp;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
public class ConditionPlayerHpPercentage extends Condition
|
||||
{
|
||||
private final double _p;
|
||||
|
||||
public ConditionPlayerHpPercentage(double p)
|
||||
{
|
||||
_p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
return env.player.getCurrentHp() <= (env.player.getMaxHp() * _p);
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionPlayerLevel extends Condition
|
||||
{
|
||||
final int _level;
|
||||
|
||||
public ConditionPlayerLevel(int level)
|
||||
{
|
||||
_level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
return env.player.getLevel() >= _level;
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.base.Race;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionPlayerRace extends Condition
|
||||
{
|
||||
final Race _race;
|
||||
|
||||
public ConditionPlayerRace(Race race)
|
||||
{
|
||||
_race = race;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (!(env.player instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ((L2PcInstance) env.player).getRace() == _race;
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionPlayerState extends Condition
|
||||
{
|
||||
public enum CheckPlayerState
|
||||
{
|
||||
RESTING,
|
||||
MOVING,
|
||||
RUNNING,
|
||||
FLYING,
|
||||
BEHIND,
|
||||
FRONT
|
||||
}
|
||||
|
||||
final CheckPlayerState _check;
|
||||
final boolean _required;
|
||||
|
||||
public ConditionPlayerState(CheckPlayerState check, boolean required)
|
||||
{
|
||||
_check = check;
|
||||
_required = required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
switch (_check)
|
||||
{
|
||||
case RESTING:
|
||||
if (env.player instanceof L2PcInstance)
|
||||
{
|
||||
return ((L2PcInstance) env.player).isSitting() == _required;
|
||||
}
|
||||
return !_required;
|
||||
case MOVING:
|
||||
return env.player.isMoving() == _required;
|
||||
case RUNNING:
|
||||
return (env.player.isMoving() == _required) && (env.player.isRunning() == _required);
|
||||
case FLYING:
|
||||
return env.player.isFlying() == _required;
|
||||
|
||||
case BEHIND:
|
||||
return env.player.isBehindTarget() == _required;
|
||||
case FRONT:
|
||||
return env.player.isInFrontOfTarget() == _required;
|
||||
}
|
||||
return !_required;
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionSkillStats extends Condition
|
||||
{
|
||||
final Stats _stat;
|
||||
|
||||
public ConditionSkillStats(Stats stat)
|
||||
{
|
||||
super();
|
||||
_stat = stat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (env.skill == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return env.skill.getStat() == _stat;
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.Inventory;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class ConditionSlotItemId extends ConditionInventory
|
||||
{
|
||||
final int _itemId;
|
||||
final int _enchantLevel;
|
||||
|
||||
public ConditionSlotItemId(int slot, int itemId, int enchantLevel)
|
||||
{
|
||||
super(slot);
|
||||
_itemId = itemId;
|
||||
_enchantLevel = enchantLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (!(env.player instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final Inventory inv = ((L2PcInstance) env.player).getInventory();
|
||||
final L2ItemInstance item = inv.getPaperdollItem(_slot);
|
||||
if (item == null)
|
||||
{
|
||||
return _itemId == 0;
|
||||
}
|
||||
return (item.getItemId() == _itemId) && (item.getEnchantLevel() >= _enchantLevel);
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.Inventory;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class ConditionSlotItemType extends ConditionInventory
|
||||
{
|
||||
final int _mask;
|
||||
|
||||
public ConditionSlotItemType(int slot, int mask)
|
||||
{
|
||||
super(slot);
|
||||
_mask = mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (!(env.player instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final Inventory inv = ((L2PcInstance) env.player).getInventory();
|
||||
final L2ItemInstance item = inv.getPaperdollItem(_slot);
|
||||
if (item == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (item.getItem().getItemMask() & _mask) != 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionTargetAggro extends Condition
|
||||
{
|
||||
final boolean _isAggro;
|
||||
|
||||
public ConditionTargetAggro(boolean isAggro)
|
||||
{
|
||||
_isAggro = isAggro;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
final L2Character target = env.target;
|
||||
if (target instanceof L2MonsterInstance)
|
||||
{
|
||||
return ((L2MonsterInstance) target).isAggressive() == _isAggro;
|
||||
}
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
return ((L2PcInstance) target).getKarma() > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.Inventory;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.templates.L2Armor;
|
||||
import com.l2jmobius.gameserver.templates.L2Item;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionTargetBodyPart extends Condition
|
||||
{
|
||||
L2Armor armor;
|
||||
|
||||
public ConditionTargetBodyPart(L2Armor pArmor)
|
||||
{
|
||||
armor = pArmor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
// target is attacker
|
||||
if (env.target == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
final int bodypart = env.target.getAttackingBodyPart();
|
||||
final int armor_part = armor.getBodyPart();
|
||||
switch (bodypart)
|
||||
{
|
||||
case Inventory.PAPERDOLL_CHEST:
|
||||
return (armor_part & (L2Item.SLOT_CHEST | L2Item.SLOT_FULL_ARMOR | L2Item.SLOT_UNDERWEAR)) != 0;
|
||||
case Inventory.PAPERDOLL_LEGS:
|
||||
return (armor_part & (L2Item.SLOT_LEGS | L2Item.SLOT_FULL_ARMOR)) != 0;
|
||||
case Inventory.PAPERDOLL_HEAD:
|
||||
return (armor_part & L2Item.SLOT_HEAD) != 0;
|
||||
case Inventory.PAPERDOLL_FEET:
|
||||
return (armor_part & L2Item.SLOT_FEET) != 0;
|
||||
case Inventory.PAPERDOLL_GLOVES:
|
||||
return (armor_part & L2Item.SLOT_GLOVES) != 0;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionTargetLevel extends Condition
|
||||
{
|
||||
final int _level;
|
||||
|
||||
public ConditionTargetLevel(int level)
|
||||
{
|
||||
_level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (env.target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return env.target.getLevel() >= _level;
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionTargetNone extends Condition
|
||||
{
|
||||
public ConditionTargetNone()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
return (env.target == null);
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.templates.L2Weapon;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public class ConditionTargetUsesWeaponKind extends Condition
|
||||
{
|
||||
final int _weaponMask;
|
||||
|
||||
public ConditionTargetUsesWeaponKind(int weaponMask)
|
||||
{
|
||||
_weaponMask = weaponMask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (env.target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Weapon item = env.target.getActiveWeaponItem();
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (item.getItemType().mask() & _weaponMask) != 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.Inventory;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class ConditionUsingItemType extends Condition
|
||||
{
|
||||
final int _mask;
|
||||
|
||||
public ConditionUsingItemType(int mask)
|
||||
{
|
||||
_mask = mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (!(env.player instanceof L2PcInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final Inventory inv = ((L2PcInstance) env.player).getInventory();
|
||||
return (_mask & inv.getWearedMask()) != 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class ConditionUsingSkill extends Condition
|
||||
{
|
||||
final int _skillId;
|
||||
|
||||
public ConditionUsingSkill(int skillId)
|
||||
{
|
||||
_skillId = skillId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (env.skill == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return env.skill.getId() == _skillId;
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.conditions;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author Steuf
|
||||
*/
|
||||
public class ConditionWithSkill extends Condition
|
||||
{
|
||||
final boolean _skill;
|
||||
|
||||
public ConditionWithSkill(boolean skill)
|
||||
{
|
||||
_skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testImpl(Env env)
|
||||
{
|
||||
if (!_skill && (env.skill != null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author LBaldi
|
||||
*/
|
||||
final class EffectBigHead extends L2Effect
|
||||
{
|
||||
public EffectBigHead(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.BUFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startAbnormalEffect((short) 0x02000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopAbnormalEffect((short) 0x02000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2FolkInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeSummonInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.BeginRotation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StopRotation;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author decad Implementation of the Bluff Effect
|
||||
*/
|
||||
final class EffectBluff extends L2Effect
|
||||
{
|
||||
public EffectBluff(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.BLUFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
if (getEffected() instanceof L2FolkInstance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((getEffected() instanceof L2NpcInstance) && (((L2NpcInstance) getEffected()).getNpcId() == 12024))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (getEffected() instanceof L2SiegeSummonInstance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getEffected().broadcastPacket(new BeginRotation(getEffected().getObjectId(), getEffected().getHeading(), 1, 65535));
|
||||
getEffected().broadcastPacket(new StopRotation(getEffected().getObjectId(), getEffector().getHeading(), 65535));
|
||||
getEffected().setHeading(getEffector().getHeading());
|
||||
getEffected().setTarget(null);
|
||||
getEffected().abortAttack();
|
||||
getEffected().abortCast();
|
||||
getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, getEffector());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jmobius.gameserver.model.L2Effect#onActionTime()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectBuff extends L2Effect
|
||||
{
|
||||
public EffectBuff(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.BUFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectChameleonRest extends L2Effect
|
||||
{
|
||||
public EffectChameleonRest(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.RELAXING;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
|
||||
if (getEffected() instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) getEffected()).setRelax(true);
|
||||
((L2PcInstance) getEffected()).setSilentMoving(true);
|
||||
((L2PcInstance) getEffected()).sitDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_REST);
|
||||
}
|
||||
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
|
||||
if (getEffected() instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) getEffected()).setRelax(false);
|
||||
((L2PcInstance) getEffected()).setSilentMoving(false);
|
||||
}
|
||||
|
||||
super.onExit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
boolean retval = true;
|
||||
final L2PcInstance effected = (L2PcInstance) getEffected();
|
||||
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
retval = false;
|
||||
}
|
||||
|
||||
// Only cont skills shouldn't end
|
||||
if (getSkill().getSkillType() != SkillType.CONT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!effected.isSitting())
|
||||
{
|
||||
retval = false;
|
||||
}
|
||||
|
||||
final double manaDam = calc();
|
||||
if (manaDam > effected.getCurrentMp())
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(140);
|
||||
effected.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!retval)
|
||||
{
|
||||
effected.setRelax(retval);
|
||||
}
|
||||
else
|
||||
{
|
||||
effected.reduceCurrentMp(manaDam);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectCharmOfLuck extends L2Effect
|
||||
{
|
||||
public EffectCharmOfLuck(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.CHARM_OF_LUCK;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
if (getEffected() instanceof L2PlayableInstance)
|
||||
{
|
||||
((L2PlayableInstance) getEffected()).startCharmOfLuck();
|
||||
}
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
if (getEffected() instanceof L2PlayableInstance)
|
||||
{
|
||||
((L2PlayableInstance) getEffected()).stopCharmOfLuck(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectCombatPointHealOverTime extends L2Effect
|
||||
{
|
||||
public EffectCombatPointHealOverTime(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.COMBAT_POINT_HEAL_OVER_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double cp = getEffected().getCurrentCp();
|
||||
final double maxcp = getEffected().getMaxCp();
|
||||
cp += calc();
|
||||
if (cp > maxcp)
|
||||
{
|
||||
cp = maxcp;
|
||||
}
|
||||
getEffected().setCurrentCp(cp);
|
||||
final StatusUpdate sump = new StatusUpdate(getEffected().getObjectId());
|
||||
sump.addAttribute(StatusUpdate.CUR_CP, (int) cp);
|
||||
getEffected().sendPacket(sump);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* @author littlecrow Implementation of the Confusion Effect
|
||||
*/
|
||||
final class EffectConfuseMob extends L2Effect
|
||||
{
|
||||
public EffectConfuseMob(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.CONFUSE_MOB_ONLY;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startConfused();
|
||||
onActionTime();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopConfused(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
final List<L2Character> targetList = new FastList<>();
|
||||
|
||||
// Getting the possible targets
|
||||
for (final L2Object obj : getEffected().getKnownList().getKnownObjects().values())
|
||||
{
|
||||
|
||||
if ((obj instanceof L2Attackable) && (obj != getEffected()) && Util.checkIfInShortRadius(600, getEffected(), obj, true))
|
||||
{
|
||||
targetList.add((L2Character) obj);
|
||||
}
|
||||
}
|
||||
|
||||
// if there is no target, exit function
|
||||
if (targetList.size() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Choosing randomly a new target
|
||||
final int nextTargetIdx = Rnd.nextInt(targetList.size());
|
||||
final L2Object target = targetList.get(nextTargetIdx);
|
||||
|
||||
// Attacking the target
|
||||
getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
import javolution.util.FastList;
|
||||
|
||||
/**
|
||||
* @author littlecrow Implementation of the Confusion Effect
|
||||
*/
|
||||
final class EffectConfusion extends L2Effect
|
||||
{
|
||||
public EffectConfusion(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.CONFUSION;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startConfused();
|
||||
onActionTime();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopConfused(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
final List<L2Character> targetList = new FastList<>();
|
||||
|
||||
// Getting the possible targets
|
||||
for (final L2Object obj : getEffected().getKnownList().getKnownObjects().values())
|
||||
{
|
||||
|
||||
if ((obj instanceof L2Character) && (obj != getEffected()) && Util.checkIfInShortRadius(600, getEffected(), obj, true))
|
||||
{
|
||||
targetList.add((L2Character) obj);
|
||||
}
|
||||
}
|
||||
|
||||
// if there is no target, exit function
|
||||
if (targetList.size() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Choosing randomly a new target
|
||||
final int nextTargetIdx = Rnd.nextInt(targetList.size());
|
||||
final L2Object target = targetList.get(nextTargetIdx);
|
||||
|
||||
// Attacking the target
|
||||
getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2Skill.SkillTargetType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectDamOverTime extends L2Effect
|
||||
{
|
||||
public EffectDamOverTime(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.DMG_OVER_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double damage = calc();
|
||||
if (damage >= (getEffected().getCurrentHp() - 1))
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
getEffected().sendPacket(new SystemMessage(610));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getEffected().getCurrentHp() <= 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
damage = getEffected().getCurrentHp() - 1;
|
||||
}
|
||||
|
||||
final boolean awake = !(getEffected() instanceof L2Attackable) && !((getSkill().getTargetType() == SkillTargetType.TARGET_SELF) && getSkill().isToggle());
|
||||
|
||||
getEffected().reduceCurrentHp(damage, getEffector(), awake);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2Skill.SkillTargetType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectDeathPoison extends L2Effect
|
||||
{
|
||||
public EffectDeathPoison(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.DMG_OVER_TIME;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startRooted();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopRooting(this);
|
||||
|
||||
final QuestState qs = ((L2PcInstance) getEffected()).getQuestState("501_ProofOfClanAlliance");
|
||||
if ((qs != null) && qs.getStateId().equals("Part4"))
|
||||
{
|
||||
qs.exitQuest(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double damage = calc();
|
||||
if (damage >= (getEffected().getCurrentHp() - 1))
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
getEffected().sendPacket(new SystemMessage(610));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean awake = !(getEffected() instanceof L2Attackable) && !((getSkill().getTargetType() == SkillTargetType.TARGET_SELF) && getSkill().isToggle());
|
||||
|
||||
getEffected().reduceCurrentHp(damage, getEffector(), awake);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectDebuff extends L2Effect
|
||||
{
|
||||
public EffectDebuff(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.DEBUFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectFakeDeath extends L2Effect
|
||||
{
|
||||
public EffectFakeDeath(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.FAKE_DEATH;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startFakeDeath();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopFakeDeath(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double manaDam = calc();
|
||||
|
||||
if (manaDam > getEffected().getCurrentMp())
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(140);
|
||||
getEffected().sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getEffected().reduceCurrentMp(manaDam);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2CharPosition;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2FolkInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeSummonInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author littlecrow Implementation of the Fear Effect
|
||||
*/
|
||||
final class EffectFear extends L2Effect
|
||||
{
|
||||
public static final int FEAR_RANGE = 500;
|
||||
|
||||
private int _dX = -1;
|
||||
private int _dY = -1;
|
||||
|
||||
public EffectFear(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.FEAR;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
if (getEffected() instanceof L2FolkInstance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((getEffected() instanceof L2NpcInstance) && (((L2NpcInstance) getEffected()).getNpcId() == 12024))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (getEffected() instanceof L2SiegeSummonInstance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// players are only affected by grandboss skills
|
||||
if ((getEffected() instanceof L2PcInstance) && (getEffector() instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getEffected().isAfraid())
|
||||
{
|
||||
if (getEffected().getX() > getEffector().getX())
|
||||
{
|
||||
_dX = 1;
|
||||
}
|
||||
if (getEffected().getY() > getEffector().getY())
|
||||
{
|
||||
_dY = 1;
|
||||
}
|
||||
|
||||
getEffected().startFear();
|
||||
onActionTime();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
|
||||
{
|
||||
getEffected().stopFear(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
int posX = getEffected().getX();
|
||||
int posY = getEffected().getY();
|
||||
final int posZ = getEffected().getZ();
|
||||
|
||||
posX += _dX * FEAR_RANGE;
|
||||
posY += _dY * FEAR_RANGE;
|
||||
|
||||
if (Config.GEODATA > 0)
|
||||
{
|
||||
final Location destiny = GeoData.getInstance().moveCheck(getEffected().getX(), getEffected().getY(), getEffected().getZ(), posX, posY, posZ);
|
||||
posX = destiny.getX();
|
||||
posY = destiny.getY();
|
||||
}
|
||||
|
||||
if (!(getEffected() instanceof L2PetInstance))
|
||||
{
|
||||
getEffected().setRunning();
|
||||
}
|
||||
|
||||
getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(posX, posY, posZ, 0));
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectHealOverTime extends L2Effect
|
||||
{
|
||||
public EffectHealOverTime(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.HEAL_OVER_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getEffected() instanceof L2DoorInstance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double hp = getEffected().getCurrentHp();
|
||||
final double maxhp = getEffected().getMaxHp();
|
||||
hp += calc();
|
||||
if (hp > maxhp)
|
||||
{
|
||||
hp = maxhp;
|
||||
}
|
||||
|
||||
getEffected().setCurrentHp(hp);
|
||||
final StatusUpdate suhp = new StatusUpdate(getEffected().getObjectId());
|
||||
suhp.addAttribute(StatusUpdate.CUR_HP, (int) hp);
|
||||
getEffected().sendPacket(suhp);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectHitMainTarget extends L2Effect
|
||||
{
|
||||
public EffectHitMainTarget(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.MANA_DMG_OVER_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().setIsSingleSpear(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().setIsSingleSpear(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double manaDam = calc();
|
||||
|
||||
if (manaDam > getEffected().getCurrentMp())
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(140);
|
||||
getEffected().sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getEffected().reduceCurrentMp(manaDam);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectImmobileBuff extends L2Effect
|
||||
{
|
||||
public EffectImmobileBuff(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.BUFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().setIsImmobilized(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().setIsImmobilized(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectManaDamOverTime extends L2Effect
|
||||
{
|
||||
public EffectManaDamOverTime(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.MANA_DMG_OVER_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double manaDam = calc();
|
||||
|
||||
if (manaDam > getEffected().getCurrentMp())
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(140);
|
||||
getEffected().sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getEffected().reduceCurrentMp(manaDam);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectManaHealOverTime extends L2Effect
|
||||
{
|
||||
public EffectManaHealOverTime(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.MANA_HEAL_OVER_TIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double mp = getEffected().getCurrentMp();
|
||||
final double maxmp = getEffected().getMaxMp();
|
||||
mp += calc();
|
||||
if (mp > maxmp)
|
||||
{
|
||||
mp = maxmp;
|
||||
}
|
||||
getEffected().setCurrentMp(mp);
|
||||
final StatusUpdate sump = new StatusUpdate(getEffected().getObjectId());
|
||||
sump.addAttribute(StatusUpdate.CUR_MP, (int) mp);
|
||||
getEffected().sendPacket(sump);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectMpConsumePerLevel extends L2Effect
|
||||
{
|
||||
public EffectMpConsumePerLevel(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.MP_CONSUME_PER_LEVEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double base = calc();
|
||||
final double consume = ((getEffected().getLevel() - 1) / 7.5) * base * getPeriod();
|
||||
|
||||
if (consume > getEffected().getCurrentMp())
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(140);
|
||||
getEffected().sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
|
||||
getEffected().reduceCurrentMp(consume);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
public class EffectMute extends L2Effect
|
||||
{
|
||||
public EffectMute(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return L2Effect.EffectType.MUTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startMuted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// Simply stop the effect
|
||||
getEffected().stopMuted(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopMuted(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author earendil TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectNoblesseBless extends L2Effect
|
||||
{
|
||||
public EffectNoblesseBless(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.NOBLESSE_BLESSING;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
if (getEffected() instanceof L2PlayableInstance)
|
||||
{
|
||||
((L2PlayableInstance) getEffected()).startNoblesseBlessing();
|
||||
}
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
if (getEffected() instanceof L2PlayableInstance)
|
||||
{
|
||||
((L2PlayableInstance) getEffected()).stopNoblesseBlessing(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
final class EffectParalyze extends L2Effect
|
||||
{
|
||||
public EffectParalyze(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.PARALYZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startAbnormalEffect((short) 0x0400);
|
||||
|
||||
getEffected().startParalyze();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopAbnormalEffect((short) 0x0400);
|
||||
getEffected().stopParalyze(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
public class EffectPetrification extends L2Effect
|
||||
{
|
||||
public EffectPetrification(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return L2Effect.EffectType.PETRIFICATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startAbnormalEffect((short) 0x0800);
|
||||
getEffected().startParalyze();
|
||||
getEffected().setIsInvul(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopAbnormalEffect((short) 0x0800);
|
||||
getEffected().stopParalyze(this);
|
||||
getEffected().setIsInvul(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
public class EffectPhysicalMute extends L2Effect
|
||||
{
|
||||
public EffectPhysicalMute(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return L2Effect.EffectType.PHYSICAL_MUTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startPhysicalMuted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// Simply stop the effect
|
||||
getEffected().stopPhysicalMuted(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopPhysicalMuted(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
class EffectRelax extends L2Effect
|
||||
{
|
||||
public EffectRelax(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.RELAXING;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
if (getEffected().getCurrentHp() == getEffected().getMaxHp())
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
|
||||
getEffected().sendPacket(new SystemMessage(175));
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (getEffected() instanceof L2PcInstance)
|
||||
{
|
||||
|
||||
((L2PcInstance) getEffected()).setRelax(true);
|
||||
((L2PcInstance) getEffected()).sitDown();
|
||||
|
||||
}
|
||||
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
if (getEffected() instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) getEffected()).setRelax(false);
|
||||
}
|
||||
|
||||
super.onExit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!((L2PcInstance) getEffected()).isSitting())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getEffected().getCurrentHp() == getEffected().getMaxHp())
|
||||
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
getEffected().sendPacket(new SystemMessage(175));
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
final double manaDam = calc();
|
||||
if (manaDam > getEffected().getCurrentMp())
|
||||
{
|
||||
if (getSkill().isToggle())
|
||||
{
|
||||
|
||||
getEffected().sendPacket(new SystemMessage(140));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getEffected().reduceCurrentMp(manaDam);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author -Nemesiss-
|
||||
*/
|
||||
public class EffectRemoveTarget extends L2Effect
|
||||
{
|
||||
public EffectRemoveTarget(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.REMOVE_TARGET;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().setTarget(null);
|
||||
getEffected().abortAttack();
|
||||
getEffected().abortCast();
|
||||
getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, getEffector());
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectRoot extends L2Effect
|
||||
{
|
||||
public EffectRoot(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.ROOT;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startRooted();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopRooting(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
public final class EffectSeed extends L2Effect
|
||||
{
|
||||
int _power = 1;
|
||||
|
||||
public EffectSeed(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.SEED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getPower()
|
||||
{
|
||||
return _power;
|
||||
}
|
||||
|
||||
public void increasePower()
|
||||
{
|
||||
_power++;
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
public class EffectSilenceMagicPhysical extends L2Effect
|
||||
{
|
||||
public EffectSilenceMagicPhysical(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return L2Effect.EffectType.SILENCE_MAGIC_PHYSICAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startMuted();
|
||||
getEffected().startPhysicalMuted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
getEffected().stopMuted(this);
|
||||
getEffected().stopPhysicalMuted(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopMuted(this);
|
||||
getEffected().stopPhysicalMuted(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2Skill.SkillType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PlayableInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
final class EffectSilentMove extends L2Effect
|
||||
{
|
||||
public EffectSilentMove(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
super.onStart();
|
||||
|
||||
if (getEffected() instanceof L2PlayableInstance)
|
||||
{
|
||||
((L2PlayableInstance) getEffected()).setSilentMoving(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
super.onExit();
|
||||
|
||||
if (getEffected() instanceof L2PlayableInstance)
|
||||
{
|
||||
((L2PlayableInstance) getEffected()).setSilentMoving(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.SILENT_MOVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
|
||||
// Only cont skills shouldn't end
|
||||
|
||||
if (getSkill().getSkillType() != SkillType.CONT)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getEffected().isDead())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final double manaDam = calc();
|
||||
if (manaDam > getEffected().getCurrentMp())
|
||||
{
|
||||
|
||||
getEffected().sendPacket(new SystemMessage(140));
|
||||
return false;
|
||||
}
|
||||
|
||||
getEffected().reduceCurrentMp(manaDam);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectSleep extends L2Effect
|
||||
{
|
||||
public EffectSleep(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.SLEEP;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startSleeping();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopSleeping(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
getEffected().stopSleeping(this);
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
final class EffectStun extends L2Effect
|
||||
{
|
||||
public EffectStun(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.STUN;
|
||||
}
|
||||
|
||||
/** Notify started */
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffected().startStunning();
|
||||
}
|
||||
|
||||
/** Notify exited */
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().stopStunning(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
public class EffectStunSelf extends L2Effect
|
||||
{
|
||||
public EffectStunSelf(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.STUN_SELF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
getEffector().startStunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffector().stopStunning(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
// just stop this effect
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.skills.funcs.FuncTemplate;
|
||||
import com.l2jmobius.gameserver.skills.funcs.Lambda;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final 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 _period; // in seconds
|
||||
public final short _abnormalEffect;
|
||||
public FuncTemplate[] _funcTemplates;
|
||||
|
||||
public final String _stackType;
|
||||
public final float _stackOrder;
|
||||
public final boolean _icon;
|
||||
|
||||
public EffectTemplate(Condition attachCond, Condition applayCond, String func, Lambda lambda, int counter, int period, short abnormalEffect, String stackType, float stackOrder, boolean showIcon)
|
||||
{
|
||||
_attachCond = attachCond;
|
||||
_applayCond = applayCond;
|
||||
_lambda = lambda;
|
||||
_counter = counter;
|
||||
_period = period;
|
||||
_abnormalEffect = abnormalEffect;
|
||||
_stackType = stackType;
|
||||
_stackOrder = stackOrder;
|
||||
_icon = showIcon;
|
||||
|
||||
try
|
||||
{
|
||||
_func = Class.forName("com.l2jmobius.gameserver.skills.effects.Effect" + func);
|
||||
}
|
||||
catch (final ClassNotFoundException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try
|
||||
{
|
||||
_constructor = _func.getConstructor(Env.class, EffectTemplate.class);
|
||||
}
|
||||
catch (final NoSuchMethodException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public L2Effect getEffect(Env env)
|
||||
{
|
||||
if ((_attachCond != null) && !_attachCond.test(env))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
final L2Effect effect = (L2Effect) _constructor.newInstance(env, this);
|
||||
return effect;
|
||||
}
|
||||
catch (final IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
catch (final InstantiationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
catch (final InvocationTargetException e)
|
||||
{
|
||||
_log.warning("Error creating new instance of Class " + _func + " Exception was:");
|
||||
e.getTargetException().printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void attach(FuncTemplate f)
|
||||
{
|
||||
if (_funcTemplates == null)
|
||||
{
|
||||
_funcTemplates = new FuncTemplate[]
|
||||
{
|
||||
f
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
final int len = _funcTemplates.length;
|
||||
final FuncTemplate[] tmp = new FuncTemplate[len + 1];
|
||||
System.arraycopy(_funcTemplates, 0, tmp, 0, len);
|
||||
tmp[len] = f;
|
||||
_funcTemplates = tmp;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.effects;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
final class EffectThrowUp extends L2Effect
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(EffectThrowUp.class.getName());
|
||||
|
||||
private int _x, _y, _z;
|
||||
|
||||
public EffectThrowUp(Env env, EffectTemplate template)
|
||||
{
|
||||
super(env, template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectType getEffectType()
|
||||
{
|
||||
return EffectType.THROW_UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
{
|
||||
// Get current position of the L2Character
|
||||
final int curX = getEffected().getX();
|
||||
final int curY = getEffected().getY();
|
||||
final int curZ = getEffected().getZ();
|
||||
|
||||
// Calculate distance between effector and effected current position
|
||||
final double dx = getEffector().getX() - curX;
|
||||
final double dy = getEffector().getY() - curY;
|
||||
final double dz = getEffector().getZ() - curZ;
|
||||
|
||||
final double distance = Math.sqrt((dx * dx) + (dy * dy));
|
||||
if (distance > 2000)
|
||||
{
|
||||
_log.info("EffectThrow was going to use invalid coordinates for characters, getEffected: " + curX + "," + curY + " and getEffector: " + getEffector().getX() + "," + getEffector().getY());
|
||||
return;
|
||||
}
|
||||
|
||||
int offset = Math.min((int) distance + getSkill().getFlyRadius(), 1400);
|
||||
|
||||
double cos;
|
||||
double sin;
|
||||
|
||||
// approximation for moving futher when z coordinates are different
|
||||
// TODO: handle Z axis movement better
|
||||
offset += Math.abs(dz);
|
||||
if (offset < 5)
|
||||
{
|
||||
offset = 5;
|
||||
}
|
||||
|
||||
// If no distance
|
||||
if (distance < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate movement angles needed
|
||||
sin = dy / distance;
|
||||
cos = dx / distance;
|
||||
|
||||
// Calculate the new destination with offset included
|
||||
_x = getEffector().getX() - (int) (offset * cos);
|
||||
_y = getEffector().getY() - (int) (offset * sin);
|
||||
_z = getEffected().getZ();
|
||||
|
||||
if (Config.GEODATA > 0)
|
||||
{
|
||||
final Location destiny = GeoData.getInstance().moveCheck(getEffected().getX(), getEffected().getY(), getEffected().getZ(), _x, _y, _z);
|
||||
_x = destiny.getX();
|
||||
_y = destiny.getY();
|
||||
}
|
||||
|
||||
getEffected().broadcastPacket(new FlyToLocation(getEffected(), _x, _y, _z, FlyType.THROW_UP));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jmobius.gameserver.model.L2Effect#onActionTime()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean onActionTime()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit()
|
||||
{
|
||||
getEffected().setXYZ(_x, _y, _z);
|
||||
getEffected().broadcastPacket(new ValidateLocation(getEffected()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
import com.l2jmobius.gameserver.skills.conditions.Condition;
|
||||
|
||||
/**
|
||||
* A Func object is a component of a Calculator created to manage and dynamically calculate the effect of a character property (ex : MAX_HP, REGENERATE_HP_RATE...). In fact, each calculator is a table of Func object in which each Func represents a mathematic function : <BR>
|
||||
* <BR>
|
||||
* FuncAtkAccuracy -> Math.sqrt(_player.getDEX())*6+_player.getLevel()<BR>
|
||||
* <BR>
|
||||
* When the calc method of a calculator is launched, each mathematic function is called according to its priority <B>_order</B>. Indeed, Func with lowest priority order is executed firsta and Funcs with the same order are executed in unspecified order. The result of the calculation is stored in the
|
||||
* value property of an Env class instance.<BR>
|
||||
* <BR>
|
||||
*/
|
||||
public abstract class Func
|
||||
{
|
||||
|
||||
/** Statistics, that is affected by this function (See L2Character.CALCULATOR_XXX constants) */
|
||||
public final Stats _stat;
|
||||
|
||||
/**
|
||||
* Order of functions calculation. Functions with lower order are executed first. Functions with the same order are executed in unspecified order. Usually add/substruct functions has lowest order, then bonus/penalty functions (multiplay/divide) are applied, then functions that do more complex
|
||||
* calculations (non-linear functions).
|
||||
*/
|
||||
public final int _order;
|
||||
|
||||
/**
|
||||
* Owner can be an armor, weapon, skill, system event, quest, etc Used to remove all functions added by this owner.
|
||||
*/
|
||||
public final Object _funcOwner;
|
||||
|
||||
/** Function may be disabled by attached condition. */
|
||||
public Condition _cond;
|
||||
|
||||
/**
|
||||
* Constructor of Func.<BR>
|
||||
* <BR>
|
||||
* @param stat
|
||||
* @param order
|
||||
* @param owner
|
||||
*/
|
||||
public Func(Stats stat, int order, Object owner)
|
||||
{
|
||||
_stat = stat;
|
||||
_order = order;
|
||||
_funcOwner = owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a condition to the Func.<BR>
|
||||
* <BR>
|
||||
* @param cond
|
||||
*/
|
||||
public void setCondition(Condition cond)
|
||||
{
|
||||
_cond = cond;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the mathematic function of the Func.<BR>
|
||||
* <BR>
|
||||
* @param env
|
||||
*/
|
||||
public abstract void calc(Env env);
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
|
||||
public class FuncAdd extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncAdd(Stats stat, int order, Object owner, Lambda lambda)
|
||||
{
|
||||
super(stat, order, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((_cond == null) || _cond.test(env))
|
||||
{
|
||||
env.value += _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
|
||||
public class FuncDiv extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncDiv(Stats stat, int order, Object owner, Lambda lambda)
|
||||
{
|
||||
super(stat, order, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((_cond == null) || _cond.test(env))
|
||||
{
|
||||
env.value /= _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
import com.l2jmobius.gameserver.templates.L2Item;
|
||||
import com.l2jmobius.gameserver.templates.L2WeaponType;
|
||||
|
||||
public class FuncEnchant extends Func
|
||||
{
|
||||
public FuncEnchant(Stats stat, int order, Object owner, Lambda lambda)
|
||||
{
|
||||
super(stat, order, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((_cond != null) && !_cond.test(env))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) _funcOwner;
|
||||
|
||||
int enchant = item.getEnchantLevel();
|
||||
if (enchant <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int overenchant = 0;
|
||||
if (enchant > 3)
|
||||
{
|
||||
overenchant = enchant - 3;
|
||||
enchant = 3;
|
||||
}
|
||||
|
||||
if ((_stat == Stats.MAGIC_DEFENCE) || (_stat == Stats.POWER_DEFENCE))
|
||||
{
|
||||
env.value += enchant + (3 * overenchant);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stat == Stats.MAGIC_ATTACK)
|
||||
{
|
||||
switch (item.getItem().getCrystalType())
|
||||
{
|
||||
case L2Item.CRYSTAL_S:
|
||||
env.value += (4 * enchant) + (8 * overenchant);
|
||||
break;
|
||||
case L2Item.CRYSTAL_A:
|
||||
env.value += (3 * enchant) + (6 * overenchant);
|
||||
break;
|
||||
case L2Item.CRYSTAL_B:
|
||||
env.value += (3 * enchant) + (6 * overenchant);
|
||||
break;
|
||||
case L2Item.CRYSTAL_C:
|
||||
env.value += (3 * enchant) + (6 * overenchant);
|
||||
break;
|
||||
case L2Item.CRYSTAL_D:
|
||||
env.value += (2 * enchant) + (4 * overenchant);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
switch (item.getItem().getCrystalType())
|
||||
{
|
||||
case L2Item.CRYSTAL_S:
|
||||
if (item.getItemType() == L2WeaponType.BOW)
|
||||
{
|
||||
env.value += (10 * enchant) + (20 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
env.value += (5 * enchant) + (10 * overenchant);
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_A:
|
||||
if (item.getItemType() == L2WeaponType.BOW)
|
||||
{
|
||||
env.value += (8 * enchant) + (16 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
env.value += (4 * enchant) + (8 * overenchant);
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_B:
|
||||
if (item.getItemType() == L2WeaponType.BOW)
|
||||
{
|
||||
env.value += (6 * enchant) + (12 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
env.value += (3 * enchant) + (6 * overenchant);
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_C:
|
||||
if (item.getItemType() == L2WeaponType.BOW)
|
||||
{
|
||||
env.value += (6 * enchant) + (12 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
env.value += (3 * enchant) + (6 * overenchant);
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_D:
|
||||
case L2Item.CRYSTAL_NONE:
|
||||
if (item.getItemType() == L2WeaponType.BOW)
|
||||
{
|
||||
env.value += (4 * enchant) + (8 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
env.value += (2 * enchant) + (4 * overenchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
|
||||
public class FuncMul extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncMul(Stats stat, int order, Object owner, Lambda lambda)
|
||||
{
|
||||
super(stat, order, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((_cond == null) || _cond.test(env))
|
||||
{
|
||||
env.value *= _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
|
||||
public class FuncSet extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncSet(Stats stat, int order, Object owner, Lambda lambda)
|
||||
{
|
||||
super(stat, order, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((_cond == null) || _cond.test(env))
|
||||
{
|
||||
env.value = _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
|
||||
public class FuncSub extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncSub(Stats stat, int order, Object owner, Lambda lambda)
|
||||
{
|
||||
super(stat, order, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((_cond == null) || _cond.test(env))
|
||||
{
|
||||
env.value -= _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.gameserver.skills.Stats;
|
||||
import com.l2jmobius.gameserver.skills.conditions.Condition;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class FuncTemplate
|
||||
{
|
||||
public Condition _attachCond;
|
||||
public Condition _applayCond;
|
||||
public final Class<?> _func;
|
||||
public final Constructor<?> _constructor;
|
||||
public final Stats _stat;
|
||||
public final int _order;
|
||||
public final Lambda _lambda;
|
||||
|
||||
public FuncTemplate(Condition attachCond, Condition applayCond, String func, Stats stat, int order, Lambda lambda)
|
||||
{
|
||||
_attachCond = attachCond;
|
||||
_applayCond = applayCond;
|
||||
_stat = stat;
|
||||
_order = order;
|
||||
_lambda = lambda;
|
||||
|
||||
try
|
||||
{
|
||||
_func = Class.forName("com.l2jmobius.gameserver.skills.funcs.Func" + func);
|
||||
}
|
||||
catch (final ClassNotFoundException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try
|
||||
{
|
||||
_constructor = _func.getConstructor(new Class[]
|
||||
{
|
||||
Stats.class, // stats to update
|
||||
Integer.TYPE, // order of execution
|
||||
Object.class, // owner
|
||||
Lambda.class // value for function
|
||||
});
|
||||
}
|
||||
catch (final NoSuchMethodException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Func getFunc(Env env, Object owner)
|
||||
{
|
||||
if ((_attachCond != null) && !_attachCond.test(env))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final Func f = (Func) _constructor.newInstance(_stat, _order, owner, _lambda);
|
||||
if (_applayCond != null)
|
||||
{
|
||||
f.setCondition(_applayCond);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
catch (final IllegalAccessException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
catch (final InstantiationException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
catch (final InvocationTargetException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public abstract class Lambda
|
||||
{
|
||||
public abstract double calc(Env env);
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class LambdaCalc extends Lambda
|
||||
{
|
||||
public Func[] _funcs;
|
||||
|
||||
public LambdaCalc()
|
||||
{
|
||||
_funcs = new Func[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(Env env)
|
||||
{
|
||||
final double saveValue = env.value;
|
||||
try
|
||||
{
|
||||
env.value = 0;
|
||||
for (final Func f : _funcs)
|
||||
{
|
||||
f.calc(env);
|
||||
}
|
||||
return env.value;
|
||||
}
|
||||
finally
|
||||
{
|
||||
env.value = saveValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void addFunc(Func f)
|
||||
{
|
||||
final int len = _funcs.length;
|
||||
final Func[] tmp = new Func[len + 1];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
tmp[i] = _funcs[i];
|
||||
}
|
||||
tmp[len] = f;
|
||||
_funcs = tmp;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class LambdaConst extends Lambda
|
||||
{
|
||||
private final double _value;
|
||||
|
||||
public LambdaConst(double value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(Env env)
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class LambdaRnd extends Lambda
|
||||
{
|
||||
private final Lambda _max;
|
||||
private final boolean _linear;
|
||||
|
||||
public LambdaRnd(Lambda max, boolean linear)
|
||||
{
|
||||
_max = max;
|
||||
_linear = linear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(Env env)
|
||||
{
|
||||
if (_linear)
|
||||
{
|
||||
return _max.calc(env) * Rnd.nextDouble();
|
||||
}
|
||||
return _max.calc(env) * Rnd.nextGaussian();
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jmobius.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
public final class LambdaStats extends Lambda
|
||||
{
|
||||
public enum StatsType
|
||||
{
|
||||
PLAYER_LEVEL,
|
||||
TARGET_LEVEL,
|
||||
PLAYER_MAX_HP,
|
||||
PLAYER_MAX_MP
|
||||
}
|
||||
|
||||
private final StatsType _stat;
|
||||
|
||||
public LambdaStats(StatsType stat)
|
||||
{
|
||||
_stat = stat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(Env env)
|
||||
{
|
||||
switch (_stat)
|
||||
{
|
||||
case PLAYER_LEVEL:
|
||||
if (env.player == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return env.player.getLevel();
|
||||
case TARGET_LEVEL:
|
||||
if (env.target == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return env.target.getLevel();
|
||||
case PLAYER_MAX_HP:
|
||||
if (env.player == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return env.player.getMaxHp();
|
||||
case PLAYER_MAX_MP:
|
||||
if (env.player == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return env.player.getMaxMp();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.skills.Formulas;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillChargeDmg extends L2Skill
|
||||
{
|
||||
final int num_charges;
|
||||
|
||||
public L2SkillChargeDmg(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
num_charges = set.getInteger("num_charges", getLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkCondition(L2Character activeChar, boolean itemOrWeapon)
|
||||
{
|
||||
final L2PcInstance player = (L2PcInstance) activeChar;
|
||||
|
||||
if (player.getCharges() < num_charges)
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(113);
|
||||
sm.addSkillName(getId());
|
||||
activeChar.sendPacket(sm);
|
||||
return false;
|
||||
}
|
||||
return super.checkCondition(activeChar, itemOrWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
final L2PcInstance player = (L2PcInstance) caster;
|
||||
|
||||
if (caster.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Formula tested by L2Guru
|
||||
double modifier = 0;
|
||||
modifier = 0.8 + (0.201 * player.getCharges());
|
||||
|
||||
player.addCharge(-num_charges);
|
||||
|
||||
final L2ItemInstance weapon = caster.getActiveWeaponInstance();
|
||||
final boolean soul = ((weapon != null) && (weapon.getChargedSoulshot() == L2ItemInstance.CHARGED_SOULSHOT));
|
||||
|
||||
for (final L2Object target2 : targets)
|
||||
{
|
||||
|
||||
final L2Character target = (L2Character) target2;
|
||||
if (target.isAlikeDead())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final boolean shld = Formulas.getInstance().calcShldUse(caster, target);
|
||||
|
||||
double damage = Formulas.getInstance().calcPhysDam(caster, target, this, shld, false, false, soul);
|
||||
|
||||
if (damage > 0)
|
||||
{
|
||||
|
||||
damage = damage * modifier;
|
||||
target.reduceCurrentHp(damage, caster);
|
||||
|
||||
caster.sendDamageMessage(target, (int) damage, false, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Nemesiss
|
||||
*/
|
||||
public class L2SkillCreateItem extends L2Skill
|
||||
{
|
||||
private final int create_item_id;
|
||||
private final int create_item_count;
|
||||
private final int random_count;
|
||||
|
||||
public L2SkillCreateItem(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
create_item_id = set.getInteger("create_item_id", 0);
|
||||
create_item_count = set.getInteger("create_item_count", 0);
|
||||
random_count = set.getInteger("random_count", 1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jmobius.gameserver.model.L2Skill#useSkill(com.l2jmobius.gameserver.model.L2Character, com.l2jmobius.gameserver.model.L2Object[])
|
||||
*/
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
if (activeChar.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((create_item_id == 0) || (create_item_count == 0))
|
||||
{
|
||||
final SystemMessage sm = new SystemMessage(SystemMessage.SKILL_NOT_AVAILABLE);
|
||||
activeChar.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
final L2PcInstance player = (L2PcInstance) activeChar;
|
||||
if (activeChar instanceof L2PcInstance)
|
||||
{
|
||||
final int rnd = Rnd.nextInt(random_count) + 1;
|
||||
final int count = create_item_count * rnd;
|
||||
|
||||
giveItems(player, create_item_id, count);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param itemId
|
||||
* @param count
|
||||
*/
|
||||
public void giveItems(L2PcInstance activeChar, int itemId, int count)
|
||||
{
|
||||
final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), itemId);
|
||||
item.setCount(count);
|
||||
activeChar.getInventory().addItem("Skill", item, activeChar, activeChar);
|
||||
|
||||
if (count > 1)
|
||||
{
|
||||
final SystemMessage smsg = new SystemMessage(SystemMessage.EARNED_S2_S1_s);
|
||||
smsg.addItemName(item.getItemId());
|
||||
smsg.addNumber(count);
|
||||
activeChar.sendPacket(smsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
final SystemMessage smsg = new SystemMessage(SystemMessage.EARNED_ITEM);
|
||||
smsg.addItemName(item.getItemId());
|
||||
activeChar.sendPacket(smsg);
|
||||
}
|
||||
|
||||
final ItemList il = new ItemList(activeChar, false);
|
||||
activeChar.sendPacket(il);
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillDefault extends L2Skill
|
||||
{
|
||||
public L2SkillDefault(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
caster.sendPacket(new ActionFailed());
|
||||
caster.sendMessage("Skill not implemented. Skill ID: " + getId() + " " + getSkillType());
|
||||
}
|
||||
}
|
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jmobius.gameserver.skills.Formulas;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillDrain extends L2Skill
|
||||
{
|
||||
private final float absorbPart;
|
||||
private final int absorbAbs;
|
||||
|
||||
public L2SkillDrain(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
absorbPart = set.getFloat("absorbPart", 0.f);
|
||||
absorbAbs = set.getInteger("absorbAbs", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character activeChar, L2Object[] targets)
|
||||
{
|
||||
if (activeChar.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean ss = false;
|
||||
boolean bss = false;
|
||||
|
||||
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
|
||||
if (weaponInst != null)
|
||||
{
|
||||
if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
|
||||
{
|
||||
bss = true;
|
||||
}
|
||||
else if (weaponInst.getChargedSpiritshot() == L2ItemInstance.CHARGED_SPIRITSHOT)
|
||||
{
|
||||
ss = true;
|
||||
}
|
||||
}
|
||||
// If there is no weapon equipped, check for an active summon.
|
||||
else if (activeChar instanceof L2Summon)
|
||||
{
|
||||
final L2Summon activeSummon = (L2Summon) activeChar;
|
||||
|
||||
if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_BLESSED_SPIRITSHOT)
|
||||
{
|
||||
bss = true;
|
||||
}
|
||||
else if (activeSummon.getChargedSpiritShot() == L2ItemInstance.CHARGED_SPIRITSHOT)
|
||||
{
|
||||
ss = true;
|
||||
}
|
||||
}
|
||||
else if (activeChar instanceof L2NpcInstance)
|
||||
{
|
||||
bss = ((L2NpcInstance) activeChar).isUsingShot(false);
|
||||
ss = ((L2NpcInstance) activeChar).isUsingShot(true);
|
||||
}
|
||||
|
||||
for (final L2Object target2 : targets)
|
||||
{
|
||||
final L2Character target = (L2Character) target2;
|
||||
if (target.isAlikeDead() && (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// No effect on invulnerable chars unless they cast it themselves.
|
||||
if ((activeChar != target) && target.isInvul())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final boolean mcrit = Formulas.getInstance().calcMCrit(activeChar.getMCriticalHit(target, this));
|
||||
final int damage = (int) Formulas.getInstance().calcMagicDam(activeChar, target, this, ss, bss, mcrit);
|
||||
|
||||
int _drain = 0;
|
||||
final int _cp = (int) target.getCurrentCp();
|
||||
final int _hp = (int) target.getCurrentHp();
|
||||
|
||||
if (_cp > 0)
|
||||
{
|
||||
if (damage < _cp)
|
||||
{
|
||||
_drain = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_drain = damage - _cp;
|
||||
}
|
||||
}
|
||||
|
||||
else if (damage > _hp)
|
||||
{
|
||||
_drain = _hp;
|
||||
}
|
||||
else
|
||||
{
|
||||
_drain = damage;
|
||||
}
|
||||
|
||||
final double hpAdd = absorbAbs + (absorbPart * _drain);
|
||||
final double hp = ((activeChar.getCurrentHp() + hpAdd) > activeChar.getMaxHp() ? activeChar.getMaxHp() : (activeChar.getCurrentHp() + hpAdd));
|
||||
|
||||
activeChar.setCurrentHp(hp);
|
||||
|
||||
final StatusUpdate suhp = new StatusUpdate(activeChar.getObjectId());
|
||||
suhp.addAttribute(StatusUpdate.CUR_HP, (int) hp);
|
||||
activeChar.sendPacket(suhp);
|
||||
|
||||
// Check to see if we should damage the target
|
||||
if ((damage > 0) && (!target.isDead() || (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB)))
|
||||
{
|
||||
target.reduceCurrentHp(damage, activeChar);
|
||||
|
||||
if (Formulas.getInstance().calcAtkBreak(target, damage))
|
||||
{
|
||||
target.breakAttack();
|
||||
target.breakCast();
|
||||
}
|
||||
|
||||
activeChar.sendDamageMessage(target, damage, mcrit, false, false);
|
||||
|
||||
}
|
||||
|
||||
// Check to see if we should do the decay right after the cast
|
||||
if (target.isDead() && (getTargetType() == SkillTargetType.TARGET_CORPSE_MOB) && (target instanceof L2NpcInstance))
|
||||
{
|
||||
((L2NpcInstance) target).endDecayTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ArtefactInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Siege;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillEngrave extends L2Skill
|
||||
{
|
||||
L2PcInstance player;
|
||||
Siege siege;
|
||||
|
||||
public L2SkillEngrave(StatsSet set)
|
||||
|
||||
{
|
||||
super(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkCondition(L2Character activeChar, boolean itemOrWeapon)
|
||||
{
|
||||
player = (L2PcInstance) activeChar;
|
||||
if (player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
siege = SiegeManager.getInstance().getSiege(player);
|
||||
|
||||
if (!player.isSkillDisabled(getId()))
|
||||
{
|
||||
if (siege == null)
|
||||
{
|
||||
player.sendMessage("You may only use this skill during a siege.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((player.getClan() == null) || !player.isClanLeader())
|
||||
{
|
||||
player.sendMessage("Only clan leaders may use this skill.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (siege.getAttackerClan(player.getClan()) == null)
|
||||
{
|
||||
player.sendMessage("You may only use this skill provided that you are an attacker.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.checkCondition(activeChar, itemOrWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (targets[0] instanceof L2ArtefactInstance)
|
||||
{
|
||||
siege.getCastle().engrave(player.getClan(), targets[0].getObjectId());
|
||||
}
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Effect;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.skills.effects.EffectSeed;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillSeed extends L2Skill
|
||||
{
|
||||
public L2SkillSeed(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Update Seeds Effects
|
||||
for (final L2Object obj : targets)
|
||||
{
|
||||
final L2Character target = (L2Character) obj;
|
||||
if (target.isAlikeDead() && (getTargetType() != SkillTargetType.TARGET_CORPSE_MOB))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean effectExists = false;
|
||||
final L2Effect[] effects = target.getAllEffects();
|
||||
for (final L2Effect seed : effects)
|
||||
{
|
||||
if (seed == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (seed.getSkill().getId() == getId())
|
||||
{
|
||||
effectExists = true;
|
||||
if (seed instanceof EffectSeed)
|
||||
{
|
||||
((EffectSeed) seed).increasePower();
|
||||
}
|
||||
}
|
||||
|
||||
if (seed.getEffectType() == L2Effect.EffectType.SEED)
|
||||
{
|
||||
seed.rescheduleEffect();
|
||||
}
|
||||
}
|
||||
|
||||
if (!effectExists)
|
||||
{
|
||||
getEffects(caster, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.NpcTable;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeFlagInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Siege;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillSiegeFlag extends L2Skill
|
||||
{
|
||||
private final int npcId;
|
||||
private L2PcInstance player;
|
||||
private Siege siege;
|
||||
|
||||
public L2SkillSiegeFlag(StatsSet set)
|
||||
|
||||
{
|
||||
super(set);
|
||||
npcId = set.getInteger("npcId", 0); // default for undescribed skills
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkCondition(L2Character activeChar, boolean itemOrWeapon)
|
||||
{
|
||||
player = (L2PcInstance) activeChar;
|
||||
if (player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
siege = SiegeManager.getInstance().getSiege(player);
|
||||
|
||||
if (siege == null)
|
||||
{
|
||||
player.sendMessage("You may only place a Siege Headquarter during a siege.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((player.getClan() == null) || !player.isClanLeader())
|
||||
{
|
||||
player.sendMessage("Only clan leaders may place a Siege Headquarter.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (siege.getAttackerClan(player.getClan()) == null)
|
||||
{
|
||||
player.sendMessage("You may only place a Siege Headquarter provided that you are an attacker.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isInsideZone(L2Character.ZONE_NOHQ))
|
||||
{
|
||||
player.sendMessage("You may not place a Siege Headquarter inside a castle.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (siege.getAttackerClan(player.getClan()).getNumFlags() >= SiegeManager.getInstance().getFlagMaxCount())
|
||||
{
|
||||
player.sendMessage("You have already placed a Siege Headquarter.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.checkCondition(activeChar, itemOrWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Spawn a new flag
|
||||
final L2SiegeFlagInstance flag = new L2SiegeFlagInstance(player, IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(npcId));
|
||||
|
||||
// Build Advanced Headquarters
|
||||
if (getId() == 326)
|
||||
{
|
||||
flag.setMaxSiegeHp(flag.getMaxHp() * 2);
|
||||
}
|
||||
|
||||
flag.setTitle(player.getClan().getName());
|
||||
|
||||
flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
|
||||
flag.setHeading(player.getHeading());
|
||||
flag.spawnMe(player.getX(), player.getY(), player.getZ() + 50);
|
||||
siege.getFlag(player.getClan()).add(flag);
|
||||
}
|
||||
catch (final Exception e)
|
||||
{
|
||||
player.sendMessage("Error placing flag:" + e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.skills.l2skills;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.NpcTable;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jmobius.gameserver.model.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Skill;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2CubicInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2SiegeSummonInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2SummonInstance;
|
||||
import com.l2jmobius.gameserver.model.base.Experience;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.templates.StatsSet;
|
||||
|
||||
public class L2SkillSummon extends L2Skill
|
||||
{
|
||||
private final int npcId;
|
||||
private final float expPenalty;
|
||||
private final boolean isCubic;
|
||||
|
||||
public L2SkillSummon(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
|
||||
npcId = set.getInteger("npcId", 0); // default for undescribed skills
|
||||
expPenalty = set.getFloat("expPenalty", 0.f);
|
||||
isCubic = set.getBool("isCubic", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkCondition(L2Character activeChar, boolean itemOrWeapon)
|
||||
{
|
||||
if (activeChar instanceof L2PcInstance)
|
||||
{
|
||||
final L2PcInstance player = (L2PcInstance) activeChar;
|
||||
|
||||
if (player.inObserverMode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isCubic)
|
||||
{
|
||||
if ((player.getPet() != null) || player.isMounted())
|
||||
{
|
||||
player.sendMessage("You already have a pet.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isAttackingNow() || player.isRooted())
|
||||
{
|
||||
player.sendPacket(new SystemMessage(SystemMessage.YOU_CANNOT_SUMMON_IN_COMBAT));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If summon siege golem (13), Summon Wild Hog Cannon (299), check if its ok to summon
|
||||
if (((getId() == 13) || (getId() == 299)) && !SiegeManager.getInstance().checkIfOkToSummon(player, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return super.checkCondition(activeChar, itemOrWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useSkill(L2Character caster, L2Object[] targets)
|
||||
{
|
||||
if (caster.isAlikeDead() || !(caster instanceof L2PcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance activeChar = (L2PcInstance) caster;
|
||||
|
||||
if (npcId == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCubic)
|
||||
{
|
||||
for (int index = 0; index < targets.length; index++)
|
||||
{
|
||||
|
||||
if (!(targets[index] instanceof L2PcInstance))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final L2PcInstance target = (L2PcInstance) targets[index];
|
||||
|
||||
int mastery = target.getSkillLevel(L2Skill.SKILL_CUBIC_MASTERY);
|
||||
if (mastery < 0)
|
||||
{
|
||||
mastery = 0;
|
||||
}
|
||||
|
||||
if ((mastery == 0) && (target.getCubics().size() > 0) && !target.getCubics().containsKey(npcId))
|
||||
{
|
||||
// Player can have only 1 cubic - we should replace old cubic with new one
|
||||
for (final L2CubicInstance c : target.getCubics().values())
|
||||
{
|
||||
c.stopAction();
|
||||
c.cancelDisappear();
|
||||
}
|
||||
target.getCubics().clear();
|
||||
}
|
||||
|
||||
if ((target.getCubics().size() > mastery) || target.getCubics().containsKey(npcId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (target == activeChar)
|
||||
{
|
||||
target.addCubic(npcId, getLevel(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.addCubic(npcId, getLevel(), true);
|
||||
}
|
||||
target.broadcastUserInfo();
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final L2NpcTemplate summonTemplate = NpcTable.getInstance().getTemplate(npcId);
|
||||
|
||||
L2SummonInstance summon;
|
||||
if (summonTemplate.type.equalsIgnoreCase("L2SiegeSummon"))
|
||||
{
|
||||
summon = new L2SiegeSummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
summon = new L2SummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
|
||||
}
|
||||
|
||||
summon.setName(summonTemplate.name);
|
||||
summon.setTitle(activeChar.getName());
|
||||
summon.setExpPenalty(expPenalty);
|
||||
if (summon.getLevel() >= Experience.LEVEL.length)
|
||||
{
|
||||
summon.getStat().setExp(Experience.LEVEL[Experience.LEVEL.length - 1]);
|
||||
_log.warning("Summon (" + summon.getName() + ") NpcID: " + summon.getNpcId() + " has a level above 78. Please rectify.");
|
||||
}
|
||||
else
|
||||
{
|
||||
summon.getStat().setExp(Experience.LEVEL[(summon.getLevel() % Experience.LEVEL.length)]);
|
||||
}
|
||||
|
||||
summon.setCurrentHp(summon.getMaxHp());
|
||||
summon.setCurrentMp(summon.getMaxMp());
|
||||
summon.setHeading(activeChar.getHeading());
|
||||
summon.setRunning();
|
||||
activeChar.setPet(summon);
|
||||
|
||||
L2World.getInstance().storeObject(summon);
|
||||
summon.spawnMe(activeChar.getX() + 50, activeChar.getY() + 100, activeChar.getZ());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user