Strange things with Swdance Marowak

Discussion in 'Bugs and Fixes' started by Bekins, Jun 13, 2015.

  1. Bekins

    Bekins Member

    Joined:
    Jan 6, 2015
    Messages:
    26
    Likes Received:
    69
    Raikou used Reflect!
    Reflect raised **'s team defense!

    Start of turn 3
    ** called Raikou back!
    ** sent out Forretress!

    The foe's Marowak used Swords Dance!
    The foe's Marowak's Attack sharply rose!

    Start of turn 4
    The foe's Marowak used Swords Dance!
    The foe's Marowak's Attack won't go any higher!

    Forretress used Spikes!
    Spikes were scattered all around the feet of 222's team!

    Start of turn 5
    The foe's Marowak used Earthquake!
    Forretress lost 166 HP! (47% of its health)

    Forretress used Curse!
    Forretress's Attack rose!
    Forretress's Defense rose!
    Forretress's Speed fell!

    Forretress restored a little HP using its Leftovers!

    Start of turn 6
    The foe's Marowak used Earthquake!
    Forretress lost 209 HP! (59% of its health)
    Forretress fainted!

    Nonsense.

    1: The second sword dance didn't reset the atk (is this an intentional fix?)
    2: With Reflect still up, a swdanced EQ did 59% to a CURSED Forretress.


    Another thing: I've recently seen that Encore doesn't work on Sleep Talk anymore. Is that correct or it's another bug?


    @sulcata
     
  2. turbedi

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

    Joined:
    Jul 18, 2013
    Messages:
    385
    Likes Received:
    155
    PO Trainer Name:
    turbedi
    I don't really understand the first part. What do you mean with "didn't reset the atk"?
    To the second part: I calculated this with Sulcata's Damage Calculator and it seems to be fine.

    EDIT: Nevermind, I am just dumb.. I shouldn't stay up too long next time. ^^'
     
    Last edited: Jun 14, 2015
  3. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    Turbedi it's GSC :x

    And to Bekins' nonsense, I say that's all GSC is!

    Forretress' Defense stat prior to boosting is 378.
    Forretress gets a +1 boost, making the defense stat 567.
    Forretress gets a 2x bonus from Reflect, making the defense stat 1134.
    I've checked with Crystal_ on the damage formula previously, screens do still affect stats in GSC like in RBY. Screens, like Thick Club, are not constrained to the 999 cap.

    Okay so we have a defense of 1134, here's where the janky GSC starts happening:
    If either or both stats exceed 255, the game divides both by 4 and then keeps only the first byte of each. This is done to prevent damage overflows. To make the explanation a little bit simpler, finding the remainder by dividing the stat by 256 can be considered equivalent in this scenario.

    floor(1134/4) = 283
    The remainder of 283 divided by 256 is 27.
    So your Forretress' defense became 27, which is correct. I recall a similar situation happening with Steelix under Reflect + Curse.

    Since Marowak did that much damage under Reflect (no curse) with a Swords Dance. I'm going to assume that it was HP Bug. I am unsure if this is correct or not, but the server did not allow me to Swords Dance twice using an HP Bug Marowak, so this would seem like the logical conclusion given the situation.

    HP Bug Marowak's Attack stat prior to boosting is 254.
    Marowak gets a +2 boost, making the attack stat 508.
    Marowak gets a 2x bonus from Thick Club, making the attack stat 1016.

    floor(1016/4) = 254
    The remainder of 254 divided by 256 is 254.
    So your opponent's attack became 254 if he was HP Bug.

    If he wasn't HP Bug and just adjusted his DVs, he'd be 255. If he didn't adjust anything he'd end up with an attack of 2, which seems unlikely given the non-Curse damage.

    Marowak's Attack: 254 (probably)
    Forretress' Defense with Reflect: 189 (no curse) and 27 (curse overflow)

    The damage roll for +2 HP Bug Marowak v. Reflect Forretress seems normal to me.
    The damage roll for +2 HP Bug Marowak (254 atk) v. Reflect +1 Forretress (27 def) should be expected to be really high.

    So the damages are correct, but I don't know about the battle mechanics. The only possible bug I can see is whether or not Marowak should've been prevented from using Swords Dance twice. If someone would like to test this on cartridge or through an emulator, that'd be really helpful. My gut is telling me it should've been able to do the second SD, but who knows.

    On a funny note, Curse+Reflect Steelix's defense stat overflows so much that it actually comes around to a half decent 117, which is about the same as an unscaled 468 defense stat.

    tl;dr your Forretress' defense stat overflowed as expected for GSC mechanics as I understand them from crystal_. idk if marowak should've been prevented from SD'ing twice.

    If your stat is greater than 511 before Light Screen/Reflect or Thick Club/Light Ball, then it overflows.

    Unrelated to the changes I made but: http://pokemon-online.eu/threads/gsc-sleep-talk-encore.28236/
     
    Last edited: Jun 14, 2015
    Crystal_ and Edna like this.
  4. Bekins

    Bekins Member

    Joined:
    Jan 6, 2015
    Messages:
    26
    Likes Received:
    69
    Thanks. I didn't knew that Reflect actually raises defense in gsc lolz
     
  5. M Dragon

    M Dragon Active Member

    Joined:
    Sep 1, 2010
    Messages:
    290
    Likes Received:
    120
    Can you link me where Crystal_ says Reflect makes the defense stat overflow? I had never heard of that
     
  6. 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
  7. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    Well, I started a VM with Crystal_ and Fuzzysqurl in which I wrote out what I understood of the GSC damage formula and had Crystal_ make a few corrections on things here and there.
    He had no objections to when I wrote out "Cap the stat at 999" occurring before "the Light Screen/Reflect boost". Essentially I wrote it in the same manner as I specified Light Ball and Thick Club in my list. There's no reason it shouldn't overflow unless it's subject to the 999 cap, which as far as I've been told and seen it is not (it can overflow in RBY too). This would be due to the stat scaling it undergoes matching that of the attack stat. He seemed very particular when he corrected the order of things, so I'd guess he didn't miss it.

    If someone wants to test and see how much damage an unboosted snorlax or marowak or whatever does v. Reflect+1 Curse Forretress, that'd be helpful as I'm not too familiar with emulators. Steelix won't work because its stat would overflow so much that the damage roll will be very similar.

    If someone is testing, they should probably also test if Thick Club's boost prevents a second swords dance while they're at it. Just take a fully EV'd Marowak+Thick Club and SD twice to see if it fails.
     
    Last edited: Jun 14, 2015
  8. M Dragon

    M Dragon Active Member

    Joined:
    Sep 1, 2010
    Messages:
    290
    Likes Received:
    120
    The Thick Club thing is a different case and it happens only in GS, I dont think it happens with Reflect or Light Screen
     
  9. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    Thick Club is the same thing as it occurs due to stat scaling. Both the attack and defense stat, if they are too large (>255) will be divided by 4, and then fit into 1 byte by discarding the rest (creates "rollover"). In other words, any stat in which after being divided by 4 is still greater than 255 rolls over. A specific case of this is with the Attack stat for Marowak+Thick Club. This can also occur if Pikachu were to be Baton Passed +4 SAtk while holding a Light Ball.

    Thick Club allows the attack stat to increase past 999 as it takes effect after the 999 cap, which would otherwise allow the scaled stats to naturally fit into 1 byte. As far as I know Reflect and Light Screen also occur after the 999 cap, allowing them to increase the stat beyond 999.
     
  10. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    968
    Likes Received:
    744
    I just tested it. People really don't realize how similar RBY and GSC are in battle mechanics. Don't have the means to record a video, but I used a Pokemon Gold ROM. Pokemon Gold was used as Crystal has slightly different in-game mechanics that revert to Gold's mechanics for Link Battles (all we're concerned with competitively).
    Hacked in a Forretress with 343 defense, Curse, and Reflect as well as a Super Rod.
    Fished in the nearest water source and eventually got a Chinchou.

    Chinchou used Confuse Ray after I used Reflect. I took 15 damage.
    I snapped out and used Curse. Chinchou proceeded to use Confuse Ray.
    I hit myself in confusion and lost the rest of my health in a single hit, 338 damage.

    343*3/2 = 514
    (514*2) = 1028
    (1028/4)%256 = 1
    So I had 1 defense (I didn't max my defense for emphasis)

    We get the original stat
    343: 0000 0001 0101 0111
    Then we multiply by 15, divide by 10, and immediately floor (integer division). Cap at 999 if necessary.
    514: 0000 0010 0000 0010
    Then we multiply by 2. Although I think the game just shifts the binary representation once to the left technically. This step and all that follow are not subject to the 999 cap.
    1028: 0000 0100 0000 0100
    Then we divide by 4 (again integer division). Also, probably just a rightward binary shift by two places instead of actually division.
    257: 0000 0001 0000 0001
    The game then tries to cram this 16-bit integer into an 8-bit integer (1 byte)
    1: 0000 0001 0000 0001
    And now we have 1 defense!

    So yah, Reflect+Light Screen do the same thing as Thick Club since they go through the same process of stat scaling that causes the Thick Club "rollover" (more like truncation).

    If that wasn't rollover, I don't know what is. Will edit in testing with Marowak+Thick Club below. I guess moral of the story is "make sure your boosted stat isn't higher than 511 while screens are up"? Or maybe just "GSC is almost as weird as RBY".

    Edit: Just tested. You shouldn't get a message of the move failing for Marowak using Swords Dance twice. I think something in PO's code got slightly misplaced/misused. I'll look into it either this weekend or earlier. It seems like damage is correct though. At the very least there's no real competitive reason to use SD twice with Marowak!

    Edit2: Tiba posted a video he made in the other thread reaffirming what I observed on the emulator. So thanks to him for that!
     
    Last edited: Jun 20, 2015
    Crystal_ and E.T. like this.
  11. Crystal_

    Crystal_ Active Member

    Joined:
    Mar 5, 2011
    Messages:
    187
    Likes Received:
    29
    Whoops, sorry for not showing up before.

    This was actually fixed in Crystal, where the game will just keep scaling by four until the highest bytes are both equal to 0. However, link battles use Gold/Silver mechs for obvious reasons as sulcata said.

    You indeed can use SD twice with Marowak since its attack stat will be lower than 999 after the first one. The thick club boost is not saved to stat value; it's a damage calculation only thing just like Reflect and Light Screen.