public static List<L2Effect> calcCancelStealEffects(L2Character activeChar, L2Character target, L2Skill skill, double power)
{
// Resists.
int cancelMagicLvl = skill.getMagicLevel();
int count = skill.getMaxNegatedEffects();
final double vuln = target.calcStat(Stats.CANCEL_VULN, 0, target, null);
final double prof = activeChar.calcStat(Stats.CANCEL_PROF, 0, target, null);
double resMod = 1 + (((vuln + prof) * -1) / 100);
double rate = power / resMod;
if (activeChar.isDebug() || Config.DEVELOPER)
{
final StringBuilder stat = new StringBuilder(100);
StringUtil.append(stat, skill.getName(), " Base Rate:", String.valueOf((int) power), " Magiclvl:", String.valueOf(cancelMagicLvl), " resMod:", String.format("%1.2f", resMod), "(", String.format("%1.2f", prof), "/", String.format("%1.2f", vuln), ") Rate:", String.valueOf(rate));
final String result = stat.toString();
if (activeChar.isDebug())
{
activeChar.sendDebugMessage(result);
}
if (Config.DEVELOPER)
{
_log.info(result);
}
}
// Cancel for Abnormals.
final L2Effect[] effects = target.getAllEffects();
List<L2Effect> canceled = new ArrayList<>(count);
if (skill.getNegateAbnormals() != null)
{
for (L2Effect eff : effects)
{
if (eff == null)
{
continue;
}
for (String negateAbnormalType : skill.getNegateAbnormals().keySet())
{
if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && (skill.getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl()))
{
if (calcCancelSuccess(eff, cancelMagicLvl, (int) rate, skill))
{
eff.exit();
}
}
}
}
}
// Common Cancel/Steal.
else
{
// First Pass.
int lastCanceledSkillId = 0;
L2Effect effect;
for (int i = effects.length; --i >= 0;) // reverse order
{
effect = effects[i];
if (effect == null)
{
continue;
}
// remove effect if can't be stolen
if (!effect.canBeStolen())
{
effects[i] = null;
continue;
}
// if effect time is smaller than 5 seconds, will not be stolen, just to save CPU,
// avoid synchronization(?) problems and NPEs
if ((effect.getAbnormalTime() - effect.getTime()) < 5)
{
effects[i] = null;
continue;
}
// Only Dances/Songs.
if (!effect.getSkill().isDance())
{
continue;
}
if (!calcCancelSuccess(effect, cancelMagicLvl, (int) rate, skill))
{
continue;
}
if (effect.getSkill().getId() != lastCanceledSkillId)
{
lastCanceledSkillId = effect.getSkill().getId();
count--;
}
canceled.add(effect);
if (count == 0)
{
break;
}
}
// Second Pass.
if (count > 0)
{
lastCanceledSkillId = 0;
for (int i = effects.length; --i >= 0;)
{
effect = effects[i];
if (effect == null)
{
continue;
}
// All Except Dances/Songs.
if (effect.getSkill().isDance())
{
continue;
}
if (!calcCancelSuccess(effect, cancelMagicLvl, (int) rate, skill))
{
continue;
}
if (effect.getSkill().getId() != lastCanceledSkillId)
{
lastCanceledSkillId = effect.getSkill().getId();
count--;
}
canceled.add(effect);
if (count == 0)
{
break;
}
}
}
}
return canceled;
}
public static boolean calcCancelSuccess(L2Effect eff, int cancelMagicLvl, int rate, L2Skill skill)
{
// Lvl Bonus Modifier.
rate *= (eff.getSkill().getMagicLevel() > 0) ? (cancelMagicLvl / eff.getSkill().getMagicLevel()) : 1;
// Check the Rate Limits.
rate = Math.min(Math.max(rate, skill.getMinChance()), skill.getMaxChance());
return Rnd.get(100) < rate;
}
}
to calculate the amount of stolen debuffs based on the character resists, however it appears that songs and dances are not being removed as first when a steal skill type is used.
Added: a brand-new default dashboard template.
You can now add multiple game/login server builds.
Full support for running both PTS & L2J servers simultaneously, with switching between them.
Payment systems: added OmegaPay and Pally (new PayPal-style API).
Account history now stores everything: donations, items delivered to characters, referrals, transfers between game accounts, and coin transfers to another master account.
Personal Promo Code System: you can create a promo code and assign it to a user or promoter. When donating, a player can enter this promo code to receive bonus coins, and the promo code owner also receives a bonus — all fully configurable in the admin panel.
Look demo site: demo
MoMoProxy has updated more static residential proxies for USA location, anyone interested in can view: https://momoproxy.com/static-residential-proxies
Question
Gries
Hello, i currently have this code:
public static List<L2Effect> calcCancelStealEffects(L2Character activeChar, L2Character target, L2Skill skill, double power) { // Resists. int cancelMagicLvl = skill.getMagicLevel(); int count = skill.getMaxNegatedEffects(); final double vuln = target.calcStat(Stats.CANCEL_VULN, 0, target, null); final double prof = activeChar.calcStat(Stats.CANCEL_PROF, 0, target, null); double resMod = 1 + (((vuln + prof) * -1) / 100); double rate = power / resMod; if (activeChar.isDebug() || Config.DEVELOPER) { final StringBuilder stat = new StringBuilder(100); StringUtil.append(stat, skill.getName(), " Base Rate:", String.valueOf((int) power), " Magiclvl:", String.valueOf(cancelMagicLvl), " resMod:", String.format("%1.2f", resMod), "(", String.format("%1.2f", prof), "/", String.format("%1.2f", vuln), ") Rate:", String.valueOf(rate)); final String result = stat.toString(); if (activeChar.isDebug()) { activeChar.sendDebugMessage(result); } if (Config.DEVELOPER) { _log.info(result); } } // Cancel for Abnormals. final L2Effect[] effects = target.getAllEffects(); List<L2Effect> canceled = new ArrayList<>(count); if (skill.getNegateAbnormals() != null) { for (L2Effect eff : effects) { if (eff == null) { continue; } for (String negateAbnormalType : skill.getNegateAbnormals().keySet()) { if (negateAbnormalType.equalsIgnoreCase(eff.getAbnormalType()) && (skill.getNegateAbnormals().get(negateAbnormalType) >= eff.getAbnormalLvl())) { if (calcCancelSuccess(eff, cancelMagicLvl, (int) rate, skill)) { eff.exit(); } } } } } // Common Cancel/Steal. else { // First Pass. int lastCanceledSkillId = 0; L2Effect effect; for (int i = effects.length; --i >= 0;) // reverse order { effect = effects[i]; if (effect == null) { continue; } // remove effect if can't be stolen if (!effect.canBeStolen()) { effects[i] = null; continue; } // if effect time is smaller than 5 seconds, will not be stolen, just to save CPU, // avoid synchronization(?) problems and NPEs if ((effect.getAbnormalTime() - effect.getTime()) < 5) { effects[i] = null; continue; } // Only Dances/Songs. if (!effect.getSkill().isDance()) { continue; } if (!calcCancelSuccess(effect, cancelMagicLvl, (int) rate, skill)) { continue; } if (effect.getSkill().getId() != lastCanceledSkillId) { lastCanceledSkillId = effect.getSkill().getId(); count--; } canceled.add(effect); if (count == 0) { break; } } // Second Pass. if (count > 0) { lastCanceledSkillId = 0; for (int i = effects.length; --i >= 0;) { effect = effects[i]; if (effect == null) { continue; } // All Except Dances/Songs. if (effect.getSkill().isDance()) { continue; } if (!calcCancelSuccess(effect, cancelMagicLvl, (int) rate, skill)) { continue; } if (effect.getSkill().getId() != lastCanceledSkillId) { lastCanceledSkillId = effect.getSkill().getId(); count--; } canceled.add(effect); if (count == 0) { break; } } } } return canceled; } public static boolean calcCancelSuccess(L2Effect eff, int cancelMagicLvl, int rate, L2Skill skill) { // Lvl Bonus Modifier. rate *= (eff.getSkill().getMagicLevel() > 0) ? (cancelMagicLvl / eff.getSkill().getMagicLevel()) : 1; // Check the Rate Limits. rate = Math.min(Math.max(rate, skill.getMinChance()), skill.getMaxChance()); return Rnd.get(100) < rate; } }to calculate the amount of stolen debuffs based on the character resists, however it appears that songs and dances are not being removed as first when a steal skill type is used.
7 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now