Additional weakness calculations.
This commit is contained in:
@ -87,6 +87,11 @@ public class CreatureStat
|
||||
public CreatureStat(Creature creature)
|
||||
{
|
||||
_creature = creature;
|
||||
for (int i = 0; i < TraitType.values().length; i++)
|
||||
{
|
||||
_attackTraitValues[i] = 1;
|
||||
_defenceTraitValues[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -583,8 +588,33 @@ public class CreatureStat
|
||||
|
||||
public void mergeAttackTrait(TraitType traitType, float value)
|
||||
{
|
||||
_attackTraitValues[traitType.ordinal()] *= value;
|
||||
_attackTraits.add(traitType);
|
||||
_lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
_attackTraitValues[traitType.ordinal()] *= value;
|
||||
_attackTraits.add(traitType);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAttackTrait(TraitType traitType, float value)
|
||||
{
|
||||
_lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
_attackTraitValues[traitType.ordinal()] /= value;
|
||||
if (_attackTraitValues[traitType.ordinal()] == 1)
|
||||
{
|
||||
_attackTraits.remove(traitType);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public float getAttackTrait(TraitType traitType)
|
||||
@ -615,8 +645,33 @@ public class CreatureStat
|
||||
|
||||
public void mergeDefenceTrait(TraitType traitType, float value)
|
||||
{
|
||||
_defenceTraitValues[traitType.ordinal()] *= value;
|
||||
_defenceTraits.add(traitType);
|
||||
_lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
_defenceTraitValues[traitType.ordinal()] *= value;
|
||||
_defenceTraits.add(traitType);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeDefenceTrait(TraitType traitType, float value)
|
||||
{
|
||||
_lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
_defenceTraitValues[traitType.ordinal()] /= value;
|
||||
if (_defenceTraitValues[traitType.ordinal()] == 1)
|
||||
{
|
||||
_defenceTraits.remove(traitType);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public float getDefenceTrait(TraitType traitType)
|
||||
@ -647,7 +702,28 @@ public class CreatureStat
|
||||
|
||||
public void mergeInvulnerableTrait(TraitType traitType)
|
||||
{
|
||||
_invulnerableTraits.add(traitType);
|
||||
_lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
_invulnerableTraits.add(traitType);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeInvulnerableTrait(TraitType traitType)
|
||||
{
|
||||
_lock.readLock().lock();
|
||||
try
|
||||
{
|
||||
_invulnerableTraits.remove(traitType);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInvulnerableTrait(TraitType traitType)
|
||||
|
@ -94,14 +94,15 @@ public final class Formulas
|
||||
}
|
||||
|
||||
// Critical
|
||||
final double criticalMod = (attacker.getStat().getValue(Stats.CRITICAL_DAMAGE, 1));
|
||||
final double criticalMod = attacker.getStat().getValue(Stats.CRITICAL_DAMAGE, 1);
|
||||
final double criticalPositionMod = attacker.getStat().getPositionTypeValue(Stats.CRITICAL_DAMAGE, Position.getPosition(attacker, target));
|
||||
final double criticalVulnMod = (target.getStat().getValue(Stats.DEFENCE_CRITICAL_DAMAGE, 1));
|
||||
final double criticalAddMod = (attacker.getStat().getValue(Stats.CRITICAL_DAMAGE_ADD, 0));
|
||||
final double criticalVulnMod = target.getStat().getValue(Stats.DEFENCE_CRITICAL_DAMAGE, 1);
|
||||
final double criticalAddMod = attacker.getStat().getValue(Stats.CRITICAL_DAMAGE_ADD, 0);
|
||||
final double criticalAddVuln = target.getStat().getValue(Stats.DEFENCE_CRITICAL_DAMAGE_ADD, 0);
|
||||
// Trait, elements
|
||||
final double weaponTraitMod = calcWeaponTraitBonus(attacker, target);
|
||||
final double generalTraitMod = calcGeneralTraitBonus(attacker, target, skill.getTraitType(), true);
|
||||
final double weaknessMod = calcWeaknessBonus(attacker, target, skill.getTraitType());
|
||||
final double attributeMod = calcAttributeBonus(attacker, target, skill);
|
||||
final double randomMod = attacker.getRandomDamageMultiplier();
|
||||
final double pvpPveMod = calculatePvpPveBonus(attacker, target, skill, true);
|
||||
@ -122,8 +123,8 @@ public final class Formulas
|
||||
// ........................_____________________________Initial Damage____________________________...___________Position Additional Damage___________..._CriticalAdd_
|
||||
// ATTACK CALCULATION 77 * [(skillpower+patk) * 0.666 * cdbonus * cdPosBonusHalf * cdVulnHalf * ss + isBack0.2Side0.05 * (skillpower+patk*ss) * random + 6 * cd_patk] / pdef
|
||||
// ````````````````````````^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^```^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^```^^^^^^^^^^^^
|
||||
final double baseMod = ((77 * (((power + attacker.getPAtk()) * 0.666) + (isPosition * (power + attacker.getPAtk()) * randomMod) + (6 * cdPatk))) / defence);
|
||||
final double damage = baseMod * ssmod * cdMult * weaponTraitMod * generalTraitMod * attributeMod * randomMod * pvpPveMod;
|
||||
final double baseMod = (77 * (((power + attacker.getPAtk()) * 0.666) + (isPosition * (power + attacker.getPAtk()) * randomMod) + (6 * cdPatk))) / defence;
|
||||
final double damage = baseMod * ssmod * cdMult * weaponTraitMod * generalTraitMod * weaknessMod * attributeMod * randomMod * pvpPveMod;
|
||||
|
||||
return damage;
|
||||
}
|
||||
@ -136,6 +137,7 @@ public final class Formulas
|
||||
|
||||
// Trait, elements
|
||||
final double generalTraitMod = calcGeneralTraitBonus(attacker, target, skill.getTraitType(), true);
|
||||
final double weaknessMod = calcWeaknessBonus(attacker, target, skill.getTraitType());
|
||||
final double attributeMod = calcAttributeBonus(attacker, target, skill);
|
||||
final double randomMod = attacker.getRandomDamageMultiplier();
|
||||
final double pvpPveMod = calculatePvpPveBonus(attacker, target, skill, mcrit);
|
||||
@ -178,7 +180,7 @@ public final class Formulas
|
||||
}
|
||||
}
|
||||
|
||||
damage = damage * critMod * generalTraitMod * attributeMod * randomMod * pvpPveMod;
|
||||
damage = damage * critMod * generalTraitMod * weaknessMod * attributeMod * randomMod * pvpPveMod;
|
||||
damage *= attacker.getStat().getValue(Stats.MAGICAL_SKILL_POWER, 1);
|
||||
|
||||
return damage;
|
||||
@ -1270,8 +1272,20 @@ public final class Formulas
|
||||
}
|
||||
}
|
||||
|
||||
final double result = (attacker.getStat().getAttackTrait(traitType) - target.getStat().getDefenceTrait(traitType)) + 1.0;
|
||||
return CommonUtil.constrain(result, 0.05, 2.0);
|
||||
return Math.max(attacker.getStat().getAttackTrait(traitType) - target.getStat().getDefenceTrait(traitType), 0.05);
|
||||
}
|
||||
|
||||
public static double calcWeaknessBonus(Creature attacker, Creature target, TraitType traitType)
|
||||
{
|
||||
double result = 1;
|
||||
for (TraitType trait : TraitType.getAllWeakness())
|
||||
{
|
||||
if ((traitType != trait) && target.getStat().hasDefenceTrait(trait) && attacker.getStat().hasAttackTrait(trait) && !target.getStat().isInvulnerableTrait(traitType))
|
||||
{
|
||||
result *= Math.max(attacker.getStat().getAttackTrait(trait) - target.getStat().getDefenceTrait(trait), 0.05);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static double calcWeaponTraitBonus(Creature attacker, Creature target)
|
||||
@ -1300,7 +1314,7 @@ public final class Formulas
|
||||
}
|
||||
}
|
||||
|
||||
return CommonUtil.constrain((weaponTraitBonus * weaknessBonus), 0.05, 2.0);
|
||||
return Math.max(weaponTraitBonus * weaknessBonus, 0.05);
|
||||
}
|
||||
|
||||
public static double getBasicPropertyResistBonus(BasicProperty basicProperty, Creature target)
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.stats;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, NosBit
|
||||
*/
|
||||
@ -88,6 +91,33 @@ public enum TraitType
|
||||
SPIRIT_WEAKNESS(2);
|
||||
|
||||
private final int _type; // 1 = weapon, 2 = weakness, 3 = resistance
|
||||
private final static List<TraitType> _weaknesses = new ArrayList<>();
|
||||
static
|
||||
{
|
||||
_weaknesses.add(BUG_WEAKNESS);
|
||||
_weaknesses.add(ANIMAL_WEAKNESS);
|
||||
_weaknesses.add(PLANT_WEAKNESS);
|
||||
_weaknesses.add(BEAST_WEAKNESS);
|
||||
_weaknesses.add(DRAGON_WEAKNESS);
|
||||
_weaknesses.add(GIANT_WEAKNESS);
|
||||
_weaknesses.add(CONSTRUCT_WEAKNESS);
|
||||
_weaknesses.add(VALAKAS);
|
||||
_weaknesses.add(ANESTHESIA);
|
||||
_weaknesses.add(DEMONIC_WEAKNESS);
|
||||
_weaknesses.add(DIVINE_WEAKNESS);
|
||||
_weaknesses.add(ELEMENTAL_WEAKNESS);
|
||||
_weaknesses.add(FAIRY_WEAKNESS);
|
||||
_weaknesses.add(HUMAN_WEAKNESS);
|
||||
_weaknesses.add(HUMANOID_WEAKNESS);
|
||||
_weaknesses.add(UNDEAD_WEAKNESS);
|
||||
_weaknesses.add(EMBRYO_WEAKNESS);
|
||||
_weaknesses.add(SPIRIT_WEAKNESS);
|
||||
}
|
||||
|
||||
public static List<TraitType> getAllWeakness()
|
||||
{
|
||||
return _weaknesses;
|
||||
}
|
||||
|
||||
TraitType(int type)
|
||||
{
|
||||
|
Reference in New Issue
Block a user