Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,100 +1,145 @@
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public enum BaseStats
|
||||
{
|
||||
STR // #TODO Check if correct
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return Math.pow(1.009, actor.getSTR() - 49);
|
||||
}
|
||||
},
|
||||
INT // @TODO Update
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return Math.pow(1.01, actor.getINT() - 49.4);
|
||||
}
|
||||
},
|
||||
DEX // Updated and better Formula to match Ertheia
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return Math.pow(1.004558949443461, actor.getDEX() - 19.27356040917275);
|
||||
}
|
||||
},
|
||||
WIT // Updated and better Formula to match Ertheia
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return Math.pow(1.013832042738272, actor.getWIT() - 64.57078483041223);
|
||||
}
|
||||
},
|
||||
CON // Updated and better Formula to match Ertheia
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return Math.pow(1.011685289099497, actor.getCON() - 34.80273839854561);
|
||||
}
|
||||
},
|
||||
MEN // Updated and better Formula to match Ertheia
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return Math.pow(1.003687502032154, actor.getMEN() + 30.4505503162);
|
||||
}
|
||||
},
|
||||
CHA // Addition for Ertheia
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return Math.pow(1.001, actor.getCHA() - 43);
|
||||
}
|
||||
},
|
||||
LUC // @TODO: Implement
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
NONE
|
||||
{
|
||||
@Override
|
||||
public double calcBonus(L2Character actor)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
public abstract double calcBonus(L2Character actor);
|
||||
}
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
|
||||
import com.l2jmobius.commons.util.IGameXmlReader;
|
||||
import com.l2jmobius.commons.util.IXmlReader;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
|
||||
/**
|
||||
* @author DS, Sdw, UnAfraid
|
||||
*/
|
||||
public enum BaseStats
|
||||
{
|
||||
STR(Stats.STAT_STR),
|
||||
INT(Stats.STAT_INT),
|
||||
DEX(Stats.STAT_DEX),
|
||||
WIT(Stats.STAT_WIT),
|
||||
CON(Stats.STAT_CON),
|
||||
MEN(Stats.STAT_MEN),
|
||||
CHA(Stats.STAT_CHA),
|
||||
LUC(Stats.STAT_LUC);
|
||||
|
||||
public static final int MAX_STAT_VALUE = 201;
|
||||
|
||||
private final double[] _bonus = new double[MAX_STAT_VALUE];
|
||||
private final Stats _stat;
|
||||
|
||||
BaseStats(Stats stat)
|
||||
{
|
||||
_stat = stat;
|
||||
}
|
||||
|
||||
public Stats getStat()
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
|
||||
public int calcValue(L2Character creature)
|
||||
{
|
||||
if ((creature != null) && (_stat != null))
|
||||
{
|
||||
return (int) Math.min(_stat.finalize(creature, Optional.empty()), MAX_STAT_VALUE - 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double calcBonus(L2Character creature)
|
||||
{
|
||||
if (creature != null)
|
||||
{
|
||||
final int value = calcValue(creature);
|
||||
if (value < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return _bonus[value];
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void setValue(int index, double value)
|
||||
{
|
||||
_bonus[index] = value;
|
||||
}
|
||||
|
||||
public double getValue(int index)
|
||||
{
|
||||
return _bonus[index];
|
||||
}
|
||||
|
||||
public static BaseStats valueOf(Stats stat)
|
||||
{
|
||||
for (BaseStats baseStat : values())
|
||||
{
|
||||
if (baseStat.getStat() == stat)
|
||||
{
|
||||
return baseStat;
|
||||
}
|
||||
}
|
||||
throw new NoSuchElementException("Unknown base stat '" + stat + "' for enum BaseStats");
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
new IGameXmlReader()
|
||||
{
|
||||
final Logger LOGGER = Logger.getLogger(BaseStats.class.getName());
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
parseDatapackFile("data/stats/statBonus.xml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, IXmlReader::isNode, statNode ->
|
||||
{
|
||||
final BaseStats baseStat;
|
||||
try
|
||||
{
|
||||
baseStat = valueOf(statNode.getNodeName());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.severe("Invalid base stats type: " + statNode.getNodeValue() + ", skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
forEach(statNode, "stat", statValue ->
|
||||
{
|
||||
final NamedNodeMap attrs = statValue.getAttributes();
|
||||
final int val = parseInteger(attrs, "value");
|
||||
final double bonus = parseDouble(attrs, "bonus");
|
||||
baseStat.setValue(val, bonus);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}.load();
|
||||
}
|
||||
}
|
||||
@@ -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.model.stats;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A class representing the basic property resist of mesmerizing debuffs.
|
||||
* @author Nik
|
||||
*/
|
||||
public class BasicPropertyResist
|
||||
{
|
||||
private static final Duration RESIST_DURATION = Duration.ofSeconds(15); // The resistance stays no longer than 15 seconds after last mesmerizing debuff.
|
||||
|
||||
private volatile Instant _resistanceEndTime = Instant.MIN;
|
||||
private volatile int _resistanceLevel;
|
||||
|
||||
/**
|
||||
* Checks if the resist has expired.
|
||||
* @return {@code true} if it has expired, {@code false} otherwise
|
||||
*/
|
||||
public boolean isExpired()
|
||||
{
|
||||
return Instant.now().isAfter(_resistanceEndTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remain time.
|
||||
* @return the remain time
|
||||
*/
|
||||
public Duration getRemainTime()
|
||||
{
|
||||
return Duration.between(Instant.now(), _resistanceEndTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resist level.
|
||||
* @return the resist level
|
||||
*/
|
||||
public int getResistLevel()
|
||||
{
|
||||
return !isExpired() ? _resistanceLevel : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the resist level while checking if the resist has expired so it starts counting it from 1.
|
||||
*/
|
||||
public synchronized void increaseResistLevel()
|
||||
{
|
||||
// Check if the level needs to be reset due to timer warn off.
|
||||
if (isExpired())
|
||||
{
|
||||
_resistanceLevel = 1;
|
||||
_resistanceEndTime = Instant.now().plus(RESIST_DURATION);
|
||||
}
|
||||
else
|
||||
{
|
||||
_resistanceLevel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* A calculator is created to manage and dynamically calculate the effect of a character property (ex : MAX_HP, REGENERATE_HP_RATE...).<br>
|
||||
* In fact, each calculator is a table of Func object in which each Func represents a mathematical function:<br>
|
||||
* FuncAtkAccuracy -> Math.sqrt(_player.getDEX())*6+_player.getLevel()<br>
|
||||
* When the calc method of a calculator is launched, each mathematical function is called according to its priority <B>_order</B>.<br>
|
||||
* Indeed, Func with lowest priority order is executed first and Funcs with the same order are executed in unspecified order.<br>
|
||||
* The result of the calculation is stored in the value property of an Env class instance.<br>
|
||||
* Method addFunc and removeFunc permit to add and remove a Func object from a Calculator.
|
||||
*/
|
||||
public final class Calculator
|
||||
{
|
||||
/** Empty Func table definition */
|
||||
private static final AbstractFunction[] EMPTY_FUNCS = new AbstractFunction[0];
|
||||
|
||||
/** Table of Func object */
|
||||
private AbstractFunction[] _functions;
|
||||
|
||||
/**
|
||||
* Constructor of Calculator (Init value : emptyFuncs).
|
||||
*/
|
||||
public Calculator()
|
||||
{
|
||||
_functions = EMPTY_FUNCS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor of Calculator (Init value : Calculator c).
|
||||
* @param c
|
||||
*/
|
||||
public Calculator(Calculator c)
|
||||
{
|
||||
_functions = c._functions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if 2 calculators are equals.
|
||||
* @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 AbstractFunction[] funcs1 = c1._functions;
|
||||
final AbstractFunction[] 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.
|
||||
* @return
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return _functions.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a function to the Calculator.
|
||||
* @param function the function
|
||||
*/
|
||||
public synchronized void addFunc(AbstractFunction function)
|
||||
{
|
||||
final AbstractFunction[] funcs = _functions;
|
||||
final AbstractFunction[] tmp = new AbstractFunction[funcs.length + 1];
|
||||
|
||||
final int order = function.getOrder();
|
||||
int i;
|
||||
|
||||
for (i = 0; (i < funcs.length) && (order >= funcs[i].getOrder()); i++)
|
||||
{
|
||||
tmp[i] = funcs[i];
|
||||
}
|
||||
|
||||
tmp[i] = function;
|
||||
|
||||
for (; i < funcs.length; i++)
|
||||
{
|
||||
tmp[i + 1] = funcs[i];
|
||||
}
|
||||
|
||||
_functions = tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a function from the Calculator.
|
||||
* @param function the function
|
||||
*/
|
||||
public synchronized void removeFunc(AbstractFunction function)
|
||||
{
|
||||
final AbstractFunction[] funcs = _functions;
|
||||
final AbstractFunction[] tmp = new AbstractFunction[funcs.length - 1];
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; (i < (funcs.length - 1)) && (function != 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 = EMPTY_FUNCS;
|
||||
}
|
||||
else
|
||||
{
|
||||
_functions = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove each Func with the specified owner of the Calculator.
|
||||
* @param owner the owner
|
||||
* @return a list of modified stats
|
||||
*/
|
||||
public synchronized List<Stats> removeOwner(Object owner)
|
||||
{
|
||||
final List<Stats> modifiedStats = new ArrayList<>();
|
||||
for (AbstractFunction func : _functions)
|
||||
{
|
||||
if (func.getFuncOwner() == owner)
|
||||
{
|
||||
modifiedStats.add(func.getStat());
|
||||
removeFunc(func);
|
||||
}
|
||||
}
|
||||
return modifiedStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run each function of the Calculator.
|
||||
* @param caster the caster
|
||||
* @param target the target
|
||||
* @param skill the skill
|
||||
* @param initVal the initial value
|
||||
* @return the calculated value
|
||||
*/
|
||||
public double calc(L2Character caster, L2Character target, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
for (AbstractFunction func : _functions)
|
||||
{
|
||||
value = func.calc(caster, target, skill, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of all function, dont use for add/remove
|
||||
* @return
|
||||
*/
|
||||
public AbstractFunction[] getFunctions()
|
||||
{
|
||||
return _functions;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,573 @@
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.CrystalType;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IStatsFunction
|
||||
{
|
||||
default void throwIfPresent(Optional<Double> base)
|
||||
{
|
||||
if (base.isPresent())
|
||||
{
|
||||
throw new IllegalArgumentException("base should not be set for " + getClass().getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
default double calcEnchantBodyPart(L2Character creature, int... slots)
|
||||
{
|
||||
double value = 0;
|
||||
for (int slot : slots)
|
||||
{
|
||||
final L2ItemInstance item = creature.getInventory().getPaperdollItemByL2ItemId(slot);
|
||||
if ((item != null) && (item.getEnchantLevel() >= 4) && (item.getItem().getCrystalTypePlus() == CrystalType.R))
|
||||
{
|
||||
value += calcEnchantBodyPartBonus(item.getEnchantLevel(), item.getItem().isBlessed());
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
default double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
default double calcWeaponBaseValue(L2Character creature, Stats stat)
|
||||
{
|
||||
final double baseTemplateBalue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
final double baseValue = creature.getTransformation().map(transform -> transform.getStats(creature, stat, baseTemplateBalue)).orElseGet(() ->
|
||||
{
|
||||
if (creature.isPet())
|
||||
{
|
||||
final L2PetInstance pet = (L2PetInstance) creature;
|
||||
final L2ItemInstance weapon = pet.getActiveWeaponInstance();
|
||||
final double baseVal = stat == Stats.PHYSICAL_ATTACK ? pet.getPetLevelData().getPetPAtk() : stat == Stats.MAGIC_ATTACK ? pet.getPetLevelData().getPetMAtk() : baseTemplateBalue;
|
||||
return baseVal + (weapon != null ? weapon.getItem().getStats(stat, baseVal) : 0);
|
||||
}
|
||||
else if (creature.isPlayer())
|
||||
{
|
||||
final L2ItemInstance weapon = creature.getActiveWeaponInstance();
|
||||
return (weapon != null ? weapon.getItem().getStats(stat, baseTemplateBalue) : baseTemplateBalue);
|
||||
}
|
||||
|
||||
return baseTemplateBalue;
|
||||
});
|
||||
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
default double calcWeaponPlusBaseValue(L2Character creature, Stats stat)
|
||||
{
|
||||
final double baseTemplateBalue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
double baseValue = creature.getTransformation().map(transform -> transform.getStats(creature, stat, baseTemplateBalue)).orElse(baseTemplateBalue);
|
||||
|
||||
if (creature.isPlayable())
|
||||
{
|
||||
final Inventory inv = creature.getInventory();
|
||||
if (inv != null)
|
||||
{
|
||||
for (L2ItemInstance item : inv.getPaperdollItems(L2ItemInstance::isEquipped))
|
||||
{
|
||||
baseValue += item.getItem().getStats(stat, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
default double calcEnchantedItemBonus(L2Character creature, Stats stat)
|
||||
{
|
||||
if (!creature.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double value = 0;
|
||||
for (L2ItemInstance item : creature.getInventory().getPaperdollItems(L2ItemInstance::isEquipped, L2ItemInstance::isEnchanted))
|
||||
{
|
||||
if (item.getItem().getStats(stat, 0) <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final double blessedBonus = item.getItem().isBlessed() ? 1.5 : 1;
|
||||
int overEnchant = 0;
|
||||
int enchant = item.getEnchantLevel();
|
||||
if (enchant > 3)
|
||||
{
|
||||
overEnchant = enchant - 3;
|
||||
enchant = 3;
|
||||
}
|
||||
|
||||
if (creature.getActingPlayer().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.MAGICAL_DEFENCE) || (stat == Stats.PHYSICAL_DEFENCE))
|
||||
{
|
||||
value += calcEnchantDefBonus(item, blessedBonus, enchant, overEnchant);
|
||||
}
|
||||
else if (stat == Stats.MAGIC_ATTACK)
|
||||
{
|
||||
value += calcEnchantMatkBonus(item, blessedBonus, enchant, overEnchant);
|
||||
}
|
||||
else if ((stat == Stats.PHYSICAL_ATTACK) && item.isWeapon())
|
||||
{
|
||||
value += calcEnchantedPAtkBonus(item, blessedBonus, enchant, overEnchant);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param blessedBonus
|
||||
* @param enchant
|
||||
* @param overEnchant
|
||||
* @return
|
||||
*/
|
||||
static double calcEnchantDefBonus(L2ItemInstance item, double blessedBonus, int enchant, int overEnchant)
|
||||
{
|
||||
double value = 0;
|
||||
switch (item.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case R:
|
||||
{
|
||||
// Enchant 0-3 adding +2
|
||||
// Enchant 3-6 adding +4
|
||||
// Enchant 6-127 adding +6
|
||||
switch (overEnchant)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
value += ((2 * blessedBonus * enchant) + (4 * blessedBonus * overEnchant));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
value += (6 * blessedBonus * overEnchant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
case A:
|
||||
case B:
|
||||
case C:
|
||||
case D:
|
||||
case NONE:
|
||||
{
|
||||
value += enchant + (3 * overEnchant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param blessedBonus
|
||||
* @param enchant
|
||||
* @param overEnchant
|
||||
* @return
|
||||
*/
|
||||
static double calcEnchantMatkBonus(L2ItemInstance item, double blessedBonus, int enchant, int overEnchant)
|
||||
{
|
||||
double value = 0;
|
||||
switch (item.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case R:
|
||||
{
|
||||
//@formatter:off
|
||||
/* M. Atk. increases by 5 for all weapons.
|
||||
* Starting at +4, M. Atk. bonus double.
|
||||
* 0-3 adding +5
|
||||
* 3-6 adding +10
|
||||
* 7-9 adding +15
|
||||
* 10-12 adding +20
|
||||
* 13-127 adding +25
|
||||
*/
|
||||
//@formatter:on
|
||||
switch (overEnchant)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
value += ((5 * blessedBonus * enchant) + (10 * blessedBonus * overEnchant));
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
{
|
||||
value += (15 * blessedBonus * overEnchant);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
{
|
||||
value += (20 * blessedBonus * (overEnchant - 1.5));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
value += (25 * blessedBonus * (overEnchant - 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
// M. Atk. increases by 4 for all weapons.
|
||||
// Starting at +4, M. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overEnchant);
|
||||
break;
|
||||
}
|
||||
case A:
|
||||
case B:
|
||||
case C:
|
||||
{
|
||||
// M. Atk. increases by 3 for all weapons.
|
||||
// Starting at +4, M. Atk. bonus double.
|
||||
value += (3 * enchant) + (6 * overEnchant);
|
||||
break;
|
||||
}
|
||||
case D:
|
||||
case NONE:
|
||||
{
|
||||
// M. Atk. increases by 2 for all weapons. Starting at +4, M. Atk. bonus double.
|
||||
// Starting at +4, M. Atk. bonus double.
|
||||
value += (2 * enchant) + (4 * overEnchant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* @param blessedBonus
|
||||
* @param enchant
|
||||
* @param overEnchant
|
||||
* @return
|
||||
*/
|
||||
static double calcEnchantedPAtkBonus(L2ItemInstance item, double blessedBonus, int enchant, int overEnchant)
|
||||
{
|
||||
double value = 0;
|
||||
switch (item.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case R:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if (item.getWeaponItem().getItemType().isRanged())
|
||||
{
|
||||
//@formatter:off
|
||||
/* P. Atk. increases by 12 for bows.
|
||||
* Starting at +4, P. Atk. bonus double.
|
||||
* 0-3 adding +12
|
||||
* 4-6 adding +24
|
||||
* 7-9 adding +36
|
||||
* 10-12 adding +48
|
||||
* 13-127 adding +60
|
||||
*/
|
||||
//@formatter:on
|
||||
switch (overEnchant)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
value += ((12 * blessedBonus * enchant) + (24 * blessedBonus * overEnchant));
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
{
|
||||
value += (36 * blessedBonus * overEnchant);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
{
|
||||
value += (48 * blessedBonus * (overEnchant - 1.5));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
value += (60 * blessedBonus * (overEnchant - 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//@formatter:off
|
||||
/* P. Atk. increases by 7 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
* Starting at +4, P. Atk. bonus double.
|
||||
* 0-3 adding +7
|
||||
* 4-6 adding +14
|
||||
* 7-9 adding +21
|
||||
* 10-12 adding +28
|
||||
* 13-127 adding +35
|
||||
*/
|
||||
//@formatter:on
|
||||
switch (overEnchant)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
value += ((7 * blessedBonus * enchant) + (14 * blessedBonus * overEnchant));
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
{
|
||||
value += (21 * blessedBonus * overEnchant);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
{
|
||||
value += (28 * blessedBonus * (overEnchant - 1.5));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
value += (35 * blessedBonus * (overEnchant - 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//@formatter:off
|
||||
/* P. Atk. increases by 6 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
* Starting at +4, P. Atk. bonus double.
|
||||
* 0-3 adding +6
|
||||
* 4-6 adding +12
|
||||
* 7-9 adding +18
|
||||
* 10-12 adding +24
|
||||
* 13-127 adding +30
|
||||
*/
|
||||
//@formatter:on
|
||||
switch (overEnchant)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
value += ((6 * blessedBonus * enchant) + (12 * blessedBonus * overEnchant));
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
{
|
||||
value += (18 * blessedBonus * overEnchant);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
{
|
||||
value += (24 * blessedBonus * (overEnchant - 1.5));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
value += (30 * blessedBonus * (overEnchant - 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if (item.getWeaponItem().getItemType().isRanged())
|
||||
{
|
||||
// P. Atk. increases by 10 for bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (10 * enchant) + (20 * overEnchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 6 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (6 * enchant) + (12 * overEnchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 5 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (5 * enchant) + (10 * overEnchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case A:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if (item.getWeaponItem().getItemType().isRanged())
|
||||
{
|
||||
// P. Atk. increases by 8 for bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (8 * enchant) + (16 * overEnchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 5 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (5 * enchant) + (10 * overEnchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 4 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overEnchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B:
|
||||
case C:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if (item.getWeaponItem().getItemType().isRanged())
|
||||
{
|
||||
// P. Atk. increases by 6 for bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (6 * enchant) + (12 * overEnchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 4 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overEnchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 3 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (3 * enchant) + (6 * overEnchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case D:
|
||||
case NONE:
|
||||
{
|
||||
if (item.getWeaponItem().getItemType().isRanged())
|
||||
{
|
||||
// Bows increase by 4.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overEnchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 2 for all weapons with the exception of bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (2 * enchant) + (4 * overEnchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
default double validateValue(L2Character creature, double value, double minValue, double maxValue)
|
||||
{
|
||||
if ((value > maxValue) && !creature.canOverrideCond(PcCondOverride.MAX_STATS_VALUE))
|
||||
{
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
return Math.max(minValue, value);
|
||||
}
|
||||
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat);
|
||||
}
|
||||
@@ -1,31 +1,28 @@
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
/**
|
||||
* Enum of move types.
|
||||
* @author GKR
|
||||
*/
|
||||
public enum MoveType
|
||||
{
|
||||
WALK,
|
||||
RUN,
|
||||
FAST_SWIM,
|
||||
SLOW_SWIM,
|
||||
FAST_FLY,
|
||||
SLOW_FLY
|
||||
}
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public enum MoveType
|
||||
{
|
||||
WALKING,
|
||||
RUNNING,
|
||||
SITTING,
|
||||
STANDING,
|
||||
}
|
||||
|
||||
@@ -1,246 +1,371 @@
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
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 & CP
|
||||
MAX_HP("maxHp"),
|
||||
MAX_MP("maxMp"),
|
||||
MAX_CP("maxCp"),
|
||||
MAX_RECOVERABLE_HP("maxRecoverableHp"), // The maximum HP that is able to be recovered trough heals
|
||||
MAX_RECOVERABLE_MP("maxRecoverableMp"),
|
||||
MAX_RECOVERABLE_CP("maxRecoverableCp"),
|
||||
REGENERATE_HP_RATE("regHp"),
|
||||
REGENERATE_CP_RATE("regCp"),
|
||||
REGENERATE_MP_RATE("regMp"),
|
||||
MANA_CHARGE("manaCharge"),
|
||||
HEAL_EFFECT("healEffect"),
|
||||
|
||||
// ATTACK & DEFENCE
|
||||
POWER_DEFENCE("pDef"),
|
||||
MAGIC_DEFENCE("mDef"),
|
||||
POWER_ATTACK("pAtk"),
|
||||
MAGIC_ATTACK("mAtk"),
|
||||
PHYSICAL_SKILL_POWER("physicalSkillPower"),
|
||||
PHYSICAL_SKILL_POWER_ADD("physicalSkillPowerAdd"),
|
||||
POWER_ATTACK_SPEED("pAtkSpd"),
|
||||
MAGIC_ATTACK_SPEED("mAtkSpd"), // Magic Skill Casting Time Rate
|
||||
ATK_REUSE("atkReuse"), // Bows Hits Reuse Rate
|
||||
P_REUSE("pReuse"), // Physical Skill Reuse Rate
|
||||
MAGIC_REUSE_RATE("mReuse"), // Magic Skill Reuse Rate
|
||||
DANCE_REUSE("dReuse"), // Dance Skill Reuse Rate
|
||||
SHIELD_DEFENCE("sDef"),
|
||||
CRITICAL_DAMAGE("critDmg"),
|
||||
CRITICAL_DAMAGE_POS("critDmgPos"),
|
||||
CRITICAL_DAMAGE_ADD("critDmgAdd"), // this is another type for special critical damage mods - vicious stance, critical power and critical damage SA
|
||||
MAGIC_CRIT_DMG("mCritPower"),
|
||||
MAGIC_CRIT_DMG_ADD("mCritPowerAdd"),
|
||||
MOMENTUM_SKILL_POWER("momentumSkillPower"),
|
||||
|
||||
// PVP BONUS
|
||||
PVP_PHYSICAL_DMG("pvpPhysDmg"),
|
||||
PVP_MAGICAL_DMG("pvpMagicalDmg"),
|
||||
PVP_PHYS_SKILL_DMG("pvpPhysSkillsDmg"),
|
||||
PVP_PHYSICAL_DEF("pvpPhysDef"),
|
||||
PVP_MAGICAL_DEF("pvpMagicalDef"),
|
||||
PVP_PHYS_SKILL_DEF("pvpPhysSkillsDef"),
|
||||
|
||||
// PVE BONUS
|
||||
PVE_PHYSICAL_DMG("pvePhysDmg"),
|
||||
PVE_PHYS_SKILL_DMG("pvePhysSkillsDmg"),
|
||||
PVE_BOW_DMG("pveBowDmg"),
|
||||
PVE_BOW_SKILL_DMG("pveBowSkillsDmg"),
|
||||
PVE_MAGICAL_DMG("pveMagicalDmg"),
|
||||
|
||||
// ATTACK & DEFENCE RATES
|
||||
EVASION_RATE("rEvas"),
|
||||
MAGIC_EVASION_RATE("mEvas"),
|
||||
P_SKILL_EVASION("pSkillEvas"),
|
||||
DEFENCE_CRITICAL_RATE("defCritRate"),
|
||||
DEFENCE_CRITICAL_RATE_ADD("defCritRateAdd"),
|
||||
DEFENCE_CRITICAL_DAMAGE("defCritDamage"),
|
||||
DEFENCE_CRITICAL_DAMAGE_ADD("defCritDamageAdd"), // Resistance to critical damage in value (Example: +100 will be 100 more critical damage, NOT 100% more).
|
||||
SHIELD_RATE("rShld"),
|
||||
CRITICAL_RATE("critRate"),
|
||||
CRITICAL_RATE_POS("critRatePos"),
|
||||
MAX_PHYS_CRIT_RATE("maxPhysCritRate"),
|
||||
BLOW_RATE("blowRate"),
|
||||
MCRITICAL_RATE("mCritRate"),
|
||||
EXPSP_RATE("rExp"),
|
||||
BONUS_EXP("bonusExp"),
|
||||
BONUS_SP("bonusSp"),
|
||||
ATTACK_CANCEL("cancel"),
|
||||
|
||||
// ACCURACY & RANGE
|
||||
ACCURACY_COMBAT("accCombat"),
|
||||
ACCURACY_MAGIC("accMagic"),
|
||||
POWER_ATTACK_RANGE("pAtkRange"),
|
||||
MAGIC_ATTACK_RANGE("mAtkRange"),
|
||||
ATTACK_COUNT_MAX("atkCountMax"),
|
||||
// Run speed, walk & escape speed are calculated proportionally, magic speed is a buff
|
||||
MOVE_SPEED("runSpd"),
|
||||
|
||||
// BASIC STATS
|
||||
STAT_STR("STR"),
|
||||
STAT_CON("CON"),
|
||||
STAT_DEX("DEX"),
|
||||
STAT_INT("INT"),
|
||||
STAT_WIT("WIT"),
|
||||
STAT_MEN("MEN"),
|
||||
STAT_LUC("LUC"),
|
||||
STAT_CHA("CHA"),
|
||||
|
||||
// Special stats, share one slot in Calculator
|
||||
|
||||
// VARIOUS
|
||||
BREATH("breath"),
|
||||
FALL("fall"),
|
||||
|
||||
// VULNERABILITIES
|
||||
DAMAGE_ZONE_VULN("damageZoneVuln"),
|
||||
MOVEMENT_VULN("movementVuln"),
|
||||
CANCEL_VULN("cancelVuln"), // Resistance for cancel type skills
|
||||
DEBUFF_VULN("debuffVuln"),
|
||||
BUFF_VULN("buffVuln"),
|
||||
|
||||
// RESISTANCES
|
||||
FIRE_RES("fireRes"),
|
||||
WIND_RES("windRes"),
|
||||
WATER_RES("waterRes"),
|
||||
EARTH_RES("earthRes"),
|
||||
HOLY_RES("holyRes"),
|
||||
DARK_RES("darkRes"),
|
||||
MAGIC_SUCCESS_RES("magicSuccRes"),
|
||||
|
||||
// ELEMENT POWER
|
||||
FIRE_POWER("firePower"),
|
||||
WATER_POWER("waterPower"),
|
||||
WIND_POWER("windPower"),
|
||||
EARTH_POWER("earthPower"),
|
||||
HOLY_POWER("holyPower"),
|
||||
DARK_POWER("darkPower"),
|
||||
WEAPON_ELEMENT_POWER("weaponElementPower"),
|
||||
|
||||
// PROFICIENCY
|
||||
CANCEL_PROF("cancelProf"),
|
||||
|
||||
REFLECT_DAMAGE_PERCENT("reflectDam"),
|
||||
REFLECT_SKILL_MAGIC("reflectSkillMagic"),
|
||||
REFLECT_SKILL_PHYSIC("reflectSkillPhysic"),
|
||||
REFLECT_DAMAGE_RESISTANCE("reflectDamageRes"),
|
||||
VENGEANCE_SKILL_MAGIC_DAMAGE("vengeanceMdam"),
|
||||
VENGEANCE_SKILL_PHYSICAL_DAMAGE("vengeancePdam"),
|
||||
ABSORB_DAMAGE_PERCENT("absorbDam"),
|
||||
TRANSFER_DAMAGE_PERCENT("transDam"),
|
||||
MANA_SHIELD_PERCENT("manaShield"),
|
||||
TRANSFER_DAMAGE_TO_PLAYER("transDamToPlayer"),
|
||||
ABSORB_MANA_DAMAGE_PERCENT("absorbDamMana"),
|
||||
RECEIVED_DAMAGE_MODIFIER("receivedDamageModifier"),
|
||||
|
||||
WEIGHT_LIMIT("weightLimit"),
|
||||
WEIGHT_PENALTY("weightPenalty"),
|
||||
|
||||
// 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"),
|
||||
DANCE_MP_CONSUME_RATE("danceMpConsumeRate"),
|
||||
BOW_MP_CONSUME_RATE("bowMpConsumeRate"),
|
||||
MP_CONSUME("mpConsume"),
|
||||
|
||||
// Shield Stats
|
||||
SHIELD_DEFENCE_ANGLE("shieldDefAngle"),
|
||||
|
||||
// Skill mastery
|
||||
SKILL_CRITICAL("skillCritical"),
|
||||
SKILL_CRITICAL_PROBABILITY("skillCriticalProbability"),
|
||||
CRAFT_MASTERY("craftMastery"),
|
||||
|
||||
// Vitality
|
||||
VITALITY_CONSUME_RATE("vitalityConsumeRate"),
|
||||
|
||||
// Souls
|
||||
MAX_SOULS("maxSouls"),
|
||||
|
||||
REDUCE_EXP_LOST_BY_PVP("reduceExpLostByPvp"),
|
||||
REDUCE_EXP_LOST_BY_MOB("reduceExpLostByMob"),
|
||||
REDUCE_EXP_LOST_BY_RAID("reduceExpLostByRaid"),
|
||||
|
||||
REDUCE_DEATH_PENALTY_BY_PVP("reduceDeathPenaltyByPvp"),
|
||||
REDUCE_DEATH_PENALTY_BY_MOB("reduceDeathPenaltyByMob"),
|
||||
REDUCE_DEATH_PENALTY_BY_RAID("reduceDeathPenaltyByRaid"),
|
||||
|
||||
// Fishing
|
||||
FISHING_EXPERTISE("fishingExpertise"),
|
||||
|
||||
// Brooches
|
||||
BROOCH_JEWELS("broochJewels"),
|
||||
|
||||
// Summon Points
|
||||
MAX_SUMMON_POINTS("summonPoints"),
|
||||
|
||||
// Max Skill Damage Receive
|
||||
MAX_SKILL_DAMAGE("maxSkillDamage"),
|
||||
|
||||
// Hp restore on kill enemy
|
||||
HP_RESTORE_ON_KILL("hpRestoreOnKill");
|
||||
|
||||
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 (Stats s : values())
|
||||
{
|
||||
if (s.getValue().equals(name))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchElementException("Unknown name '" + name + "' for enum " + Stats.class.getSimpleName());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.util.MathUtil;
|
||||
import com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.AttributeFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.BaseStatsFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MAccuracyFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MAttackFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MAttackSpeedFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MCritRateFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MDefenseFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MEvasionRateFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MaxCpFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MaxHpFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.MaxMpFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.PAccuracyFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.PAttackFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.PAttackSpeedFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.PCriticalRateFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.PDefenseFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.PEvasionRateFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.PRangeFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.RandomDamageFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.RegenCPFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.RegenHPFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.RegenMPFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.ShotsBonusFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.SpeedFinalizer;
|
||||
import com.l2jmobius.gameserver.model.stats.finalizers.VampiricChanceFinalizer;
|
||||
|
||||
/**
|
||||
* Enum of basic stats.
|
||||
* @author mkizub, UnAfraid, NosBit, Sdw
|
||||
*/
|
||||
public enum Stats
|
||||
{
|
||||
// HP, MP & CP
|
||||
MAX_HP("maxHp", new MaxHpFinalizer()),
|
||||
MAX_MP("maxMp", new MaxMpFinalizer()),
|
||||
MAX_CP("maxCp", new MaxCpFinalizer()),
|
||||
MAX_RECOVERABLE_HP("maxRecoverableHp"), // The maximum HP that is able to be recovered trough heals
|
||||
MAX_RECOVERABLE_MP("maxRecoverableMp"),
|
||||
MAX_RECOVERABLE_CP("maxRecoverableCp"),
|
||||
REGENERATE_HP_RATE("regHp", new RegenHPFinalizer()),
|
||||
REGENERATE_CP_RATE("regCp", new RegenCPFinalizer()),
|
||||
REGENERATE_MP_RATE("regMp", new RegenMPFinalizer()),
|
||||
MANA_CHARGE("manaCharge"),
|
||||
HEAL_EFFECT("healEffect"),
|
||||
|
||||
// ATTACK & DEFENCE
|
||||
PHYSICAL_DEFENCE("pDef", new PDefenseFinalizer()),
|
||||
MAGICAL_DEFENCE("mDef", new MDefenseFinalizer()),
|
||||
PHYSICAL_ATTACK("pAtk", new PAttackFinalizer()),
|
||||
MAGIC_ATTACK("mAtk", new MAttackFinalizer()),
|
||||
PHYSICAL_ATTACK_SPEED("pAtkSpd", new PAttackSpeedFinalizer()),
|
||||
MAGIC_ATTACK_SPEED("mAtkSpd", new MAttackSpeedFinalizer()), // Magic Skill Casting Time Rate
|
||||
ATK_REUSE("atkReuse"), // Bows Hits Reuse Rate
|
||||
SHIELD_DEFENCE("sDef"),
|
||||
CRITICAL_DAMAGE("cAtk"),
|
||||
CRITICAL_DAMAGE_ADD("cAtkAdd"), // this is another type for special critical damage mods - vicious stance, critical power and critical damage SA
|
||||
HATE_ATTACK("attackHate"),
|
||||
|
||||
// PVP BONUS
|
||||
PVP_PHYSICAL_ATTACK_DAMAGE("pvpPhysDmg"),
|
||||
PVP_MAGICAL_SKILL_DAMAGE("pvpMagicalDmg"),
|
||||
PVP_PHYSICAL_SKILL_DAMAGE("pvpPhysSkillsDmg"),
|
||||
PVP_PHYSICAL_ATTACK_DEFENCE("pvpPhysDef"),
|
||||
PVP_MAGICAL_SKILL_DEFENCE("pvpMagicalDef"),
|
||||
PVP_PHYSICAL_SKILL_DEFENCE("pvpPhysSkillsDef"),
|
||||
|
||||
// PVE BONUS
|
||||
PVE_PHYSICAL_ATTACK_DAMAGE("pvePhysDmg"),
|
||||
PVE_PHYSICAL_SKILL_DAMAGE("pvePhysSkillsDmg"),
|
||||
PVE_MAGICAL_SKILL_DAMAGE("pveMagicalDmg"),
|
||||
PVE_PHYSICAL_ATTACK_DEFENCE("pvePhysDef"),
|
||||
PVE_PHYSICAL_SKILL_DEFENCE("pvePhysSkillsDef"),
|
||||
PVE_MAGICAL_SKILL_DEFENCE("pveMagicalDef"),
|
||||
PVE_RAID_PHYSICAL_ATTACK_DEFENCE("pveRaidPhysDef"),
|
||||
PVE_RAID_PHYSICAL_SKILL_DEFENCE("pveRaidPhysSkillsDef"),
|
||||
PVE_RAID_MAGICAL_SKILL_DEFENCE("pveRaidMagicalDef"),
|
||||
|
||||
// ATTACK & DEFENCE RATES
|
||||
MAGIC_CRITICAL_DAMAGE("mCritPower"),
|
||||
PHYSICAL_SKILL_POWER("physicalSkillPower"), // Adding skill power (not multipliers) results in points added directly to final value unmodified by defence, traits, elements, criticals etc.
|
||||
// Even when damage is 0 due to general trait immune multiplier, added skill power is active and clearly visible (damage not being 0 but at the value of added skill power).
|
||||
CRITICAL_DAMAGE_SKILL("cAtkSkill"),
|
||||
CRITICAL_DAMAGE_SKILL_ADD("cAtkSkillAdd"),
|
||||
MAGIC_CRITICAL_DAMAGE_ADD("mCritPowerAdd"),
|
||||
SHIELD_DEFENCE_RATE("rShld"),
|
||||
CRITICAL_RATE("rCrit", new PCriticalRateFinalizer(), MathUtil::add, MathUtil::add, null, 1d),
|
||||
CRITICAL_RATE_SKILL("rCritSkill", Stats::defaultValue, MathUtil::add, MathUtil::add, null, 1d),
|
||||
MAGIC_CRITICAL_RATE("mCritRate", new MCritRateFinalizer()),
|
||||
BLOW_RATE("blowRate"),
|
||||
DEFENCE_CRITICAL_RATE("defCritRate"),
|
||||
DEFENCE_CRITICAL_RATE_ADD("defCritRateAdd"),
|
||||
DEFENCE_MAGIC_CRITICAL_RATE("defMCritRate"),
|
||||
DEFENCE_MAGIC_CRITICAL_RATE_ADD("defMCritRateAdd"),
|
||||
DEFENCE_CRITICAL_DAMAGE("defCritDamage"),
|
||||
DEFENCE_MAGIC_CRITICAL_DAMAGE("defMCritDamage"),
|
||||
DEFENCE_MAGIC_CRITICAL_DAMAGE_ADD("defMCritDamageAdd"),
|
||||
DEFENCE_CRITICAL_DAMAGE_ADD("defCritDamageAdd"), // Resistance to critical damage in value (Example: +100 will be 100 more critical damage, NOT 100% more).
|
||||
DEFENCE_CRITICAL_DAMAGE_SKILL("defCAtkSkill"),
|
||||
DEFENCE_CRITICAL_DAMAGE_SKILL_ADD("defCAtkSkillAdd"),
|
||||
INSTANT_KILL_RESIST("instantKillResist"),
|
||||
EXPSP_RATE("rExp"),
|
||||
BONUS_EXP("bonusExp"),
|
||||
BONUS_SP("bonusSp"),
|
||||
ATTACK_CANCEL("cancel"),
|
||||
|
||||
// ACCURACY & RANGE
|
||||
ACCURACY_COMBAT("accCombat", new PAccuracyFinalizer()),
|
||||
ACCURACY_MAGIC("accMagic", new MAccuracyFinalizer()),
|
||||
EVASION_RATE("rEvas", new PEvasionRateFinalizer()),
|
||||
MAGIC_EVASION_RATE("mEvas", new MEvasionRateFinalizer()),
|
||||
PHYSICAL_ATTACK_RANGE("pAtkRange", new PRangeFinalizer()),
|
||||
MAGIC_ATTACK_RANGE("mAtkRange"),
|
||||
ATTACK_COUNT_MAX("atkCountMax"),
|
||||
// Run speed, walk & escape speed are calculated proportionally, magic speed is a buff
|
||||
MOVE_SPEED("moveSpeed"),
|
||||
RUN_SPEED("runSpd", new SpeedFinalizer()),
|
||||
WALK_SPEED("walkSpd", new SpeedFinalizer()),
|
||||
SWIM_RUN_SPEED("fastSwimSpd", new SpeedFinalizer()),
|
||||
SWIM_WALK_SPEED("slowSimSpd", new SpeedFinalizer()),
|
||||
FLY_RUN_SPEED("fastFlySpd", new SpeedFinalizer()),
|
||||
FLY_WALK_SPEED("slowFlySpd", new SpeedFinalizer()),
|
||||
|
||||
// BASIC STATS
|
||||
STAT_STR("STR", new BaseStatsFinalizer()),
|
||||
STAT_CON("CON", new BaseStatsFinalizer()),
|
||||
STAT_DEX("DEX", new BaseStatsFinalizer()),
|
||||
STAT_INT("INT", new BaseStatsFinalizer()),
|
||||
STAT_WIT("WIT", new BaseStatsFinalizer()),
|
||||
STAT_MEN("MEN", new BaseStatsFinalizer()),
|
||||
STAT_LUC("LUC", new BaseStatsFinalizer()),
|
||||
STAT_CHA("CHA", new BaseStatsFinalizer()),
|
||||
|
||||
// Special stats, share one slot in Calculator
|
||||
|
||||
// VARIOUS
|
||||
BREATH("breath"),
|
||||
FALL("fall"),
|
||||
|
||||
// VULNERABILITIES
|
||||
DAMAGE_ZONE_VULN("damageZoneVuln"),
|
||||
RESIST_DISPEL_BUFF("cancelVuln"), // Resistance for cancel type skills
|
||||
RESIST_ABNORMAL_DEBUFF("debuffVuln"),
|
||||
|
||||
// RESISTANCES
|
||||
FIRE_RES("fireRes", new AttributeFinalizer(AttributeType.FIRE, false)),
|
||||
WIND_RES("windRes", new AttributeFinalizer(AttributeType.WIND, false)),
|
||||
WATER_RES("waterRes", new AttributeFinalizer(AttributeType.WATER, false)),
|
||||
EARTH_RES("earthRes", new AttributeFinalizer(AttributeType.EARTH, false)),
|
||||
HOLY_RES("holyRes", new AttributeFinalizer(AttributeType.HOLY, false)),
|
||||
DARK_RES("darkRes", new AttributeFinalizer(AttributeType.DARK, false)),
|
||||
BASE_ATTRIBUTE_RES("baseAttrRes"),
|
||||
MAGIC_SUCCESS_RES("magicSuccRes"),
|
||||
// BUFF_IMMUNITY("buffImmunity"), //TODO: Implement me
|
||||
ABNORMAL_RESIST_PHYSICAL("abnormalResPhysical"),
|
||||
ABNORMAL_RESIST_MAGICAL("abnormalResMagical"),
|
||||
|
||||
// ELEMENT POWER
|
||||
FIRE_POWER("firePower", new AttributeFinalizer(AttributeType.FIRE, true)),
|
||||
WATER_POWER("waterPower", new AttributeFinalizer(AttributeType.WATER, true)),
|
||||
WIND_POWER("windPower", new AttributeFinalizer(AttributeType.WIND, true)),
|
||||
EARTH_POWER("earthPower", new AttributeFinalizer(AttributeType.EARTH, true)),
|
||||
HOLY_POWER("holyPower", new AttributeFinalizer(AttributeType.HOLY, true)),
|
||||
DARK_POWER("darkPower", new AttributeFinalizer(AttributeType.DARK, true)),
|
||||
|
||||
// PROFICIENCY
|
||||
REFLECT_DAMAGE_PERCENT("reflectDam"),
|
||||
REFLECT_DAMAGE_PERCENT_DEFENSE("reflectDamDef"),
|
||||
REFLECT_SKILL_MAGIC("reflectSkillMagic"), // Need rework
|
||||
REFLECT_SKILL_PHYSIC("reflectSkillPhysic"), // Need rework
|
||||
VENGEANCE_SKILL_MAGIC_DAMAGE("vengeanceMdam"),
|
||||
VENGEANCE_SKILL_PHYSICAL_DAMAGE("vengeancePdam"),
|
||||
ABSORB_DAMAGE_PERCENT("absorbDam"),
|
||||
ABSORB_DAMAGE_CHANCE("absorbDamChance", new VampiricChanceFinalizer()),
|
||||
ABSORB_DAMAGE_DEFENCE("absorbDamDefence"),
|
||||
TRANSFER_DAMAGE_SUMMON_PERCENT("transDam"),
|
||||
MANA_SHIELD_PERCENT("manaShield"),
|
||||
TRANSFER_DAMAGE_TO_PLAYER("transDamToPlayer"),
|
||||
ABSORB_MANA_DAMAGE_PERCENT("absorbDamMana"),
|
||||
|
||||
WEIGHT_LIMIT("weightLimit"),
|
||||
WEIGHT_PENALTY("weightPenalty"),
|
||||
|
||||
// ExSkill
|
||||
INVENTORY_NORMAL("inventoryLimit"),
|
||||
STORAGE_PRIVATE("whLimit"),
|
||||
TRADE_SELL("PrivateSellLimit"),
|
||||
TRADE_BUY("PrivateBuyLimit"),
|
||||
RECIPE_DWARVEN("DwarfRecipeLimit"),
|
||||
RECIPE_COMMON("CommonRecipeLimit"),
|
||||
|
||||
// Skill mastery
|
||||
SKILL_CRITICAL("skillCritical"),
|
||||
SKILL_CRITICAL_PROBABILITY("skillCriticalProbability"),
|
||||
|
||||
// Vitality
|
||||
VITALITY_CONSUME_RATE("vitalityConsumeRate"),
|
||||
|
||||
// Souls
|
||||
MAX_SOULS("maxSouls"),
|
||||
|
||||
REDUCE_EXP_LOST_BY_PVP("reduceExpLostByPvp"),
|
||||
REDUCE_EXP_LOST_BY_MOB("reduceExpLostByMob"),
|
||||
REDUCE_EXP_LOST_BY_RAID("reduceExpLostByRaid"),
|
||||
|
||||
REDUCE_DEATH_PENALTY_BY_PVP("reduceDeathPenaltyByPvp"),
|
||||
REDUCE_DEATH_PENALTY_BY_MOB("reduceDeathPenaltyByMob"),
|
||||
REDUCE_DEATH_PENALTY_BY_RAID("reduceDeathPenaltyByRaid"),
|
||||
|
||||
// Brooches
|
||||
BROOCH_JEWELS("broochJewels"),
|
||||
|
||||
// Summon Points
|
||||
MAX_SUMMON_POINTS("summonPoints"),
|
||||
|
||||
// Cubic Count
|
||||
MAX_CUBIC("cubicCount"),
|
||||
|
||||
// The maximum allowed range to be damaged/debuffed from.
|
||||
SPHERIC_BARRIER_RANGE("sphericBarrier"),
|
||||
|
||||
// Blocks given amount of debuffs.
|
||||
DEBUFF_BLOCK("debuffBlock"),
|
||||
|
||||
// Affects the random weapon damage.
|
||||
RANDOM_DAMAGE("randomDamage", new RandomDamageFinalizer()),
|
||||
|
||||
// Affects the random weapon damage.
|
||||
DAMAGE_LIMIT("damageCap"),
|
||||
|
||||
// Maximun momentum one can charge
|
||||
MAX_MOMENTUM("maxMomentum"),
|
||||
|
||||
// Which base stat ordinal should alter skill critical formula.
|
||||
STAT_BONUS_SKILL_CRITICAL("statSkillCritical"),
|
||||
STAT_BONUS_SPEED("statSpeed"),
|
||||
SHOTS_BONUS("shotBonus", new ShotsBonusFinalizer());
|
||||
|
||||
static final Logger LOGGER = Logger.getLogger(Stats.class.getName());
|
||||
public static final int NUM_STATS = values().length;
|
||||
|
||||
private final String _value;
|
||||
private final IStatsFunction _valueFinalizer;
|
||||
private final BiFunction<Double, Double, Double> _addFunction;
|
||||
private final BiFunction<Double, Double, Double> _mulFunction;
|
||||
private final Double _resetAddValue;
|
||||
private final Double _resetMulValue;
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
Stats(String xmlString)
|
||||
{
|
||||
this(xmlString, Stats::defaultValue, MathUtil::add, MathUtil::mul, null, null);
|
||||
}
|
||||
|
||||
Stats(String xmlString, IStatsFunction valueFinalizer)
|
||||
{
|
||||
this(xmlString, valueFinalizer, MathUtil::add, MathUtil::mul, null, null);
|
||||
|
||||
}
|
||||
|
||||
Stats(String xmlString, IStatsFunction valueFinalizer, BiFunction<Double, Double, Double> addFunction, BiFunction<Double, Double, Double> mulFunction, Double resetAddValue, Double resetMulValue)
|
||||
{
|
||||
_value = xmlString;
|
||||
_valueFinalizer = valueFinalizer;
|
||||
_addFunction = addFunction;
|
||||
_mulFunction = mulFunction;
|
||||
_resetAddValue = resetAddValue;
|
||||
_resetMulValue = resetMulValue;
|
||||
}
|
||||
|
||||
public static Stats valueOfXml(String name)
|
||||
{
|
||||
name = name.intern();
|
||||
for (Stats s : values())
|
||||
{
|
||||
if (s.getValue().equals(name))
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoSuchElementException("Unknown name '" + name + "' for enum " + Stats.class.getSimpleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param creature
|
||||
* @param baseValue
|
||||
* @return the final value
|
||||
*/
|
||||
public Double finalize(L2Character creature, Optional<Double> baseValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _valueFinalizer.calc(creature, baseValue, this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Exception during finalization for : " + creature + " stat: " + toString() + " : ", e);
|
||||
return defaultValue(creature, baseValue, this);
|
||||
}
|
||||
}
|
||||
|
||||
public double functionAdd(double oldValue, double value)
|
||||
{
|
||||
return _addFunction.apply(oldValue, value);
|
||||
}
|
||||
|
||||
public double functionMul(double oldValue, double value)
|
||||
{
|
||||
return _mulFunction.apply(oldValue, value);
|
||||
}
|
||||
|
||||
public Double getResetAddValue()
|
||||
{
|
||||
return _resetAddValue;
|
||||
}
|
||||
|
||||
public Double getResetMulValue()
|
||||
{
|
||||
return _resetMulValue;
|
||||
}
|
||||
|
||||
public static double weaponBaseValue(L2Character creature, Stats stat)
|
||||
{
|
||||
return stat._valueFinalizer.calcWeaponBaseValue(creature, stat);
|
||||
}
|
||||
|
||||
public static double defaultValue(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
final double mul = creature.getStat().getMul(stat);
|
||||
final double add = creature.getStat().getAdd(stat);
|
||||
return base.isPresent() ? defaultValue(creature, stat, base.get()) : mul * (add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType()));
|
||||
}
|
||||
|
||||
public static double defaultValue(L2Character creature, Stats stat, double baseValue)
|
||||
{
|
||||
final double mul = creature.getStat().getMul(stat);
|
||||
final double add = creature.getStat().getAdd(stat);
|
||||
return (baseValue * mul) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.model.stats;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class StatsHolder
|
||||
{
|
||||
private final Stats _stat;
|
||||
private final double _value;
|
||||
private final BiPredicate<L2Character, StatsHolder> _condition;
|
||||
|
||||
public StatsHolder(Stats stat, double value, BiPredicate<L2Character, StatsHolder> condition)
|
||||
{
|
||||
_stat = stat;
|
||||
_value = value;
|
||||
_condition = condition;
|
||||
}
|
||||
|
||||
public StatsHolder(Stats stat, double value)
|
||||
{
|
||||
this(stat, value, null);
|
||||
}
|
||||
|
||||
public Stats getStat()
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
|
||||
public double getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
public boolean verifyCondition(L2Character creature)
|
||||
{
|
||||
return (_condition == null) || _condition.test(creature, this);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,97 @@
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, NosBit
|
||||
*/
|
||||
public enum TraitType
|
||||
{
|
||||
UNK_0(0, 0),
|
||||
SWORD(1, 1),
|
||||
BLUNT(2, 1),
|
||||
DAGGER(3, 1),
|
||||
POLE(4, 1),
|
||||
FIST(5, 1),
|
||||
BOW(6, 1),
|
||||
ETC(7, 1),
|
||||
UNK_8(8, 0),
|
||||
POISON(9, 3),
|
||||
HOLD(10, 3),
|
||||
BLEED(11, 3),
|
||||
SLEEP(12, 3),
|
||||
SHOCK(13, 3),
|
||||
DERANGEMENT(14, 3),
|
||||
BUG_WEAKNESS(15, 2),
|
||||
ANIMAL_WEAKNESS(16, 2),
|
||||
PLANT_WEAKNESS(17, 2),
|
||||
BEAST_WEAKNESS(18, 2),
|
||||
DRAGON_WEAKNESS(19, 2),
|
||||
PARALYZE(20, 3),
|
||||
DUAL(21, 1),
|
||||
DUALFIST(22, 1),
|
||||
BOSS(23, 3),
|
||||
GIANT_WEAKNESS(24, 2),
|
||||
CONSTRUCT_WEAKNESS(25, 2),
|
||||
DEATH(26, 3),
|
||||
VALAKAS(27, 2),
|
||||
UNK_28(28, 2),
|
||||
UNK_29(29, 3),
|
||||
ROOT_PHYSICALLY(30, 3),
|
||||
UNK_31(31, 3),
|
||||
RAPIER(32, 1),
|
||||
CROSSBOW(33, 1),
|
||||
ANCIENTSWORD(34, 1),
|
||||
TURN_STONE(35, 3),
|
||||
GUST(36, 3),
|
||||
PHYSICAL_BLOCKADE(37, 3),
|
||||
UNK_38(38, 3),
|
||||
UNK_39(39, 3),
|
||||
UNK_40(40, 3),
|
||||
DUALDAGGER(41, 1),
|
||||
DUALBLUNT(42, 1),
|
||||
KNOCKBACK(43, 3),
|
||||
KNOCKDOWN(44, 3),
|
||||
MUTE(45, 3),
|
||||
NONE(46, 0);
|
||||
|
||||
private final int _id;
|
||||
private final int _type; // 1 = weapon, 2 = weakness, 3 = resistance
|
||||
|
||||
TraitType(int id, int type)
|
||||
{
|
||||
_id = id;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, NosBit
|
||||
*/
|
||||
public enum TraitType
|
||||
{
|
||||
UNK_0(0, 0),
|
||||
SWORD(1, 1),
|
||||
BLUNT(2, 1),
|
||||
DAGGER(3, 1),
|
||||
POLE(4, 1),
|
||||
FIST(5, 1),
|
||||
BOW(6, 1),
|
||||
ETC(7, 1),
|
||||
UNK_8(8, 0),
|
||||
POISON(9, 3),
|
||||
HOLD(10, 3),
|
||||
BLEED(11, 3),
|
||||
SLEEP(12, 3),
|
||||
SHOCK(13, 3),
|
||||
DERANGEMENT(14, 3),
|
||||
BUG_WEAKNESS(15, 2),
|
||||
ANIMAL_WEAKNESS(16, 2),
|
||||
PLANT_WEAKNESS(17, 2),
|
||||
BEAST_WEAKNESS(18, 2),
|
||||
DRAGON_WEAKNESS(19, 2),
|
||||
PARALYZE(20, 3),
|
||||
DUAL(21, 1),
|
||||
DUALFIST(22, 1),
|
||||
BOSS(23, 3),
|
||||
GIANT_WEAKNESS(24, 2),
|
||||
CONSTRUCT_WEAKNESS(25, 2),
|
||||
DEATH(26, 3),
|
||||
VALAKAS(27, 2),
|
||||
UNK_28(28, 2),
|
||||
UNK_29(29, 3),
|
||||
ROOT_PHYSICALLY(30, 3),
|
||||
UNK_31(31, 3),
|
||||
RAPIER(32, 1),
|
||||
CROSSBOW(33, 1),
|
||||
ANCIENTSWORD(34, 1),
|
||||
TURN_STONE(35, 3),
|
||||
GUST(36, 3),
|
||||
PHYSICAL_BLOCKADE(37, 3),
|
||||
TARGET(38, 3),
|
||||
PHYSICAL_WEAKNESS(39, 3),
|
||||
MAGICAL_WEAKNESS(40, 3),
|
||||
DUALDAGGER(41, 1),
|
||||
DUALBLUNT(42, 1),
|
||||
KNOCKBACK(43, 3),
|
||||
KNOCKDOWN(44, 3),
|
||||
PULL(45, 3),
|
||||
HATE(46, 3),
|
||||
AGGRESSION(47, 3),
|
||||
AIRBIND(48, 3),
|
||||
DISARM(49, 3),
|
||||
DEPORT(50, 3),
|
||||
CHANGEBODY(51, 3),
|
||||
TWOHANDCROSSBOW(52, 1),
|
||||
NONE(53, 0);
|
||||
|
||||
private final int _id;
|
||||
private final int _type; // 1 = weapon, 2 = weakness, 3 = resistance
|
||||
|
||||
TraitType(int id, int type)
|
||||
{
|
||||
_id = id;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.enchant.attribute.AttributeHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AttributeFinalizer implements IStatsFunction
|
||||
{
|
||||
private final AttributeType _type;
|
||||
private final boolean _isWeapon;
|
||||
|
||||
public AttributeFinalizer(AttributeType type, boolean isWeapon)
|
||||
{
|
||||
_type = type;
|
||||
_isWeapon = isWeapon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
if (creature.isPlayable())
|
||||
{
|
||||
if (_isWeapon)
|
||||
{
|
||||
final L2ItemInstance weapon = creature.getActiveWeaponInstance();
|
||||
if (weapon != null)
|
||||
{
|
||||
final AttributeHolder weaponInstanceHolder = weapon.getAttribute(_type);
|
||||
if (weaponInstanceHolder != null)
|
||||
{
|
||||
baseValue += weaponInstanceHolder.getValue();
|
||||
}
|
||||
|
||||
final AttributeHolder weaponHolder = weapon.getItem().getAttribute(_type);
|
||||
if (weaponHolder != null)
|
||||
{
|
||||
baseValue += weaponHolder.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Inventory inventory = creature.getInventory();
|
||||
if (inventory != null)
|
||||
{
|
||||
for (L2ItemInstance item : inventory.getPaperdollItems(L2ItemInstance::isArmor))
|
||||
{
|
||||
final AttributeHolder weaponInstanceHolder = item.getAttribute(_type);
|
||||
if (weaponInstanceHolder != null)
|
||||
{
|
||||
baseValue += weaponInstanceHolder.getValue();
|
||||
}
|
||||
|
||||
final AttributeHolder weaponHolder = item.getItem().getAttribute(_type);
|
||||
if (weaponHolder != null)
|
||||
{
|
||||
baseValue += weaponHolder.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
|
||||
import com.l2jmobius.gameserver.model.L2ArmorSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class BaseStatsFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
// Apply template value
|
||||
double baseValue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
final Set<L2ArmorSet> appliedSets = new HashSet<>(2);
|
||||
|
||||
// Armor sets calculation
|
||||
for (L2ItemInstance item : player.getInventory().getPaperdollItems())
|
||||
{
|
||||
for (L2ArmorSet set : ArmorSetsData.getInstance().getSets(item.getId()))
|
||||
{
|
||||
if ((set.getPiecesCount(player, L2ItemInstance::getId) >= set.getMinimumPieces()) && appliedSets.add(set))
|
||||
{
|
||||
baseValue += set.getStatsBonus(BaseStats.valueOf(stat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Henna calculation
|
||||
baseValue += player.getHennaValue(BaseStats.valueOf(stat));
|
||||
}
|
||||
return validateValue(creature, Stats.defaultValue(creature, stat, baseValue), 1, BaseStats.MAX_STAT_VALUE - 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MAccuracyFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponPlusBaseValue(creature, stat);
|
||||
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// Enchanted gloves bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_GLOVES);
|
||||
}
|
||||
|
||||
return Stats.defaultValue(creature, stat, baseValue + (Math.sqrt(creature.getWIT()) * 3) + (creature.getLevel() * 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (0.3 * Math.max(enchantLevel - 3, 0)) + (0.3 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (0.2 * Math.max(enchantLevel - 3, 0)) + (0.2 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MAttackFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponBaseValue(creature, stat);
|
||||
baseValue += calcEnchantedItemBonus(creature, stat);
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// Enchanted chest bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_CHEST, L2Item.SLOT_FULL_ARMOR);
|
||||
}
|
||||
|
||||
if (Config.L2JMOD_CHAMPION_ENABLE && creature.isChampion())
|
||||
{
|
||||
baseValue *= Config.L2JMOD_CHAMPION_ATK;
|
||||
}
|
||||
if (creature.isRaid())
|
||||
{
|
||||
baseValue *= Config.RAID_MATTACK_MULTIPLIER;
|
||||
}
|
||||
|
||||
// Calculate modifiers Magic Attack
|
||||
final double chaMod = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
|
||||
final double intBonus = BaseStats.INT.calcBonus(creature);
|
||||
baseValue *= Math.pow(intBonus, 2) * Math.pow(creature.getLevelMod(), 2) * chaMod;
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (2 * Math.max(enchantLevel - 3, 0)) + (2 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (1.4 * Math.max(enchantLevel - 3, 0)) + (1.4 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,48 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMaxCpMul extends AbstractFunction
|
||||
{
|
||||
private static final FuncMaxCpMul _fmcm_instance = new FuncMaxCpMul();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fmcm_instance;
|
||||
}
|
||||
|
||||
private FuncMaxCpMul()
|
||||
{
|
||||
super(Stats.MAX_CP, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.CON.calcBonus(effector) * BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MAttackSpeedFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponBaseValue(creature, stat);
|
||||
if (Config.L2JMOD_CHAMPION_ENABLE && creature.isChampion())
|
||||
{
|
||||
baseValue *= Config.L2JMOD_CHAMPION_SPD_ATK;
|
||||
}
|
||||
|
||||
final double chaBonus = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
|
||||
final double witBonus = creature.getWIT() > 0 ? BaseStats.WIT.calcBonus(creature) : 1.;
|
||||
baseValue *= witBonus * chaBonus;
|
||||
return validateValue(creature, Stats.defaultValue(creature, stat, baseValue), 1, Config.MAX_MATK_SPEED);
|
||||
}
|
||||
}
|
||||
@@ -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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MCritRateFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponPlusBaseValue(creature, stat);
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_LEGS);
|
||||
}
|
||||
|
||||
final double witBonus = creature.getWIT() > 0 ? BaseStats.WIT.calcBonus(creature) : 1.;
|
||||
baseValue *= witBonus * 10;
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (0.5 * Math.max(enchantLevel - 3, 0)) + (0.5 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (0.34 * Math.max(enchantLevel - 3, 0)) + (0.34 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MDefenseFinalizer implements IStatsFunction
|
||||
{
|
||||
private static final int[] SLOTS =
|
||||
{
|
||||
Inventory.PAPERDOLL_LFINGER,
|
||||
Inventory.PAPERDOLL_RFINGER,
|
||||
Inventory.PAPERDOLL_LEAR,
|
||||
Inventory.PAPERDOLL_REAR,
|
||||
Inventory.PAPERDOLL_NECK
|
||||
};
|
||||
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
double baseValue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
if (creature.isPet())
|
||||
{
|
||||
final L2PetInstance pet = (L2PetInstance) creature;
|
||||
baseValue = pet.getPetLevelData().getPetMDef();
|
||||
}
|
||||
baseValue += calcEnchantedItemBonus(creature, stat);
|
||||
|
||||
final Inventory inv = creature.getInventory();
|
||||
if (inv != null)
|
||||
{
|
||||
for (L2ItemInstance item : inv.getPaperdollItems(L2ItemInstance::isEquipped))
|
||||
{
|
||||
baseValue += item.getItem().getStats(stat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
for (int slot : SLOTS)
|
||||
{
|
||||
if (!player.getInventory().isPaperdollSlotEmpty(slot))
|
||||
{
|
||||
final int defaultStatValue = player.getTemplate().getBaseDefBySlot(slot);
|
||||
baseValue -= creature.getTransformation().map(transform -> transform.getBaseDefBySlot(player, slot)).orElse(defaultStatValue);
|
||||
}
|
||||
}
|
||||
|
||||
baseValue *= BaseStats.CHA.calcBonus(creature);
|
||||
}
|
||||
else if (creature.isPet() && (creature.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_NECK) != 0))
|
||||
{
|
||||
baseValue -= 13;
|
||||
}
|
||||
if (creature.isRaid())
|
||||
{
|
||||
baseValue *= Config.RAID_MDEFENCE_MULTIPLIER;
|
||||
}
|
||||
|
||||
final double bonus = creature.getMEN() > 0 ? BaseStats.MEN.calcBonus(creature) : 1.;
|
||||
baseValue *= bonus * creature.getLevelMod();
|
||||
return defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
|
||||
private double defaultValue(L2Character creature, Stats stat, double baseValue)
|
||||
{
|
||||
final double mul = Math.max(creature.getStat().getMul(stat), 0.5);
|
||||
final double add = creature.getStat().getAdd(stat);
|
||||
return (baseValue * mul) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MEvasionRateFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponPlusBaseValue(creature, stat);
|
||||
|
||||
final int level = creature.getLevel();
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// [Square(WIT)] * 3 + lvl;
|
||||
baseValue += (Math.sqrt(creature.getWIT()) * 3) + (level * 2);
|
||||
|
||||
// Enchanted helm bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_HEAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
// [Square(DEX)] * 6 + lvl;
|
||||
baseValue += (Math.sqrt(creature.getWIT()) * 3) + (level * 2);
|
||||
if (level > 69)
|
||||
{
|
||||
baseValue += (level - 69) + 2;
|
||||
}
|
||||
}
|
||||
return validateValue(creature, Stats.defaultValue(creature, stat, baseValue), Double.NEGATIVE_INFINITY, Config.MAX_EVASION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (0.3 * Math.max(enchantLevel - 3, 0)) + (0.3 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (0.2 * Math.max(enchantLevel - 3, 0)) + (0.2 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,48 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMAtkSpeed extends AbstractFunction
|
||||
{
|
||||
private static final FuncMAtkSpeed _fas_instance = new FuncMAtkSpeed();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fas_instance;
|
||||
}
|
||||
|
||||
private FuncMAtkSpeed()
|
||||
{
|
||||
super(Stats.MAGIC_ATTACK_SPEED, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.WIT.calcBonus(effector) * BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MaxCpFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
baseValue = player.getTemplate().getBaseCpMax(player.getLevel());
|
||||
}
|
||||
final double chaBonus = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
|
||||
final double conBonus = creature.getCON() > 0 ? BaseStats.CON.calcBonus(creature) : 1.;
|
||||
baseValue *= conBonus * chaBonus;
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MaxHpFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
if (creature.isPet())
|
||||
{
|
||||
final L2PetInstance pet = (L2PetInstance) creature;
|
||||
baseValue = pet.getPetLevelData().getPetMaxHP();
|
||||
}
|
||||
else if (creature.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
baseValue = player.getTemplate().getBaseHpMax(player.getLevel());
|
||||
|
||||
// Apply enchanted item's bonus HP
|
||||
for (L2ItemInstance item : player.getInventory().getPaperdollItems(L2ItemInstance::isEnchanted))
|
||||
{
|
||||
baseValue += EnchantItemHPBonusData.getInstance().getHPBonus(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
final double chaBonus = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
|
||||
final double conBonus = creature.getCON() > 0 ? BaseStats.CON.calcBonus(creature) : 1.;
|
||||
baseValue *= conBonus * chaBonus;
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class MaxMpFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
if (creature.isPet())
|
||||
{
|
||||
final L2PetInstance pet = (L2PetInstance) creature;
|
||||
baseValue = pet.getPetLevelData().getPetMaxMP();
|
||||
}
|
||||
else if (creature.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
baseValue = player.getTemplate().getBaseMpMax(player.getLevel());
|
||||
}
|
||||
}
|
||||
final double chaBonus = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
|
||||
final double menBonus = creature.getMEN() > 0 ? BaseStats.MEN.calcBonus(creature) : 1.;
|
||||
baseValue *= menBonus * chaBonus;
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PAccuracyFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponPlusBaseValue(creature, stat);
|
||||
|
||||
// [Square(DEX)] * 5 + lvl + weapon hitbonus;
|
||||
final int level = creature.getLevel();
|
||||
baseValue += (Math.sqrt(creature.getDEX()) * 5) + level;
|
||||
if (level > 69)
|
||||
{
|
||||
baseValue += level - 69;
|
||||
}
|
||||
if (level > 77)
|
||||
{
|
||||
baseValue += 1;
|
||||
}
|
||||
if (level > 80)
|
||||
{
|
||||
baseValue += 2;
|
||||
}
|
||||
if (level > 87)
|
||||
{
|
||||
baseValue += 2;
|
||||
}
|
||||
if (level > 92)
|
||||
{
|
||||
baseValue += 1;
|
||||
}
|
||||
if (level > 97)
|
||||
{
|
||||
baseValue += 1;
|
||||
}
|
||||
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// Enchanted gloves bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_GLOVES);
|
||||
}
|
||||
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (0.3 * Math.max(enchantLevel - 3, 0)) + (0.3 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (0.2 * Math.max(enchantLevel - 3, 0)) + (0.2 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PAttackFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponBaseValue(creature, stat);
|
||||
baseValue += calcEnchantedItemBonus(creature, stat);
|
||||
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// Enchanted chest bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_CHEST, L2Item.SLOT_FULL_ARMOR);
|
||||
}
|
||||
|
||||
if (Config.L2JMOD_CHAMPION_ENABLE && creature.isChampion())
|
||||
{
|
||||
baseValue *= Config.L2JMOD_CHAMPION_ATK;
|
||||
}
|
||||
if (creature.isRaid())
|
||||
{
|
||||
baseValue *= Config.RAID_PATTACK_MULTIPLIER;
|
||||
}
|
||||
final double chaBonus = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
|
||||
final double strBonus = creature.getSTR() > 0 ? BaseStats.STR.calcBonus(creature) : 1.;
|
||||
baseValue *= strBonus * creature.getLevelMod() * chaBonus;
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (3 * Math.max(enchantLevel - 3, 0)) + (3 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (2 * Math.max(enchantLevel - 3, 0)) + (2 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,46 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMAtkCritical extends AbstractFunction
|
||||
{
|
||||
private static final FuncMAtkCritical _fac_instance = new FuncMAtkCritical();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fac_instance;
|
||||
}
|
||||
|
||||
private FuncMAtkCritical()
|
||||
{
|
||||
super(Stats.MCRITICAL_RATE, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.WIT.calcBonus(effector) * 10;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PAttackSpeedFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
double baseValue = calcWeaponBaseValue(creature, stat);
|
||||
if (Config.L2JMOD_CHAMPION_ENABLE && creature.isChampion())
|
||||
{
|
||||
baseValue = Config.L2JMOD_CHAMPION_SPD_ATK;
|
||||
}
|
||||
final double chaBonus = creature.isPlayer() ? BaseStats.CHA.calcBonus(creature) : 1.;
|
||||
final double dexBonus = creature.getDEX() > 0 ? BaseStats.DEX.calcBonus(creature) : 1.;
|
||||
baseValue *= dexBonus * chaBonus;
|
||||
return validateValue(creature, Stats.defaultValue(creature, stat, baseValue), 1, Config.MAX_PATK_SPEED);
|
||||
}
|
||||
}
|
||||
@@ -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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PCriticalRateFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponBaseValue(creature, stat);
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// Enchanted legs bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_LEGS);
|
||||
}
|
||||
final double dexBonus = creature.getDEX() > 0 ? BaseStats.DEX.calcBonus(creature) : 1.;
|
||||
return validateValue(creature, Stats.defaultValue(creature, stat, baseValue * dexBonus * 10), 0, Config.MAX_PCRIT_RATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (0.5 * Math.max(enchantLevel - 3, 0)) + (0.5 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (0.34 * Math.max(enchantLevel - 3, 0)) + (0.34 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PDefenseFinalizer implements IStatsFunction
|
||||
{
|
||||
private static final int[] SLOTS =
|
||||
{
|
||||
Inventory.PAPERDOLL_CHEST,
|
||||
Inventory.PAPERDOLL_LEGS,
|
||||
Inventory.PAPERDOLL_HEAD,
|
||||
Inventory.PAPERDOLL_FEET,
|
||||
Inventory.PAPERDOLL_GLOVES,
|
||||
Inventory.PAPERDOLL_UNDER,
|
||||
Inventory.PAPERDOLL_CLOAK
|
||||
};
|
||||
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
double baseValue = creature.getTemplate().getBaseValue(stat, 0);
|
||||
if (creature.isPet())
|
||||
{
|
||||
final L2PetInstance pet = (L2PetInstance) creature;
|
||||
baseValue = pet.getPetLevelData().getPetPDef();
|
||||
}
|
||||
baseValue += calcEnchantedItemBonus(creature, stat);
|
||||
|
||||
final Inventory inv = creature.getInventory();
|
||||
if (inv != null)
|
||||
{
|
||||
for (L2ItemInstance item : inv.getPaperdollItems())
|
||||
{
|
||||
baseValue += item.getItem().getStats(stat, 0);
|
||||
}
|
||||
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
for (int slot : SLOTS)
|
||||
{
|
||||
if (!inv.isPaperdollSlotEmpty(slot) || ((slot == Inventory.PAPERDOLL_LEGS) && !inv.isPaperdollSlotEmpty(Inventory.PAPERDOLL_CHEST) && (inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR)))
|
||||
{
|
||||
final int defaultStatValue = player.getTemplate().getBaseDefBySlot(slot);
|
||||
baseValue -= creature.getTransformation().map(transform -> transform.getBaseDefBySlot(player, slot)).orElse(defaultStatValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
baseValue *= BaseStats.CHA.calcBonus(creature);
|
||||
}
|
||||
if (creature.isRaid())
|
||||
{
|
||||
baseValue *= Config.RAID_PDEFENCE_MULTIPLIER;
|
||||
}
|
||||
baseValue *= creature.getLevelMod();
|
||||
|
||||
return defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
|
||||
private double defaultValue(L2Character creature, Stats stat, double baseValue)
|
||||
{
|
||||
final double mul = Math.max(creature.getStat().getMul(stat), 0.5);
|
||||
final double add = creature.getStat().getAdd(stat);
|
||||
return (baseValue * mul) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PEvasionRateFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = calcWeaponPlusBaseValue(creature, stat);
|
||||
final Inventory inv = creature.getInventory();
|
||||
if (inv != null)
|
||||
{
|
||||
for (L2ItemInstance item : inv.getPaperdollItems(L2ItemInstance::isEquipped))
|
||||
{
|
||||
baseValue += item.getItem().getStats(stat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
final int level = creature.getLevel();
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// [Square(DEX)] * 5 + lvl;
|
||||
baseValue += (Math.sqrt(creature.getDEX()) * 5) + level;
|
||||
if (level > 69)
|
||||
{
|
||||
baseValue += level - 69;
|
||||
}
|
||||
if (level > 77)
|
||||
{
|
||||
baseValue += 1;
|
||||
}
|
||||
if (level > 80)
|
||||
{
|
||||
baseValue += 2;
|
||||
}
|
||||
if (level > 87)
|
||||
{
|
||||
baseValue += 2;
|
||||
}
|
||||
if (level > 92)
|
||||
{
|
||||
baseValue += 1;
|
||||
}
|
||||
if (level > 97)
|
||||
{
|
||||
baseValue += 1;
|
||||
}
|
||||
|
||||
// Enchanted helm bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_HEAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
// [Square(DEX)] * 5 + lvl;
|
||||
baseValue += (Math.sqrt(creature.getDEX()) * 5) + level;
|
||||
if (level > 69)
|
||||
{
|
||||
baseValue += (level - 69) + 2;
|
||||
}
|
||||
}
|
||||
|
||||
return validateValue(creature, Stats.defaultValue(creature, stat, baseValue), Double.NEGATIVE_INFINITY, Config.MAX_EVASION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (0.3 * Math.max(enchantLevel - 3, 0)) + (0.3 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (0.2 * Math.max(enchantLevel - 3, 0)) + (0.2 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMoveSpeed extends AbstractFunction
|
||||
{
|
||||
private static final FuncMoveSpeed _fms_instance = new FuncMoveSpeed();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fms_instance;
|
||||
}
|
||||
|
||||
private FuncMoveSpeed()
|
||||
{
|
||||
super(Stats.MOVE_SPEED, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.DEX.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class PRangeFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
final double baseValue = calcWeaponBaseValue(creature, stat);
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncAtkCritical extends AbstractFunction
|
||||
{
|
||||
private static final FuncAtkCritical _fac_instance = new FuncAtkCritical();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fac_instance;
|
||||
}
|
||||
|
||||
private FuncAtkCritical()
|
||||
{
|
||||
super(Stats.CRITICAL_RATE, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.DEX.calcBonus(effector) * 10;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RandomDamageFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
final double baseValue = calcWeaponBaseValue(creature, stat);
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RegenCPFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
if (!creature.isPlayer())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
double baseValue = player.getTemplate().getBaseCpRegen(creature.getLevel()) * creature.getLevelMod() * BaseStats.CON.calcBonus(creature);
|
||||
if (player.isSitting())
|
||||
{
|
||||
baseValue *= 1.5; // Sitting
|
||||
}
|
||||
else if (!player.isMoving())
|
||||
{
|
||||
baseValue *= 1.1; // Staying
|
||||
}
|
||||
else if (player.isRunning())
|
||||
{
|
||||
baseValue *= 0.7; // Running
|
||||
}
|
||||
return Stats.defaultValue(player, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.L2SiegeClan;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Siege;
|
||||
import com.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||
import com.l2jmobius.gameserver.model.residences.ResidenceFunction;
|
||||
import com.l2jmobius.gameserver.model.residences.ResidenceFunctionType;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2CastleZone;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2ClanHallZone;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2FortZone;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2MotherTreeZone;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RegenHPFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = creature.isPlayer() ? creature.getActingPlayer().getTemplate().getBaseHpRegen(creature.getLevel()) : creature.getTemplate().getBaseHpReg();
|
||||
baseValue *= creature.isRaid() ? Config.RAID_HP_REGEN_MULTIPLIER : Config.HP_REGEN_MULTIPLIER;
|
||||
|
||||
if (Config.L2JMOD_CHAMPION_ENABLE && creature.isChampion())
|
||||
{
|
||||
baseValue *= Config.L2JMOD_CHAMPION_HP_REGEN;
|
||||
}
|
||||
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
|
||||
final double siegeModifier = calcSiegeRegenModifier(player);
|
||||
if (siegeModifier > 0)
|
||||
{
|
||||
baseValue *= siegeModifier;
|
||||
}
|
||||
|
||||
if (player.isInsideZone(ZoneId.CLAN_HALL) && (player.getClan() != null) && (player.getClan().getHideoutId() > 0))
|
||||
{
|
||||
final L2ClanHallZone zone = ZoneManager.getInstance().getZone(player, L2ClanHallZone.class);
|
||||
final int posChIndex = zone == null ? -1 : zone.getResidenceId();
|
||||
final int clanHallIndex = player.getClan().getHideoutId();
|
||||
if ((clanHallIndex > 0) && (clanHallIndex == posChIndex))
|
||||
{
|
||||
final AbstractResidence residense = ClanHallData.getInstance().getClanHallById(player.getClan().getHideoutId());
|
||||
if (residense != null)
|
||||
{
|
||||
final ResidenceFunction func = residense.getFunction(ResidenceFunctionType.HP_REGEN);
|
||||
if (func != null)
|
||||
{
|
||||
baseValue *= func.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player.isInsideZone(ZoneId.CASTLE) && (player.getClan() != null) && (player.getClan().getCastleId() > 0))
|
||||
{
|
||||
final L2CastleZone zone = ZoneManager.getInstance().getZone(player, L2CastleZone.class);
|
||||
final int posCastleIndex = zone == null ? -1 : zone.getResidenceId();
|
||||
final int castleIndex = player.getClan().getCastleId();
|
||||
if ((castleIndex > 0) && (castleIndex == posCastleIndex))
|
||||
{
|
||||
final AbstractResidence residense = CastleManager.getInstance().getCastleById(player.getClan().getCastleId());
|
||||
if (residense != null)
|
||||
{
|
||||
final ResidenceFunction func = residense.getFunction(ResidenceFunctionType.HP_REGEN);
|
||||
if (func != null)
|
||||
{
|
||||
baseValue *= func.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player.isInsideZone(ZoneId.FORT) && (player.getClan() != null) && (player.getClan().getFortId() > 0))
|
||||
{
|
||||
final L2FortZone zone = ZoneManager.getInstance().getZone(player, L2FortZone.class);
|
||||
final int posFortIndex = zone == null ? -1 : zone.getResidenceId();
|
||||
final int fortIndex = player.getClan().getFortId();
|
||||
if ((fortIndex > 0) && (fortIndex == posFortIndex))
|
||||
{
|
||||
final AbstractResidence residense = FortManager.getInstance().getFortById(player.getClan().getCastleId());
|
||||
if (residense != null)
|
||||
{
|
||||
final ResidenceFunction func = residense.getFunction(ResidenceFunctionType.HP_REGEN);
|
||||
if (func != null)
|
||||
{
|
||||
baseValue *= func.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mother Tree effect is calculated at last
|
||||
if (player.isInsideZone(ZoneId.MOTHER_TREE))
|
||||
{
|
||||
final L2MotherTreeZone zone = ZoneManager.getInstance().getZone(player, L2MotherTreeZone.class);
|
||||
final int hpBonus = zone == null ? 0 : zone.getHpRegenBonus();
|
||||
baseValue += hpBonus;
|
||||
}
|
||||
|
||||
// Calculate Movement bonus
|
||||
if (player.isSitting())
|
||||
{
|
||||
baseValue *= 1.5; // Sitting
|
||||
}
|
||||
else if (!player.isMoving())
|
||||
{
|
||||
baseValue *= 1.1; // Staying
|
||||
}
|
||||
else if (player.isRunning())
|
||||
{
|
||||
baseValue *= 0.7; // Running
|
||||
}
|
||||
|
||||
// Add CON bonus
|
||||
baseValue *= creature.getLevelMod() * BaseStats.CON.calcBonus(creature);
|
||||
}
|
||||
else if (creature.isPet())
|
||||
{
|
||||
baseValue = ((L2PetInstance) creature).getPetLevelData().getPetRegenHP() * Config.PET_HP_REGEN_MULTIPLIER;
|
||||
}
|
||||
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
|
||||
private static double calcSiegeRegenModifier(L2PcInstance activeChar)
|
||||
{
|
||||
if ((activeChar == null) || (activeChar.getClan() == null))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final Siege siege = SiegeManager.getInstance().getSiege(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
if ((siege == null) || !siege.isInProgress())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final L2SiegeClan siegeClan = siege.getAttackerClan(activeChar.getClan().getId());
|
||||
if ((siegeClan == null) || siegeClan.getFlag().isEmpty() || !Util.checkIfInRange(200, activeChar, siegeClan.getFlag().stream().findAny().get(), true))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1.5; // If all is true, then modifier will be 50% more
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.residences.AbstractResidence;
|
||||
import com.l2jmobius.gameserver.model.residences.ResidenceFunction;
|
||||
import com.l2jmobius.gameserver.model.residences.ResidenceFunctionType;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2CastleZone;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2ClanHallZone;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2FortZone;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2MotherTreeZone;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class RegenMPFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = creature.isPlayer() ? creature.getActingPlayer().getTemplate().getBaseMpRegen(creature.getLevel()) : creature.getTemplate().getBaseMpReg();
|
||||
baseValue *= creature.isRaid() ? Config.RAID_MP_REGEN_MULTIPLIER : Config.MP_REGEN_MULTIPLIER;
|
||||
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
|
||||
if (player.isInsideZone(ZoneId.CLAN_HALL) && (player.getClan() != null) && (player.getClan().getHideoutId() > 0))
|
||||
{
|
||||
final L2ClanHallZone zone = ZoneManager.getInstance().getZone(player, L2ClanHallZone.class);
|
||||
final int posChIndex = zone == null ? -1 : zone.getResidenceId();
|
||||
final int clanHallIndex = player.getClan().getHideoutId();
|
||||
if ((clanHallIndex > 0) && (clanHallIndex == posChIndex))
|
||||
{
|
||||
final AbstractResidence residense = ClanHallData.getInstance().getClanHallById(player.getClan().getHideoutId());
|
||||
if (residense != null)
|
||||
{
|
||||
final ResidenceFunction func = residense.getFunction(ResidenceFunctionType.MP_REGEN);
|
||||
if (func != null)
|
||||
{
|
||||
baseValue *= func.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player.isInsideZone(ZoneId.CASTLE) && (player.getClan() != null) && (player.getClan().getCastleId() > 0))
|
||||
{
|
||||
final L2CastleZone zone = ZoneManager.getInstance().getZone(player, L2CastleZone.class);
|
||||
final int posCastleIndex = zone == null ? -1 : zone.getResidenceId();
|
||||
final int castleIndex = player.getClan().getCastleId();
|
||||
if ((castleIndex > 0) && (castleIndex == posCastleIndex))
|
||||
{
|
||||
final AbstractResidence residense = CastleManager.getInstance().getCastleById(player.getClan().getCastleId());
|
||||
if (residense != null)
|
||||
{
|
||||
final ResidenceFunction func = residense.getFunction(ResidenceFunctionType.MP_REGEN);
|
||||
if (func != null)
|
||||
{
|
||||
baseValue *= func.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (player.isInsideZone(ZoneId.FORT) && (player.getClan() != null) && (player.getClan().getFortId() > 0))
|
||||
{
|
||||
final L2FortZone zone = ZoneManager.getInstance().getZone(player, L2FortZone.class);
|
||||
final int posFortIndex = zone == null ? -1 : zone.getResidenceId();
|
||||
final int fortIndex = player.getClan().getFortId();
|
||||
if ((fortIndex > 0) && (fortIndex == posFortIndex))
|
||||
{
|
||||
final AbstractResidence residense = FortManager.getInstance().getFortById(player.getClan().getCastleId());
|
||||
if (residense != null)
|
||||
{
|
||||
final ResidenceFunction func = residense.getFunction(ResidenceFunctionType.MP_REGEN);
|
||||
if (func != null)
|
||||
{
|
||||
baseValue *= func.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mother Tree effect is calculated at last'
|
||||
if (player.isInsideZone(ZoneId.MOTHER_TREE))
|
||||
{
|
||||
final L2MotherTreeZone zone = ZoneManager.getInstance().getZone(player, L2MotherTreeZone.class);
|
||||
final int mpBonus = zone == null ? 0 : zone.getMpRegenBonus();
|
||||
baseValue += mpBonus;
|
||||
}
|
||||
|
||||
// Calculate Movement bonus
|
||||
if (player.isSitting())
|
||||
{
|
||||
baseValue *= 1.5; // Sitting
|
||||
}
|
||||
else if (!player.isMoving())
|
||||
{
|
||||
baseValue *= 1.1; // Staying
|
||||
}
|
||||
else if (player.isRunning())
|
||||
{
|
||||
baseValue *= 0.7; // Running
|
||||
}
|
||||
|
||||
// Add MEN bonus
|
||||
baseValue *= creature.getLevelMod() * BaseStats.MEN.calcBonus(creature);
|
||||
}
|
||||
else if (creature.isPet())
|
||||
{
|
||||
baseValue = ((L2PetInstance) creature).getPetLevelData().getPetRegenMP() * Config.PET_MP_REGEN_MULTIPLIER;
|
||||
}
|
||||
|
||||
return Stats.defaultValue(creature, stat, baseValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ShotsBonusFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = 1;
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
final L2ItemInstance weapon = player.getActiveWeaponInstance();
|
||||
if ((weapon != null) && weapon.isEnchanted())
|
||||
{
|
||||
baseValue += (weapon.getEnchantLevel() * 0.7) / 100;
|
||||
}
|
||||
}
|
||||
return CommonUtil.constrain(baseValue, 1.0, 1.21);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.L2PetLevelData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2SwampZone;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class SpeedFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
double baseValue = getBaseSpeed(creature, stat);
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
// Enchanted feet bonus
|
||||
baseValue += calcEnchantBodyPart(creature, L2Item.SLOT_FEET);
|
||||
}
|
||||
|
||||
final byte speedStat = (byte) creature.getStat().getAdd(Stats.STAT_BONUS_SPEED, -1);
|
||||
if ((speedStat >= 0) && (speedStat < BaseStats.values().length))
|
||||
{
|
||||
final BaseStats baseStat = BaseStats.values()[speedStat];
|
||||
final double bonusDex = Math.max(0, baseStat.calcValue(creature) - 55);
|
||||
baseValue += bonusDex;
|
||||
}
|
||||
|
||||
return validateValue(creature, Stats.defaultValue(creature, stat, baseValue), 1, Config.MAX_RUN_SPEED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calcEnchantBodyPartBonus(int enchantLevel, boolean isBlessed)
|
||||
{
|
||||
if (isBlessed)
|
||||
{
|
||||
return (1 * Math.max(enchantLevel - 3, 0)) + (1 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
return (0.6 * Math.max(enchantLevel - 3, 0)) + (0.6 * Math.max(enchantLevel - 6, 0));
|
||||
}
|
||||
|
||||
private double getBaseSpeed(L2Character creature, Stats stat)
|
||||
{
|
||||
double baseValue = calcWeaponPlusBaseValue(creature, stat);
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
final L2PcInstance player = creature.getActingPlayer();
|
||||
if (player.isMounted())
|
||||
{
|
||||
final L2PetLevelData data = PetDataTable.getInstance().getPetLevelData(player.getMountNpcId(), player.getMountLevel());
|
||||
if (data != null)
|
||||
{
|
||||
baseValue = data.getSpeedOnRide(stat);
|
||||
// if level diff with mount >= 10, it decreases move speed by 50%
|
||||
if ((player.getMountLevel() - creature.getLevel()) >= 10)
|
||||
{
|
||||
baseValue /= 2;
|
||||
}
|
||||
|
||||
// if mount is hungry, it decreases move speed by 50%
|
||||
if (player.isHungry())
|
||||
{
|
||||
baseValue /= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
baseValue += Config.RUN_SPD_BOOST;
|
||||
}
|
||||
if (creature.isPlayable() && creature.isInsideZone(ZoneId.SWAMP))
|
||||
{
|
||||
final L2SwampZone zone = ZoneManager.getInstance().getZone(creature, L2SwampZone.class);
|
||||
if (zone != null)
|
||||
{
|
||||
baseValue *= zone.getMoveBonus();
|
||||
}
|
||||
}
|
||||
return baseValue;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class FuncMatkAccuracy extends AbstractFunction
|
||||
{
|
||||
private static final FuncMatkAccuracy _faa_instance = new FuncMatkAccuracy();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _faa_instance;
|
||||
}
|
||||
|
||||
private FuncMatkAccuracy()
|
||||
{
|
||||
super(Stats.ACCURACY_MAGIC, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal + (Math.sqrt(effector.getWIT()) * 3) + (effector.getLevel() * 2);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.finalizers;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.stats.IStatsFunction;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class VampiricChanceFinalizer implements IStatsFunction
|
||||
{
|
||||
@Override
|
||||
public double calc(L2Character creature, Optional<Double> base, Stats stat)
|
||||
{
|
||||
throwIfPresent(base);
|
||||
|
||||
final double amount = creature.getStat().getValue(Stats.ABSORB_DAMAGE_PERCENT, 0) * 100;
|
||||
final double vampiricSum = creature.getStat().getVampiricSum();
|
||||
|
||||
return amount > 0 ? Stats.defaultValue(creature, stat, Math.min(1.0, vampiricSum / amount / 100)) : 0;
|
||||
}
|
||||
}
|
||||
@@ -1,130 +1,130 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.stats.functions;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* A Function 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...).<br>
|
||||
* In fact, each calculator is a table of functions object in which each function represents a mathematics function:<br>
|
||||
* FuncAtkAccuracy -> Math.sqrt(_player.getDEX())*6+_player.getLevel()<br>
|
||||
* When the calc method of a calculator is launched, each mathematics function is called according to its priority <B>_order</B>.<br>
|
||||
* Indeed, functions with lowest priority order is executed first and functions with the same order are executed in unspecified order.<br>
|
||||
* @author Zoey76
|
||||
*/
|
||||
public abstract class AbstractFunction
|
||||
{
|
||||
/** Logger. */
|
||||
protected static final Logger LOG = Logger.getLogger(AbstractFunction.class.getName());
|
||||
/** Statistics, that is affected by this function (See L2Character.CALCULATOR_XXX constants) */
|
||||
private final Stats _stat;
|
||||
/**
|
||||
* Order of functions calculation.<br>
|
||||
* Functions with lower order are executed first.<br>
|
||||
* Functions with the same order are executed in unspecified order.<br>
|
||||
* Usually add/subtract functions has lowest order,<br>
|
||||
* then bonus/penalty functions (multiply/divide) are applied, then functions that do more complex<br>
|
||||
* calculations (non-linear functions).
|
||||
*/
|
||||
private final int _order;
|
||||
/**
|
||||
* Owner can be an armor, weapon, skill, system event, quest, etc.<br>
|
||||
* Used to remove all functions added by this owner.
|
||||
*/
|
||||
private final Object _funcOwner;
|
||||
/** Function may be disabled by attached condition. */
|
||||
private final Condition _applayCond;
|
||||
/** The value. */
|
||||
private final double _value;
|
||||
|
||||
/**
|
||||
* Constructor of Func.
|
||||
* @param stat the stat
|
||||
* @param order the order
|
||||
* @param owner the owner
|
||||
* @param value the value
|
||||
* @param applayCond the apply condition
|
||||
*/
|
||||
public AbstractFunction(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
_stat = stat;
|
||||
_order = order;
|
||||
_funcOwner = owner;
|
||||
_value = value;
|
||||
_applayCond = applayCond;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the apply condition
|
||||
* @return the apply condition
|
||||
*/
|
||||
public Condition getApplayCond()
|
||||
{
|
||||
return _applayCond;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fuction owner.
|
||||
* @return the function owner
|
||||
*/
|
||||
public final Object getFuncOwner()
|
||||
{
|
||||
return _funcOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function order.
|
||||
* @return the order
|
||||
*/
|
||||
public final int getOrder()
|
||||
{
|
||||
return _order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stat.
|
||||
* @return the stat
|
||||
*/
|
||||
public final Stats getStat()
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
* @return the value
|
||||
*/
|
||||
public final double getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the mathematics function of the Func.
|
||||
* @param effector the effector
|
||||
* @param effected the effected
|
||||
* @param skill the skill
|
||||
* @param initVal the initial value
|
||||
* @return the calculated value
|
||||
*/
|
||||
public abstract double calc(L2Character effector, L2Character effected, Skill skill, double initVal);
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* A Function 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...).<br>
|
||||
* In fact, each calculator is a table of functions object in which each function represents a mathematics function:<br>
|
||||
* FuncAtkAccuracy -> Math.sqrt(_player.getDEX())*6+_player.getLevel()<br>
|
||||
* When the calc method of a calculator is launched, each mathematics function is called according to its priority <B>_order</B>.<br>
|
||||
* Indeed, functions with lowest priority order is executed first and functions with the same order are executed in unspecified order.<br>
|
||||
* @author Zoey76
|
||||
*/
|
||||
public abstract class AbstractFunction
|
||||
{
|
||||
/** Logger. */
|
||||
protected static final Logger LOG = Logger.getLogger(AbstractFunction.class.getName());
|
||||
/** Statistics, that is affected by this function (See L2Character.CALCULATOR_XXX constants) */
|
||||
private final Stats _stat;
|
||||
/**
|
||||
* Order of functions calculation.<br>
|
||||
* Functions with lower order are executed first.<br>
|
||||
* Functions with the same order are executed in unspecified order.<br>
|
||||
* Usually add/subtract functions has lowest order,<br>
|
||||
* then bonus/penalty functions (multiply/divide) are applied, then functions that do more complex<br>
|
||||
* calculations (non-linear functions).
|
||||
*/
|
||||
private final int _order;
|
||||
/**
|
||||
* Owner can be an armor, weapon, skill, system event, quest, etc.<br>
|
||||
* Used to remove all functions added by this owner.
|
||||
*/
|
||||
private final Object _funcOwner;
|
||||
/** Function may be disabled by attached condition. */
|
||||
private final Condition _applayCond;
|
||||
/** The value. */
|
||||
private final double _value;
|
||||
|
||||
/**
|
||||
* Constructor of Func.
|
||||
* @param stat the stat
|
||||
* @param order the order
|
||||
* @param owner the owner
|
||||
* @param value the value
|
||||
* @param applayCond the apply condition
|
||||
*/
|
||||
public AbstractFunction(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
_stat = stat;
|
||||
_order = order;
|
||||
_funcOwner = owner;
|
||||
_value = value;
|
||||
_applayCond = applayCond;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the apply condition
|
||||
* @return the apply condition
|
||||
*/
|
||||
public Condition getApplayCond()
|
||||
{
|
||||
return _applayCond;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fuction owner.
|
||||
* @return the function owner
|
||||
*/
|
||||
public final Object getFuncOwner()
|
||||
{
|
||||
return _funcOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function order.
|
||||
* @return the order
|
||||
*/
|
||||
public final int getOrder()
|
||||
{
|
||||
return _order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stat.
|
||||
* @return the stat
|
||||
*/
|
||||
public final Stats getStat()
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
* @return the value
|
||||
*/
|
||||
public final double getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the mathematics function of the Func.
|
||||
* @param effector the effector
|
||||
* @param effected the effected
|
||||
* @param skill the skill
|
||||
* @param initVal the initial value
|
||||
* @return the calculated value
|
||||
*/
|
||||
public abstract double calc(L2Character effector, L2Character effected, Skill skill, double initVal);
|
||||
}
|
||||
|
||||
@@ -1,44 +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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value plus the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncAdd extends AbstractFunction
|
||||
{
|
||||
public FuncAdd(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return initVal + getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value plus the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncAdd extends AbstractFunction
|
||||
{
|
||||
public FuncAdd(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return initVal + getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value divided the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncDiv extends AbstractFunction
|
||||
{
|
||||
public FuncDiv(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
try
|
||||
{
|
||||
return initVal / getValue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warning(FuncDiv.class.getSimpleName() + ": Division by zero: " + getValue() + "!");
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value divided the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncDiv extends AbstractFunction
|
||||
{
|
||||
public FuncDiv(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
try
|
||||
{
|
||||
return initVal / getValue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warning(FuncDiv.class.getSimpleName() + ": Division by zero: " + getValue() + "!");
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.WeaponType;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
public class FuncEnchant extends AbstractFunction
|
||||
{
|
||||
public FuncEnchant(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
|
||||
int enchant = item.getEnchantLevel();
|
||||
if (enchant <= 0)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
int overenchant = 0;
|
||||
if (enchant > 3)
|
||||
{
|
||||
overenchant = enchant - 3;
|
||||
enchant = 3;
|
||||
}
|
||||
|
||||
if (effector.isPlayer() && effector.getActingPlayer().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 ((getStat() == Stats.MAGIC_DEFENCE) || (getStat() == Stats.POWER_DEFENCE))
|
||||
{
|
||||
switch (item.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case R:
|
||||
{
|
||||
value += (2 * enchant) + (4 * overenchant);
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
case A:
|
||||
case B:
|
||||
case C:
|
||||
case D:
|
||||
case NONE:
|
||||
{
|
||||
value += enchant + (3 * overenchant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
if (getStat() == Stats.MAGIC_ATTACK)
|
||||
{
|
||||
switch (item.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case R:
|
||||
{
|
||||
// M. Atk. increases by 5 for all weapons.
|
||||
// Starting at +4, M. Atk. bonus double.
|
||||
value += (5 * enchant) + (10 * overenchant);
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
// M. Atk. increases by 4 for all weapons.
|
||||
// Starting at +4, M. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overenchant);
|
||||
break;
|
||||
}
|
||||
case A:
|
||||
case B:
|
||||
case C:
|
||||
{
|
||||
// M. Atk. increases by 3 for all weapons.
|
||||
// Starting at +4, M. Atk. bonus double.
|
||||
value += (3 * enchant) + (6 * overenchant);
|
||||
break;
|
||||
}
|
||||
case D:
|
||||
case NONE:
|
||||
{
|
||||
// M. Atk. increases by 2 for all weapons. Starting at +4, M. Atk. bonus double.
|
||||
// Starting at +4, M. Atk. bonus double.
|
||||
value += (2 * enchant) + (4 * overenchant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
if (item.isWeapon())
|
||||
{
|
||||
final WeaponType type = (WeaponType) item.getItemType();
|
||||
switch (item.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case R:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if ((type == WeaponType.BOW) || (type == WeaponType.CROSSBOW))
|
||||
{
|
||||
// P. Atk. increases by 12 for bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (12 * enchant) + (24 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 7 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (7 * enchant) + (14 * overenchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 6 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (6 * enchant) + (12 * overenchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if ((type == WeaponType.BOW) || (type == WeaponType.CROSSBOW))
|
||||
{
|
||||
// P. Atk. increases by 10 for bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (10 * enchant) + (20 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 6 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (6 * enchant) + (12 * overenchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 5 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (5 * enchant) + (10 * overenchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case A:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if ((type == WeaponType.BOW) || (type == WeaponType.CROSSBOW))
|
||||
{
|
||||
// P. Atk. increases by 8 for bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (8 * enchant) + (16 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 5 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (5 * enchant) + (10 * overenchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 4 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overenchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B:
|
||||
case C:
|
||||
{
|
||||
if (item.getWeaponItem().getBodyPart() == L2Item.SLOT_LR_HAND)
|
||||
{
|
||||
if ((type == WeaponType.BOW) || (type == WeaponType.CROSSBOW))
|
||||
{
|
||||
// P. Atk. increases by 6 for bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (6 * enchant) + (12 * overenchant);
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 4 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overenchant);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// P. Atk. increases by 3 for one-handed swords, one-handed blunts, daggers, spears, and other weapons.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (3 * enchant) + (6 * overenchant);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case D:
|
||||
case NONE:
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BOW:
|
||||
case CROSSBOW:
|
||||
{
|
||||
// Bows increase by 4.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (4 * enchant) + (8 * overenchant);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// P. Atk. increases by 2 for all weapons with the exception of bows.
|
||||
// Starting at +4, P. Atk. bonus double.
|
||||
value += (2 * enchant) + (4 * overenchant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
public class FuncEnchantAccEvas extends AbstractFunction
|
||||
{
|
||||
private static final double blessedBonus = 1.5;
|
||||
|
||||
public FuncEnchantAccEvas(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
|
||||
if (item.getEnchantLevel() > 3)
|
||||
{
|
||||
// Increases Phys.Evasion / Mag. Evasion for helmets
|
||||
// Increases Phys.Accuracy / Mag.Accuracy for gloves
|
||||
if (item.getEnchantLevel() == 4)
|
||||
{
|
||||
value += 0.2 * blessedBonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
value += 0.2 * blessedBonus * ((item.getEnchantLevel() * 2) - 9);
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemBonusData;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author Yamaneko
|
||||
*/
|
||||
public class FuncEnchantHp extends AbstractFunction
|
||||
{
|
||||
public FuncEnchantHp(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return initVal;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
|
||||
if (item.getEnchantLevel() > 0)
|
||||
{
|
||||
return initVal + EnchantItemBonusData.getInstance().getHPBonus(item);
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
public class FuncEnchantMAtk extends AbstractFunction
|
||||
{
|
||||
private static final double blessedBonus = 1.5;
|
||||
|
||||
public FuncEnchantMAtk(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
|
||||
if (item.getEnchantLevel() > 3)
|
||||
{
|
||||
// Increases Mag. Atk for chest
|
||||
if (item.getEnchantLevel() == 4)
|
||||
{
|
||||
value += 1.4 * blessedBonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
value += 1.4 * blessedBonus * ((item.getEnchantLevel() * 2) - 9);
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
public class FuncEnchantPAtk extends AbstractFunction
|
||||
{
|
||||
private static final double blessedBonus = 1.5;
|
||||
|
||||
public FuncEnchantPAtk(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
|
||||
if (item.getEnchantLevel() > 3)
|
||||
{
|
||||
// Increases Phys.Atk for chest
|
||||
if (item.getEnchantLevel() == 4)
|
||||
{
|
||||
value += 2 * blessedBonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
value += 2 * blessedBonus * ((item.getEnchantLevel() * 2) - 9);
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
public class FuncEnchantPMCritRate extends AbstractFunction
|
||||
{
|
||||
private static final double blessedBonus = 1.5;
|
||||
|
||||
public FuncEnchantPMCritRate(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
|
||||
if (item.getEnchantLevel() > 3)
|
||||
{
|
||||
// Increases P. Critical Rate / magic damage for legs
|
||||
if (item.getEnchantLevel() == 4)
|
||||
{
|
||||
value += 0.34 * blessedBonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
value += 0.34 * blessedBonus * ((item.getEnchantLevel() * 2) - 9);
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
public abstract class FuncEnchantRunSpd extends AbstractFunction
|
||||
{
|
||||
private static final double blessedBonus = 1.5;
|
||||
|
||||
public FuncEnchantRunSpd(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
|
||||
if (item.getEnchantLevel() > 3)
|
||||
{
|
||||
// Increases speed for feets
|
||||
if (item.getEnchantLevel() == 4)
|
||||
{
|
||||
value += 0.6 * blessedBonus;
|
||||
}
|
||||
else
|
||||
{
|
||||
value += 0.6 * blessedBonus * ((item.getEnchantLevel() * 2) - 9);
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value plus the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncMul extends AbstractFunction
|
||||
{
|
||||
public FuncMul(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return initVal * getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value plus the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncMul extends AbstractFunction
|
||||
{
|
||||
public FuncMul(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return initVal * getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncSet extends AbstractFunction
|
||||
{
|
||||
public FuncSet(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncSet extends AbstractFunction
|
||||
{
|
||||
public FuncSet(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncShare extends AbstractFunction
|
||||
{
|
||||
public FuncShare(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
if ((effector != null) && effector.isServitor())
|
||||
{
|
||||
final L2Summon summon = (L2Summon) effector;
|
||||
final L2PcInstance player = summon.getOwner();
|
||||
if (player != null)
|
||||
{
|
||||
return initVal + (getBaseValue(getStat(), player) * getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
|
||||
public static double getBaseValue(Stats stat, L2PcInstance player)
|
||||
{
|
||||
switch (stat)
|
||||
{
|
||||
case MAX_HP:
|
||||
{
|
||||
return player.getMaxHp();
|
||||
}
|
||||
case MAX_MP:
|
||||
{
|
||||
return player.getMaxMp();
|
||||
}
|
||||
case PHYSICAL_ATTACK:
|
||||
{
|
||||
return player.getPAtk();
|
||||
}
|
||||
case MAGIC_ATTACK:
|
||||
{
|
||||
return player.getMAtk();
|
||||
}
|
||||
case PHYSICAL_DEFENCE:
|
||||
{
|
||||
return player.getPDef();
|
||||
}
|
||||
case MAGICAL_DEFENCE:
|
||||
{
|
||||
return player.getMDef();
|
||||
}
|
||||
case CRITICAL_RATE:
|
||||
{
|
||||
return player.getCriticalHit();
|
||||
}
|
||||
case PHYSICAL_ATTACK_SPEED:
|
||||
{
|
||||
return player.getPAtkSpd();
|
||||
}
|
||||
case MAGIC_ATTACK_SPEED:
|
||||
{
|
||||
return player.getMAtkSpd();
|
||||
}
|
||||
default:
|
||||
{
|
||||
return player.getStat().getValue(stat, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value minus the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncSub extends AbstractFunction
|
||||
{
|
||||
public FuncSub(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return initVal - getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Returns the initial value minus the function value, if the condition are met.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class FuncSub extends AbstractFunction
|
||||
{
|
||||
public FuncSub(Stats stat, int order, Object owner, double value, Condition applayCond)
|
||||
{
|
||||
super(stat, order, owner, value, applayCond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
if ((getApplayCond() == null) || getApplayCond().test(effector, effected, skill))
|
||||
{
|
||||
return initVal - getValue();
|
||||
}
|
||||
return initVal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,155 +1,111 @@
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.StatFunction;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Function template.
|
||||
* @author mkizub, Zoey76
|
||||
*/
|
||||
public final class FuncTemplate
|
||||
{
|
||||
private static final Logger LOG = Logger.getLogger(FuncTemplate.class.getName());
|
||||
|
||||
private final Condition _attachCond;
|
||||
private final Condition _applayCond;
|
||||
private final Constructor<?> _constructor;
|
||||
private final Stats _stat;
|
||||
private final int _order;
|
||||
private final double _value;
|
||||
|
||||
public FuncTemplate(Condition attachCond, Condition applayCond, String functionName, int order, Stats stat, double value)
|
||||
{
|
||||
final StatFunction function = StatFunction.valueOf(functionName.toUpperCase());
|
||||
if (order >= 0)
|
||||
{
|
||||
_order = order;
|
||||
}
|
||||
else
|
||||
{
|
||||
_order = function.getOrder();
|
||||
}
|
||||
|
||||
_attachCond = attachCond;
|
||||
_applayCond = applayCond;
|
||||
_stat = stat;
|
||||
_value = value;
|
||||
|
||||
try
|
||||
{
|
||||
final Class<?> functionClass = Class.forName("com.l2jmobius.gameserver.model.stats.functions.Func" + function.getName());
|
||||
_constructor = functionClass.getConstructor(Stats.class, // Stats to update
|
||||
Integer.TYPE, // Order of execution
|
||||
Object.class, // Owner
|
||||
Double.TYPE, // Value for function
|
||||
Condition.class // Condition
|
||||
);
|
||||
}
|
||||
catch (ClassNotFoundException | NoSuchMethodException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function stat.
|
||||
* @return the stat.
|
||||
*/
|
||||
public Stats getStat()
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function priority order.
|
||||
* @return the order
|
||||
*/
|
||||
public int getOrder()
|
||||
{
|
||||
return _order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function value.
|
||||
* @return the value
|
||||
*/
|
||||
public double getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the functions for skills.
|
||||
* @param caster the caster
|
||||
* @param target the target
|
||||
* @param skill the skill
|
||||
* @param owner the owner
|
||||
* @return the function if conditions are met, {@code null} otherwise
|
||||
*/
|
||||
public AbstractFunction getFunc(L2Character caster, L2Character target, Skill skill, Object owner)
|
||||
{
|
||||
return getFunc(caster, target, skill, null, owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the functions for items.
|
||||
* @param caster the caster
|
||||
* @param target the target
|
||||
* @param item the item
|
||||
* @param owner the owner
|
||||
* @return the function if conditions are met, {@code null} otherwise
|
||||
*/
|
||||
public AbstractFunction getFunc(L2Character caster, L2Character target, L2ItemInstance item, Object owner)
|
||||
{
|
||||
return getFunc(caster, target, null, item, owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the functions for skills and items.
|
||||
* @param caster the caster
|
||||
* @param target the target
|
||||
* @param skill the skill
|
||||
* @param item the item
|
||||
* @param owner the owner
|
||||
* @return the function if conditions are met, {@code null} otherwise
|
||||
*/
|
||||
private AbstractFunction getFunc(L2Character caster, L2Character target, Skill skill, L2ItemInstance item, Object owner)
|
||||
{
|
||||
if ((_attachCond != null) && !_attachCond.test(caster, target, skill))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
return (AbstractFunction) _constructor.newInstance(_stat, _order, owner, _value, _applayCond);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warning(FuncTemplate.class.getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.model.stats.functions;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.StatFunction;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
|
||||
/**
|
||||
* Function template.
|
||||
* @author mkizub, Zoey76
|
||||
*/
|
||||
public final class FuncTemplate
|
||||
{
|
||||
private final Class<?> _functionClass;
|
||||
private final Condition _attachCond;
|
||||
private final Condition _applayCond;
|
||||
private final Stats _stat;
|
||||
private final int _order;
|
||||
private final double _value;
|
||||
|
||||
public FuncTemplate(Condition attachCond, Condition applayCond, String functionName, int order, Stats stat, double value)
|
||||
{
|
||||
final StatFunction function = StatFunction.valueOf(functionName.toUpperCase());
|
||||
if (order >= 0)
|
||||
{
|
||||
_order = order;
|
||||
}
|
||||
else
|
||||
{
|
||||
_order = function.getOrder();
|
||||
}
|
||||
|
||||
_attachCond = attachCond;
|
||||
_applayCond = applayCond;
|
||||
_stat = stat;
|
||||
_value = value;
|
||||
|
||||
try
|
||||
{
|
||||
_functionClass = Class.forName("com.l2jmobius.gameserver.model.stats.functions.Func" + function.getName());
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Class<?> getFunctionClass()
|
||||
{
|
||||
return _functionClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function stat.
|
||||
* @return the stat.
|
||||
*/
|
||||
public Stats getStat()
|
||||
{
|
||||
return _stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function priority order.
|
||||
* @return the order
|
||||
*/
|
||||
public int getOrder()
|
||||
{
|
||||
return _order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function value.
|
||||
* @return the value
|
||||
*/
|
||||
public double getValue()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
public boolean meetCondition(L2Character effected, Skill skill)
|
||||
{
|
||||
if ((_attachCond != null) && !_attachCond.test(effected, effected, skill))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((_applayCond != null) && !_applayCond.test(effected, effected, skill))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
|
||||
import com.l2jmobius.gameserver.model.L2ArmorSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncArmorSet extends AbstractFunction
|
||||
{
|
||||
private static final Map<Stats, FuncArmorSet> _fh_instance = new HashMap<>();
|
||||
|
||||
public static AbstractFunction getInstance(Stats st)
|
||||
{
|
||||
if (!_fh_instance.containsKey(st))
|
||||
{
|
||||
_fh_instance.put(st, new FuncArmorSet(st));
|
||||
}
|
||||
return _fh_instance.get(st);
|
||||
}
|
||||
|
||||
private FuncArmorSet(Stats stat)
|
||||
{
|
||||
super(stat, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
final L2PcInstance player = effector.getActingPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
final L2ItemInstance chest = player.getChestArmorInstance();
|
||||
if (chest != null)
|
||||
{
|
||||
final L2ArmorSet set = ArmorSetsData.getInstance().getSet(chest.getId());
|
||||
if ((set != null) && (set.getPiecesCount(player) >= set.getMinimumPieces()))
|
||||
{
|
||||
switch (getStat())
|
||||
{
|
||||
case STAT_STR:
|
||||
{
|
||||
value += set.getSTR();
|
||||
break;
|
||||
}
|
||||
case STAT_DEX:
|
||||
{
|
||||
value += set.getDEX();
|
||||
break;
|
||||
}
|
||||
case STAT_INT:
|
||||
{
|
||||
value += set.getINT();
|
||||
break;
|
||||
}
|
||||
case STAT_MEN:
|
||||
{
|
||||
value += set.getMEN();
|
||||
break;
|
||||
}
|
||||
case STAT_CON:
|
||||
{
|
||||
value += set.getCON();
|
||||
break;
|
||||
}
|
||||
case STAT_WIT:
|
||||
{
|
||||
value += set.getWIT();
|
||||
break;
|
||||
}
|
||||
case STAT_LUC:
|
||||
{
|
||||
value += set.getLUC();
|
||||
break;
|
||||
}
|
||||
case STAT_CHA:
|
||||
{
|
||||
value += set.getCHA();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncAtkAccuracy extends AbstractFunction
|
||||
{
|
||||
private static final FuncAtkAccuracy _faa_instance = new FuncAtkAccuracy();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _faa_instance;
|
||||
}
|
||||
|
||||
private FuncAtkAccuracy()
|
||||
{
|
||||
super(Stats.ACCURACY_COMBAT, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
final int level = effector.getLevel();
|
||||
// [Square(DEX)] * 5 + lvl + weapon hitbonus;
|
||||
double value = initVal + (Math.sqrt(effector.getDEX()) * 5) + level;
|
||||
if (level > 77)
|
||||
{
|
||||
value += 1;
|
||||
}
|
||||
if (level > 80)
|
||||
{
|
||||
value += 2;
|
||||
}
|
||||
if (level > 87)
|
||||
{
|
||||
value += 2;
|
||||
}
|
||||
if (level > 92)
|
||||
{
|
||||
value += 1;
|
||||
}
|
||||
if (level > 97)
|
||||
{
|
||||
value += 1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncAtkEvasion extends AbstractFunction
|
||||
{
|
||||
private static final FuncAtkEvasion _fae_instance = new FuncAtkEvasion();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fae_instance;
|
||||
}
|
||||
|
||||
private FuncAtkEvasion()
|
||||
{
|
||||
super(Stats.EVASION_RATE, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
final int level = effector.getLevel();
|
||||
// [Square(DEX)] * 5 + lvl;
|
||||
double value = initVal + (Math.sqrt(effector.getDEX()) * 5) + level;
|
||||
if (effector.isPlayer())
|
||||
{
|
||||
if (level > 69)
|
||||
{
|
||||
value += level - 69;
|
||||
}
|
||||
if (level > 77)
|
||||
{
|
||||
value += 1;
|
||||
}
|
||||
if (level > 80)
|
||||
{
|
||||
value += 2;
|
||||
}
|
||||
if (level > 87)
|
||||
{
|
||||
value += 2;
|
||||
}
|
||||
if (level > 92)
|
||||
{
|
||||
value += 1;
|
||||
}
|
||||
if (level > 97)
|
||||
{
|
||||
value += 1;
|
||||
}
|
||||
}
|
||||
else if (level > 69)
|
||||
{
|
||||
value += (level - 69) + 2;
|
||||
}
|
||||
return (int) value;
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncHenna extends AbstractFunction
|
||||
{
|
||||
private static final Map<Stats, FuncHenna> _fh_instance = new HashMap<>();
|
||||
|
||||
public static AbstractFunction getInstance(Stats st)
|
||||
{
|
||||
if (!_fh_instance.containsKey(st))
|
||||
{
|
||||
_fh_instance.put(st, new FuncHenna(st));
|
||||
}
|
||||
return _fh_instance.get(st);
|
||||
}
|
||||
|
||||
private FuncHenna(Stats stat)
|
||||
{
|
||||
super(stat, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
final L2PcInstance pc = effector.getActingPlayer();
|
||||
double value = initVal;
|
||||
if (pc != null)
|
||||
{
|
||||
switch (getStat())
|
||||
{
|
||||
case STAT_STR:
|
||||
{
|
||||
value += pc.getHennaStatSTR();
|
||||
break;
|
||||
}
|
||||
case STAT_CON:
|
||||
{
|
||||
value += pc.getHennaStatCON();
|
||||
break;
|
||||
}
|
||||
case STAT_DEX:
|
||||
{
|
||||
value += pc.getHennaStatDEX();
|
||||
break;
|
||||
}
|
||||
case STAT_INT:
|
||||
{
|
||||
value += pc.getHennaStatINT();
|
||||
break;
|
||||
}
|
||||
case STAT_WIT:
|
||||
{
|
||||
value += pc.getHennaStatWIT();
|
||||
break;
|
||||
}
|
||||
case STAT_MEN:
|
||||
{
|
||||
value += pc.getHennaStatMEN();
|
||||
break;
|
||||
}
|
||||
case STAT_LUC:
|
||||
{
|
||||
value += pc.getHennaStatLUC();
|
||||
break;
|
||||
}
|
||||
case STAT_CHA:
|
||||
{
|
||||
value += pc.getHennaStatCHA();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMAtkMod extends AbstractFunction
|
||||
{
|
||||
private static final FuncMAtkMod _fma_instance = new FuncMAtkMod();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fma_instance;
|
||||
}
|
||||
|
||||
private FuncMAtkMod()
|
||||
{
|
||||
super(Stats.MAGIC_ATTACK, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
// Level Modifier^2 * INT Modifier^2
|
||||
final double lvlMod = effector.isPlayer() ? BaseStats.INT.calcBonus(effector.getActingPlayer()) : BaseStats.INT.calcBonus(effector);
|
||||
final double intMod = effector.isPlayer() ? effector.getActingPlayer().getLevelMod() : effector.getLevelMod();
|
||||
return initVal * Math.pow(lvlMod, 2) * Math.pow(intMod, 2) * BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMDefMod extends AbstractFunction
|
||||
{
|
||||
private static final FuncMDefMod _fmm_instance = new FuncMDefMod();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fmm_instance;
|
||||
}
|
||||
|
||||
private FuncMDefMod()
|
||||
{
|
||||
super(Stats.MAGIC_DEFENCE, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if (effector.isPlayer())
|
||||
{
|
||||
final L2PcInstance p = effector.getActingPlayer();
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_LFINGER))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_LFINGER) : Inventory.PAPERDOLL_LFINGER);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_RFINGER))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_RFINGER) : Inventory.PAPERDOLL_RFINGER);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_LEAR))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_LEAR) : Inventory.PAPERDOLL_LEAR);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_REAR))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_REAR) : Inventory.PAPERDOLL_REAR);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_NECK))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_NECK) : Inventory.PAPERDOLL_NECK);
|
||||
}
|
||||
value *= BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
else if (effector.isPet() && (effector.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_NECK) != 0))
|
||||
{
|
||||
value -= 13;
|
||||
}
|
||||
return value * BaseStats.MEN.calcBonus(effector) * effector.getLevelMod();
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMatkEvasion extends AbstractFunction
|
||||
{
|
||||
private static final FuncMatkEvasion _fae_instance = new FuncMatkEvasion();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fae_instance;
|
||||
}
|
||||
|
||||
private FuncMatkEvasion()
|
||||
{
|
||||
super(Stats.MAGIC_EVASION_RATE, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
final int level = effector.getLevel();
|
||||
double value = initVal;
|
||||
// [Square(WIT)] * 3 + lvl;
|
||||
value += (Math.sqrt(effector.getWIT()) * 3) + (level * 2);
|
||||
if (!effector.isPlayer())
|
||||
{
|
||||
if (level > 69)
|
||||
{
|
||||
value += (level - 69) + 2;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMaxHpMul extends AbstractFunction
|
||||
{
|
||||
private static final FuncMaxHpMul _fmhm_instance = new FuncMaxHpMul();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fmhm_instance;
|
||||
}
|
||||
|
||||
private FuncMaxHpMul()
|
||||
{
|
||||
super(Stats.MAX_HP, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.CON.calcBonus(effector) * BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncMaxMpMul extends AbstractFunction
|
||||
{
|
||||
private static final FuncMaxMpMul _fmmm_instance = new FuncMaxMpMul();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fmmm_instance;
|
||||
}
|
||||
|
||||
private FuncMaxMpMul()
|
||||
{
|
||||
super(Stats.MAX_MP, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.MEN.calcBonus(effector) * BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncPAtkMod extends AbstractFunction
|
||||
{
|
||||
private static final FuncPAtkMod _fpa_instance = new FuncPAtkMod();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fpa_instance;
|
||||
}
|
||||
|
||||
private FuncPAtkMod()
|
||||
{
|
||||
super(Stats.POWER_ATTACK, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.STR.calcBonus(effector) * effector.getLevelMod() * BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncPAtkSpeed extends AbstractFunction
|
||||
{
|
||||
private static final FuncPAtkSpeed _fas_instance = new FuncPAtkSpeed();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fas_instance;
|
||||
}
|
||||
|
||||
private FuncPAtkSpeed()
|
||||
{
|
||||
super(Stats.POWER_ATTACK_SPEED, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
return initVal * BaseStats.DEX.calcBonus(effector) * BaseStats.CHA.calcBonus(effector);
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* 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.model.stats.functions.formulas;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.model.stats.BaseStats;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class FuncPDefMod extends AbstractFunction
|
||||
{
|
||||
private static final FuncPDefMod _fmm_instance = new FuncPDefMod();
|
||||
|
||||
public static AbstractFunction getInstance()
|
||||
{
|
||||
return _fmm_instance;
|
||||
}
|
||||
|
||||
private FuncPDefMod()
|
||||
{
|
||||
super(Stats.POWER_DEFENCE, 1, null, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
|
||||
{
|
||||
double value = initVal;
|
||||
if (effector.isPlayer())
|
||||
{
|
||||
final L2PcInstance p = effector.getActingPlayer();
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_CHEST))
|
||||
{
|
||||
value -= p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_CHEST) : p.getTemplate().getBaseDefBySlot(Inventory.PAPERDOLL_CHEST);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_LEGS) || (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_CHEST) && (p.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR)))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_LEGS) : Inventory.PAPERDOLL_LEGS);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_HEAD))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_HEAD) : Inventory.PAPERDOLL_HEAD);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_FEET))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_FEET) : Inventory.PAPERDOLL_FEET);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_GLOVES))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_GLOVES) : Inventory.PAPERDOLL_GLOVES);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_UNDER))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_UNDER) : Inventory.PAPERDOLL_UNDER);
|
||||
}
|
||||
if (!p.getInventory().isPaperdollSlotEmpty(Inventory.PAPERDOLL_CLOAK))
|
||||
{
|
||||
value -= p.getTemplate().getBaseDefBySlot(p.isTransformed() ? p.getTransformation().getBaseDefBySlot(p, Inventory.PAPERDOLL_CLOAK) : Inventory.PAPERDOLL_CLOAK);
|
||||
}
|
||||
|
||||
value *= BaseStats.CHA.calcBonus(p);
|
||||
}
|
||||
return value * effector.getLevelMod();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user