{
return true;
}
env.value = Math.max(Math.min(env.value, 100), 1);
final double base = env.value;
final Skill skill = env.skill;
if (!skill.isOffensive())
{
return Rnd.chance(env.value);
}
final Creature caster = env.character;
final Creature target = env.target;
boolean debugCaster = false;
boolean debugTarget = false;
boolean debugGlobal = false;
if (Config.ALT_DEBUG_ENABLED)
{
debugCaster = (caster.getPlayer() != null) && caster.getPlayer().isDebug();
debugTarget = (target.getPlayer() != null) && target.getPlayer().isDebug();
final boolean debugPvP = Config.ALT_DEBUG_PVP_ENABLED && (debugCaster && debugTarget) && (!Config.ALT_DEBUG_PVP_DUEL_ONLY || (caster.getPlayer().isInDuel() && target.getPlayer().isInDuel()));
debugGlobal = debugPvP || (Config.ALT_DEBUG_PVE_ENABLED && ((debugCaster && target.isMonster()) || (debugTarget && caster.isMonster())));
}
double statMod = 1.;
if (skill.getSaveVs() != null)
{
statMod = skill.getSaveVs().calcChanceMod(target);
env.value *= statMod;
}
env.value = Math.max(env.value, 1);
double mAtkMod = 1.;
int ssMod = 0;
if (skill.isMagic())
{
int mdef = Math.max(1, target.getMDef(target, skill));
double matk = caster.getMAtk(target, skill);
if (skill.isSSPossible())
{
switch (spiritshot)
{
case ItemInstance.CHARGED_BLESSED_SPIRITSHOT:
ssMod = 4;
break;
case ItemInstance.CHARGED_SPIRITSHOT:
ssMod = 2;
break;
default:
ssMod = 1;
}
matk *= ssMod;
}
mAtkMod = (Config.SKILLS_CHANCE_MOD * Math.pow(matk, Config.SKILLS_CHANCE_POW)) / mdef;
env.value *= mAtkMod;
env.value = Math.max(env.value, 1);
}
double lvlDependMod = skill.getLevelModifier();
if (lvlDependMod != 0)
{
final int attackLevel = skill.getMagicLevel() > 0 ? skill.getMagicLevel() : caster.getLevel();
lvlDependMod = 1. + ((attackLevel - target.getLevel()) * 0.03 * lvlDependMod);
if (lvlDependMod < 0)
{
lvlDependMod = 0;
}
else if (lvlDependMod > 2)
{
lvlDependMod = 2;
}
env.value *= lvlDependMod;
}
double vulnMod = 0;
double profMod = 0;
double resMod = 1.;
double debuffMod = 1.;
if (!skill.isIgnoreResists())
{
debuffMod = 1. - (target.calcStat(Stats.DEBUFF_RESIST, caster, skill) / 120.);
if (debuffMod != 1)
{
if (debuffMod == Double.NEGATIVE_INFINITY)
{
if (debugGlobal)
{
if (debugCaster)
{
caster.getPlayer().sendMessage("Full debuff immunity");
}
if (debugTarget)
{
target.getPlayer().sendMessage("Full debuff immunity");
}
}
return false;
}
if (debuffMod == Double.POSITIVE_INFINITY)
{
if (debugGlobal)
{
if (debugCaster)
{
caster.getPlayer().sendMessage("Full debuff vulnerability");
}
if (debugTarget)
{
target.getPlayer().sendMessage("Full debuff vulnerability");
}
}
return true;
}
debuffMod = Math.max(debuffMod, 0);
env.value *= debuffMod;
}
SkillTrait trait = skill.getTraitType();
if (trait != null)
{
vulnMod = trait.calcVuln(env);
profMod = trait.calcProf(env);
final double maxResist = 90 + (profMod * 0.85);
resMod = (maxResist - vulnMod) / 60.;
}
if (resMod != 1)
{
if (resMod == Double.NEGATIVE_INFINITY)
{
if (debugGlobal)
{
if (debugCaster)
{
caster.getPlayer().sendMessage("Full immunity");
}
if (debugTarget)
{
target.getPlayer().sendMessage("Full immunity");
}
}
return false;
}
if (resMod == Double.POSITIVE_INFINITY)
{
if (debugGlobal)
{
if (debugCaster)
{
caster.getPlayer().sendMessage("Full vulnerability");
}
if (debugTarget)
{
target.getPlayer().sendMessage("Full vulnerability");
}
}
return true;
}
resMod = Math.max(resMod, 0);
env.value *= resMod;
}
}
double elementMod = 0;
final Element element = skill.getElement();
if (element != Element.NONE)
{
elementMod = skill.getElementPower();
Element attackElement = getAttackElement(caster, target);
if (attackElement == element)
{
elementMod += caster.calcStat(element.getAttack(), 0);
}
elementMod -= target.calcStat(element.getDefence(), 0);
elementMod = Math.round(elementMod / 10);
env.value += elementMod;
}
env.value = Math.max(env.value, Math.min(base, Config.SKILLS_CHANCE_MIN));
env.value = Math.max(Math.min(env.value, Config.SKILLS_CHANCE_CAP), 1);
final boolean result = Rnd.chance((int) env.value);
if (debugGlobal)
{
StringBuilder stat = new StringBuilder(100);
if (et == null)
{
stat.append(skill.getName());
}
else
{
stat.append(et._effectType.name());
}
stat.append(" AR:");
stat.append((int) base);
stat.append(' ');
if (skill.getSaveVs() != null)
{
stat.append(skill.getSaveVs().name());
stat.append(':');
stat.append(String.format("%1.1f", statMod));
}
if (skill.isMagic())
{
stat.append(' ');
stat.append(" mAtk:");
stat.append(String.format("%1.1f", mAtkMod));
}
if (skill.getTraitType() != null)
{
stat.append(' ');
stat.append(skill.getTraitType().name());
}
stat.append(' ');
stat.append(String.format("%1.1f", resMod));
stat.append('(');
stat.append(String.format("%1.1f", profMod));