From 1abcc2495613acd7f06dfc2de8cf7e23955edb9e Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 29 Oct 2024 16:22:22 -0300 Subject: [PATCH 1/4] Removed hardcoding of Pledge Move IDs --- data/battle_scripts_1.s | 4 ++- include/battle_scripts.h | 4 ++- include/constants/battle_move_effects.h | 4 ++- src/battle_ai_main.c | 21 ++++++++++---- src/battle_script_commands.c | 37 +++++++++++++++++-------- src/battle_util.c | 14 ++++++---- src/data/battle_move_effects.h | 16 +++++++++-- src/data/moves_info.h | 6 ++-- test/battle/move_effect/pledge.c | 6 ++-- 9 files changed, 79 insertions(+), 33 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 52c21dc68a76..469b11832587 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -322,7 +322,9 @@ BattleScript_MoveSwitchOpenPartyScreen: BattleScript_MoveSwitchEnd: end -BattleScript_EffectPledge:: +BattleScript_EffectWaterPledge:: +BattleScript_EffectFirePledge:: +BattleScript_EffectGrassPledge:: attackcanceler setpledge BattleScript_HitFromAccCheck attackstring diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 9e2fb84485f8..b845df875c00 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -714,7 +714,9 @@ extern const u8 BattleScript_EffectWaterSport[]; extern const u8 BattleScript_EffectCalmMind[]; extern const u8 BattleScript_EffectDragonDance[]; extern const u8 BattleScript_EffectCamouflage[]; -extern const u8 BattleScript_EffectPledge[]; +extern const u8 BattleScript_EffectWaterPledge[]; +extern const u8 BattleScript_EffectFirePledge[]; +extern const u8 BattleScript_EffectGrassPledge[]; extern const u8 BattleScript_EffectFling[]; extern const u8 BattleScript_EffectNaturalGift[]; extern const u8 BattleScript_EffectRoost[]; diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index b1472d028000..51ee55fed04c 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -174,7 +174,9 @@ enum { EFFECT_CALM_MIND, EFFECT_DRAGON_DANCE, EFFECT_CAMOUFLAGE, - EFFECT_PLEDGE, + EFFECT_WATER_PLEDGE, + EFFECT_FIRE_PLEDGE, + EFFECT_GRASS_PLEDGE, EFFECT_FLING, EFFECT_NATURAL_GIFT, EFFECT_POWER_BASED_ON_TARGET_HP, diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 3ffcecd99609..d4bc88ebeb92 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2241,12 +2241,15 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) if (PartnerMoveEffectIsTerrain(BATTLE_PARTNER(battlerAtk), aiData->partnerMove) || gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN) ADJUST_SCORE(-10); break; - case EFFECT_PLEDGE: + case EFFECT_WATER_PLEDGE: + case EFFECT_FIRE_PLEDGE: + case EFFECT_GRASS_PLEDGE: if (isDoubleBattle && gBattleMons[BATTLE_PARTNER(battlerAtk)].hp > 0) { + u32 partnerEffect = gMovesInfo[aiData->partnerMove].effect; if (aiData->partnerMove != MOVE_NONE - && gMovesInfo[aiData->partnerMove].effect == EFFECT_PLEDGE - && move != aiData->partnerMove) // Different pledge moves + && (partnerEffect == EFFECT_WATER_PLEDGE || partnerEffect == EFFECT_FIRE_PLEDGE || partnerEffect == EFFECT_GRASS_PLEDGE) + && moveEffect != partnerEffect) // 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 @@ -4237,8 +4240,16 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move) if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_TERRAIN_EXTENDER) ADJUST_SCORE(GOOD_EFFECT); break; - case EFFECT_PLEDGE: - if (isDoubleBattle && HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_PLEDGE)) + case EFFECT_WATER_PLEDGE: + if (isDoubleBattle && (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_FIRE_PLEDGE) || HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_GRASS_PLEDGE))) + ADJUST_SCORE(GOOD_EFFECT); // Partner might use pledge move + break; + case EFFECT_FIRE_PLEDGE: + if (isDoubleBattle && (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_WATER_PLEDGE) || HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_GRASS_PLEDGE))) + ADJUST_SCORE(GOOD_EFFECT); // Partner might use pledge move + break; + case EFFECT_GRASS_PLEDGE: + if (isDoubleBattle && (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_WATER_PLEDGE) || HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_FIRE_PLEDGE))) ADJUST_SCORE(GOOD_EFFECT); // Partner might use pledge move break; case EFFECT_TRICK_ROOM: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5424d1b4995b..59dd334f811c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2249,7 +2249,9 @@ static void Cmd_adjustdamage(void) if (gSpecialStatuses[gBattlerAttacker].gemBoost && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBattlerAttacker].item - && gMovesInfo[gCurrentMove].effect != EFFECT_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_WATER_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_FIRE_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_GRASS_PLEDGE && gCurrentMove != MOVE_STRUGGLE) { BattleScriptPushCursor(); @@ -16752,8 +16754,10 @@ void BS_SetPledge(void) { NATIVE_ARGS(const u8 *jumpInstr); + u32 currentEffect = gMovesInfo[gCurrentMove].effect; u32 partner = BATTLE_PARTNER(gBattlerAttacker); u32 partnerMove = gBattleMons[partner].moves[gBattleStruct->chosenMovePositions[partner]]; + u32 partnerEffect = gMovesInfo[partnerMove].effect; u32 i = 0; u32 k = 0; @@ -16762,22 +16766,31 @@ 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)) + if ((currentEffect == EFFECT_GRASS_PLEDGE && partnerEffect == EFFECT_WATER_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)) + else if ((currentEffect == EFFECT_WATER_PLEDGE && partnerEffect == EFFECT_GRASS_PLEDGE)) + { + gCurrentMove = partnerMove; + gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Grass; + } + else if ((currentEffect == EFFECT_FIRE_PLEDGE && partnerEffect == EFFECT_GRASS_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)) + else if ((currentEffect == EFFECT_GRASS_PLEDGE && partnerEffect == EFFECT_FIRE_PLEDGE)) + { + gCurrentMove = partnerMove; + gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Fire; + } + else if ((currentEffect == EFFECT_WATER_PLEDGE && partnerEffect == EFFECT_FIRE_PLEDGE)) + { + gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water; + } + else if ((currentEffect == EFFECT_FIRE_PLEDGE && partnerEffect == EFFECT_WATER_PLEDGE)) { - gCurrentMove = MOVE_WATER_PLEDGE; + gCurrentMove = partnerMove; gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water; } @@ -16788,8 +16801,8 @@ void BS_SetPledge(void) && IsBattlerAlive(partner) && GetBattlerTurnOrderNum(gBattlerAttacker) < GetBattlerTurnOrderNum(partner) && !(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) - && gCurrentMove != partnerMove - && gMovesInfo[partnerMove].effect == EFFECT_PLEDGE) + && currentEffect != partnerEffect + && (partnerEffect == EFFECT_WATER_PLEDGE || partnerEffect == EFFECT_FIRE_PLEDGE || partnerEffect == EFFECT_GRASS_PLEDGE)) { u32 currPledgeUser = 0; u32 newTurnOrder[] = {0xFF, 0xFF}; diff --git a/src/battle_util.c b/src/battle_util.c index 74c7fd62aa9c..6498c014441d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -240,7 +240,9 @@ void HandleAction_UseMove(void) || (GetBattlerAbility(battler) == ABILITY_STORM_DRAIN && moveType == TYPE_WATER)) && GetBattlerTurnOrderNum(battler) < var && gMovesInfo[gCurrentMove].effect != EFFECT_SNIPE_SHOT - && gMovesInfo[gCurrentMove].effect != EFFECT_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_WATER_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_FIRE_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_GRASS_PLEDGE && GetBattlerAbility(gBattlerAttacker) != ABILITY_PROPELLER_TAIL && GetBattlerAbility(gBattlerAttacker) != ABILITY_STALWART) { @@ -3522,10 +3524,10 @@ 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 partnerEffect = gMovesInfo[gBattleMons[BATTLE_PARTNER(gBattlerAttacker)].moves[gBattleStruct->chosenMovePositions[BATTLE_PARTNER(gBattlerAttacker)]]].effect; if ((moveType == TYPE_FIRE && !gBattleStruct->pledgeMove) - || (gCurrentMove == MOVE_FIRE_PLEDGE && partnerMove == MOVE_GRASS_PLEDGE) - || (gCurrentMove == MOVE_GRASS_PLEDGE && partnerMove == MOVE_FIRE_PLEDGE && gBattleStruct->pledgeMove)) + || (gMovesInfo[gCurrentMove].effect == EFFECT_FIRE_PLEDGE && partnerEffect == EFFECT_GRASS_PLEDGE) + || (gMovesInfo[gCurrentMove].effect == EFFECT_GRASS_PLEDGE && partnerEffect == EFFECT_FIRE_PLEDGE && gBattleStruct->pledgeMove)) { gProtectStructs[gBattlerAttacker].powderSelfDmg = TRUE; if (GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD @@ -8888,7 +8890,9 @@ static inline u32 CalcMoveBasePower(u32 move, u32 battlerAtk, u32 battlerDef, u3 switch (gMovesInfo[move].effect) { - case EFFECT_PLEDGE: + case EFFECT_WATER_PLEDGE: + case EFFECT_FIRE_PLEDGE: + case EFFECT_GRASS_PLEDGE: if (gBattleStruct->pledgeMove) basePower = 150; break; diff --git a/src/data/battle_move_effects.h b/src/data/battle_move_effects.h index 956a2d0f2306..fa3c8b45f850 100644 --- a/src/data/battle_move_effects.h +++ b/src/data/battle_move_effects.h @@ -1124,9 +1124,21 @@ const struct BattleMoveEffect gBattleMoveEffects[NUM_BATTLE_MOVE_EFFECTS] = .encourageEncore = TRUE, }, - [EFFECT_PLEDGE] = + [EFFECT_WATER_PLEDGE] = { - .battleScript = BattleScript_EffectPledge, + .battleScript = BattleScript_EffectWaterPledge, + .battleTvScore = 0, // TODO: Assign points + }, + + [EFFECT_FIRE_PLEDGE] = + { + .battleScript = BattleScript_EffectFirePledge, + .battleTvScore = 0, // TODO: Assign points + }, + + [EFFECT_GRASS_PLEDGE] = + { + .battleScript = BattleScript_EffectGrassPledge, .battleTvScore = 0, // TODO: Assign points }, diff --git a/src/data/moves_info.h b/src/data/moves_info.h index db5f2eaf7529..90af0809c3a2 100644 --- a/src/data/moves_info.h +++ b/src/data/moves_info.h @@ -12915,7 +12915,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "Attacks with a column of\n" "water. May make a rainbow."), - .effect = EFFECT_PLEDGE, + .effect = EFFECT_WATER_PLEDGE, .power = B_UPDATED_MOVE_DATA >= GEN_6 ? 80 : 50, .type = TYPE_WATER, .accuracy = 100, @@ -12937,7 +12937,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "Attacks with a column of\n" "fire. May burn the grass."), - .effect = EFFECT_PLEDGE, + .effect = EFFECT_FIRE_PLEDGE, .power = B_UPDATED_MOVE_DATA >= GEN_6 ? 80 : 50, .type = TYPE_FIRE, .accuracy = 100, @@ -12959,7 +12959,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "Attacks with a column of\n" "grass. May create a swamp."), - .effect = EFFECT_PLEDGE, + .effect = EFFECT_GRASS_PLEDGE, .power = B_UPDATED_MOVE_DATA >= GEN_6 ? 80 : 50, .type = TYPE_GRASS, .accuracy = 100, diff --git a/test/battle/move_effect/pledge.c b/test/battle/move_effect/pledge.c index 726adc81521f..ebe90d43cddd 100644 --- a/test/battle/move_effect/pledge.c +++ b/test/battle/move_effect/pledge.c @@ -3,9 +3,9 @@ ASSUMPTIONS { - ASSUME(gMovesInfo[MOVE_WATER_PLEDGE].effect == EFFECT_PLEDGE); - ASSUME(gMovesInfo[MOVE_FIRE_PLEDGE].effect == EFFECT_PLEDGE); - ASSUME(gMovesInfo[MOVE_GRASS_PLEDGE].effect == EFFECT_PLEDGE); + ASSUME(gMovesInfo[MOVE_WATER_PLEDGE].effect == EFFECT_WATER_PLEDGE); + ASSUME(gMovesInfo[MOVE_FIRE_PLEDGE].effect == EFFECT_FIRE_PLEDGE); + ASSUME(gMovesInfo[MOVE_GRASS_PLEDGE].effect == EFFECT_GRASS_PLEDGE); } DOUBLE_BATTLE_TEST("Water and Fire Pledge create a rainbow on the user's side of the field for four turns") From a1af19ca471cbb03ecb804ca1dd010aacf099249 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 29 Oct 2024 20:34:51 -0300 Subject: [PATCH 2/4] Using move types instead of separate effects --- data/battle_scripts_1.s | 4 +--- include/battle_scripts.h | 4 +--- include/constants/battle_move_effects.h | 4 +--- src/battle_ai_main.c | 21 +++++---------------- src/battle_script_commands.c | 24 +++++++++++------------- src/battle_util.c | 14 ++++++-------- src/data/battle_move_effects.h | 16 ++-------------- src/data/moves_info.h | 6 +++--- test/battle/move_effect/pledge.c | 6 +++--- 9 files changed, 33 insertions(+), 66 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 469b11832587..52c21dc68a76 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -322,9 +322,7 @@ BattleScript_MoveSwitchOpenPartyScreen: BattleScript_MoveSwitchEnd: end -BattleScript_EffectWaterPledge:: -BattleScript_EffectFirePledge:: -BattleScript_EffectGrassPledge:: +BattleScript_EffectPledge:: attackcanceler setpledge BattleScript_HitFromAccCheck attackstring diff --git a/include/battle_scripts.h b/include/battle_scripts.h index b845df875c00..9e2fb84485f8 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -714,9 +714,7 @@ extern const u8 BattleScript_EffectWaterSport[]; extern const u8 BattleScript_EffectCalmMind[]; extern const u8 BattleScript_EffectDragonDance[]; extern const u8 BattleScript_EffectCamouflage[]; -extern const u8 BattleScript_EffectWaterPledge[]; -extern const u8 BattleScript_EffectFirePledge[]; -extern const u8 BattleScript_EffectGrassPledge[]; +extern const u8 BattleScript_EffectPledge[]; extern const u8 BattleScript_EffectFling[]; extern const u8 BattleScript_EffectNaturalGift[]; extern const u8 BattleScript_EffectRoost[]; diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 51ee55fed04c..b1472d028000 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -174,9 +174,7 @@ enum { EFFECT_CALM_MIND, EFFECT_DRAGON_DANCE, EFFECT_CAMOUFLAGE, - EFFECT_WATER_PLEDGE, - EFFECT_FIRE_PLEDGE, - EFFECT_GRASS_PLEDGE, + EFFECT_PLEDGE, EFFECT_FLING, EFFECT_NATURAL_GIFT, EFFECT_POWER_BASED_ON_TARGET_HP, diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index d4bc88ebeb92..66a3e0b2f829 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -2241,15 +2241,12 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score) if (PartnerMoveEffectIsTerrain(BATTLE_PARTNER(battlerAtk), aiData->partnerMove) || gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN) ADJUST_SCORE(-10); break; - case EFFECT_WATER_PLEDGE: - case EFFECT_FIRE_PLEDGE: - case EFFECT_GRASS_PLEDGE: + case EFFECT_PLEDGE: if (isDoubleBattle && gBattleMons[BATTLE_PARTNER(battlerAtk)].hp > 0) { - u32 partnerEffect = gMovesInfo[aiData->partnerMove].effect; if (aiData->partnerMove != MOVE_NONE - && (partnerEffect == EFFECT_WATER_PLEDGE || partnerEffect == EFFECT_FIRE_PLEDGE || partnerEffect == EFFECT_GRASS_PLEDGE) - && moveEffect != partnerEffect) // Different pledge moves + && gMovesInfo[aiData->partnerMove].effect == EFFECT_PLEDGE + && 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 @@ -4240,16 +4237,8 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move) if (aiData->holdEffects[battlerAtk] == HOLD_EFFECT_TERRAIN_EXTENDER) ADJUST_SCORE(GOOD_EFFECT); break; - case EFFECT_WATER_PLEDGE: - if (isDoubleBattle && (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_FIRE_PLEDGE) || HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_GRASS_PLEDGE))) - ADJUST_SCORE(GOOD_EFFECT); // Partner might use pledge move - break; - case EFFECT_FIRE_PLEDGE: - if (isDoubleBattle && (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_WATER_PLEDGE) || HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_GRASS_PLEDGE))) - ADJUST_SCORE(GOOD_EFFECT); // Partner might use pledge move - break; - case EFFECT_GRASS_PLEDGE: - if (isDoubleBattle && (HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_WATER_PLEDGE) || HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_FIRE_PLEDGE))) + case EFFECT_PLEDGE: + if (isDoubleBattle && HasMoveEffect(BATTLE_PARTNER(battlerAtk), EFFECT_PLEDGE)) ADJUST_SCORE(GOOD_EFFECT); // Partner might use pledge move break; case EFFECT_TRICK_ROOM: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 59dd334f811c..6bb527154929 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2249,9 +2249,7 @@ static void Cmd_adjustdamage(void) if (gSpecialStatuses[gBattlerAttacker].gemBoost && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBattlerAttacker].item - && gMovesInfo[gCurrentMove].effect != EFFECT_WATER_PLEDGE - && gMovesInfo[gCurrentMove].effect != EFFECT_FIRE_PLEDGE - && gMovesInfo[gCurrentMove].effect != EFFECT_GRASS_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_PLEDGE && gCurrentMove != MOVE_STRUGGLE) { BattleScriptPushCursor(); @@ -16754,10 +16752,10 @@ void BS_SetPledge(void) { NATIVE_ARGS(const u8 *jumpInstr); - u32 currentEffect = gMovesInfo[gCurrentMove].effect; + u32 moveType = gMovesInfo[gCurrentMove].type; u32 partner = BATTLE_PARTNER(gBattlerAttacker); u32 partnerMove = gBattleMons[partner].moves[gBattleStruct->chosenMovePositions[partner]]; - u32 partnerEffect = gMovesInfo[partnerMove].effect; + u32 partnerMoveType = gMovesInfo[partnerMove].type; u32 i = 0; u32 k = 0; @@ -16766,29 +16764,29 @@ void BS_SetPledge(void) PrepareStringBattle(STRINGID_USEDMOVE, gBattlerAttacker); gHitMarker |= HITMARKER_ATTACKSTRING_PRINTED; - if ((currentEffect == EFFECT_GRASS_PLEDGE && partnerEffect == EFFECT_WATER_PLEDGE)) + if ((moveType == TYPE_GRASS && partnerMoveType == TYPE_WATER)) { gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Grass; } - else if ((currentEffect == EFFECT_WATER_PLEDGE && partnerEffect == EFFECT_GRASS_PLEDGE)) + else if ((moveType == TYPE_WATER && partnerMoveType == TYPE_GRASS)) { gCurrentMove = partnerMove; gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Grass; } - else if ((currentEffect == EFFECT_FIRE_PLEDGE && partnerEffect == EFFECT_GRASS_PLEDGE)) + else if ((moveType == TYPE_FIRE && partnerMoveType == TYPE_GRASS)) { gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Fire; } - else if ((currentEffect == EFFECT_GRASS_PLEDGE && partnerEffect == EFFECT_FIRE_PLEDGE)) + else if ((moveType == TYPE_GRASS && partnerMoveType == TYPE_FIRE)) { gCurrentMove = partnerMove; gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Fire; } - else if ((currentEffect == EFFECT_WATER_PLEDGE && partnerEffect == EFFECT_FIRE_PLEDGE)) + else if ((moveType == TYPE_WATER && partnerMoveType == TYPE_FIRE)) { gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water; } - else if ((currentEffect == EFFECT_FIRE_PLEDGE && partnerEffect == EFFECT_WATER_PLEDGE)) + else if ((moveType == TYPE_FIRE && partnerMoveType == TYPE_WATER)) { gCurrentMove = partnerMove; gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water; @@ -16801,8 +16799,8 @@ void BS_SetPledge(void) && IsBattlerAlive(partner) && GetBattlerTurnOrderNum(gBattlerAttacker) < GetBattlerTurnOrderNum(partner) && !(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) - && currentEffect != partnerEffect - && (partnerEffect == EFFECT_WATER_PLEDGE || partnerEffect == EFFECT_FIRE_PLEDGE || partnerEffect == EFFECT_GRASS_PLEDGE)) + && moveType != partnerMoveType + && gMovesInfo[partnerMove].effect == EFFECT_PLEDGE) { u32 currPledgeUser = 0; u32 newTurnOrder[] = {0xFF, 0xFF}; diff --git a/src/battle_util.c b/src/battle_util.c index 6498c014441d..d2592324ee39 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -240,9 +240,7 @@ void HandleAction_UseMove(void) || (GetBattlerAbility(battler) == ABILITY_STORM_DRAIN && moveType == TYPE_WATER)) && GetBattlerTurnOrderNum(battler) < var && gMovesInfo[gCurrentMove].effect != EFFECT_SNIPE_SHOT - && gMovesInfo[gCurrentMove].effect != EFFECT_WATER_PLEDGE - && gMovesInfo[gCurrentMove].effect != EFFECT_FIRE_PLEDGE - && gMovesInfo[gCurrentMove].effect != EFFECT_GRASS_PLEDGE + && gMovesInfo[gCurrentMove].effect != EFFECT_PLEDGE && GetBattlerAbility(gBattlerAttacker) != ABILITY_PROPELLER_TAIL && GetBattlerAbility(gBattlerAttacker) != ABILITY_STALWART) { @@ -3524,10 +3522,12 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType) case CANCELLER_POWDER_STATUS: if (gBattleMons[gBattlerAttacker].status2 & STATUS2_POWDER) { + 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) - || (gMovesInfo[gCurrentMove].effect == EFFECT_FIRE_PLEDGE && partnerEffect == EFFECT_GRASS_PLEDGE) - || (gMovesInfo[gCurrentMove].effect == EFFECT_GRASS_PLEDGE && partnerEffect == EFFECT_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 @@ -8890,9 +8890,7 @@ static inline u32 CalcMoveBasePower(u32 move, u32 battlerAtk, u32 battlerDef, u3 switch (gMovesInfo[move].effect) { - case EFFECT_WATER_PLEDGE: - case EFFECT_FIRE_PLEDGE: - case EFFECT_GRASS_PLEDGE: + case EFFECT_PLEDGE: if (gBattleStruct->pledgeMove) basePower = 150; break; diff --git a/src/data/battle_move_effects.h b/src/data/battle_move_effects.h index fa3c8b45f850..956a2d0f2306 100644 --- a/src/data/battle_move_effects.h +++ b/src/data/battle_move_effects.h @@ -1124,21 +1124,9 @@ const struct BattleMoveEffect gBattleMoveEffects[NUM_BATTLE_MOVE_EFFECTS] = .encourageEncore = TRUE, }, - [EFFECT_WATER_PLEDGE] = + [EFFECT_PLEDGE] = { - .battleScript = BattleScript_EffectWaterPledge, - .battleTvScore = 0, // TODO: Assign points - }, - - [EFFECT_FIRE_PLEDGE] = - { - .battleScript = BattleScript_EffectFirePledge, - .battleTvScore = 0, // TODO: Assign points - }, - - [EFFECT_GRASS_PLEDGE] = - { - .battleScript = BattleScript_EffectGrassPledge, + .battleScript = BattleScript_EffectPledge, .battleTvScore = 0, // TODO: Assign points }, diff --git a/src/data/moves_info.h b/src/data/moves_info.h index 90af0809c3a2..db5f2eaf7529 100644 --- a/src/data/moves_info.h +++ b/src/data/moves_info.h @@ -12915,7 +12915,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "Attacks with a column of\n" "water. May make a rainbow."), - .effect = EFFECT_WATER_PLEDGE, + .effect = EFFECT_PLEDGE, .power = B_UPDATED_MOVE_DATA >= GEN_6 ? 80 : 50, .type = TYPE_WATER, .accuracy = 100, @@ -12937,7 +12937,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "Attacks with a column of\n" "fire. May burn the grass."), - .effect = EFFECT_FIRE_PLEDGE, + .effect = EFFECT_PLEDGE, .power = B_UPDATED_MOVE_DATA >= GEN_6 ? 80 : 50, .type = TYPE_FIRE, .accuracy = 100, @@ -12959,7 +12959,7 @@ const struct MoveInfo gMovesInfo[MOVES_COUNT_DYNAMAX] = .description = COMPOUND_STRING( "Attacks with a column of\n" "grass. May create a swamp."), - .effect = EFFECT_GRASS_PLEDGE, + .effect = EFFECT_PLEDGE, .power = B_UPDATED_MOVE_DATA >= GEN_6 ? 80 : 50, .type = TYPE_GRASS, .accuracy = 100, diff --git a/test/battle/move_effect/pledge.c b/test/battle/move_effect/pledge.c index ebe90d43cddd..726adc81521f 100644 --- a/test/battle/move_effect/pledge.c +++ b/test/battle/move_effect/pledge.c @@ -3,9 +3,9 @@ ASSUMPTIONS { - ASSUME(gMovesInfo[MOVE_WATER_PLEDGE].effect == EFFECT_WATER_PLEDGE); - ASSUME(gMovesInfo[MOVE_FIRE_PLEDGE].effect == EFFECT_FIRE_PLEDGE); - ASSUME(gMovesInfo[MOVE_GRASS_PLEDGE].effect == EFFECT_GRASS_PLEDGE); + ASSUME(gMovesInfo[MOVE_WATER_PLEDGE].effect == EFFECT_PLEDGE); + ASSUME(gMovesInfo[MOVE_FIRE_PLEDGE].effect == EFFECT_PLEDGE); + ASSUME(gMovesInfo[MOVE_GRASS_PLEDGE].effect == EFFECT_PLEDGE); } DOUBLE_BATTLE_TEST("Water and Fire Pledge create a rainbow on the user's side of the field for four turns") From 01f2afc3463e3559effd10e2bf662d264c9c3e33 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 30 Oct 2024 10:23:13 -0300 Subject: [PATCH 3/4] Pledge Combo Struct --- include/battle_util.h | 9 ++++++++ src/battle_script_commands.c | 45 ++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 504c3be3ad1b..2eb340f055f0 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_script_commands.c b/src/battle_script_commands.c index 6bb527154929..f28d8e0e5a9c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16748,6 +16748,14 @@ 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); @@ -16764,32 +16772,19 @@ void BS_SetPledge(void) PrepareStringBattle(STRINGID_USEDMOVE, gBattlerAttacker); gHitMarker |= HITMARKER_ATTACKSTRING_PRINTED; - if ((moveType == TYPE_GRASS && partnerMoveType == TYPE_WATER)) - { - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Grass; - } - else if ((moveType == TYPE_WATER && partnerMoveType == TYPE_GRASS)) + for (i = 0; i < ARRAY_COUNT(sPledgeCombos); i++) { - gCurrentMove = partnerMove; - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Grass; - } - else if ((moveType == TYPE_FIRE && partnerMoveType == TYPE_GRASS)) - { - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Fire; - } - else if ((moveType == TYPE_GRASS && partnerMoveType == TYPE_FIRE)) - { - gCurrentMove = partnerMove; - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Fire; - } - else if ((moveType == TYPE_WATER && partnerMoveType == TYPE_FIRE)) - { - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water; - } - else if ((moveType == TYPE_FIRE && partnerMoveType == TYPE_WATER)) - { - gCurrentMove = partnerMove; - gBattlescriptCurrInstr = BattleScript_EffectCombinedPledge_Water; + if (moveType == sPledgeCombos[i].mainType && partnerMoveType == sPledgeCombos[i].subType) + { + gBattlescriptCurrInstr = sPledgeCombos[i].battleScript; + break; + } + else if (moveType == sPledgeCombos[i].subType && partnerMoveType == sPledgeCombos[i].mainType) + { + gCurrentMove = partnerMove; + gBattlescriptCurrInstr = sPledgeCombos[i].battleScript; + break; + } } gBattleCommunication[MSG_DISPLAY] = 0; From 7ea1d337638219e7070949b631ad80b9c95322fc Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Wed, 30 Oct 2024 10:57:36 -0300 Subject: [PATCH 4/4] "Two moves become one" message now always shows --- data/battle_scripts_1.s | 13 +++++++------ include/battle_scripts.h | 1 + src/battle_script_commands.c | 6 ++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 52c21dc68a76..63ba181585e4 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 9e2fb84485f8..890438e3648a 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/src/battle_script_commands.c b/src/battle_script_commands.c index f28d8e0e5a9c..e1ef29be5534 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16776,13 +16776,15 @@ void BS_SetPledge(void) { if (moveType == sPledgeCombos[i].mainType && partnerMoveType == sPledgeCombos[i].subType) { - gBattlescriptCurrInstr = sPledgeCombos[i].battleScript; + BattleScriptPush(sPledgeCombos[i].battleScript); + gBattlescriptCurrInstr = BattleScript_TwoMovesBecomeOne; break; } else if (moveType == sPledgeCombos[i].subType && partnerMoveType == sPledgeCombos[i].mainType) { gCurrentMove = partnerMove; - gBattlescriptCurrInstr = sPledgeCombos[i].battleScript; + BattleScriptPush(sPledgeCombos[i].battleScript); + gBattlescriptCurrInstr = BattleScript_TwoMovesBecomeOne; break; } }