Addition of HpLimit effect handler.
Contributed by dontknowdontcare.
This commit is contained in:
@ -209,6 +209,7 @@ public class Config
|
||||
public static int MAX_PATK_SPEED;
|
||||
public static int MAX_MATK_SPEED;
|
||||
public static int MAX_EVASION;
|
||||
public static int MAX_HP;
|
||||
public static int MIN_ABNORMAL_STATE_SUCCESS_RATE;
|
||||
public static int MAX_ABNORMAL_STATE_SUCCESS_RATE;
|
||||
public static long MAX_SP;
|
||||
@ -1781,6 +1782,7 @@ public class Config
|
||||
MAX_PATK_SPEED = characterConfig.getInt("MaxPAtkSpeed", 1500);
|
||||
MAX_MATK_SPEED = characterConfig.getInt("MaxMAtkSpeed", 1999);
|
||||
MAX_EVASION = characterConfig.getInt("MaxEvasion", 250);
|
||||
MAX_HP = characterConfig.getInt("MaxHP", 150000);
|
||||
MIN_ABNORMAL_STATE_SUCCESS_RATE = characterConfig.getInt("MinAbnormalStateSuccessRate", 10);
|
||||
MAX_ABNORMAL_STATE_SUCCESS_RATE = characterConfig.getInt("MaxAbnormalStateSuccessRate", 90);
|
||||
MAX_SP = characterConfig.getLong("MaxSp", 50000000000L) >= 0 ? characterConfig.getLong("MaxSp", 50000000000L) : Long.MAX_VALUE;
|
||||
|
@ -756,8 +756,6 @@ public class Player extends Playable
|
||||
private int _cursedWeaponEquippedId = 0;
|
||||
private boolean _combatFlagEquippedId = false;
|
||||
|
||||
private boolean _isDragonWeaponEquipped = false;
|
||||
|
||||
private boolean _canRevive = true;
|
||||
private int _reviveRequested = 0;
|
||||
private double _revivePower = 0;
|
||||
@ -11441,16 +11439,6 @@ public class Player extends Playable
|
||||
return _cursedWeaponEquippedId;
|
||||
}
|
||||
|
||||
public void setDragonWeaponEquipped(boolean value)
|
||||
{
|
||||
_isDragonWeaponEquipped = value;
|
||||
}
|
||||
|
||||
public boolean isDragonWeaponEquipped()
|
||||
{
|
||||
return _isDragonWeaponEquipped;
|
||||
}
|
||||
|
||||
public boolean isCombatFlagEquipped()
|
||||
{
|
||||
return _combatFlagEquippedId;
|
||||
|
@ -38,6 +38,7 @@ public class Weapon extends ItemTemplate
|
||||
{
|
||||
private WeaponType _type;
|
||||
private boolean _isMagicWeapon;
|
||||
private boolean _isDragonWeapon;
|
||||
private int _soulShotCount;
|
||||
private int _spiritShotCount;
|
||||
private int _mpConsume;
|
||||
@ -73,6 +74,7 @@ public class Weapon extends ItemTemplate
|
||||
_type1 = ItemTemplate.TYPE1_WEAPON_RING_EARRING_NECKLACE;
|
||||
_type2 = ItemTemplate.TYPE2_WEAPON;
|
||||
_isMagicWeapon = set.getBoolean("is_magic_weapon", false);
|
||||
_isDragonWeapon = set.getBoolean("is_dragon_weapon", false);
|
||||
_soulShotCount = set.getInt("soulshots", 0);
|
||||
_spiritShotCount = set.getInt("spiritshots", 0);
|
||||
_mpConsume = set.getInt("mp_consume", 0);
|
||||
@ -138,6 +140,14 @@ public class Weapon extends ItemTemplate
|
||||
return _isMagicWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the weapon is a dragon weapon, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isDragonWeapon()
|
||||
{
|
||||
return _isDragonWeapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quantity of SoulShot used.
|
||||
*/
|
||||
|
@ -1612,7 +1612,8 @@ public class Formulas
|
||||
|
||||
// Dragon weapon defence stat.
|
||||
final double dragonDefense;
|
||||
if (attackerPlayer.isDragonWeaponEquipped())
|
||||
final Weapon weapon = attacker.getActiveWeaponItem();
|
||||
if ((weapon != null) && weapon.isDragonWeapon())
|
||||
{
|
||||
dragonDefense = target.getStat().getMul(Stat.DRAGON_WEAPON_DEFENCE, 1);
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ import org.l2jmobius.gameserver.util.MathUtil;
|
||||
public enum Stat
|
||||
{
|
||||
// HP, MP & CP
|
||||
HP_LIMIT("hpLimit"),
|
||||
MAX_HP("maxHp", new MaxHpFinalizer()),
|
||||
MAX_MP("maxMp", new MaxMpFinalizer()),
|
||||
MAX_CP("maxCp", new MaxCpFinalizer()),
|
||||
|
@ -18,11 +18,13 @@ package org.l2jmobius.gameserver.model.stats.finalizers;
|
||||
|
||||
import java.util.OptionalDouble;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemHPBonusData;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.Pet;
|
||||
import org.l2jmobius.gameserver.model.item.ItemTemplate;
|
||||
import org.l2jmobius.gameserver.model.item.Weapon;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.model.stats.BaseStat;
|
||||
@ -63,30 +65,64 @@ public class MaxHpFinalizer implements IStatFunction
|
||||
|
||||
private static double defaultValue(Creature creature, Stat stat, double baseValue)
|
||||
{
|
||||
final double mul = creature.getStat().getMul(stat);
|
||||
final double add = creature.getStat().getAdd(stat);
|
||||
double addItem = 0;
|
||||
double mul = creature.getStat().getMul(stat);
|
||||
double add = creature.getStat().getAdd(stat);
|
||||
|
||||
double maxHp = (mul * baseValue) + add + creature.getStat().getMoveTypeValue(stat, creature.getMoveType());
|
||||
final boolean isPlayer = creature.isPlayer();
|
||||
|
||||
final Inventory inv = creature.getInventory();
|
||||
if (inv != null)
|
||||
if (inv == null)
|
||||
{
|
||||
// Add maxHP bonus from items
|
||||
for (Item item : inv.getPaperdollItems())
|
||||
if (isPlayer)
|
||||
{
|
||||
addItem += item.getTemplate().getStats(stat, 0);
|
||||
|
||||
// Apply enchanted item bonus HP
|
||||
if (item.isArmor() && item.isEnchanted())
|
||||
if (creature.getActingPlayer().isCursedWeaponEquipped())
|
||||
{
|
||||
final int bodyPart = item.getTemplate().getBodyPart();
|
||||
if ((bodyPart != ItemTemplate.SLOT_NECK) && (bodyPart != ItemTemplate.SLOT_LR_EAR) && (bodyPart != ItemTemplate.SLOT_LR_FINGER))
|
||||
{
|
||||
addItem += EnchantItemHPBonusData.getInstance().getHPBonus(item);
|
||||
}
|
||||
return Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
mul = creature.getStat().getMul(Stat.HP_LIMIT);
|
||||
add = creature.getStat().getAdd(Stat.HP_LIMIT);
|
||||
return Math.min(maxHp, (Config.MAX_HP * mul) + add);
|
||||
}
|
||||
return maxHp;
|
||||
}
|
||||
|
||||
boolean shouldLiftLimit = false;
|
||||
|
||||
// Add maxHP bonus from items
|
||||
for (Item item : inv.getPaperdollItems())
|
||||
{
|
||||
maxHp += item.getTemplate().getStats(stat, 0);
|
||||
|
||||
// Apply enchanted item bonus HP
|
||||
if (item.isArmor() && item.isEnchanted())
|
||||
{
|
||||
final int bodyPart = item.getTemplate().getBodyPart();
|
||||
if ((bodyPart != ItemTemplate.SLOT_NECK) && (bodyPart != ItemTemplate.SLOT_LR_EAR) && (bodyPart != ItemTemplate.SLOT_LR_FINGER))
|
||||
{
|
||||
maxHp += EnchantItemHPBonusData.getInstance().getHPBonus(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.isWeapon() && item.getWeaponItem().isDragonWeapon())
|
||||
{
|
||||
shouldLiftLimit = true;
|
||||
}
|
||||
}
|
||||
|
||||
return (mul * baseValue) + add + addItem + creature.getStat().getMoveTypeValue(stat, creature.getMoveType());
|
||||
final double hpLimit;
|
||||
if (isPlayer && !shouldLiftLimit && !creature.getActingPlayer().isCursedWeaponEquipped())
|
||||
{
|
||||
mul = creature.getStat().getMul(Stat.HP_LIMIT);
|
||||
add = creature.getStat().getAdd(Stat.HP_LIMIT);
|
||||
hpLimit = (Config.MAX_HP * mul) + add;
|
||||
}
|
||||
else
|
||||
{
|
||||
hpLimit = Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
return Math.min(maxHp, hpLimit);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user