From 56a2e91518ce4170722a4fe73131d4bb78dba6df Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Tue, 23 Aug 2022 22:40:04 -0400 Subject: [PATCH] Updated move limitations --- data/battle_scripts_1.s | 13 +++++++++++++ include/battle_scripts.h | 4 ++++ include/battle_util.h | 12 ++++++++++-- src/battle_util.c | 37 ++++++++++++++++++++----------------- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 5e6ab3392..08474a1e8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7257,6 +7257,10 @@ BattleScript_SelectingNotAllowedStuffCheeks:: printselectionstring STRINGID_STUFFCHEEKSCANTSELECT endselectionscript +BattleScript_SelectingNotAllowedStuffCheeksInPalace:: + printstring STRINGID_STUFFCHEEKSCANTSELECT + goto BattleScript_SelectingUnusableMoveInPalace + BattleScript_SelectingNotAllowedBelch:: printselectionstring STRINGID_BELCHCANTSELECT endselectionscript @@ -9196,14 +9200,23 @@ BattleScript_ItemHealHP_Ret:: BattleScript_SelectingNotAllowedMoveChoiceItem:: printselectionstring STRINGID_ITEMALLOWSONLYYMOVE endselectionscript +BattleScript_SelectingNotAllowedMoveChoiceItemInPalace:: + printstring STRINGID_ITEMALLOWSONLYYMOVE + goto BattleScript_SelectingUnusableMoveInPalace BattleScript_SelectingNotAllowedMoveGorillaTactics:: printselectionstring STRINGID_ABILITYALLOWSONLYMOVE endselectionscript +BattleScript_SelectingNotAllowedMoveGorillaTacticsInPalace:: + printstring STRINGID_ABILITYALLOWSONLYMOVE + goto BattleScript_SelectingUnusableMoveInPalace BattleScript_SelectingNotAllowedMoveAssaultVest:: printselectionstring STRINGID_ASSAULTVESTDOESNTALLOW endselectionscript +BattleScript_SelectingNotAllowedMoveAssaultVestInPalace:: + printstring STRINGID_ASSAULTVESTDOESNTALLOW + goto BattleScript_SelectingUnusableMoveInPalace BattleScript_HangedOnMsg:: playanimation BS_TARGET, B_ANIM_HANGED_ON diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 09e11bd8c..77d889cc3 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -210,6 +210,7 @@ extern const u8 BattleScript_BerryPPHealEnd2[]; extern const u8 BattleScript_ItemHealHP_End2[]; extern const u8 BattleScript_ItemHealHP_Ret[]; extern const u8 BattleScript_SelectingNotAllowedMoveChoiceItem[]; +extern const u8 BattleScript_SelectingNotAllowedMoveChoiceItemInPalace[]; extern const u8 BattleScript_HangedOnMsg[]; extern const u8 BattleScript_BerryConfuseHealEnd2[]; extern const u8 BattleScript_BerryConfuseHealRet[]; @@ -275,6 +276,7 @@ extern const u8 BattleScript_SnowWarningActivates[]; extern const u8 BattleScript_HarvestActivates[]; extern const u8 BattleScript_ImposterActivates[]; extern const u8 BattleScript_SelectingNotAllowedMoveAssaultVest[]; +extern const u8 BattleScript_SelectingNotAllowedMoveAssaultVestInPalace[]; extern const u8 BattleScript_SelectingNotAllowedMoveGravity[]; extern const u8 BattleScript_MoveUsedGravityPrevents[]; extern const u8 BattleScript_SelectingNotAllowedMoveGravityInPalace[]; @@ -301,6 +303,7 @@ extern const u8 BattleScript_DazzlingProtected[]; extern const u8 BattleScript_MoveUsedPsychicTerrainPrevents[]; extern const u8 BattleScript_MoveUsedPowder[]; extern const u8 BattleScript_SelectingNotAllowedStuffCheeks[]; +extern const u8 BattleScript_SelectingNotAllowedStuffCheeksInPalace[]; extern const u8 BattleScript_SelectingNotAllowedBelch[]; extern const u8 BattleScript_SelectingNotAllowedBelchInPalace[]; extern const u8 BattleScript_PsychicSurgeActivates[]; @@ -405,6 +408,7 @@ extern const u8 BattleScript_BlockedByPrimalWeatherRet[]; extern const u8 BattleScript_PrimalReversion[]; extern const u8 BattleScript_HyperspaceFuryRemoveProtect[]; extern const u8 BattleScript_SelectingNotAllowedMoveGorillaTactics[]; +extern const u8 BattleScript_SelectingNotAllowedMoveGorillaTacticsInPalace[]; extern const u8 BattleScript_WanderingSpiritActivates[]; extern const u8 BattleScript_MirrorArmorReflect[]; extern const u8 BattleScript_GooeyActivates[]; diff --git a/include/battle_util.h b/include/battle_util.h index d0edbc9d1..0219a0e6a 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -7,7 +7,15 @@ #define MOVE_LIMITATION_TORMENTED (1 << 3) #define MOVE_LIMITATION_TAUNT (1 << 4) #define MOVE_LIMITATION_IMPRISON (1 << 5) -#define MOVE_LIMITATIONS_ALL 0xFF +#define MOVE_LIMITATION_ENCORE (1 << 6) +#define MOVE_LIMITATION_CHOICE_ITEM (1 << 7) +#define MOVE_LIMITATION_ASSAULT_VEST (1 << 8) +#define MOVE_LIMITATION_GRAVITY (1 << 9) +#define MOVE_LIMITATION_HEAL_BLOCK (1 << 10) +#define MOVE_LIMITATION_BELCH (1 << 11) +#define MOVE_LIMITATION_THROAT_CHOP (1 << 12) +#define MOVE_LIMITATION_STUFF_CHEEKS (1 << 13) +#define MOVE_LIMITATIONS_ALL 0xFFFF #define ABILITYEFFECT_ON_SWITCHIN 0 #define ABILITYEFFECT_ENDTURN 1 @@ -89,7 +97,7 @@ void BattleScriptPush(const u8 *bsPtr); void BattleScriptPushCursor(void); void BattleScriptPop(void); u8 TrySetCantSelectMoveBattleScript(void); -u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check); +u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u16 check); bool8 AreAllMovesUnusable(void); u8 GetImprisonedMovesCount(u8 battlerId, u16 move); u8 DoFieldEndTurnEffects(void); diff --git a/src/battle_util.c b/src/battle_util.c index 7f4274b20..22c319a46 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1859,7 +1859,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace; + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedStuffCheeksInPalace; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else @@ -1876,6 +1876,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gLastUsedItem = gBattleMons[gActiveBattler].item; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveChoiceItemInPalace; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else @@ -1890,6 +1891,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gLastUsedItem = gBattleMons[gActiveBattler].item; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveAssaultVestInPalace; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else @@ -1905,6 +1907,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gLastUsedItem = gBattleMons[gActiveBattler].item; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGorillaTacticsInPalace; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else @@ -1930,7 +1933,7 @@ u8 TrySetCantSelectMoveBattleScript(void) return limitations; } -u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check) +u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u16 check) { u8 holdEffect = GetBattlerHoldEffect(battlerId, TRUE); u16 *choicedMove = &gBattleStruct->choicedMove[battlerId]; @@ -1941,49 +1944,49 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check) for (i = 0; i < MAX_MON_MOVES; i++) { // No move - if (gBattleMons[battlerId].moves[i] == MOVE_NONE && check & MOVE_LIMITATION_ZEROMOVE) + if (check & MOVE_LIMITATION_ZEROMOVE && gBattleMons[battlerId].moves[i] == MOVE_NONE) unusableMoves |= gBitTable[i]; // No PP - else if (gBattleMons[battlerId].pp[i] == 0 && check & MOVE_LIMITATION_PP) + else if (check & MOVE_LIMITATION_PP && gBattleMons[battlerId].pp[i] == 0) unusableMoves |= gBitTable[i]; // Disable - else if (gBattleMons[battlerId].moves[i] == gDisableStructs[battlerId].disabledMove && check & MOVE_LIMITATION_DISABLED) + else if (check & MOVE_LIMITATION_DISABLED && gBattleMons[battlerId].moves[i] == gDisableStructs[battlerId].disabledMove) unusableMoves |= gBitTable[i]; // Torment - else if (gBattleMons[battlerId].moves[i] == gLastMoves[battlerId] && check & MOVE_LIMITATION_TORMENTED && gBattleMons[battlerId].status2 & STATUS2_TORMENT) + else if (check & MOVE_LIMITATION_TORMENTED && gBattleMons[battlerId].moves[i] == gLastMoves[battlerId] && gBattleMons[battlerId].status2 & STATUS2_TORMENT) unusableMoves |= gBitTable[i]; // Taunt - else if (gDisableStructs[battlerId].tauntTimer && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[battlerId].moves[i]].power == 0) + else if (check & MOVE_LIMITATION_TAUNT && gDisableStructs[battlerId].tauntTimer && IS_MOVE_STATUS(gBattleMons[battlerId].moves[i])) unusableMoves |= gBitTable[i]; // Imprison - else if (GetImprisonedMovesCount(battlerId, gBattleMons[battlerId].moves[i]) && check & MOVE_LIMITATION_IMPRISON) + else if (check & MOVE_LIMITATION_IMPRISON && GetImprisonedMovesCount(battlerId, gBattleMons[battlerId].moves[i])) unusableMoves |= gBitTable[i]; // Encore - else if (gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i]) + else if (check & MOVE_LIMITATION_ENCORE && gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i]) unusableMoves |= gBitTable[i]; // Choice Items - else if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != gBattleMons[battlerId].moves[i]) + else if (check & MOVE_LIMITATION_CHOICE_ITEM && HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != gBattleMons[battlerId].moves[i]) unusableMoves |= gBitTable[i]; // Assault Vest - else if (holdEffect == HOLD_EFFECT_ASSAULT_VEST && gBattleMoves[gBattleMons[battlerId].moves[i]].power == 0 && gBattleMons[battlerId].moves[i] != MOVE_ME_FIRST) + else if (check & MOVE_LIMITATION_ASSAULT_VEST && holdEffect == HOLD_EFFECT_ASSAULT_VEST && IS_MOVE_STATUS(gBattleMons[battlerId].moves[i]) && gBattleMons[battlerId].moves[i] != MOVE_ME_FIRST) unusableMoves |= gBitTable[i]; // Gravity - else if (IsGravityPreventingMove(gBattleMons[battlerId].moves[i])) + else if (check & MOVE_LIMITATION_GRAVITY && IsGravityPreventingMove(gBattleMons[battlerId].moves[i])) unusableMoves |= gBitTable[i]; // Heal Block - else if (IsHealBlockPreventingMove(battlerId, gBattleMons[battlerId].moves[i])) + else if (check & MOVE_LIMITATION_HEAL_BLOCK && IsHealBlockPreventingMove(battlerId, gBattleMons[battlerId].moves[i])) unusableMoves |= gBitTable[i]; // Belch - else if (IsBelchPreventingMove(battlerId, gBattleMons[battlerId].moves[i])) + else if (check & MOVE_LIMITATION_BELCH && IsBelchPreventingMove(battlerId, gBattleMons[battlerId].moves[i])) unusableMoves |= gBitTable[i]; // Throat Chop - else if (gDisableStructs[battlerId].throatChopTimer && gBattleMoves[gBattleMons[battlerId].moves[i]].flags & FLAG_SOUND) + else if (check & MOVE_LIMITATION_THROAT_CHOP && gDisableStructs[battlerId].throatChopTimer && gBattleMoves[gBattleMons[battlerId].moves[i]].flags & FLAG_SOUND) unusableMoves |= gBitTable[i]; // Stuff Cheeks - else if (gBattleMons[battlerId].moves[i] == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[gActiveBattler].item) != POCKET_BERRIES) + else if (check & MOVE_LIMITATION_STUFF_CHEEKS && gBattleMons[battlerId].moves[i] == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[gActiveBattler].item) != POCKET_BERRIES) unusableMoves |= gBitTable[i]; // Gorilla Tactics - else if (GetBattlerAbility(battlerId) == ABILITY_GORILLA_TACTICS && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != gBattleMons[battlerId].moves[i]) + else if (check & MOVE_LIMITATION_CHOICE_ITEM && GetBattlerAbility(battlerId) == ABILITY_GORILLA_TACTICS && *choicedMove != MOVE_NONE && *choicedMove != MOVE_UNAVAILABLE && *choicedMove != gBattleMons[battlerId].moves[i]) unusableMoves |= gBitTable[i]; } return unusableMoves;