Merged with released L2J-Unity files.

This commit is contained in:
mobiusdev
2016-06-12 01:34:09 +00:00
parent e003e87887
commit 635557f5da
18352 changed files with 3245113 additions and 2892959 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -0,0 +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.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);
}
}

View File

@@ -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));
}
}

View File

@@ -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());
}
}

View File

@@ -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));
}
}

View File

@@ -0,0 +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.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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}
}

View File

@@ -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));
}
}

View File

@@ -0,0 +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.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);
}
}

View File

@@ -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));
}
}

View File

@@ -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());
}
}

View File

@@ -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));
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.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);
}
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.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);
}
}

View File

@@ -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);
}
}

View File

@@ -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
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,40 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.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;
}
}