User:Sljm/AP Drain

AP(MP) DRAIN AND YOU
A guide by Sljm

Preface
This guide serves a very simple purpose: To explain in detail how the current AP and MP drain system works and perhaps how to use it effectively.

First of all, this guide is written with a few assumptions. One is that you have sufficient grasp of Dofus jargon and math to make use of it. The other is that you understand that AP drain and MP drain are interchangeable for the purposes of this guide.

It's entirely possible to apply what is written here to any other class with AP or MP draining spells. I happen to play a Xelor, and am most familiar with the spells of that class, however, so this guide is written from that perspective.

Keep in mind that AP loss and MP loss equations function the same, so instances of AP can be replaced with MP where loss and resistances are concerned.

For ease of writing, however, I will always refer to AP drain.

Seriously, I want to stress that this guide can also apply to MP drain. So if you post asking if these equations work for MP drain, I will ignore you, because yes they do and yes I've already said so.

Introduction
I began work on this guide as a tool for a guild mate of mine who had had more success funding and raising his Wisdom Xelor than I had, but who was still a bit blurry in his understanding of the AP drain system. (Remember that AP and MP drain equations function the same way) Parts of this guide are clipped from my post for him, and parts of that were from an earlier post I had made on Imps about the way AP drain works. ADDENDUM: Most of the guide has been rewritten. The previous versions are there in spirit, but since the drain mechanic is drastically altered, the math portion of the guide had to be redone almost from the ground up.

Starting before the Otomai patch (1.20) was released, there was dissent in the Dofus community about the 1.17 patch and its dramatic re-hashing of many class's spells, including the infamous "Counter/BP Nerf." For the newer players, before the update in question, Counter was active for 4 turns, and could be recast every 4 turns, making it continuous, and Blinding Protection could be cast once per fight and had infinite duration. The "Nerf" switched both Counter and Blinding Protection to have 3 turn durations and 6 turn cool downs. This alone was seen as the "death" of the Wisdom Xelor build by many.

However, in the same update (or in subsequent patches), Xelors were given a 10% chance of gaining an AP upon successfully casting any of their class spells.

Also at the same time, the AP and MP loss system was completely revised. I, among others, foresaw that the new AP drain system would save Wisdom Xelors as a build, and merely switch their role from being a tank to being a disabler. Even amidst cries that Ankama had killed Wisdom Xelors, there were some who understood what had been unleashed.

Now, some months later, there are cries to nerf Wisdom Xelors again, some think their AP drain too powerful. Why would a dead build need nerfing? That update didn't kill the build, but changed its role.

And what a role. Somewhere between then and now, somebody either finally listened to the ones saying that Wisdom Xelors had went from tanks to AP draining masters, or figured it out for himself. More and more people bore witness to this new beast and followed suit with their own Xelors, until Wisdom Xelor went from being a "dead build" to being one of the more popular alternate characters in the game.

I think the main reason there was such an outcry by Wisdom Xelors was that few of them understood or cared to think about the new AP loss system. They were so focused on their roles as tanks that considering being a disabler was beyond their scope of thought. All it took was time for the Wisdom Xelor to reveal itself as useful still, but in a different way.

However, even now most people's understanding of the AP loss system is sketchy at best. I originally wrote this guide as an attempt to fix that.

ADDENDUM: This guide has been updated for version 1.25 of Dofus!

