BrandoSheriff
Has a tendency to figure things out
- 776
- Posts
- 17
- Years
- Age 30
- On an island with Hakaze
- Seen Feb 2, 2025
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:
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.
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:
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.
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:
![[PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work [PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work](https://imagizer.imageshack.com/img923/3659/NQqieJ.png)
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:
![[PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work [PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work](https://imagizer.imageshack.com/img922/8514/EJekrR.png)
![[PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work [PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work](https://imagizer.imageshack.com/img924/5959/F9yvcV.png)
![[PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work [PokeCommunity.com] [pokeemerald] Adding A New Ability, But It Doesn't Appear To Work](https://imagizer.imageshack.com/img922/4484/VZDq6u.png)
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:
Code:
static void Cmd_ppreduce(void)
{
CMD_ARGS();
s32 i, ppToDeduct = 1, [COLOR="Green"]ppToDeductPoly = 3[/COLOR];
if (gBattleControllerExecFlags)
return;
if (!gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure)
{
switch (GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove))
{
case MOVE_TARGET_FOES_AND_ALLY:
for (i = 0; i < gBattlersCount; i++)
{
if (i != gBattlerAttacker && IsBattlerAlive(i))
ppToDeduct += (GetBattlerAbility(i) == ABILITY_PRESSURE);
}
break;
case MOVE_TARGET_BOTH:
case MOVE_TARGET_OPPONENTS_FIELD:
for (i = 0; i < gBattlersCount; i++)
{
if (GetBattlerSide(i) != GetBattlerSide(gBattlerAttacker) && IsBattlerAlive(i))
ppToDeduct += (GetBattlerAbility(i) == ABILITY_PRESSURE);
}
break;
default:
if (gBattlerAttacker != gBattlerTarget && GetBattlerAbility(gBattlerTarget) == ABILITY_PRESSURE)
ppToDeduct++;
break;
}
}
[COLOR="Green"] if (!gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPolycompression)
{
switch (GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove))
{
case MOVE_TARGET_FOES_AND_ALLY:
for (i = 0; i < gBattlersCount; i++)
{
if (i != gBattlerAttacker && IsBattlerAlive(i))
ppToDeductPoly += (GetBattlerAbility(i) == ABILITY_POLY_COMPRESSION);
}
break;
case MOVE_TARGET_BOTH:
case MOVE_TARGET_OPPONENTS_FIELD:
for (i = 0; i < gBattlersCount; i++)
{
if (GetBattlerSide(i) != GetBattlerSide(gBattlerAttacker) && IsBattlerAlive(i))
ppToDeductPoly += (GetBattlerAbility(i) == ABILITY_POLY_COMPRESSION);
}
break;
default:
if (gBattlerAttacker != gBattlerTarget && GetBattlerAbility(gBattlerTarget) == ABILITY_POLY_COMPRESSION)
ppToDeductPoly++;
break;
}
} [/COLOR]
if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos])
{
gProtectStructs[gBattlerAttacker].notFirstStrike = TRUE;
// For item Metronome, echoed voice
if (gCurrentMove == gLastResultingMoves[gBattlerAttacker]
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& !WasUnableToUseMove(gBattlerAttacker)
&& gSpecialStatuses[gBattlerAttacker].parentalBondState != PARENTAL_BOND_1ST_HIT) // Don't increment counter on first hit
gBattleStruct->sameMoveTurns[gBattlerAttacker]++;
else
gBattleStruct->sameMoveTurns[gBattlerAttacker] = 0;
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;
if (MOVE_IS_PERMANENT(gBattlerAttacker, gCurrMovePos))
{
gActiveBattler = gBattlerAttacker;
BtlController_EmitSetMonData(BUFFER_A, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0,
sizeof(gBattleMons[gBattlerAttacker].pp[gCurrMovePos]),
&gBattleMons[gBattlerAttacker].pp[gCurrMovePos]);
MarkBattlerForControllerExec(gBattlerAttacker);
}
}
gHitMarker &= ~HITMARKER_NO_PPDEDUCT;
gBattlescriptCurrInstr = cmd->nextInstr;
}
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: