Jump to content
  • 0

Buff-Steal Order


Question

Posted

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

  • 0
Posted

 

did you read the code?

 // All Except Dances/Songs.
     if (effect.getSkill().isDance())
     {
      continue;
     }

Already tried to remove that part, still wasn't solved.

  • 0
Posted

What about canBeStolen() method?

Songs/Dances can be stolen, however they are not being stolen as first, but randomly.

 

For example 2 normal buffs and 2 dances.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...