Version 1.25 introduced an entirely new AP loss system, catering for more balanced dodge chances, as well as capping Wisdom's effect on AP drain. The previous update, Version 1.24, set the maximum basic AP loss Resistance to 200%, and Version 1.25 caused AP drain to be based on the caster's basic AP loss Resistance compared to the target's total AP loss resistance. This also meant that having enough Wisdom to grant more than 200% Resistance would not affect AP drain potential anymore, the potential had in effect been capped at 200%, since additional Resist effects like Blinding Protection aren't taken into account for the caster. Wisdom's effect on experience gained isn't capped however, (or if it is, they haven't told us...) so having more than 800 Wisdom will still grant more experience.

In addition to all this, Version 1.25 forced the AP loss equation to be based on the ratio of current to starting AP, which means that having more AP than you started the fight with (such as with Devotion, Stim, or Smell) makes it easier for opponents to drain AP from you, while having less makes it harder. This way, it becomes increasingly more difficult to drain an opponent to 0 AP.

Furthermore, the chance to drain AP loss has been hard-capped to 10% minimum, and 90% maximum, which means it's statistically impossible to always (or never) dodge or drain AP.

The Official Quote
Sljm's Note: Excerpted from this post on the Official Forums
 * The dodge system has been revised. The formula used is the following:
 * Probability to make someone lose a AP/MP = Da / Dt * Pr / 2
 * With:


 * * Da: dodge of the attacker
 * * Dt: dodge of the target
 * * Pr: percentage of AP/MP that the target still has


 * The values are limited, so that they are between minimum 10% of chance and maximum 90% of chance.
 * If both parties have an equivalent of wisdom, the attacker has a 50% chance to remove the first AP/MP.
 * The dodge bonus and penalties are only handled like wisdom bonus and penalties for the dodge attempts only (and not for the other retreat attempts).
 * You will find more information about this on the devblog

Expansion on the Math
I changed the names of some of the variables, more for my own sake than anyone else's.
 * In figuring the probability of AP being drained,
 * RC is the Caster's BASIC AP loss Resistance
 * RT is the Target's TOTAL AP loss Resistance
 * APb is the Target's starting AP
 * APc is the Target's current AP

((RC / RT) * (APc / APb)) / 2

Let us consider RC / RT to be the "Resist Ratio," the ratio of caster's basic resist to target's total resist.

Let's also consider APc / APb to be the "AP Ratio," the ratio of current to starting AP. This was called "Percentage of current and maximum AP" by Lichen, but my name for it has fewer letters. (Technically, it should be called AP Quotient, but since I'm typing it, I'm going to use Ratio.)

Remember that this equation calculates the probability of the AP being drained. This is important.

Each successful AP drain will reduce the chance of success of subsequent AP drain attempts. However, there will never be greater than 90% or less than 10% chance of successful AP drain.


 * In estimating the average AP drained,
 * The value D is the average AP drained of X,
 * Where Pi is the probability of Ni of X to be drained,
 * And where 0 < P < 1.0

D = sum_of (Pi), for i in range 1 < X

Note that D's unit is AP (or MP). For simplicity, this is assumed and not noted explicitly.

X is not limited to the number of AP drained by a single spell. X could be equal to the number of AP the target currently has, so long as the probability of success is figured correctly for each AP to be drained. For example, if the target has 9 starting AP, but has 12 AP currently, you would figure out the probability of draining each AP successfully from 12 to 0, and go from there. When figuring average AP drained, assume that each AP drain has succeeded when you go on to the next Ni of X.

No matter what, each AP to be drained recalculates the probability of success. Since the equation considers the ratio of starting to current AP, this makes sense, since you'd want it to give the right dodge rate.

If an AP loss is dodged, then the AP ratio remains the same, but if the AP is lost, then the next AP to be lost has a different AP ratio.

Since success rates are dependent on the target's AP and resists, and not the number of AP drained in a spell, it can be said that now every AP to be drained can be considered independently of the others, because each one calculates resists and AP ratio.

Apparently using this method of averaging tends to underestimate the average drain, since it assumes that each AP succeeds, which reduces the chances of subsequent AP to be drained. But considering each case in terms of success and failure among a large set of drain attempts... gets hairy fast, because one must consider every combination of the previous AP in the series failing or not. I'll look into a more accurate way to estimate this, that doesn't involve writing a computer program to figure it out, but for now, I'm happier underestimating it and being pleasantly surprised.

Let's figure some examples, to give the math substance, and to make sense of everything I just spat at you. In an old version of the guide, I went on to consider up to 10 cases of AP drain. However, in order to represent more accurate probabilities, I've reduced the number of cases in each example to 3. Because, for each subsequent APi, one must calculate the probability of APi succeeding given every possible combinations of outcomes of the previous cases. To keep it from becoming too complex, but to still convey the sort of progression one can expect, I reduced N to 3. You'll see what I mean.

Example 1
Consider a Xelor with base 100% AP resists casting level 6 Slow Down against an opponent with base 100% AP resists, and no additional resists. The target has 10 out of 10 starting AP.


 * 100 = RC is the Caster's BASIC AP loss Resistance
 * 100 = RT is the Target's TOTAL AP loss Resistance
 * 10 = APb is the Target's starting AP
 * 10 = APc is the Target's current AP

((RC / RT) * (APc / APb)) / 2


 * N1 of 3

((100 / 100) * (10 / 10)) / 2 (1 * 1) / 2 1 / 2 = 0.5 P1 = 0.5

So N1 has a 50% chance of being drained. That one was easy. Note that every time the caster and target have equal resists, and the target has an AP ratio of 1, Pi will be 0.5 or 50%.

If N1 fails to be drained (that is, the target dodges it) then P1 is still 0.5, since the AP ratio is still 1.

Since we're on the subject, you can find the probability of each AP succeeding given every AP before it failing most easily, since it's the same chance as the one before it succeeding. In this case, P1, P2, and P3 given that condition is 0.5, 0.5, and 0.5. Easy, hm? We'll need to remember this later.

Now suppose that AP1 succeeded.
 * N2 of 3

((100 / 100) * (9 / 10)) / 2 (1 * 0.9) / 2 0.9 / 2 = 0.45 P2 = 0.45

So N2 has a 45% chance of being drained if N1 were to succeed, or a 50% chance of being drained if N1 were to fail. To find our average probability, we'll simply average 0.45 and 0.5 (0.45 + 0.5) / 2 = 0.475 P2 = 0.475

Each successful AP drain will reduce the chance of success of subsequent AP drain attempts. However, there will never be greater than 90% or less than 10% chance of successful AP drain.

Now it starts to get a little complex. AP3, being the third in the series, has 4 possible values, since it's dependent on two other cases succeeding or failing.
 * If both AP1 and N2 had both failed, then APc would be 9.
 * If N1 had succeeded, but N2 had failed, then APc would be 8.
 * If N1 had failed, but N2 had succeeded, then APc would be 8.
 * If both AP1 and N2 had both failed, then APc would be 7.

The middle two end up having the same value, but from distinct outcomes. However, by writing it like this I hope to illustrate the point that going much further than 3 cases gets extremely tedious. Let me represent this as a table. On top, the possible values of N1, on the side, the possible values of N2, expressed in binary, where 0 is "false" and 1 is "true," and the test being whether the AP drain succeeded.

In order to find the probability of N3, we have to consider each of these cases. Technically, we're considering 1,0 twice, because there are two ways it can occur. Or if you prefer, we're considering both 0,1 and 1,0. We already have 0,0 (0.5) and both cases of 1,0 (0.45) so now let's work out 1,1.

N3 of 3 ((100 / 100) * (8 / 10)) / 2 (1 * 0.8) / 2 0.89 / 2 = 0.4 P3 = 0.4

So N3 has a 40% chance of being drained if both N1 and N2 succeed.

Now let's average N3. We have to use 0.45 twice because there are two ways to get that outcome. (0.4 + 0.45 + 0.45 + 0.5) / 4 = 0.45

Now we find our average AP drained.
 * The value D is the average AP drained of X,
 * Where Pi is the probability of Ni of X to be drained,
 * And where 0 < P < 1.0

D = sum_of (Pi), for Ni in range 1 < X D = (0.5 + 0.475 + 0.45) D = 1.425

So in this case, the Xelor will drain on average 1.425 AP from his target with Slow Down.

WORK IN PROGRESS, to be continued.