diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4ea8042a71..f0d4f4c973 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6948,13 +6948,13 @@ BattleScript_SnowWarningActivates:: BattleScript_TerrainSeedLoop: savetarget setbyte gBattlerTarget, 0 -TerrainSeedLoop: +BattleScript_TerrainSeedLoopIter: copybyte sBATTLER, gBattlerTarget - doterrainseed BS_TARGET, TerrainSeedLoop_NextBattler + doterrainseed BS_TARGET, BattleScript_TerrainSeedLoop_NextBattler removeitem BS_TARGET -TerrainSeedLoop_NextBattler: +BattleScript_TerrainSeedLoop_NextBattler: addbyte gBattlerTarget, 0x1 - jumpifbytenotequal gBattlerTarget, gBattlersCount, TerrainSeedLoop + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TerrainSeedLoopIter restoretarget return @@ -7187,6 +7187,7 @@ BattleScript_AbilityNoSpecificStatLoss:: printstring STRINGID_PKMNSXPREVENTSYLOSS waitmessage B_WAIT_TIME_LONG setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY + orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT return BattleScript_StickyHoldActivates:: diff --git a/include/battle.h b/include/battle.h index a3f7d027d0..43a941737e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -126,7 +126,7 @@ struct ProtectStruct u32 stealMove:1; u32 prlzImmobility:1; u32 confusionSelfDmg:1; - u32 targetNotAffected:1; + u32 targetAffected:1; u32 chargingTurn:1; u32 fleeFlag:2; // For RunAway and Smoke Ball. u32 usedImprisonedMove:1; diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index f35a377669..a59b930b49 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -231,15 +231,15 @@ #define MOVEEND_ITEM_EFFECTS_TARGET 13 #define MOVEEND_MOVE_EFFECTS2 14 #define MOVEEND_ITEM_EFFECTS_ALL 15 -#define MOVEEND_KINGSROCK 16 // these item effects will occur each strike of a multi-hit move +#define MOVEEND_KINGSROCK 16 // These item effects will occur each strike of a multi-hit move #define MOVEEND_SUBSTITUTE 17 #define MOVEEND_UPDATE_LAST_MOVES 18 #define MOVEEND_MIRROR_MOVE 19 -#define MOVEEND_NEXT_TARGET 20 // everything up until here is handled for each strike of a multi-hit move +#define MOVEEND_NEXT_TARGET 20 // Everything up until here is handled for each strike of a multi-hit move #define MOVEEND_EJECT_BUTTON 21 #define MOVEEND_RED_CARD 22 #define MOVEEND_EJECT_PACK 23 -#define MOVEEND_LIFEORB_SHELLBELL 24 // includes shell bell, throat spray, etc +#define MOVEEND_LIFEORB_SHELLBELL 24 // Includes shell bell, throat spray, etc #define MOVEEND_PICKPOCKET 25 #define MOVEEND_DANCER 26 #define MOVEEND_EMERGENCY_EXIT 27 diff --git a/src/battle_main.c b/src/battle_main.c index aed1dc568d..74995bbf3a 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3078,7 +3078,7 @@ void FaintClearSetData(void) gProtectStructs[gActiveBattler].stealMove = 0; gProtectStructs[gActiveBattler].prlzImmobility = 0; gProtectStructs[gActiveBattler].confusionSelfDmg = 0; - gProtectStructs[gActiveBattler].targetNotAffected = 0; + gProtectStructs[gActiveBattler].targetAffected = 0; gProtectStructs[gActiveBattler].chargingTurn = 0; gProtectStructs[gActiveBattler].fleeFlag = 0; gProtectStructs[gActiveBattler].usedImprisonedMove = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0440900697..6ba74177df 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4913,8 +4913,8 @@ static void Cmd_moveend(void) else gBattleScripting.moveendState++; break; - case MOVEEND_KINGSROCK: // king's rock and shell bell - // these effects will occur at each hit in a multi-strike move + case MOVEEND_KINGSROCK: // King's rock and shell bell + // These effects will occur at each hit in a multi-strike move if (ItemBattleEffects(ITEMEFFECT_KINGSROCK, 0, FALSE)) effect = TRUE; gBattleScripting.moveendState++; @@ -5043,6 +5043,11 @@ static void Cmd_moveend(void) gBattleScripting.moveendState++; break; case MOVEEND_NEXT_TARGET: // For moves hitting two opposing Pokemon. + // Set a flag if move hits either target (for throat spray that can't check damage) + if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) + gProtectStructs[gBattlerAttacker].targetAffected = 1; + if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !gProtectStructs[gBattlerAttacker].chargingTurn @@ -5285,6 +5290,7 @@ static void Cmd_moveend(void) if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget) *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3; gProtectStructs[gBattlerAttacker].usesBouncedMove = 0; + gProtectStructs[gBattlerAttacker].targetAffected = 0; gBattleStruct->ateBoost[gBattlerAttacker] = 0; gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST); gSpecialStatuses[gBattlerAttacker].gemBoost = 0; @@ -5554,7 +5560,7 @@ bool32 CanBattlerSwitch(u32 battlerId) } else { - // check if attacker side has mon to switch into + // Check if attacker side has mon to switch into battlerIn1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) @@ -6147,7 +6153,7 @@ static void Cmd_endlinkbattle(void) } static void Cmd_returntoball(void) -{ +{ gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); BtlController_EmitReturnMonToBall(0, 1); MarkBattlerForControllerExec(gActiveBattler); @@ -7802,7 +7808,7 @@ static void Cmd_various(void) if (GetBattlerAbility(gActiveBattler) == ABILITY_BEAST_BOOST && HasAttackerFaintedTarget() && !NoAliveMonsForEitherParty() - && CompareStat(gActiveBattler, i, MAX_STAT_STAGE, CMP_LESS_THAN)) + && CompareStat(gBattlerAttacker, i, MAX_STAT_STAGE, CMP_LESS_THAN)) { gBattleMons[gBattlerAttacker].statStages[i]++; SET_STATCHANGER(i, 1, FALSE); diff --git a/src/battle_util.c b/src/battle_util.c index bc5c7e0e79..ab7db3d88e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1410,7 +1410,6 @@ void CancelMultiTurnMoves(u8 battler) bool8 WasUnableToUseMove(u8 battler) { if (gProtectStructs[battler].prlzImmobility - || gProtectStructs[battler].targetNotAffected || gProtectStructs[battler].usedImprisonedMove || gProtectStructs[battler].loveImmobility || gProtectStructs[battler].usedDisabledMove @@ -6399,10 +6398,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) switch (atkHoldEffect) { case HOLD_EFFECT_SHELL_BELL: - if (gBattleMoveDamage != 0 // Need to have done damage - && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gSpecialStatuses[gBattlerTarget].dmg != 0 - && gSpecialStatuses[gBattlerTarget].dmg != 0xFFFF + if (gSpecialStatuses[gBattlerAttacker].damagedMons // Need to have done damage && gBattlerAttacker != gBattlerTarget && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP && gBattleMons[gBattlerAttacker].hp != 0) @@ -6435,8 +6431,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_THROAT_SPRAY: // Does NOT need to be a damaging move - if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && !(gHitMarker & (HITMARKER_UNABLE_TO_USE_MOVE)) + if (gProtectStructs[gBattlerAttacker].targetAffected && gBattleMons[gBattlerAttacker].hp != 0 && gBattleMoves[gCurrentMove].flags & FLAG_SOUND && CompareStat(gBattlerAttacker, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN)