• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Need Help Hex Editing the following Script

55
Posts
9
Years
    • Seen May 4, 2024
    You know how you can not only hex edit which types hit for super effective or not very effective correct?

    Example: In a data table, you can find <00 05 05> which signifies Normal is not very effective against Rock which halfs the damage hence the <05> at the end of that entry.

    Turns out editing the third value to something like 0f which means x 1.5 the damage, it doesn't register the attack as dealing "Super Effective" Damage.

    Normally this wouldn't matter because the damage mod for type effectiveness would be what's on the table. That is until we run into a Shedinja, ergo a Wonder Guard Shendinja

    This means changing each entry's third byte from 14 to anything else would make it so Shedinja won't be damaged by the attack.

    I've traced the part of the battle_command script from the pokeemerald disassembly which determines whether an attack is registered as "super-effective" or not.

    The part of the script is as follows:


    if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20)
    flags |= 1;
    if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
    && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
    && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE)
    flags |= 1;

    if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5)
    flags |= 2;
    if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2
    && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2
    && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE)
    flags |= 2;
    }
    i += 3;
    }


    I need to know either the hexcode that corresponds to the operands/functions to this part of the script or more ideally the offset of the location where I can find and edit this part of the script in a Hex Editor seeing as I have no laptop to use a better method for this. Knowing both however would greatly help.

    If anyone has anything that could help me edit this accordingly here...much appreciated.

    Thanks in advance.
     
    Last edited:

    Asith

    Uwao
    237
    Posts
    3
    Years
    • Seen yesterday
    I'm really not understanding your goal but in any case the function you quoted is CheckWonderGuardAndLevitate() and it starts at 0801eab8 in the rom. It being such a long function will not make it easy to find the exact location you want to edit though, good luck
     
    55
    Posts
    9
    Years
    • Seen May 4, 2024
    What in trying to edit is in the script I posted, ideally I want to edit these lines

    if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20)
    flags |= 1;


    if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5)
    flags |= 2;

    Specifically I want to make it

    " > 10 " where it says "== 20"

    and

    " < 10 " where it says "== 5"

    That way anything above a x1 mod registers as super effective and will hit through wonder guard and anything below that registers as not very effective. I know this is possible because the values 20 and 5(hex 14 and 05) are hardcoded and can theoretically be changed maybe even the operabd comparing the value to whatever it checks on the table as well.
     
    55
    Posts
    9
    Years
    • Seen May 4, 2024
    Ok so I found the bytes in the script I wish to edit

    1f46d-1f46e which is <20 14>; 20 I assume is the operand byte that corresponds to "==" which is the "equal to" operand and 14 is 20 in hex which denotes x2 type effectiveness damage modifier for which the game normally considers an attack super effective.

    And of course 1f48b-1f48c which is the same as above but deals with registering an attack based on type effectiveness as not very effective, hence the 05 in <20 05>.

    All that's left to do is figure out what to change each 20 to in order to change the operand from "equal to" to either "less than" or "greater than". Unless someone here already knows and is willing to tell me.

    Either way thanks for your help on pointing me in the right direction @Asith.
     
    55
    Posts
    9
    Years
    • Seen May 4, 2024
    OK it turns out hex editing the values above did absolutely nothing and now I am at a complete loss as of what to do to in order to register any damage above 100% as Super Effective and and anything below that as Not Very Effective.

    Anyone have any ideas?
     

    Asith

    Uwao
    237
    Posts
    3
    Years
    • Seen yesterday
    OK it turns out hex editing the values above did absolutely nothing and now I am at a complete loss as of what to do to in order to register any damage above 100% as Super Effective and and anything below that as Not Very Effective.

    Anyone have any ideas?
    fwiw, there's more than one place you'd have to change in that function. TYPE_EFFECT_MULTIPLIER(i) == 20 and TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE are both really the same thing, you'd have to change both instances to alter logic the way you want. Same for not very effective.
    That's just a guess though, this is a really messy methodology so any number of things may not work. I'd ask why you can't just use a multiplier of 20 instead of 16 (0F is 16/x1.6, not 15/x1.5)
     
    55
    Posts
    9
    Years
    • Seen May 4, 2024
    Unfortunately my lack of ASM knowledge with an inability to code it and recompile it on a Phone, means I'll have to settle for the defaults.

    (Also 0f is 15 in Hex 10 is 16 in Hex, not that it matters much, I'll just have to adapt accordingly.
     
    Back
    Top