This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..
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