updated Cmd_attackstring and Cmd_ppreduce

This commit is contained in:
cawtds 2024-04-29 23:19:22 +02:00
parent bb55f18b33
commit 459c59b42e
3 changed files with 41 additions and 27 deletions

View File

@ -104,7 +104,7 @@ void PressurePPLoseOnUsingPerishSong(u8 attacker);
void MarkBattlerForControllerExec(u8 battlerId);
void MarkBattlerReceivedLinkData(u8 battlerId);
void CancelMultiTurnMoves(u8 battler);
bool8 WasUnableToUseMove(u8 battler);
bool32 WasUnableToUseMove(u32 battler);
void PrepareStringBattle(u16 stringId, u8 battler);
void ResetSentPokesToOpponentValue(void);
void OpponentSwitchInResetSentPokesToOpponentValue(u8 battler);

View File

@ -346,9 +346,9 @@ static void Cmd_callnative(void);
void (* const gBattleScriptingCommandsTable[])(void) =
{
Cmd_attackcanceler, //0x0
Cmd_accuracycheck, //0x1
Cmd_attackstring, //0x2
Cmd_attackcanceler, //0x0 // done
Cmd_accuracycheck, //0x1 // done
Cmd_attackstring, //0x2 // done
Cmd_ppreduce, //0x3
Cmd_critcalc, //0x4
Cmd_damagecalc, //0x5
@ -1485,6 +1485,8 @@ static void Cmd_accuracycheck(void)
static void Cmd_attackstring(void)
{
CMD_ARGS();
if (gBattleControllerExecFlags)
return;
@ -1493,38 +1495,47 @@ static void Cmd_attackstring(void)
PrepareStringBattle(STRINGID_USEDMOVE, gBattlerAttacker);
gHitMarker |= HITMARKER_ATTACKSTRING_PRINTED;
}
gBattlescriptCurrInstr++;
gBattlescriptCurrInstr = cmd->nextInstr;
gBattleCommunication[MSG_DISPLAY] = 0;
}
static void Cmd_ppreduce(void)
{
s32 ppToDeduct = 1;
CMD_ARGS();
s32 i, ppToDeduct = 1;
u32 moveTarget = GetBattlerMoveTargetType(gBattlerAttacker, gCurrentMove);
if (gBattleControllerExecFlags)
return;
if (!gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure)
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)
gHitMarker |= HITMARKER_NO_PPDEDUCT;
if (moveTarget == MOVE_TARGET_BOTH
|| moveTarget == MOVE_TARGET_FOES_AND_ALLY
|| moveTarget == MOVE_TARGET_ALL_BATTLERS
|| gMovesInfo[gCurrentMove].forcePressure)
{
switch (gMovesInfo[gCurrentMove].target)
for (i = 0; i < gBattlersCount; i++)
{
case MOVE_TARGET_FOES_AND_ALLY:
ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_ON_FIELD, gBattlerAttacker, ABILITY_PRESSURE, 0, 0);
break;
case MOVE_TARGET_BOTH:
case MOVE_TARGET_OPPONENTS_FIELD:
ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattlerAttacker, ABILITY_PRESSURE, 0, 0);
break;
default:
if (gBattlerAttacker != gBattlerTarget && gBattleMons[gBattlerTarget].ability == ABILITY_PRESSURE)
ppToDeduct++;
break;
if (GetBattlerSide(i) != GetBattlerSide(gBattlerAttacker) && IsBattlerAlive(i))
ppToDeduct += (GetBattlerAbility(i) == ABILITY_PRESSURE);
}
}
else if (moveTarget != MOVE_TARGET_OPPONENTS_FIELD)
{
if (gBattlerAttacker != gBattlerTarget && GetBattlerAbility(gBattlerTarget) == ABILITY_PRESSURE)
ppToDeduct++;
}
if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos])
{
gProtectStructs[gBattlerAttacker].notFirstStrike = 1;
gProtectStructs[gBattlerAttacker].notFirstStrike = TRUE;
// For item Metronome, echoed voice
if (gCurrentMove != gLastResultingMoves[gBattlerAttacker] || WasUnableToUseMove(gBattlerAttacker))
gBattleStruct->sameMoveTurns[gBattlerAttacker] = 0;
if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeduct)
gBattleMons[gBattlerAttacker].pp[gCurrMovePos] -= ppToDeduct;
@ -1533,7 +1544,6 @@ static void Cmd_ppreduce(void)
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]);
@ -1542,7 +1552,7 @@ static void Cmd_ppreduce(void)
}
gHitMarker &= ~HITMARKER_NO_PPDEDUCT;
gBattlescriptCurrInstr++;
gBattlescriptCurrInstr = cmd->nextInstr;
}
static void Cmd_critcalc(void)

View File

@ -240,17 +240,20 @@ void CancelMultiTurnMoves(u8 battler)
gDisableStructs[battler].furyCutterCounter = 0;
}
bool8 WasUnableToUseMove(u8 battler)
bool32 WasUnableToUseMove(u32 battler)
{
if (gProtectStructs[battler].prlzImmobility
|| gProtectStructs[battler].targetNotAffected
|| gProtectStructs[battler].usedImprisonedMove
|| gProtectStructs[battler].loveImmobility
|| gProtectStructs[battler].usedDisabledMove
|| gProtectStructs[battler].usedTauntedMove
|| gProtectStructs[battler].usedGravityPreventedMove
|| gProtectStructs[battler].usedHealBlockedMove
|| gProtectStructs[battler].flag2Unknown
|| gProtectStructs[battler].flinchImmobility
|| gProtectStructs[battler].confusionSelfDmg)
|| gProtectStructs[battler].confusionSelfDmg
|| gProtectStructs[battler].powderSelfDmg
|| gProtectStructs[battler].usedThroatChopPreventedMove)
return TRUE;
else
return FALSE;
@ -3885,12 +3888,13 @@ static bool32 UnnerveOn(u32 battler, u32 itemId)
u8 GetBattleMoveCategory(u32 moveId)
{
// TODO: Z-Move and Dynamax
// if (gBattleStruct != NULL && gBattleStruct->zmove.active && !IS_MOVE_STATUS(moveId))
// return gBattleStruct->zmove.activeCategory;
// if (gBattleStruct != NULL && IsMaxMove(moveId)) // TODO: Might be buggy depending on when this is called.
// return gBattleStruct->dynamax.activeCategory;
// if (gBattleStruct != NULL && gBattleStruct->swapDamageCategory) // Photon Geyser, Shell Side Arm, Light That Burns the Sky
// return DAMAGE_CATEGORY_PHYSICAL;
if (gBattleStruct != NULL && gBattleStruct->swapDamageCategory) // Photon Geyser, Shell Side Arm, Light That Burns the Sky
return DAMAGE_CATEGORY_PHYSICAL;
if (B_PHYSICAL_SPECIAL_SPLIT >= GEN_4)
return gMovesInfo[moveId].category;