• 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.

[Battle✓] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work

BrandoSheriff

Has a tendency to figure things out
776
Posts
16
Years
  • Hi, sorry again for flooding this with all my silly questions.

    I'm trying to implement a new ability that's basically Pressure, but takes away more PP. I've been following this guide here:
    https://github.com/pret/pokeemerald/wiki/How-to-add-a-new-ability

    Now, the ability itself shows up in-game and everything, including the popup text, but it just doesn't work like it's supposed to. Like the guide says, I looked into how Pressure was being done, and basically copied it but replaced things like "ABILITY_PRESSURE" with the name of my ability. Like so in src\battle_util.c:
    Spoiler:
    This just seems to control the ability popup when you send out the Pokemon with said ability.


    And then there are these 3 functions as well in include\battle_util.h. Pressure's versions are included for comparison. I found them in battle_util.c and basically copied them.
    Spoiler:


    I also edited the ppreduce function in src\battle_script_commands.c to account for the new ability, which is supposed to take away 4 PP instead of 2:
    Spoiler:
    And yes, I did define ppNotAffectedByPolycompression:1 the exact same way as ppNotAffectedByPressure:1 in include\battle.h. Could that be why? Is there a specific reason for the :1 at the end of u8 ppNotAffectedByPressure:1;?

    I'm just not sure what's wrong here tbh. Am I reading the code wrong? (Knowing me, I probably am somewhere) Or am I missing any other reference to the ability Pressure? Something to note is if I happen to change the ppToDeduct variable to 3 like the one I made, Pressure does in fact work in-game exactly as I want my new ability to do. But the new ability just doesn't work, and I just lose 1 PP like normal. Any help would be incredibly appreciated, as I can't for the life of me figure out why I can't at least imitate Pressure.
     
    Last edited:
    448
    Posts
    6
    Years
    • Seen May 6, 2024

    I think your problem might be here:
    Code:
            if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeduct)
                gBattleMons[gBattlerAttacker].pp[gCurrMovePos] -= ppToDeduct;
    [COLOR="Green"]        else if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeductPoly) //Not sure about this here tbh
                gBattleMons[gBattlerAttacker].pp[gCurrMovePos] -= ppToDeductPoly;	[/COLOR]	
            else
                gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = 0;

    Your code will never actually run since ppToDeduct is set to 1, so the second condition is never true when the first isn't.
    Is there any reason for this code and the ppToDeductPoly variable to exist? Couldn't you just change the value of ppToDeduct inside the polycompression code block the same way the game normally changes its value in the pressure code block?

    Also, since you created ppNotAffectedByPolycompression, you should probably set its value in the same places where ppNotAffectedByPressure is set. If you don't have a specific reason for creating that struct field, you might want to just use ppNotAffectedByPressure instead.
     
    Last edited:

    BrandoSheriff

    Has a tendency to figure things out
    776
    Posts
    16
    Years
  • I think your problem might be here:
    Code:
            if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeduct)
                gBattleMons[gBattlerAttacker].pp[gCurrMovePos] -= ppToDeduct;
    [COLOR="Green"]        else if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeductPoly) //Not sure about this here tbh
                gBattleMons[gBattlerAttacker].pp[gCurrMovePos] -= ppToDeductPoly;	[/COLOR]	
            else
                gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = 0;

    Your code will never actually run since ppToDeduct is set to 1, so the second condition is never true when the first isn't.
    Is there any reason for this code and the ppToDeductPoly variable to exist? Couldn't you just change the value of ppToDeduct inside the polycompression code block the same way the game normally changes its value in the pressure code block?

    Also, since you created ppNotAffectedByPolycompression, you should probably set its value in the same places where ppNotAffectedByPressure is set. If you don't have a specific reason for creating that struct field, you might want to just use ppNotAffectedByPressure instead.

    Thank you for the feedback! I've revised the ppreduce codeblock to consider both abilities in the same ppNotAffectedByPressure block and removed the aforementioned bit colored in green that was quoted since it really wasn't needed after all. You're also right, there was no need to define another variable when I could just set the initial ppToDeduct to equal a different value when I needed it to.

    And after doing all that, lo and behold, my new ability now works the way it should! I appreciate the help!
     
    448
    Posts
    6
    Years
    • Seen May 6, 2024
    Thank you for the feedback! I've revised the ppreduce codeblock to consider both abilities in the same ppNotAffectedByPressure block and removed the aforementioned bit colored in green that was quoted since it really wasn't needed after all. You're also right, there was no need to define another variable when I could just set the initial ppToDeduct to equal a different value when I needed it to.

    And after doing all that, lo and behold, my new ability now works the way it should! I appreciate the help!

    Glad to hear that you got it to work!

    Looking at your initial post again, I see that I overlooked the code in the second spoiler. You should probably make those functions reduce PP by more than 1 and add calls to them in the same places where the original pressure functions are called, if you didn't do that already.
     
    Back
    Top