diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 52c21dc68a7..63ba181585e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -333,7 +333,8 @@ BattleScript_EffectPledge:: goto BattleScript_MoveEnd BattleScript_EffectCombinedPledge_Water:: - call BattleScript_EffectHit_Pledge + call BattleScript_EffectHit_RetFromAccCheck + tryfaintmon BS_TARGET setpledgestatus BS_ATTACKER, SIDE_STATUS_RAINBOW pause B_WAIT_TIME_SHORTEST printstring STRINGID_ARAINBOWAPPEAREDONSIDE @@ -348,7 +349,8 @@ BattleScript_TheRainbowDisappeared:: end2 BattleScript_EffectCombinedPledge_Fire:: - call BattleScript_EffectHit_Pledge + call BattleScript_EffectHit_RetFromAccCheck + tryfaintmon BS_TARGET setpledgestatus BS_TARGET, SIDE_STATUS_SEA_OF_FIRE pause B_WAIT_TIME_SHORTEST printstring STRINGID_SEAOFFIREENVELOPEDSIDE @@ -368,7 +370,8 @@ BattleScript_TheSeaOfFireDisappeared:: end2 BattleScript_EffectCombinedPledge_Grass:: - call BattleScript_EffectHit_Pledge + call BattleScript_EffectHit_RetFromAccCheck + tryfaintmon BS_TARGET setpledgestatus BS_TARGET, SIDE_STATUS_SWAMP pause B_WAIT_TIME_SHORTEST printstring STRINGID_SWAMPENVELOPEDSIDE @@ -382,12 +385,10 @@ BattleScript_TheSwampDisappeared:: waitmessage B_WAIT_TIME_LONG end2 -BattleScript_EffectHit_Pledge:: +BattleScript_TwoMovesBecomeOne:: pause B_WAIT_TIME_MED printstring STRINGID_THETWOMOVESBECOMEONE waitmessage B_WAIT_TIME_LONG - call BattleScript_EffectHit_RetFromAccCheck - tryfaintmon BS_TARGET return BattleScript_EffectSaltCure:: diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 9e2fb84485f..890438e3648 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -503,6 +503,7 @@ extern const u8 BattleScript_SelectingNotAllowedCurrentMoveInPalace[]; extern const u8 BattleScript_SaltCureExtraDamage[]; extern const u8 BattleScript_SyrupBombEndTurn[]; extern const u8 BattleScript_SyrupBombActivates[]; +extern const u8 BattleScript_TwoMovesBecomeOne[]; extern const u8 BattleScript_EffectCombinedPledge_Water[]; extern const u8 BattleScript_EffectCombinedPledge_Fire[]; extern const u8 BattleScript_EffectCombinedPledge_Grass[]; diff --git a/include/battle_util.h b/include/battle_util.h index 504c3be3ad1..2eb340f055f 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -93,6 +93,15 @@ struct TypePower u16 effect; }; +// If the sub type is used after the main type of the combo, +// gCurrentMove is set to the main type when the combo is executed. +struct PledgeCombo +{ + u8 mainType; + u8 subType; + const u8* battleScript; // Script to execute upon combining. +}; + enum { CANCELLER_FLAGS, diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 3ffcecd9960..66a3e0b2f82 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2246,7 +2246,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) { if (aiData->partnerMove != MOVE_NONE && gMovesInfo[aiData->partnerMove].effect == EFFECT_PLEDGE - && move != aiData->partnerMove) // Different pledge moves + && gMovesInfo[move].type != gMovesInfo[aiData->partnerMove].type) // Different pledge moves { if (gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) // && gBattleMons[BATTLE_PARTNER(battlerAtk)].status1 != 1) // Will wake up this turn - how would AI know diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5424d1b4995..e1ef29be553 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16748,12 +16748,22 @@ void BS_TryRelicSong(void) } } +static const struct PledgeCombo sPledgeCombos[] = +{ + // Dominant, Passive, Script to execute + { TYPE_GRASS, TYPE_WATER, BattleScript_EffectCombinedPledge_Grass }, + { TYPE_WATER, TYPE_FIRE, BattleScript_EffectCombinedPledge_Water }, + { TYPE_FIRE, TYPE_GRASS, BattleScript_EffectCombinedPledge_Fire }, +}; + void BS_SetPledge(void) { NATIVE_ARGS(const u8 *jumpInstr); + u32 moveType = gMovesInfo[gCurrentMove].type; u32 partner = BATTLE_PARTNER(gBattlerAttacker); u32 partnerMove = gBattleMons[partner].moves[gBattleStruct->chosenMovePositions[partner]]; + u32 partnerMoveType = gMovesInfo[partnerMove].type; u32 i = 0; u32 k = 0; @@ -16762,23 +16772,21 @@ void BS_SetPledge(void) PrepareStringBattle(STRINGID_USEDMOVE, gBattlerAttacker); gHitMarker |= HITMARKER_ATTACKSTRING_PRINTED; - if ((gCurrentMove == MOVE_GRASS_PLEDGE && partnerMove == MOVE_WATER_PLEDGE) - || (gCurrentMove == MOVE_WATER_PLEDGE && partnerMove == MOVE_GRASS_PLEDGE)) - { - gCurrentMove = MOVE_GRASS_PLEDGE; - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Grass; - } - else if ((gCurrentMove == MOVE_FIRE_PLEDGE && partnerMove == MOVE_GRASS_PLEDGE) - || (gCurrentMove == MOVE_GRASS_PLEDGE && partnerMove == MOVE_FIRE_PLEDGE)) - { - gCurrentMove = MOVE_FIRE_PLEDGE; - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Fire; - } - else if ((gCurrentMove == MOVE_WATER_PLEDGE && partnerMove == MOVE_FIRE_PLEDGE) - || (gCurrentMove == MOVE_FIRE_PLEDGE && partnerMove == MOVE_WATER_PLEDGE)) + for (i = 0; i < ARRAY_COUNT(sPledgeCombos); i++) { - gCurrentMove = MOVE_WATER_PLEDGE; - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water; + if (moveType == sPledgeCombos[i].mainType && partnerMoveType == sPledgeCombos[i].subType) + { + BattleScriptPush(sPledgeCombos[i].battleScript); + gBattlescriptCurrInstr = BattleScript_TwoMovesBecomeOne; + break; + } + else if (moveType == sPledgeCombos[i].subType && partnerMoveType == sPledgeCombos[i].mainType) + { + gCurrentMove = partnerMove; + BattleScriptPush(sPledgeCombos[i].battleScript); + gBattlescriptCurrInstr = BattleScript_TwoMovesBecomeOne; + break; + } } gBattleCommunication[MSG_DISPLAY] = 0; @@ -16788,7 +16796,7 @@ void BS_SetPledge(void) && IsBattlerAlive(partner) && GetBattlerTurnOrderNum(gBattlerAttacker) < GetBattlerTurnOrderNum(partner) && !(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) - && gCurrentMove != partnerMove + && moveType != partnerMoveType && gMovesInfo[partnerMove].effect == EFFECT_PLEDGE) { u32 currPledgeUser = 0; diff --git a/src/battle_util.c b/src/battle_util.c index 74c7fd62aa9..d2592324ee3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3522,10 +3522,12 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType) case CANCELLER_POWDER_STATUS: if (gBattleMons[gBattlerAttacker].status2 & STATUS2_POWDER) { - u32 partnerMove = gBattleMons[BATTLE_PARTNER(gBattlerAttacker)].moves[gBattleStruct->chosenMovePositions[BATTLE_PARTNER(gBattlerAttacker)]]; + u32 userEffect = gMovesInfo[gCurrentMove].effect; + u32 partnerEffect = gMovesInfo[gBattleMons[BATTLE_PARTNER(gBattlerAttacker)].moves[gBattleStruct->chosenMovePositions[BATTLE_PARTNER(gBattlerAttacker)]]].effect; + u32 partnerMoveType = gMovesInfo[gBattleMons[BATTLE_PARTNER(gBattlerAttacker)].moves[gBattleStruct->chosenMovePositions[BATTLE_PARTNER(gBattlerAttacker)]]].type; if ((moveType == TYPE_FIRE && !gBattleStruct->pledgeMove) - || (gCurrentMove == MOVE_FIRE_PLEDGE && partnerMove == MOVE_GRASS_PLEDGE) - || (gCurrentMove == MOVE_GRASS_PLEDGE && partnerMove == MOVE_FIRE_PLEDGE && gBattleStruct->pledgeMove)) + || (userEffect == EFFECT_PLEDGE && moveType == TYPE_FIRE && partnerEffect == EFFECT_PLEDGE && partnerMoveType == TYPE_GRASS) + || (userEffect == EFFECT_PLEDGE && moveType == TYPE_GRASS && partnerEffect == EFFECT_PLEDGE && partnerMoveType == TYPE_FIRE && gBattleStruct->pledgeMove)) { gProtectStructs[gBattlerAttacker].powderSelfDmg = TRUE; if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD