|
@@ -839,21 +839,10 @@ public final class Formulas
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static final Formulas _instance = new Formulas();
|
|
|
-
|
|
|
- public static Formulas getInstance()
|
|
|
- {
|
|
|
- return _instance;
|
|
|
- }
|
|
|
-
|
|
|
- private Formulas()
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Return the period between 2 regenerations task (3s for L2Character, 5 min for L2DoorInstance).<BR><BR>
|
|
|
*/
|
|
|
- public int getRegeneratePeriod(L2Character cha)
|
|
|
+ public static int getRegeneratePeriod(L2Character cha)
|
|
|
{
|
|
|
if (cha instanceof L2DoorInstance) return HP_REGENERATE_PERIOD * 100; // 5 mins
|
|
|
|
|
@@ -872,7 +861,7 @@ public final class Formulas
|
|
|
* To reduce cache memory use, L2NPCInstances who don't have skills share the same Calculator set called <B>NPC_STD_CALCULATOR</B>.<BR><BR>
|
|
|
*
|
|
|
*/
|
|
|
- public Calculator[] getStdNPCCalculators()
|
|
|
+ public static Calculator[] getStdNPCCalculators()
|
|
|
{
|
|
|
Calculator[] std = new Calculator[Stats.NUM_STATS];
|
|
|
|
|
@@ -887,7 +876,7 @@ public final class Formulas
|
|
|
return std;
|
|
|
}
|
|
|
|
|
|
- public Calculator[] getStdDoorCalculators()
|
|
|
+ public static Calculator[] getStdDoorCalculators()
|
|
|
{
|
|
|
Calculator[] std = new Calculator[Stats.NUM_STATS];
|
|
|
|
|
@@ -919,7 +908,7 @@ public final class Formulas
|
|
|
*
|
|
|
* @param cha L2PcInstance or L2Summon that must obtain basic Func objects
|
|
|
*/
|
|
|
- public void addFuncsToNewCharacter(L2Character cha)
|
|
|
+ public static void addFuncsToNewCharacter(L2Character cha)
|
|
|
{
|
|
|
if (cha instanceof L2PcInstance)
|
|
|
{
|
|
@@ -977,7 +966,7 @@ public final class Formulas
|
|
|
/**
|
|
|
* Calculate the HP regen rate (base + modifiers).<BR><BR>
|
|
|
*/
|
|
|
- public final double calcHpRegen(L2Character cha)
|
|
|
+ public static final double calcHpRegen(L2Character cha)
|
|
|
{
|
|
|
double init = cha.getTemplate().baseHpReg;
|
|
|
double hpRegenMultiplier = cha.isRaid() ? Config.RAID_HP_REGEN_MULTIPLIER : Config.HP_REGEN_MULTIPLIER;
|
|
@@ -1058,7 +1047,7 @@ public final class Formulas
|
|
|
/**
|
|
|
* Calculate the MP regen rate (base + modifiers).<BR><BR>
|
|
|
*/
|
|
|
- public final double calcMpRegen(L2Character cha)
|
|
|
+ public static final double calcMpRegen(L2Character cha)
|
|
|
{
|
|
|
double init = cha.getTemplate().baseMpReg;
|
|
|
double mpRegenMultiplier = cha.isRaid() ? Config.RAID_MP_REGEN_MULTIPLIER : Config.MP_REGEN_MULTIPLIER;
|
|
@@ -1131,7 +1120,7 @@ public final class Formulas
|
|
|
/**
|
|
|
* Calculate the CP regen rate (base + modifiers).<BR><BR>
|
|
|
*/
|
|
|
- public final double calcCpRegen(L2Character cha)
|
|
|
+ public static final double calcCpRegen(L2Character cha)
|
|
|
{
|
|
|
double init = cha.getTemplate().baseHpReg;
|
|
|
double cpRegenMultiplier = Config.CP_REGEN_MULTIPLIER;
|
|
@@ -1163,7 +1152,7 @@ public final class Formulas
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
- public final double calcFestivalRegenModifier(L2PcInstance activeChar)
|
|
|
+ public static final double calcFestivalRegenModifier(L2PcInstance activeChar)
|
|
|
{
|
|
|
final int[] festivalInfo = SevenSignsFestival.getInstance().getFestivalForPlayer(activeChar);
|
|
|
final int oracle = festivalInfo[0];
|
|
@@ -1186,7 +1175,7 @@ public final class Formulas
|
|
|
return 1.0 - (distToCenter * 0.0005); // Maximum Decreased Regen of ~ -65%;
|
|
|
}
|
|
|
|
|
|
- public final double calcSiegeRegenModifer(L2PcInstance activeChar)
|
|
|
+ public static final double calcSiegeRegenModifer(L2PcInstance activeChar)
|
|
|
{
|
|
|
if (activeChar == null || activeChar.getClan() == null) return 0;
|
|
|
|
|
@@ -1202,7 +1191,7 @@ public final class Formulas
|
|
|
return 1.5; // If all is true, then modifer will be 50% more
|
|
|
}
|
|
|
/** Calculate blow damage based on cAtk */
|
|
|
- public double calcBlowDamage(L2Character attacker, L2Character target, L2Skill skill, byte shld, boolean ss)
|
|
|
+ public static double calcBlowDamage(L2Character attacker, L2Character target, L2Skill skill, byte shld, boolean ss)
|
|
|
{
|
|
|
double power = skill.getPower();
|
|
|
double damage = attacker.getPAtk(target);
|
|
@@ -1274,7 +1263,7 @@ public final class Formulas
|
|
|
* @param ss if weapon item was charged by soulshot
|
|
|
* @return damage points
|
|
|
*/
|
|
|
- public final double calcPhysDam(L2Character attacker, L2Character target, L2Skill skill,
|
|
|
+ public static final double calcPhysDam(L2Character attacker, L2Character target, L2Skill skill,
|
|
|
byte shld, boolean crit, boolean dual, boolean ss)
|
|
|
{
|
|
|
double damage = attacker.getPAtk(target);
|
|
@@ -1463,7 +1452,7 @@ public final class Formulas
|
|
|
return damage;
|
|
|
}
|
|
|
|
|
|
- public final double calcMagicDam(L2Character attacker, L2Character target, L2Skill skill,
|
|
|
+ public static final double calcMagicDam(L2Character attacker, L2Character target, L2Skill skill,
|
|
|
byte shld, boolean ss, boolean bss, boolean mcrit)
|
|
|
{
|
|
|
double mAtk = attacker.getMAtk(target, skill);
|
|
@@ -1544,7 +1533,7 @@ public final class Formulas
|
|
|
return damage;
|
|
|
}
|
|
|
|
|
|
- public final double calcMagicDam(L2CubicInstance attacker, L2Character target, L2Skill skill, boolean mcrit, byte shld)
|
|
|
+ public static final double calcMagicDam(L2CubicInstance attacker, L2Character target, L2Skill skill, boolean mcrit, byte shld)
|
|
|
{
|
|
|
double mAtk = attacker.getMAtk();
|
|
|
double mDef = target.getMDef(attacker.getOwner(), skill);
|
|
@@ -1604,17 +1593,17 @@ public final class Formulas
|
|
|
}
|
|
|
|
|
|
/** Returns true in case of critical hit */
|
|
|
- public final boolean calcCrit(double rate)
|
|
|
+ public static final boolean calcCrit(double rate)
|
|
|
{
|
|
|
return rate > Rnd.get(1000);
|
|
|
}
|
|
|
/** Calculate value of blow success */
|
|
|
- public final boolean calcBlow(L2Character activeChar, L2Character target, int chance)
|
|
|
+ public static final boolean calcBlow(L2Character activeChar, L2Character target, int chance)
|
|
|
{
|
|
|
return activeChar.calcStat(Stats.BLOW_RATE, chance*(1.0+(activeChar.getDEX()-20)/100), target, null)>Rnd.get(100);
|
|
|
}
|
|
|
/** Calculate value of lethal chance */
|
|
|
- public final double calcLethal(L2Character activeChar, L2Character target, int baseLethal, int magiclvl)
|
|
|
+ public static final double calcLethal(L2Character activeChar, L2Character target, int baseLethal, int magiclvl)
|
|
|
{
|
|
|
double chance = 0;
|
|
|
if (magiclvl > 0)
|
|
@@ -1647,7 +1636,7 @@ public final class Formulas
|
|
|
return 10 * activeChar.calcStat(Stats.LETHAL_RATE, chance, target, null);
|
|
|
}
|
|
|
|
|
|
- public final boolean calcLethalHit(L2Character activeChar, L2Character target, L2Skill skill)
|
|
|
+ public static final boolean calcLethalHit(L2Character activeChar, L2Character target, L2Skill skill)
|
|
|
{
|
|
|
if (!target.isRaid()
|
|
|
&& !(target instanceof L2DoorInstance)
|
|
@@ -1709,13 +1698,13 @@ public final class Formulas
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public final boolean calcMCrit(double mRate)
|
|
|
+ public static final boolean calcMCrit(double mRate)
|
|
|
{
|
|
|
return mRate > Rnd.get(1000);
|
|
|
}
|
|
|
|
|
|
/** Returns true in case when ATTACK is canceled due to hit */
|
|
|
- public final boolean calcAtkBreak(L2Character target, double dmg)
|
|
|
+ public static final boolean calcAtkBreak(L2Character target, double dmg)
|
|
|
{
|
|
|
if (target instanceof L2PcInstance)
|
|
|
{
|
|
@@ -1751,7 +1740,7 @@ public final class Formulas
|
|
|
}
|
|
|
|
|
|
/** Calculate delay (in milliseconds) before next ATTACK */
|
|
|
- public final int calcPAtkSpd(L2Character attacker, L2Character target, double rate)
|
|
|
+ public static final int calcPAtkSpd(L2Character attacker, L2Character target, double rate)
|
|
|
{
|
|
|
// measured Oct 2006 by Tank6585, formula by Sami
|
|
|
// attack speed 312 equals 1500 ms delay... (or 300 + 40 ms delay?)
|
|
@@ -1760,7 +1749,7 @@ public final class Formulas
|
|
|
}
|
|
|
|
|
|
/** Calculate delay (in milliseconds) for skills cast */
|
|
|
- public final int calcAtkSpd(L2Character attacker, L2Skill skill, double skillTime)
|
|
|
+ public static final int calcAtkSpd(L2Character attacker, L2Skill skill, double skillTime)
|
|
|
{
|
|
|
if (skill.isMagic()) return (int) (skillTime * 333 / attacker.getMAtkSpd());
|
|
|
return (int) (skillTime * 333 / attacker.getPAtkSpd());
|
|
@@ -1769,7 +1758,7 @@ public final class Formulas
|
|
|
/** Returns true if hit missed (target evaded)
|
|
|
* Formula based on http://l2p.l2wh.com/nonskillattacks.html
|
|
|
**/
|
|
|
- public boolean calcHitMiss(L2Character attacker, L2Character target)
|
|
|
+ public static boolean calcHitMiss(L2Character attacker, L2Character target)
|
|
|
{
|
|
|
int delta = attacker.getAccuracy() - target.getEvasionRate(attacker);
|
|
|
int chance;
|
|
@@ -1838,7 +1827,7 @@ public final class Formulas
|
|
|
* @param sendSysMsg
|
|
|
* @return
|
|
|
*/
|
|
|
- public byte calcShldUse(L2Character attacker, L2Character target, boolean sendSysMsg)
|
|
|
+ public static byte calcShldUse(L2Character attacker, L2Character target, boolean sendSysMsg)
|
|
|
{
|
|
|
double shldRate = target.calcStat(Stats.SHIELD_RATE, 0, attacker, null)
|
|
|
* DEXbonus[target.getDEX()];
|
|
@@ -1883,12 +1872,12 @@ public final class Formulas
|
|
|
return shldSuccess;
|
|
|
}
|
|
|
|
|
|
- public byte calcShldUse(L2Character attacker, L2Character target)
|
|
|
+ public static byte calcShldUse(L2Character attacker, L2Character target)
|
|
|
{
|
|
|
return calcShldUse(attacker, target, true);
|
|
|
}
|
|
|
|
|
|
- public boolean calcMagicAffected(L2Character actor, L2Character target, L2Skill skill)
|
|
|
+ public static boolean calcMagicAffected(L2Character actor, L2Character target, L2Skill skill)
|
|
|
{
|
|
|
// TODO: CHECK/FIX THIS FORMULA UP!!
|
|
|
L2SkillType type = skill.getSkillType();
|
|
@@ -1913,7 +1902,7 @@ public final class Formulas
|
|
|
return d > 0;
|
|
|
}
|
|
|
|
|
|
- public double calcSkillVulnerability(L2Character target, L2Skill skill)
|
|
|
+ public static double calcSkillVulnerability(L2Character target, L2Skill skill)
|
|
|
{
|
|
|
double multiplier = 1; // initialize...
|
|
|
|
|
@@ -2048,7 +2037,7 @@ public final class Formulas
|
|
|
}
|
|
|
|
|
|
|
|
|
- public double calcSkillProficiency(L2Skill skill, L2Character attacker, L2Character target)
|
|
|
+ public static double calcSkillProficiency(L2Skill skill, L2Character attacker, L2Character target)
|
|
|
{
|
|
|
double multiplier = 1; // initialize...
|
|
|
|
|
@@ -2106,7 +2095,7 @@ public final class Formulas
|
|
|
}
|
|
|
|
|
|
|
|
|
- public double calcSkillStatModifier(L2SkillType type, L2Character target)
|
|
|
+ public static double calcSkillStatModifier(L2SkillType type, L2Character target)
|
|
|
{
|
|
|
double multiplier = 1;
|
|
|
if (type == null) return multiplier;
|
|
@@ -2145,7 +2134,7 @@ public final class Formulas
|
|
|
return multiplier;
|
|
|
}
|
|
|
|
|
|
- public boolean calcSkillSuccess(L2Character attacker, L2Character target, L2Skill skill, byte shld, boolean ss, boolean sps, boolean bss)
|
|
|
+ public static boolean calcSkillSuccess(L2Character attacker, L2Character target, L2Skill skill, byte shld, boolean ss, boolean sps, boolean bss)
|
|
|
{
|
|
|
if (shld == 2) // perfect block
|
|
|
{
|
|
@@ -2268,7 +2257,7 @@ public final class Formulas
|
|
|
return (Rnd.get(100) < rate);
|
|
|
}
|
|
|
|
|
|
- public boolean calcCubicSkillSuccess(L2CubicInstance attacker, L2Character target, L2Skill skill, byte shld)
|
|
|
+ public static boolean calcCubicSkillSuccess(L2CubicInstance attacker, L2Character target, L2Skill skill, byte shld)
|
|
|
{
|
|
|
if (shld == 2) // perfect block
|
|
|
{
|
|
@@ -2372,7 +2361,7 @@ public final class Formulas
|
|
|
return (Rnd.get(100) < rate);
|
|
|
}
|
|
|
|
|
|
- public boolean calcMagicSuccess(L2Character attacker, L2Character target, L2Skill skill)
|
|
|
+ public static boolean calcMagicSuccess(L2Character attacker, L2Character target, L2Skill skill)
|
|
|
{
|
|
|
double lvlDifference = (target.getLevel() - (skill.getMagicLevel() > 0 ? skill.getMagicLevel() : attacker.getLevel()));
|
|
|
int rate = Math.round((float)(Math.pow(1.3, lvlDifference) * 100));
|
|
@@ -2380,7 +2369,7 @@ public final class Formulas
|
|
|
return (Rnd.get(10000) > rate);
|
|
|
}
|
|
|
|
|
|
- public boolean calculateUnlockChance(L2Skill skill)
|
|
|
+ public static boolean calculateUnlockChance(L2Skill skill)
|
|
|
{
|
|
|
int level = skill.getLevel();
|
|
|
int chance = 0;
|
|
@@ -2417,7 +2406,7 @@ public final class Formulas
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public double calcManaDam(L2Character attacker, L2Character target, L2Skill skill,
|
|
|
+ public static double calcManaDam(L2Character attacker, L2Character target, L2Skill skill,
|
|
|
boolean ss, boolean bss)
|
|
|
{
|
|
|
//Mana Burnt = (SQR(M.Atk)*Power*(Target Max MP/97))/M.Def
|
|
@@ -2432,7 +2421,7 @@ public final class Formulas
|
|
|
return damage;
|
|
|
}
|
|
|
|
|
|
- public double calculateSkillResurrectRestorePercent(double baseRestorePercent, int casterWIT)
|
|
|
+ public static double calculateSkillResurrectRestorePercent(double baseRestorePercent, int casterWIT)
|
|
|
{
|
|
|
double restorePercent = baseRestorePercent;
|
|
|
double modifier = WITbonus[casterWIT];
|
|
@@ -2453,11 +2442,11 @@ public final class Formulas
|
|
|
return restorePercent;
|
|
|
}
|
|
|
|
|
|
- public double getSTRBonus(L2Character activeChar)
|
|
|
+ public static double getSTRBonus(L2Character activeChar)
|
|
|
{
|
|
|
return STRbonus[activeChar.getSTR()];
|
|
|
}
|
|
|
- public boolean calcPhysicalSkillEvasion(L2Character target, L2Skill skill)
|
|
|
+ public static boolean calcPhysicalSkillEvasion(L2Character target, L2Skill skill)
|
|
|
{
|
|
|
if (skill.isMagic() && skill.getSkillType() != L2SkillType.BLOW)
|
|
|
return false;
|
|
@@ -2465,7 +2454,7 @@ public final class Formulas
|
|
|
return Rnd.get(100) < target.calcStat(Stats.P_SKILL_EVASION, 0, null, skill);
|
|
|
}
|
|
|
|
|
|
- public boolean calcSkillMastery(L2Character actor, L2Skill sk)
|
|
|
+ public static boolean calcSkillMastery(L2Character actor, L2Skill sk)
|
|
|
{
|
|
|
if (sk.getSkillType() == L2SkillType.FISHING)
|
|
|
return false;
|