actual freya branch
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
import com.l2jserver.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>
|
||||
*/
|
||||
public Func(Stats pStat, int pOrder, Object owner)
|
||||
{
|
||||
stat = pStat;
|
||||
order = pOrder;
|
||||
funcOwner = owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a condition to the Func.<BR>
|
||||
* <BR>
|
||||
*/
|
||||
public void setCondition(Condition pCond)
|
||||
{
|
||||
cond = pCond;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the mathematic function of the Func.<BR>
|
||||
* <BR>
|
||||
*/
|
||||
public abstract void calc(Env env);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
|
||||
public class FuncAdd extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncAdd(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond == null) || cond.test(env))
|
||||
{
|
||||
env.value += _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
|
||||
public class FuncBaseMul extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncBaseMul(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond == null) || cond.test(env))
|
||||
{
|
||||
env.value += env.baseValue * _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
|
||||
public class FuncDiv extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncDiv(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond == null) || cond.test(env))
|
||||
{
|
||||
env.value /= _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
import com.l2jserver.gameserver.templates.item.L2Item;
|
||||
import com.l2jserver.gameserver.templates.item.L2WeaponType;
|
||||
|
||||
public class FuncEnchant extends Func
|
||||
{
|
||||
|
||||
public FuncEnchant(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond != null) && !cond.test(env))
|
||||
{
|
||||
return;
|
||||
}
|
||||
L2ItemInstance item = (L2ItemInstance) funcOwner;
|
||||
|
||||
int enchant = item.getEnchantLevel();
|
||||
|
||||
if (enchant <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int overenchant = 0;
|
||||
|
||||
if (enchant > 3)
|
||||
{
|
||||
overenchant = enchant - 3;
|
||||
enchant = 3;
|
||||
}
|
||||
|
||||
if ((env.player != null) && (env.player instanceof L2PcInstance))
|
||||
{
|
||||
L2PcInstance player = (L2PcInstance) env.player;
|
||||
if (player.isInOlympiadMode() && (Config.ALT_OLY_ENCHANT_LIMIT >= 0) && ((enchant + overenchant) > Config.ALT_OLY_ENCHANT_LIMIT))
|
||||
{
|
||||
if (Config.ALT_OLY_ENCHANT_LIMIT > 3)
|
||||
{
|
||||
overenchant = Config.ALT_OLY_ENCHANT_LIMIT - 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
overenchant = 0;
|
||||
enchant = Config.ALT_OLY_ENCHANT_LIMIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((stat == Stats.MAGIC_DEFENCE) || (stat == Stats.POWER_DEFENCE))
|
||||
{
|
||||
env.value += enchant + (3 * overenchant);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stat == Stats.MAGIC_ATTACK)
|
||||
{
|
||||
switch (item.getItem().getItemGradeSPlus())
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (item.isWeapon())
|
||||
{
|
||||
L2WeaponType type = (L2WeaponType) item.getItemType();
|
||||
|
||||
switch (item.getItem().getItemGradeSPlus())
|
||||
{
|
||||
case L2Item.CRYSTAL_S:
|
||||
switch (type)
|
||||
{
|
||||
case BOW:
|
||||
case CROSSBOW:
|
||||
env.value += (10 * enchant) + (20 * overenchant);
|
||||
break;
|
||||
default:
|
||||
env.value += (5 * enchant) + (10 * overenchant);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_A:
|
||||
switch (type)
|
||||
{
|
||||
case BOW:
|
||||
case CROSSBOW:
|
||||
env.value += (8 * enchant) + (16 * overenchant);
|
||||
break;
|
||||
default:
|
||||
env.value += (4 * enchant) + (8 * overenchant);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_B:
|
||||
switch (type)
|
||||
{
|
||||
case BOW:
|
||||
case CROSSBOW:
|
||||
env.value += (6 * enchant) + (12 * overenchant);
|
||||
break;
|
||||
default:
|
||||
env.value += (3 * enchant) + (6 * overenchant);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_C:
|
||||
switch (type)
|
||||
{
|
||||
case BOW:
|
||||
case CROSSBOW:
|
||||
env.value += (6 * enchant) + (12 * overenchant);
|
||||
break;
|
||||
default:
|
||||
env.value += (3 * enchant) + (6 * overenchant);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case L2Item.CRYSTAL_D:
|
||||
case L2Item.CRYSTAL_NONE:
|
||||
switch (type)
|
||||
{
|
||||
case BOW:
|
||||
case CROSSBOW:
|
||||
{
|
||||
env.value += (4 * enchant) + (8 * overenchant);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
env.value += (2 * enchant) + (4 * overenchant);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.EnchantHPBonusData;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
|
||||
/**
|
||||
* @author Yamaneko
|
||||
*/
|
||||
public class FuncEnchantHp extends Func
|
||||
{
|
||||
public FuncEnchantHp(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond != null) && !cond.test(env))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) funcOwner;
|
||||
if (item.getEnchantLevel() > 0)
|
||||
{
|
||||
env.value += EnchantHPBonusData.getInstance().getHPBonus(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
|
||||
public class FuncMul extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncMul(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond == null) || cond.test(env))
|
||||
{
|
||||
env.value *= _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
|
||||
public class FuncSet extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncSet(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond == null) || cond.test(env))
|
||||
{
|
||||
env.value = _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
|
||||
public class FuncSub extends Func
|
||||
{
|
||||
private final Lambda _lambda;
|
||||
|
||||
public FuncSub(Stats pStat, int pOrder, Object owner, Lambda lambda)
|
||||
{
|
||||
super(pStat, pOrder, owner);
|
||||
_lambda = lambda;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calc(Env env)
|
||||
{
|
||||
if ((cond == null) || cond.test(env))
|
||||
{
|
||||
env.value -= _lambda.calc(env);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
import com.l2jserver.gameserver.skills.conditions.Condition;
|
||||
|
||||
/**
|
||||
* @author mkizub
|
||||
*/
|
||||
public final class FuncTemplate
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(FuncTemplate.class.getName());
|
||||
|
||||
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 pAttachCond, Condition pApplayCond, String pFunc, Stats pStat, int pOrder, Lambda pLambda)
|
||||
{
|
||||
attachCond = pAttachCond;
|
||||
applayCond = pApplayCond;
|
||||
stat = pStat;
|
||||
order = pOrder;
|
||||
lambda = pLambda;
|
||||
try
|
||||
{
|
||||
func = Class.forName("com.l2jserver.gameserver.skills.funcs.Func" + pFunc);
|
||||
}
|
||||
catch (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 (NoSuchMethodException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Func getFunc(Env env, Object owner)
|
||||
{
|
||||
if ((attachCond != null) && !attachCond.test(env))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
Func f = (Func) constructor.newInstance(stat, order, owner, lambda);
|
||||
if (applayCond != null)
|
||||
{
|
||||
f.setCondition(applayCond);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
return null;
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
return null;
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub
|
||||
*/
|
||||
public abstract class Lambda
|
||||
{
|
||||
public abstract double calc(Env env);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub
|
||||
*/
|
||||
public final class LambdaCalc extends Lambda
|
||||
{
|
||||
|
||||
public Func[] funcs;
|
||||
|
||||
public LambdaCalc()
|
||||
{
|
||||
funcs = new Func[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(Env env)
|
||||
{
|
||||
double saveValue = env.value;
|
||||
try
|
||||
{
|
||||
env.value = 0;
|
||||
for (Func f : funcs)
|
||||
{
|
||||
f.calc(env);
|
||||
}
|
||||
return env.value;
|
||||
}
|
||||
finally
|
||||
{
|
||||
env.value = saveValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void addFunc(Func f)
|
||||
{
|
||||
int len = funcs.length;
|
||||
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 program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub
|
||||
*/
|
||||
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 program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author mkizub
|
||||
*/
|
||||
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,80 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.gameserver.skills.funcs;
|
||||
|
||||
import com.l2jserver.gameserver.skills.Env;
|
||||
|
||||
/**
|
||||
* @author mkizub
|
||||
*/
|
||||
public final class LambdaStats extends Lambda
|
||||
{
|
||||
|
||||
public enum StatsType
|
||||
{
|
||||
PLAYER_LEVEL,
|
||||
CUBIC_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 CUBIC_LEVEL:
|
||||
if (env.cubic == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return env.cubic.getOwner().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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user