[Fixed] Damage Formula Errors

Discussion in 'Solved Bugs' started by Sasuke Uchiha, Jul 10, 2014.

  1. Sasuke Uchiha

    Sasuke Uchiha God of tits and wine

    Joined:
    Dec 18, 2011
    Messages:
    316
    Likes Received:
    204
    PO Trainer Name:
    Yellan
    FUZZY EDIT: HI. I MERGED THREADS TOGETHER THAT RELATE TO THE REWRITING OF THE DAMAGE FORMULA. ALSO I LEFT CAPS LOCK ON. When the damage formula is fixed, all the issues in this thread will be double checked. If they remain an issue, they will be split again (worked well enough for Battle window PP tool tip, thought i'd try it again)

    I was playing battle factory LC and it was Porygon vs Lileep.

    Lileep got +1 in all stats thanks to Ancientpower and I dropped his Sp Def with a Shadow Ball.
    Shadow Ball was doing 19% and atfer another drop it kept doing 11% while obviously it should have been doing more than 19%. (he was at -1 at this point)

    Start of turn 23
    Porygon used Shadow Ball!
    The foe's Lileep lost 19% of its health!

    The foe's Lileep used Ancient Power!
    Porygon lost 4 HP! (15% of its health)

    Start of turn 24
    Porygon used Shadow Ball!
    The foe's Lileep lost 7% of its health!


    The foe's Lileep used Ancient Power!
    Porygon lost 4 HP! (15% of its health)
    The foe's Lileep's Attack rose!
    The foe's Lileep's Defense rose!
    The foe's Lileep's Sp. Att. rose!
    The foe's Lileep's Sp. Def. rose!
    The foe's Lileep's Speed rose!

    Start of turn 25
    Porygon used Recover!
    Porygon regained health!

    The foe's Lileep used Giga Drain!
    Porygon lost 7 HP! (26% of its health)
    Porygon had its energy drained!

    Start of turn 26
    Porygon used Recover!
    Porygon regained health!

    The foe's Lileep used Giga Drain!
    Porygon lost 7 HP! (26% of its health)
    Porygon had its energy drained!

    Start of turn 27
    Porygon used Shadow Ball!
    The foe's Lileep lost 11% of its health!

    The foe's Lileep used Giga Drain!
    Porygon lost 7 HP! (26% of its health)
    Porygon had its energy drained!

    Start of turn 28
    Porygon used Shadow Ball!
    The foe's Lileep lost 7% of its health!

    The foe's Lileep used Ancient Power!
    Porygon lost 6 HP! (23% of its health)

    Start of turn 29
    Porygon used Recover!
    Porygon regained health!

    The foe's Lileep used Ancient Power!
    Porygon lost 6 HP! (23% of its health)

    Start of turn 30
    Porygon used Recover!
    Porygon regained health!

    The foe's Lileep used Ancient Power!
    Porygon lost 6 HP! (23% of its health)

    Start of turn 31
    Porygon used Shadow Ball!
    The foe's Lileep lost 11% of its health!
    The foe's Lileep's Sp. Def. fell!

    The foe's Lileep is paralyzed! It can't move!

    Start of turn 32
    Porygon used Shadow Ball!
    The foe's Lileep lost 19% of its health!

    The foe's Lileep used Ancient Power!
    Porygon lost 6 HP! (23% of its health)

    Start of turn 33
    Porygon used Shadow Ball!
    The foe's Lileep lost 19% of its health!

    The foe's Lileep used Giga Drain!
    Porygon lost 9 HP! (34% of its health)
    Porygon had its energy drained!

    Start of turn 34
    Porygon used Recover!
    Porygon regained health!

    The foe's Lileep is paralyzed! It can't move!

    Start of turn 35
    Porygon used Shadow Ball!
    The foe's Lileep lost 19% of its health!
    The foe's Lileep's Sp. Def. fell!

    The foe's Lileep used Giga Drain!
    Porygon lost 7 HP! (26% of its health)
    Porygon had its energy drained!

    Start of turn 36
    Porygon used Shadow Ball!
    The foe's Lileep lost 11% of its health!


    The foe's Lileep used Giga Drain!
    Porygon lost 7 HP! (26% of its health)
    Porygon had its energy drained!

    Sasuke Uchiha: wtf

    Start of turn 37
    Porygon used Recover!
    Porygon regained health!

    The foe's Lileep used Giga Drain!
    Porygon lost 7 HP! (26% of its health)
    Porygon had its energy drained!

    And it kept doing 11% after that. Now that I look at it Shadow Ball's damage was really aberant.
    There was a point where it randomly did only 7% in the beginning.
     
    Last edited by a moderator: Jan 31, 2015
  2. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    I don't think this is a bug related to the defense drop.
    However, it seems that PO does calculate damage wrong at least. According to both Smogon's and Sulcata's damage calculators, some of the damages posted shouldn't have been possible (that 7% being one example)

    Sets are
    Porygon @ Eviolite
    Ability: Trace
    Bold Nature, Level 5
    Tri Attack / Thunder Wave / Recover / Shadow Ball
    EVs: 236 HP / 196 Def / 76 SpD
    IVs: All 31
    Stats: 26 HP / 10 Atk / 17 Def / 15 SpA / 15 SpD / 10 Spe

    Lileep @ Eviolite
    Ability: Storm Drain
    Bold Nature, Level 5
    Stealth Rock / Giga Drain / Recover / Ancient Power
    EVs: 228 HP / 220 Def / 60 SpD
    IVs: 0 Atk
    Stats: 26 HP / 8 Atk / 18 Def / 12 SpA / 16 SpD / 8 Spe

    If anyone wants to see if I made a mistake
     
  3. ;Moonlight

    ;Moonlight Member

    Joined:
    Aug 5, 2014
    Messages:
    56
    Likes Received:
    99
    [​IMG]

    Giga drain inflicted 37% to Tyranitar while the right damage output is Exeggutor Giga Drain vs. Tyranitar: 154-182 (38.2 - 45.1%) -- guaranteed 3HKO after Leftovers recovery
     
  4. Withoutatrace

    Withoutatrace im a filthy weeb

    Joined:
    Jun 11, 2013
    Messages:
    563
    Likes Received:
    370
    PO Trainer Name:
    Withoutatrace
    (18:28:22) Proof: isnt it just
    (18:28:24) Proof: a dumb rounding error
    (18:28:57) Proof: maybe it was missing DVs accidentally
    (18:28:57) Proof: Exeggutor Giga Drain vs. Tyranitar: 139-164 (34.4 - 40.6%) -- 53.9% chance to 3HKO after Leftovers recovery
    (18:29:00) Proof: (no IVs)

    im lazy
    so yeah, make sure you have your stuff right pls
    otherwise it is the rounding error because of the way damage is calculated, math wise
     
  5. ;Moonlight

    ;Moonlight Member

    Joined:
    Aug 5, 2014
    Messages:
    56
    Likes Received:
    99
    yes i have max ivs
     
  6. Withoutatrace

    Withoutatrace im a filthy weeb

    Joined:
    Jun 11, 2013
    Messages:
    563
    Likes Received:
    370
    PO Trainer Name:
    Withoutatrace
    Can you post an export of the team please?
     
  7. Fuzzysqurl

    Fuzzysqurl baa baa mareep I do what I want Server Owner Developer I do what I want Server Owner Developer

    Joined:
    Sep 12, 2012
    Messages:
    2,096
    Likes Received:
    967
    Damage = int(int(int(2×L ÷ 5+2)×A×P ÷ D)/50)+2
    L = attacker level (100 on Exegg)
    A = attack (348 on Exegg)
    P = base damage (60 BP, SE, STAB)
    D = defense (298 on Ttar)

    int(int(int(2×100 ÷ 5+2)×348×(60*2*1.5) ÷ 298)/50)+2
    int(int(42×348×(60*2*1.5) ÷ 298)/50)+2
    int(8828/50)+2
    176+2
    178

    Min: 217/255 * 178 = 151
    Max: 255/255 * 178 = 178

    151/403 (Ttar HP) = 37.468% = 37%


    Unless I did something wrong, this should actually be correct.
     
  8. sulcata

    sulcata stéphane curry best waifu Forum Moderator Server Administrator Forum Moderator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    http://upokecenter.dreamhosters.com...rsion-and-crystal-version-damage-calculation/

    Damage = int(int(int(2×L ÷ 5+2)×A×P ÷ D)/50)
    Crit?
    Do some more multipliers and stuff for things like mystic water, charcoal, pink bow, etc (110/100).
    Damage is greater than 997? Make it 997.
    Add 2.
    Sunny Day or Rain Dance multiplier?
    lolbadgesignore
    STAB multiplier?
    Type effectiveness multiplier.
    Variance 217/255 to 255/255.

    So that damage range he gave looks right following this (for some reason UPC's main site seems to be a little weird). It's also the one my calculator gives.

    edit: i realized that what i said could be a bit ambiguous, I meant to say that it seems moonlight is correct
     
    Last edited: Dec 20, 2014
  9. Conflict

    Conflict Member

    Joined:
    Mar 16, 2012
    Messages:
    32
    Likes Received:
    60
    Hey i think the damage formula might be off because ive in encountered this same problem aswell.

    The most recent battle ive had this happen in i got this:

    For the record this was +3 Vaporeon vs. Snorlax. And every calc ive done has given me results similar to this one: +3 Vaporeon Surf vs. Snorlax: 257-303 (49.1 - 57.9%) -- 60.9% chance to 2HKO after Leftovers recovery
    Which makes me wonder why it didnt do 49% but only 48% (prompting the lax to survive with 1% and nullifying my advantage).
    Also immediately checked my EV's/IV's but everything was at max....

    So yeah please look into this and fix it. Thank you!
     
    Last edited: Jan 3, 2015
  10. Fuzzysqurl

    Fuzzysqurl baa baa mareep I do what I want Server Owner Developer I do what I want Server Owner Developer

    Joined:
    Sep 12, 2012
    Messages:
    2,096
    Likes Received:
    967
    sulcata and I started to work on it, but there's just so much wrong that neither of us wants to attempt it tonight. We will be gutting the entire damage formula for gens 2-6 and seeing if we can't get it correct for once. This will hopefully solve the +/- 1 damage on everything.
     
  11. sulcata

    sulcata stéphane curry best waifu Forum Moderator Server Administrator Forum Moderator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    Just going to leave a quick comment on this as well, apparently GSC was calculating things way more like ADV than it was like RBY.
    For example, probability was apparently 85-100/100 instead of 217-255/255.
     
  12. fitzy

    fitzy Heart of the cards Forum Moderator Forum Moderator

    Joined:
    Apr 16, 2012
    Messages:
    883
    Likes Received:
    296
    Vulpix @ Choice Scarf
    Ability: Drought
    Modest Nature, Level 5
    Fire Blast / Overheat / Energy Ball / Hidden Power
    EVs: 56 HP / 196 SpA / 236 Spe
    IVs: 30 HP / 30 Def

    vs

    Bulbasaur @ Eviolite
    Ability: Chlorophyll
    Careful Nature, Level 5
    Curse / Power Whip / Knock Off / Synthesis
    EVs: 236 HP / 236 SpD

    Fireblast in sun did 83% which is a max roll without sun but 17% less than min damage with sun up. Tested with Weavile and we can't find anything wrong with sun in general.

    Log to show no airlock or anything like that :
    Battle between Draciel and fitzyhbbe started!

    Tier: Battle Factory 6v6
    Mode: Singles
    Rule: Unrated
    Rule: Sleep Clause
    Rule: Species Clause
    Rule: Wifi Battle
    Rule: Self-KO Clause

    Your team: Spinarak / Riolu / Corphish / Houndour / Tirtouga / Vulpix
    Opponent's team: Gastly / Croagunk / Pumpkaboo-L / Foongus / Porygon / Bulbasaur

    priyank is watching the battle.
    stewie is watching the battle.
    La.Casparov is watching the battle.
    La.Casparov: you stuk draciel
    Draciel: ah LC for the final
    La.Casparov: suk*
    Draciel: couldnt be better
    La.Casparov: gl
    Draciel: lol
    fitzyhbbe: you have
    Draciel: Your team: Gastly / Croagunk / Pumpkaboo-L / Foongus / Porygon / Bulbasaur
    Draciel: Opponent's team: Spinarak / Riolu / Corphish / Houndour / Tirtouga / Vulpix
    fitzyhbbe: a grass stall team
    fitzyhbbe: with nearly mono poison as well
    Draciel: and u have scarf ninetales
    La.Casparov: and pory
    Draciel: g_g
    Atli is watching the battle.
    Draciel: vulpix*
    La.Casparov: twave with pory
    Draciel: nou
    La.Casparov: and chloro bulba
    fitzyhbbe: keep the porygon alive and you it beats my whole squad
    Draciel sent out Foongus!
    stewie stopped watching the battle.
    fitzyhbbe sent out Spinarak!

    Start of turn 1
    Spinarak used Sticky Web!
    Sticky Web was put around Draciel's team!

    The foe's Foongus used Spore!
    Spinarak fell asleep!

    Start of turn 2
    Draciel called Foongus back!
    Draciel sent out Croagunk!
    The foe's Croagunk became entangled in Sticky Web!
    The foe's Croagunk's Speed fell!

    Spinarak is fast asleep.

    Start of turn 3
    Spinarak woke up!
    Spinarak used Toxic Spikes!
    Poison spikes were scattered all around the feet of Draciel's team!

    The foe's Croagunk used Knock Off!
    Spinarak lost 12 HP! (57% of its health)
    The foe's Croagunk knocked off Spinarak's Focus Sash!

    Start of turn 4
    Spinarak used Megahorn!
    It's not very effective...
    The foe's Croagunk lost 13% of its health!

    The foe's Croagunk used Knock Off!
    Spinarak lost 8 HP! (38% of its health)

    Start of turn 5
    Spinarak used Megahorn!
    The attack of Spinarak missed!

    The foe's Croagunk used Drain Punch!
    It's not very effective...
    Spinarak lost 1 HP! (4% of its health)
    Spinarak had its energy drained!
    Spinarak fainted!

    fitzyhbbe sent out Vulpix!

    Vulpix's Drought intensified the sun's rays!
    La.Neptune is watching the battle.
    La.Neptune stopped watching the battle.
    fitzyhbbe: hello
    Draciel: eh sorry phone call

    Start of turn 6
    Draciel called Croagunk back!
    Draciel sent out Bulbasaur!
    The foe's Bulbasaur became entangled in Sticky Web!
    The foe's Bulbasaur's Speed fell!
    The poison spikes disappeared around the foe's Bulbasaur's feet!

    Vulpix used Fire Blast!
    It's super effective!
    The foe's Bulbasaur lost 83% of its health!

    The sunlight is strong.
    priyank stopped watching the battle.
    La.Casparov: lies

    Start of turn 7

     
  13. Fuzzysqurl

    Fuzzysqurl baa baa mareep I do what I want Server Owner Developer I do what I want Server Owner Developer

    Joined:
    Sep 12, 2012
    Messages:
    2,096
    Likes Received:
    967
    I briefly tested this and in my 10 or so uses, I rolled the exact same damage each time (the 83%, or 20 HP), so just confirming there's a bug, but who knows where. I tried to see if maybe Croagunk had an effect with Dry Skin but got nothing. We'll have to double check after sulcata fixes damage formula if this is still present or not.
     
  14. sulcata

    sulcata stéphane curry best waifu Forum Moderator Server Administrator Forum Moderator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    Fixed all of GSC's damage I think. Speaking that I just rewrote the whole damage formula for GSC, it's very possible I introduced some bugs, but so far things seem fine and each feature seems to be working.

    There were also some very minor issues with RBY that I fixed.

    Next I think I'll try gutting it for Adv, although I'm not really sure if there's anything wrong with Adv. Either way it'd be good to go over.
     
  15. turbedi

    turbedi Professional circle clicker ~~~ Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jul 18, 2013
    Messages:
    385
    Likes Received:
    155
    PO Trainer Name:
    turbedi
    Are there still any known Damage Formula errors or can this be marked as Fixed?
     
  16. sulcata

    sulcata stéphane curry best waifu Forum Moderator Server Administrator Forum Moderator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    All of gen 5 is done mostly wrong from what I've seen, and I think gen 6 should probably also be most similar to 5, but nobody has really done a look through a disassembly. RBY and GSC should be fine in terms of damage. Gens 3 and 4 I don't know about.

    It's not like it's multiple percent off, usually something gets rounded wrong or something is applied in the wrong order, little nuances like that.

    Edit: in terms of specific bugs, I'm 99% sure rolls in LC for gens 5 & 6 are still quite bugged.
     
    turbedi likes this.
  17. turbedi

    turbedi Professional circle clicker ~~~ Forum Moderator Developer Forum Moderator Developer

    Joined:
    Jul 18, 2013
    Messages:
    385
    Likes Received:
    155
    PO Trainer Name:
    turbedi