doshidak / showdex

Pokémon Showdown extension that harnesses the power of parabolic calculus to strategically extract your opponents' Elo.
GNU Affero General Public License v3.0
104 stars 18 forks source link

Damage calculation does not update after power trick #143

Closed BlackCapCoder closed 1 year ago

BlackCapCoder commented 1 year ago

If I have a max defense shuckle and use power trick my attack is correctly displayed as 614, but the damage calculation for attacks seems to use my original attack stat (showing things like 1-2% when it's really a 1HKO), and attacks against me uses my original defense stat (basically any physical move should be a 1HKO).

screenshot

BlackCapCoder commented 1 year ago

On turn 4, shuckle's attack is correctly displayed as 921, but smeargle transformed into shuckle has a displayed attack of 87. An attack from either pokemon allegedly does the same amount of damage: https://play.pokemonshowdown.com/battle-gen7doublesou-1910442270

Edit: Showdown recently lost all replays, so just for archiving reasons, here is the team in question https://pokepast.es/8353fa3c5fcba429 , and the scenario we are talking about is probably trick room+power trick, followed by transform+rock slide.

doshidak commented 1 year ago

Hiya!

Ayy Power Trick Shuckle, one of my favs... but two ?! Yikes... Ditto has somehow found a way to haunt me again, just when I was thinking it was over hahah. Seems to be some kind of strange interaction handling both Transform & Power Trick (think I have an idea where actually!).

I'll take a look into this & see if I can squeeze it in the v1.1.6 release that's dropping soon.

Also just fyi, the stats you see in the Calcdex are purely visual & unfortunately not passed to the internal damage calc that spits out the numbers & NHKO amounts you see in the Moves table. I say unfortunately because Showdex uses the same internal calc library as the good 'ol calc.ps & just like how you can't specify the final stat values on there (only base/IVs/EVs/boosts), the internal calc's API doesn't allow me to do that either, hence the discrepancies in the calc'd damages & displayed stat values.

(Also on the flip-side, there was no way for me to tap its internal stat modifiers, so I had to write my own, which is what you see for the stat values.)

Anyway, thanks for your report (& the replay)!

doshidak commented 1 year ago

Good news! I was able to fix this issue.

Turns out that the internal damage calc doesn't respond to Power Trick at all, which I'm faintly remembering that I had to manually switch the base ATK & DEF stats to get around that. The fix is to basically do the ATK/DEF switch for you when the Power Trick volatile is detected (which you can verify if you see it underneath the Pokémon's HP bar).

Also didn't know about the Transform & Power Trick interaction, so I made sure that was being handled properly. Instead of copying the swapped base stats of the Transform-target Pokémon, I just made sure the Power Trick volatile was also copied to the post-transformed Pokémon, so you can make use of this new feature I also added:

showdex-power-trick-toggle

...which basically toggles the Power Trick volatile. Then during a battle sync, the toggle will revert to whatever state was detected in-battle.

This will be included in the upcoming v1.1.6 release. Thanks again! c:

BlackCapCoder commented 9 months ago

Hey, sorry about the radio silence- I didn't see this until now! I really appreciate how quickly you handled this :heart: