rushanshekar / gen6-damage-calc

VGC-focused Damage Calculator for Gen 6 @ http://nuggetbridge.com/damagecalc
MIT License
0 stars 3 forks source link

Handle Sitrus Berry #30

Closed augmt closed 9 years ago

augmt commented 9 years ago

This commit includes the Sitrus Berry into the KO Chance calculation for single-hit and multi-hit moves.

Please, please someone verify that the KO Chance calculation is correct. I have doubts but I can't pinpoint them.

Tapin42 commented 9 years ago

Thanks! I'll check it out tonight, but would love input from others as well.

(Tagging #19 just so I can find this later)

Tapin42 commented 9 years ago

Still tracking it down, but there's something funky going on. This is non-mega Abomasnow vs. Abomasnow, with the left Aboma carrying a Sitrus:

screen shot 2015-03-05 at 7 58 49 am

Tapin42 commented 9 years ago

...I take it back. The "0% chance" is effectively correct. After working it out by hand, there's a 1/16^3 chance (max damage on three consecutive rolls) to 3HKO with Sitrus Berry recovery:

197 HP
69-82 damage per attack

After 1 attack: 115-128 (no Sitrus proc)
After 2 attacks: 33-59 (always Sitrus proc, which makes it:) 82-108
After 3 attacks: 0-39

...so I propose the following stylistic change, but otherwise I think this PR is accurate as far as I can see:

    for (i = 2; i <= 4; i++) {
        c = getKOChance(damage, move.hits, defender.curHP - hazards, eot, i, defender.maxHP, toxicCounter, hasSitrus);
        if (c === 1) {
            return 'guaranteed ' + i + 'HKO' + afterText;
        } else if (c > 0) {
            var pct = Math.round(c * 1000) / 10;
            var chance = pct ? qualifier + pct + '%' : 'Miniscule';
            return chance + ' chance to ' + i + 'HKO' + afterText;
        }
    }
augmt commented 9 years ago

Funky, indeed.

As you've seen, the KO Chance only shows up to the tenths place. And, as it turns out, Blizzard does have a chance of 3HKOing Abomasnow, albeit a 0.0244140625% chance.

More of the decimal should be shown.

Tapin42 commented 9 years ago

I think a single decimal place is fine; more than that is just noise, IMO. Nice timing, btw.

Tapin42 commented 9 years ago

Also potentially worth noting that this sort of thing could only possibly show up on something that's a 3HKO or worse, since the minimum nonzero chance for a 2HKO is 0.4%. Lucky(?) catch, I guess. Sorry about the false alarm.

augmt commented 9 years ago

Proclaiming that it's a minuscule chance works well. Choose whichever fix you like more.

Haha, no problem. It's better to catch this sort of thing sooner rather than later.

rushanshekar commented 9 years ago

However, if you get a min roll and then a max roll, the Sitrus actually wouldn't activate and it would be a 2HKO. Any way to account for those cases easily?

augmt commented 9 years ago

Nice catch!

If you comment out the following lines of code from the getKOChance function:

if (predictTotal(maxDamage, eot, hits, toxicCounter, hp, maxHP, hasSitrus) < hp) {
    return 0;
} else if (predictTotal(minDamage, eot, hits, toxicCounter, hp, maxHP, hasSitrus) >= hp) {
    return 1;
}

you'll get:

From what I've gathered, the calculator is only about a millisecond slower with that code commented out.