From f046a25ce036e7af01efafdb22dade424ca7bd7b Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 5 Jan 2021 21:15:21 -0700 Subject: [PATCH 01/26] ripen & hp restoring berries --- data/battle_scripts_1.s | 10 ++++++++++ src/battle_util.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3eb1f5cbe..f892e2611 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7461,6 +7461,11 @@ BattleScript_WhiteHerbRet:: return BattleScript_ItemHealHP_RemoveItemRet:: + jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_ItemHealHP_RemoveItemRet_AbilityPopUp + goto BattleScript_ItemHealHP_RemoveItemRet_Anim +BattleScript_ItemHealHP_RemoveItemRet_AbilityPopUp: + call BattleScript_AbilityPopUp +BattleScript_ItemHealHP_RemoveItemRet_Anim: playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNSITEMRESTOREDHEALTH waitmessage 0x40 @@ -7470,6 +7475,11 @@ BattleScript_ItemHealHP_RemoveItemRet:: removeitem BS_SCRIPTING return BattleScript_ItemHealHP_RemoveItemEnd2:: + jumpifability BS_ATTACKER, ABILITY_RIPEN BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp + goto BattleScript_ItemHealHP_RemoveItemEnd2_Anim +BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp: + call BattleScript_AbilityPopUp +BattleScript_ItemHealHP_RemoveItemEnd2_Anim: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNSITEMRESTOREDHEALTH waitmessage 0x40 diff --git a/src/battle_util.c b/src/battle_util.c index aeeefa734..aff3a1c53 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4980,7 +4980,7 @@ enum static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) { bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES); - + if (gBattleMons[battlerId].hp == 0) return FALSE; // Unnerve prevents consumption of opponents' berries. @@ -5073,6 +5073,7 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId) return 0; } +// berries, berry juice static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) @@ -5081,7 +5082,12 @@ static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerHoldEffectParam(battlerId) / 100) * -1; else gBattleMoveDamage = GetBattlerHoldEffectParam(battlerId) * -1; - + + // check ripen + if (ItemId_GetPocket(itemId) == POCKET_BERRIES && GetBattlerAbility(battlerId) == ABILITY_RIPEN) + gBattleMoveDamage *= 2; + + gBattlerAbility = battlerId; // in SWSH, berry juice shows ability pop up but has no effect. This is mimicked here if (end2) { BattleScriptExecute(BattleScript_ItemHealHP_RemoveItemEnd2); From b3a6df8d572a06a7ca03d546667c63b5152084e4 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 5 Jan 2021 22:13:32 -0700 Subject: [PATCH 02/26] stat raising berries --- data/battle_scripts_1.s | 51 +++++++++++- include/battle_scripts.h | 2 + src/battle_util.c | 166 ++++++++++++++++++++++++++++++--------- 3 files changed, 183 insertions(+), 36 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index f892e2611..03f3b00de 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7474,8 +7474,9 @@ BattleScript_ItemHealHP_RemoveItemRet_Anim: datahpupdate BS_SCRIPTING removeitem BS_SCRIPTING return + BattleScript_ItemHealHP_RemoveItemEnd2:: - jumpifability BS_ATTACKER, ABILITY_RIPEN BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp + jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp goto BattleScript_ItemHealHP_RemoveItemEnd2_Anim BattleScript_ItemHealHP_RemoveItemEnd2_AbilityPopUp: call BattleScript_AbilityPopUp @@ -7490,6 +7491,11 @@ BattleScript_ItemHealHP_RemoveItemEnd2_Anim: end2 BattleScript_BerryPPHealEnd2:: + jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryPPHealEnd2_AbilityPopup + goto BattleScript_BerryPPHealEnd2_Anim +BattleScript_BerryPPHealEnd2_AbilityPopup: + call BattleScript_AbilityPopUp +BattleScript_BerryPPHealEnd2_Anim: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNSITEMRESTOREDPP waitmessage 0x40 @@ -7553,6 +7559,11 @@ BattleScript_HangedOnMsgRet: return BattleScript_BerryConfuseHealEnd2:: + jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryConfuseHealEnd2_AbilityPopup + goto BattleScript_BerryConfuseHealEnd2_Anim +BattleScript_BerryConfuseHealEnd2_AbilityPopup: + call BattleScript_AbilityPopUp +BattleScript_BerryConfuseHealEnd2_Anim: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNSITEMRESTOREDHEALTH waitmessage 0x40 @@ -7566,7 +7577,31 @@ BattleScript_BerryConfuseHealEnd2:: removeitem BS_ATTACKER end2 +BattleScript_BerryConfuseHealRet:: + jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_BerryConfuseHealRet_AbilityPopup + goto BattleScript_BerryConfuseHealRet_Anim +BattleScript_BerryConfuseHealRet_AbilityPopup: + call BattleScript_AbilityPopUp +BattleScript_BerryConfuseHealRet_Anim: + playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL + printstring STRINGID_PKMNSITEMRESTOREDHEALTH + waitmessage 0x40 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + healthbarupdate BS_SCRIPTING + datahpupdate BS_SCRIPTING + printstring STRINGID_FORXCOMMAYZ + waitmessage 0x40 + setmoveeffect MOVE_EFFECT_CONFUSION | MOVE_EFFECT_AFFECTS_USER + seteffectprimary + removeitem BS_SCRIPTING + return + BattleScript_BerryStatRaiseEnd2:: + jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_BerryStatRaiseEnd2_AbilityPopup + goto BattleScript_BerryStatRaiseEnd2_Anim +BattleScript_BerryStatRaiseEnd2_AbilityPopup: + call BattleScript_AbilityPopUp +BattleScript_BerryStatRaiseEnd2_Anim: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_82DB85B BattleScript_82DB85B:: @@ -7575,6 +7610,20 @@ BattleScript_82DB85B:: removeitem BS_ATTACKER end2 +BattleScript_BerryStatRaiseRet:: + jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_BerryStatRaiseRet_AbilityPopup + goto BattleScript_BerryStatRaiseRet_Anim +BattleScript_BerryStatRaiseRet_AbilityPopup: + call BattleScript_AbilityPopUp +BattleScript_BerryStatRaiseRet_Anim: + playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL + statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseRet_End +BattleScript_BerryStatRaiseRet_End: + setbyte cMULTISTRING_CHOOSER, 0x4 + call BattleScript_StatUp + removeitem BS_SCRIPTING + return + BattleScript_BerryFocusEnergyEnd2:: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNUSEDXTOGETPUMPED diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 3566a1c4d..f0e59cba3 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -208,7 +208,9 @@ extern const u8 BattleScript_ItemHealHP_Ret[]; extern const u8 BattleScript_SelectingNotAllowedMoveChoiceItem[]; extern const u8 BattleScript_HangedOnMsg[]; extern const u8 BattleScript_BerryConfuseHealEnd2[]; +extern const u8 BattleScript_BerryConfuseHealRet[]; extern const u8 BattleScript_BerryStatRaiseEnd2[]; +extern const u8 BattleScript_BerryStatRaiseRet[]; extern const u8 BattleScript_BerryFocusEnergyEnd2[]; extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[]; extern const u8 BattleScript_ArenaTurnBeginning[]; diff --git a/src/battle_util.c b/src/battle_util.c index aff3a1c53..56e7a2928 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4999,7 +4999,7 @@ static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) return FALSE; } -static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId) +static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2) { if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) { @@ -5009,17 +5009,35 @@ static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId) if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, flavorId) < 0) - BattleScriptExecute(BattleScript_BerryConfuseHealEnd2); + + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + { + gBattleMoveDamage *= 2; + gBattlerAbility = battlerId; + } + + if (end2) + { + if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, flavorId) < 0) + BattleScriptExecute(BattleScript_BerryConfuseHealEnd2); + else + BattleScriptExecute(BattleScript_ItemHealHP_RemoveItemEnd2); + } else - BattleScriptExecute(BattleScript_ItemHealHP_RemoveItemEnd2); + { + BattleScriptPushCursor(); + if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, flavorId) < 0) + gBattlescriptCurrInstr = BattleScript_BerryConfuseHealRet; + else + gBattlescriptCurrInstr = BattleScript_ItemHealHP_RemoveItemRet; + } return ITEM_HP_CHANGE; } return 0; } -static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId) +static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2) { if (gBattleMons[battlerId].statStages[statId] < 0xC && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId)) { @@ -5027,16 +5045,29 @@ static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId) PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); gEffectBattler = battlerId; - SET_STATCHANGER(statId, 1, FALSE); + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + SET_STATCHANGER(statId, 2, FALSE); + else + SET_STATCHANGER(statId, 1, FALSE); + gBattleScripting.animArg1 = 0xE + statId; gBattleScripting.animArg2 = 0; - BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); + + if (end2) + { + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); + } + else + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet; + } return ITEM_STATS_CHANGE; } return 0; } -static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId) +static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2) { s32 i; @@ -5064,10 +5095,24 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId) gBattleTextBuff2[7] = EOS; gEffectBattler = battlerId; - SET_STATCHANGER(i + 1, 2, FALSE); + + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + SET_STATCHANGER(i + 1, 4, FALSE); + else + SET_STATCHANGER(i + 1, 2, FALSE); + gBattleScripting.animArg1 = 0x21 + i + 6; gBattleScripting.animArg2 = 0; - BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); + + if (end2) + { + BattleScriptExecute(BattleScript_BerryStatRaiseEnd2); + } + else + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet; + } return ITEM_STATS_CHANGE; } return 0; @@ -5155,43 +5200,43 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_CONFUSE_SPICY: if (B_BERRIES_INSTANT >= GEN_4) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, TRUE); break; case HOLD_EFFECT_CONFUSE_DRY: if (B_BERRIES_INSTANT >= GEN_4) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, TRUE); break; case HOLD_EFFECT_CONFUSE_SWEET: if (B_BERRIES_INSTANT >= GEN_4) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, TRUE); break; case HOLD_EFFECT_CONFUSE_BITTER: if (B_BERRIES_INSTANT >= GEN_4) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, TRUE); break; case HOLD_EFFECT_CONFUSE_SOUR: if (B_BERRIES_INSTANT >= GEN_4) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, TRUE); break; case HOLD_EFFECT_ATTACK_UP: if (B_BERRIES_INSTANT >= GEN_4) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, TRUE); break; case HOLD_EFFECT_DEFENSE_UP: if (B_BERRIES_INSTANT >= GEN_4) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, TRUE); break; case HOLD_EFFECT_SPEED_UP: if (B_BERRIES_INSTANT >= GEN_4) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, TRUE); break; case HOLD_EFFECT_SP_ATTACK_UP: if (B_BERRIES_INSTANT >= GEN_4) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, TRUE); break; case HOLD_EFFECT_SP_DEFENSE_UP: if (B_BERRIES_INSTANT >= GEN_4) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, TRUE); break; case HOLD_EFFECT_CRITICAL_UP: if (B_BERRIES_INSTANT >= GEN_4 && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem)) @@ -5203,7 +5248,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_RANDOM_STAT_UP: if (B_BERRIES_INSTANT >= GEN_4) - effect = RandomStatRaiseBerry(battlerId, gLastUsedItem); + effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, TRUE); break; case HOLD_EFFECT_CURE_PAR: if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem)) @@ -5335,7 +5380,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) effect = ItemHealHp(battlerId, gLastUsedItem, TRUE, FALSE); break; case HOLD_EFFECT_RESTORE_PCT_HP: - if (B_BERRIES_INSTANT >= GEN_4) + if (!moveTurn) effect = ItemHealHp(battlerId, gLastUsedItem, TRUE, TRUE); break; case HOLD_EFFECT_RESTORE_PP: @@ -5360,10 +5405,17 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) if (i != MAX_MON_MOVES) { u8 maxPP = CalculatePPWithBonus(move, ppBonuses, i); - if (changedPP + GetBattlerHoldEffectParam(battlerId) > maxPP) + u8 ppRestored = GetBattlerHoldEffectParam(battlerId); + + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + { + ppRestored *= 2; + gBattlerAbility = battlerId; + } + if (changedPP + ppRestored > maxPP) changedPP = maxPP; else - changedPP = changedPP + GetBattlerHoldEffectParam(battlerId); + changedPP = changedPP + ppRestored; PREPARE_MOVE_BUFFER(gBattleTextBuff1, move); @@ -5421,43 +5473,43 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_CONFUSE_SPICY: if (!moveTurn) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, TRUE); break; case HOLD_EFFECT_CONFUSE_DRY: if (!moveTurn) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, TRUE); break; case HOLD_EFFECT_CONFUSE_SWEET: if (!moveTurn) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, TRUE); break; case HOLD_EFFECT_CONFUSE_BITTER: if (!moveTurn) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, TRUE); break; case HOLD_EFFECT_CONFUSE_SOUR: if (!moveTurn) - effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR); + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, TRUE); break; case HOLD_EFFECT_ATTACK_UP: if (!moveTurn) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, TRUE); break; case HOLD_EFFECT_DEFENSE_UP: if (!moveTurn) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, TRUE); break; case HOLD_EFFECT_SPEED_UP: if (!moveTurn) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, TRUE); break; case HOLD_EFFECT_SP_ATTACK_UP: if (!moveTurn) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, TRUE); break; case HOLD_EFFECT_SP_DEFENSE_UP: if (!moveTurn) - effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF); + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, TRUE); break; case HOLD_EFFECT_CRITICAL_UP: if (!moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem)) @@ -5469,7 +5521,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_RANDOM_STAT_UP: if (!moveTurn) - effect = RandomStatRaiseBerry(battlerId, gLastUsedItem); + effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, TRUE); break; case HOLD_EFFECT_CURE_PAR: if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem)) @@ -5609,6 +5661,50 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) if (B_BERRIES_INSTANT >= GEN_4) effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, TRUE); break; + case HOLD_EFFECT_CONFUSE_SPICY: + if (B_BERRIES_INSTANT >= GEN_4) + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SPICY, FALSE); + break; + case HOLD_EFFECT_CONFUSE_DRY: + if (B_BERRIES_INSTANT >= GEN_4) + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_DRY, FALSE); + break; + case HOLD_EFFECT_CONFUSE_SWEET: + if (B_BERRIES_INSTANT >= GEN_4) + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SWEET, FALSE); + break; + case HOLD_EFFECT_CONFUSE_BITTER: + if (B_BERRIES_INSTANT >= GEN_4) + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_BITTER, FALSE); + break; + case HOLD_EFFECT_CONFUSE_SOUR: + if (B_BERRIES_INSTANT >= GEN_4) + effect = HealConfuseBerry(battlerId, gLastUsedItem, FLAVOR_SOUR, FALSE); + break; + case HOLD_EFFECT_ATTACK_UP: + if (B_BERRIES_INSTANT >= GEN_4) + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_ATK, FALSE); + break; + case HOLD_EFFECT_DEFENSE_UP: + if (B_BERRIES_INSTANT >= GEN_4) + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_DEF, FALSE); + break; + case HOLD_EFFECT_SPEED_UP: + if (B_BERRIES_INSTANT >= GEN_4) + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPEED, FALSE); + break; + case HOLD_EFFECT_SP_ATTACK_UP: + if (B_BERRIES_INSTANT >= GEN_4) + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPATK, FALSE); + break; + case HOLD_EFFECT_SP_DEFENSE_UP: + if (B_BERRIES_INSTANT >= GEN_4) + effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, FALSE); + break; + case HOLD_EFFECT_RANDOM_STAT_UP: + if (B_BERRIES_INSTANT >= GEN_4) + effect = RandomStatRaiseBerry(battlerId, gLastUsedItem, FALSE); + break; case HOLD_EFFECT_CURE_PAR: if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem)) { From d3ae05189db302fc981cfffdaf413a036b46f94b Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 5 Jan 2021 22:21:38 -0700 Subject: [PATCH 03/26] resist berry ripen boost --- src/battle_util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index 56e7a2928..fcfa97e82 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7407,7 +7407,10 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move if (moveType == GetBattlerHoldEffectParam(battlerDef) && (moveType == TYPE_NORMAL || typeEffectivenessModifier >= UQ_4_12(2.0))) { - MulModifier(&finalModifier, UQ_4_12(0.5)); + if (abilityDef == ABILITY_RIPEN) + MulModifier(&finalModifier, UQ_4_12(0.25)); + else + MulModifier(&finalModifier, UQ_4_12(0.5)); if (updateFlags) gSpecialStatuses[battlerDef].berryReduced = 1; } From f2e486eb0d92ff6d7099de5899dbb4d260a64160 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 6 Jan 2021 09:37:31 -0700 Subject: [PATCH 04/26] custap berry effect, custap/quick claw activation message --- data/battle_scripts_1.s | 15 +++++++ include/battle.h | 9 ++++ include/battle_scripts.h | 2 + include/battle_util.h | 1 + include/constants/battle_string_ids.h | 3 +- include/constants/hold_effects.h | 3 ++ src/battle_main.c | 61 ++++++++++++++++++++++----- src/battle_message.c | 2 + src/battle_util.c | 2 +- 9 files changed, 86 insertions(+), 12 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3eb1f5cbe..28da6de0e 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7714,3 +7714,18 @@ BattleScript_AnnounceAirLockCloudNine:: waitmessage 0x40 call BattleScript_WeatherFormChanges end3 + +BattleScript_QuickClawActivation:: + playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP, NULL + waitanimation + printstring STRINGID_CANACTFASTERTHANKSTO + waitmessage 0x40 + end2 + +BattleScript_CustapBerryActivation:: + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + waitanimation + printstring STRINGID_CANACTFASTERTHANKSTO + waitmessage 0x40 + removeitem BS_ATTACKER + end2 diff --git a/include/battle.h b/include/battle.h index 488e0fc51..a7e8f5212 100644 --- a/include/battle.h +++ b/include/battle.h @@ -427,6 +427,13 @@ struct Illusion struct Pokemon *mon; }; +struct PinchBerry +{ + u8 micleBerry:1; + u8 custap:1; // also quick claw + +}; + struct BattleStruct { u8 turnEffectsTracker; @@ -542,6 +549,8 @@ struct BattleStruct u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used. u16 moveEffect2; // For Knock Off u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. + struct PinchBerry pinchBerry[MAX_BATTLERS_COUNT]; + u8 quickClawBattlerId; }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 3566a1c4d..a5548791a 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -350,5 +350,7 @@ extern const u8 BattleScript_EmergencyExitWild[]; extern const u8 BattleScript_EmergencyExitWildNoPopUp[]; extern const u8 BattleScript_CheekPouchActivates[]; extern const u8 BattleScript_AnnounceAirLockCloudNine[]; +extern const u8 BattleScript_QuickClawActivation[]; +extern const u8 BattleScript_CustapBerryActivation[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/battle_util.h b/include/battle_util.h index f7699fced..06256aa77 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -130,5 +130,6 @@ void ClearIllusionMon(u32 battlerId); bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId); bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId); u8 GetBattleMoveSplit(u32 moveId); +bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId); #endif // GUARD_BATTLE_UTIL_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 9348d67d5..bcb3e8678 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -558,8 +558,9 @@ #define STRINGID_AURABREAKENTERS 554 #define STRINGID_COMATOSEENTERS 555 #define STRINGID_SCREENCLEANERENTERS 556 +#define STRINGID_CANACTFASTERTHANKSTO 557 -#define BATTLESTRINGS_COUNT 557 +#define BATTLESTRINGS_COUNT 558 //// multichoice message IDs // switch in ability message diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index 85017cb40..3de2e7b43 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -104,6 +104,9 @@ #define HOLD_EFFECT_RESIST_BERRY 98 #define HOLD_EFFECT_POWER_ITEM 99 #define HOLD_EFFECT_RESTORE_PCT_HP 100 +#define HOLD_EFFECT_MICLE_BERRY 101 +#define HOLD_EFFECT_JABOCA_BERRY 102 +#define HOLD_EFFECT_CUSTAP_BERRY 103 // Gen5 hold effects #define HOLD_EFFECT_FLOAT_STONE 115 diff --git a/src/battle_main.c b/src/battle_main.c index 48129c523..916bf20b1 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -107,6 +107,7 @@ static void sub_803CDF8(void); static bool8 AllAtActionConfirmed(void); static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void); static void CheckMegaEvolutionBeforeTurn(void); +static void CheckQuickClaw_CustapBerryActivation(void); static void FreeResetData_ReturnToOvOrDoEvolutions(void); static void ReturnFromBattleToOverworld(void); static void TryEvolvePokemon(void); @@ -4324,20 +4325,23 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) u8 strikesFirst = 0; u32 speedBattler1 = 0, speedBattler2 = 0; u32 holdEffectBattler1 = 0, holdEffectBattler2 = 0; - bool32 quickClawBattler1 = FALSE, quickClawBattler2 = FALSE; s8 priority1 = 0, priority2 = 0; speedBattler1 = GetBattlerTotalSpeedStat(battler1); holdEffectBattler1 = GetBattlerHoldEffect(battler1, TRUE); - if (holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW - && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100) - quickClawBattler1 = TRUE; + if ((holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100) + || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) + && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY + && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))) + gBattleStruct->pinchBerry[battler1].custap = TRUE; speedBattler2 = GetBattlerTotalSpeedStat(battler2); holdEffectBattler2 = GetBattlerHoldEffect(battler2, TRUE); - if (holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW - && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100) - quickClawBattler2 = TRUE; + if ((holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100) + || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) + && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY + && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))) + gBattleStruct->pinchBerry[battler2].custap = TRUE; if (!ignoreChosenMoves) { @@ -4349,13 +4353,13 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) if (priority1 == priority2) { - // QUICK CLAW - always first + // QUICK CLAW / CUSTAP - always first // LAGGING TAIL - always last // STALL - always last - if (quickClawBattler1 && !quickClawBattler2) + if (gBattleStruct->pinchBerry[battler1].custap && !gBattleStruct->pinchBerry[battler2].custap) strikesFirst = 0; - else if (quickClawBattler2 && !quickClawBattler1) + else if (gBattleStruct->pinchBerry[battler2].custap && !gBattleStruct->pinchBerry[battler1].custap) strikesFirst = 1; else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) strikesFirst = 1; @@ -4592,6 +4596,43 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) } } + gBattleMainFunc = CheckQuickClaw_CustapBerryActivation; + gBattleStruct->quickClawBattlerId = 0; +} + +static void CheckQuickClaw_CustapBerryActivation(void) +{ + u32 i; + + if (!(gHitMarker & HITMARKER_RUN)) + { + while (gBattleStruct->quickClawBattlerId < gBattlersCount) + { + gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId; + gBattleStruct->quickClawBattlerId++; + if (gBattleStruct->pinchBerry[gActiveBattler].custap + && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) + && !(gDisableStructs[gBattlerAttacker].truantCounter) + && !(gProtectStructs[gActiveBattler].noValidMoves)) + { + gBattleStruct->pinchBerry[gActiveBattler].custap = FALSE; + gLastUsedItem = gBattleMons[gActiveBattler].item; + if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) + { + // don't record berry since its gone now + BattleScriptExecute(BattleScript_CustapBerryActivation); + } + else + { + RecordItemEffectBattle(gActiveBattler, GetBattlerHoldEffect(gActiveBattler, FALSE)); + BattleScriptExecute(BattleScript_QuickClawActivation); + } + return; + } + } + } + + // setup stuff before turns/actions TryClearRageAndFuryCutter(); gCurrentTurnActionNumber = 0; gCurrentActionFuncId = gActionsByTurnOrder[0]; diff --git a/src/battle_message.c b/src/battle_message.c index 35ccc6e26..bf52cba31 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -685,9 +685,11 @@ static const u8 sText_FairyAuraActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} static const u8 sText_AuraBreakActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} reversed all\nother POKéMON's auras!"); static const u8 sText_ComatoseActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is drowsing!"); static const u8 sText_ScreenCleanerActivates[] = _("All screens on the field were\ncleansed!"); +static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act\nfaster, thanks to {B_LAST_ITEM}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_CANACTFASTERTHANKSTO - 12] = sText_CanActFaster, [STRINGID_STATWASNOTLOWERED - 12] = sText_StatWasNotLowered, [STRINGID_CLOAKEDINAFREEZINGLIGHT - 12] = sText_CloakedInAFreezingLight, [STRINGID_DESTINYKNOTACTIVATES - 12] = sText_DestinyKnotActivates, diff --git a/src/battle_util.c b/src/battle_util.c index aeeefa734..586454efb 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4977,7 +4977,7 @@ enum }; // second argument is 1/X of current hp compared to max hp -static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) +bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) { bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES); From efa4fe89adeadaaf43eb1ba59b0b1ac9999c8e16 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 6 Jan 2021 10:47:07 -0700 Subject: [PATCH 05/26] micle berry --- data/battle_scripts_1.s | 25 ++++++++++++++++++++++++ include/battle.h | 2 +- include/battle_scripts.h | 2 ++ include/constants/battle_string_ids.h | 3 ++- src/battle_message.c | 4 +++- src/battle_script_commands.c | 9 +++++++++ src/battle_util.c | 28 +++++++++++++++++++++++++++ 7 files changed, 70 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 28da6de0e..c7f3cc663 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7729,3 +7729,28 @@ BattleScript_CustapBerryActivation:: waitmessage 0x40 removeitem BS_ATTACKER end2 + +BattleScript_MicleBerryActivateEnd2:: + jumpifability BS_ATTACKER, ABILITY_RIPEN, BattleScript_MicleBerryActivateEnd2_Ripen + goto BattleScript_MicleBerryActivateEnd2_Anim +BattleScript_MicleBerryActivateEnd2_Ripen: + call BattleScript_AbilityPopUp +BattleScript_MicleBerryActivateEnd2_Anim: + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + printstring STRINGID_MICLEBERRYACTIVATES + waitmessage 0x40 + removeitem BS_ATTACKER + end2 + +BattleScript_MicleBerryActivateRet:: + jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_MicleBerryActivateRet_Ripen + goto BattleScript_MicleBerryActivateRet_Anim +BattleScript_MicleBerryActivateRet_Ripen: + call BattleScript_AbilityPopUp +BattleScript_MicleBerryActivateRet_Anim: + playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL + printstring STRINGID_MICLEBERRYACTIVATES + waitmessage 0x40 + removeitem BS_SCRIPTING + return + diff --git a/include/battle.h b/include/battle.h index a7e8f5212..a108bac8e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -429,7 +429,7 @@ struct Illusion struct PinchBerry { - u8 micleBerry:1; + u8 micle:1; u8 custap:1; // also quick claw }; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index a5548791a..aec8dbc6e 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -352,5 +352,7 @@ extern const u8 BattleScript_CheekPouchActivates[]; extern const u8 BattleScript_AnnounceAirLockCloudNine[]; extern const u8 BattleScript_QuickClawActivation[]; extern const u8 BattleScript_CustapBerryActivation[]; +extern const u8 BattleScript_MicleBerryActivateEnd2[]; +extern const u8 BattleScript_MicleBerryActivateRet[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index bcb3e8678..321411cab 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -559,8 +559,9 @@ #define STRINGID_COMATOSEENTERS 555 #define STRINGID_SCREENCLEANERENTERS 556 #define STRINGID_CANACTFASTERTHANKSTO 557 +#define STRINGID_MICLEBERRYACTIVATES 558 -#define BATTLESTRINGS_COUNT 558 +#define BATTLESTRINGS_COUNT 559 //// multichoice message IDs // switch in ability message diff --git a/src/battle_message.c b/src/battle_message.c index bf52cba31..078175bd2 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -685,10 +685,12 @@ static const u8 sText_FairyAuraActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} static const u8 sText_AuraBreakActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} reversed all\nother POKéMON's auras!"); static const u8 sText_ComatoseActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} is drowsing!"); static const u8 sText_ScreenCleanerActivates[] = _("All screens on the field were\ncleansed!"); -static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act\nfaster, thanks to {B_LAST_ITEM}!"); +static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faster,\nthanks to {B_LAST_ITEM}!"); +static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_MICLEBERRYACTIVATES - 12] = sText_MicleBerryActivates, [STRINGID_CANACTFASTERTHANKSTO - 12] = sText_CanActFaster, [STRINGID_STATWASNOTLOWERED - 12] = sText_StatWasNotLowered, [STRINGID_CLOAKEDINAFREEZINGLIGHT - 12] = sText_CloakedInAFreezingLight, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bc427698e..48fe60aa5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1563,6 +1563,15 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move) calc = (calc * (100 + atkParam)) / 100; else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)); calc = (calc * (100 + atkParam)) / 100; + + if (gBattleStruct->pinchBerry[battlerAtk].micle) + { + gBattleStruct->pinchBerry[battlerAtk].micle = FALSE; + if (atkAbility == ABILITY_RIPEN) + calc = (calc * 140) / 100; // ripen gives 40% acc boost + else + calc = (calc * 120) / 100; // 20% acc boost + } return calc; } diff --git a/src/battle_util.c b/src/battle_util.c index 586454efb..54df2df63 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5073,6 +5073,26 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId) return 0; } +static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2) +{ + if (HasEnoughHpToEatBerry(battlerId, 4, itemId)) + { + gBattleStruct->pinchBerry[battlerId].micle = TRUE; // battler's next attack has increased accuracy + + if (end2) + { + BattleScriptExecute(BattleScript_MicleBerryActivateEnd2); + } + else + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_MicleBerryActivateRet; + } + return ITEM_EFFECT_OTHER; + } + return 0; +} + static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) @@ -5569,6 +5589,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) effect = ITEM_EFFECT_OTHER; } break; + case HOLD_EFFECT_MICLE_BERRY: + if (!moveTurn) + effect = TrySetMicleBerry(battlerId, gLastUsedItem, TRUE); + break; } if (effect) @@ -5595,6 +5619,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE); switch (battlerHoldEffect) { + case HOLD_EFFECT_MICLE_BERRY: + if (B_HP_BERRIES >= GEN_4) + effect = TrySetMicleBerry(battlerId, gLastUsedItem, FALSE); + break; case HOLD_EFFECT_RESTORE_HP: if (B_HP_BERRIES >= GEN_4) effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, FALSE); From 7646855e797416de9a25a2bd76e3760432cb6b8b Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 6 Jan 2021 11:15:56 -0700 Subject: [PATCH 06/26] jaboca, rowap berry effects --- data/battle_scripts_1.s | 14 ++++++++++++++ include/battle_scripts.h | 1 + include/constants/hold_effects.h | 1 + src/battle_util.c | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index c7f3cc663..3a503315a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7754,3 +7754,17 @@ BattleScript_MicleBerryActivateRet_Anim: removeitem BS_SCRIPTING return +BattleScript_JabocaRowapBerryActivates:: + jumpifability BS_TARGET, ABILITY_RIPEN, BattleScript_JabocaRowapBerryActivate_Ripen + goto BattleScript_JabocaRowapBerryActivate_Anim +BattleScript_JabocaRowapBerryActivate_Ripen: + call BattleScript_AbilityPopUp +BattleScript_JabocaRowapBerryActivate_Anim: + jumpifabsent BS_TARGET, BattleScript_JabocaRowapBerryActivate_Dmg @ dont play the animation for a fainted target + playanimation BS_TARGET, B_ANIM_HELD_ITEM_EFFECT, NULL + waitanimation +BattleScript_JabocaRowapBerryActivate_Dmg: + call BattleScript_HurtAttacker + removeitem BS_TARGET + return + diff --git a/include/battle_scripts.h b/include/battle_scripts.h index aec8dbc6e..4ca82e3bf 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -354,5 +354,6 @@ extern const u8 BattleScript_QuickClawActivation[]; extern const u8 BattleScript_CustapBerryActivation[]; extern const u8 BattleScript_MicleBerryActivateEnd2[]; extern const u8 BattleScript_MicleBerryActivateRet[]; +extern const u8 BattleScript_JabocaRowapBerryActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index 3de2e7b43..52a3ffda4 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -107,6 +107,7 @@ #define HOLD_EFFECT_MICLE_BERRY 101 #define HOLD_EFFECT_JABOCA_BERRY 102 #define HOLD_EFFECT_CUSTAP_BERRY 103 +#define HOLD_EFFECT_RETALIATE_BERRY 104 // rowap, jaboca // Gen5 hold effects #define HOLD_EFFECT_FLOAT_STONE 115 diff --git a/src/battle_util.c b/src/battle_util.c index 54df2df63..b6d83d957 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5890,6 +5890,25 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE); } break; + case HOLD_EFFECT_RETALIATE_BERRY: + if (IsBattlerAlive(battlerId) + && TARGET_TURN_DAMAGED + && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) + && GetBattleMoveSplit(gCurrentMove) == ItemId_GetHoldEffectParam(gLastUsedItem)) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + gBattleMoveDamage *= 2; + + effect = ITEM_HP_CHANGE; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_JabocaRowapBerryActivates; + PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem); + RecordItemEffectBattle(battlerId, HOLD_EFFECT_ROCKY_HELMET); + } + break; } } break; From aac3f9c3db7e53d77c5fab1d4fab9c6430aecdd0 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 6 Jan 2021 13:07:18 -0700 Subject: [PATCH 07/26] kee, maranga, sitrus beries --- include/constants/hold_effects.h | 9 +++-- src/battle_util.c | 56 ++++++++++++++++++++++++++++++-- src/data/items.h | 4 +-- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index 52a3ffda4..0b3236db9 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -105,9 +105,12 @@ #define HOLD_EFFECT_POWER_ITEM 99 #define HOLD_EFFECT_RESTORE_PCT_HP 100 #define HOLD_EFFECT_MICLE_BERRY 101 -#define HOLD_EFFECT_JABOCA_BERRY 102 -#define HOLD_EFFECT_CUSTAP_BERRY 103 -#define HOLD_EFFECT_RETALIATE_BERRY 104 // rowap, jaboca +#define HOLD_EFFECT_CUSTAP_BERRY 102 +#define HOLD_EFFECT_JABOCA_BERRY 103 +#define HOLD_EFFECT_ROWAP_BERRY 104 +#define HOLD_EFFECT_KEE_BERRY 105 +#define HOLD_EFFECT_MARANGA_BERRY 106 + // Gen5 hold effects #define HOLD_EFFECT_FLOAT_STONE 115 diff --git a/src/battle_util.c b/src/battle_util.c index 6981b811a..b452c10b4 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5138,6 +5138,33 @@ static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2) return 0; } +static u8 DamagedStatBoostBerryEffect(u8 battlerId, u8 statId, u8 split) +{ + if (IsBattlerAlive(battlerId) + && TARGET_TURN_DAMAGED + && gBattleMons[battlerId].statStages[statId] < MAX_STAT_STAGE + && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) + && GetBattleMoveSplit(gCurrentMove) == split) + { + + PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); + PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); + + gEffectBattler = battlerId; + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + SET_STATCHANGER(statId, 2, FALSE); + else + SET_STATCHANGER(statId, 1, FALSE); + + gBattleScripting.animArg1 = 0xE + statId; + gBattleScripting.animArg2 = 0; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet; + return ITEM_STATS_CHANGE; + } + return 0; +} + static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) @@ -5991,11 +6018,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gBattleScripting.statChanger = SET_STATCHANGER(STAT_SPATK, 1, FALSE); } break; - case HOLD_EFFECT_RETALIATE_BERRY: + case HOLD_EFFECT_JABOCA_BERRY: // consume and damage attacker if used physical move if (IsBattlerAlive(battlerId) && TARGET_TURN_DAMAGED && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) - && GetBattleMoveSplit(gCurrentMove) == ItemId_GetHoldEffectParam(gLastUsedItem)) + && IS_MOVE_PHYSICAL(gCurrentMove)) { gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) @@ -6010,6 +6037,31 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) RecordItemEffectBattle(battlerId, HOLD_EFFECT_ROCKY_HELMET); } break; + case HOLD_EFFECT_ROWAP_BERRY: // consume and damage attacker if used special move + if (IsBattlerAlive(battlerId) + && TARGET_TURN_DAMAGED + && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) + && IS_MOVE_SPECIAL(gCurrentMove)) + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) + gBattleMoveDamage *= 2; + + effect = ITEM_HP_CHANGE; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_JabocaRowapBerryActivates; + PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem); + RecordItemEffectBattle(battlerId, HOLD_EFFECT_ROCKY_HELMET); + } + break; + case HOLD_EFFECT_KEE_BERRY: // consume and boost defense if used physical move + effect = DamagedStatBoostBerryEffect(battlerId, STAT_DEF, SPLIT_PHYSICAL); + break; + case HOLD_EFFECT_MARANGA_BERRY: // consume and boost sp. defense if used special move + effect = DamagedStatBoostBerryEffect(battlerId, STAT_SPDEF, SPLIT_SPECIAL); + break; } } break; diff --git a/src/data/items.h b/src/data/items.h index 30beb5352..0f2e8461c 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -1867,8 +1867,8 @@ const struct Item gItems[] = .name = _("SITRUS BERRY"), .itemId = ITEM_SITRUS_BERRY, .price = 20, - .holdEffect = HOLD_EFFECT_RESTORE_HP, - .holdEffectParam = 30, + .holdEffect = HOLD_EFFECT_RESTORE_PCT_HP, + .holdEffectParam = 25, .description = sSitrusBerryDesc, .pocket = POCKET_BERRIES, .type = 1, From bfb7333507ab825a6cd116acf30de4d7a74c2e22 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 21 Jan 2021 12:03:30 -0700 Subject: [PATCH 08/26] memento gen4 failing --- include/constants/battle_config.h | 1 + src/battle_script_commands.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index f7b38000c..5e0491b61 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -112,6 +112,7 @@ #define B_PP_REDUCED_BY_SPITE GEN_6 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5. #define B_CAN_SPITE_FAIL GEN_6 // In Gen4+, Spite can no longer fail if the foe's last move only has 1 remaining PP. #define B_CRASH_IF_TARGET_IMMUNE GEN_6 // In Gen4+, The user of Jump Kick or Hi Jump Kick will "keep going and crash" if it attacks a target that is immune to the move. +#define B_MEMENTO_FAIL GEN_4 // in Gen4+, memento fails if there is no target or if the target is protected or behind substitute. But not if atk/sp.atk are at -6 // Ability settings #define B_ABILITY_WEATHER GEN_6 // In Gen6+, ability-induced weather lasts 5 turns. Before, it lasted until the battle ended or until it was changed by a move. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6c5f37a7d..4eb6aaf09 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10952,9 +10952,16 @@ static void Cmd_sethail(void) static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento { + #if B_MEMENTO_FAIL == GEN_3 if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == MIN_STAT_STAGE && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == MIN_STAT_STAGE && gBattleCommunication[6] != 1) + #else + if (gBattleCommunication[6] != 1 + || gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE + || IsBattlerProtected(gBattlerTarget, gCurrentMove) + || DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove)) + #endif { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } From 5aff5333dc76794f84469882c06e8cab8fb37c10 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 21 Jan 2021 12:05:01 -0700 Subject: [PATCH 09/26] fix B_MEMENTO_FAIL comment --- include/constants/battle_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 5e0491b61..ef9405cc5 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -112,7 +112,7 @@ #define B_PP_REDUCED_BY_SPITE GEN_6 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5. #define B_CAN_SPITE_FAIL GEN_6 // In Gen4+, Spite can no longer fail if the foe's last move only has 1 remaining PP. #define B_CRASH_IF_TARGET_IMMUNE GEN_6 // In Gen4+, The user of Jump Kick or Hi Jump Kick will "keep going and crash" if it attacks a target that is immune to the move. -#define B_MEMENTO_FAIL GEN_4 // in Gen4+, memento fails if there is no target or if the target is protected or behind substitute. But not if atk/sp.atk are at -6 +#define B_MEMENTO_FAIL GEN_4 // In Gen4+, memento fails if there is no target or if the target is protected or behind substitute. But not if atk/sp.atk are at -6 // Ability settings #define B_ABILITY_WEATHER GEN_6 // In Gen6+, ability-induced weather lasts 5 turns. Before, it lasted until the battle ended or until it was changed by a move. From f428e5e2dcbb8f03c2deed7a4a5802004206a804 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 31 Jan 2021 23:31:27 -0700 Subject: [PATCH 10/26] some quick claw/custap berry fixes --- data/battle_scripts_1.s | 4 ++++ include/battle.h | 10 ++-------- src/battle_main.c | 14 ++++++++------ src/battle_script_commands.c | 4 ++-- src/battle_util.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 4d3ef6c94..eab1de169 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7853,6 +7853,8 @@ BattleScript_AnnounceAirLockCloudNine:: end3 BattleScript_QuickClawActivation:: + printstring STRINGID_EMPTYSTRING3 + waitmessage 0x1 playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP, NULL waitanimation printstring STRINGID_CANACTFASTERTHANKSTO @@ -7860,6 +7862,8 @@ BattleScript_QuickClawActivation:: end2 BattleScript_CustapBerryActivation:: + printstring STRINGID_EMPTYSTRING3 + waitmessage 0x1 playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL waitanimation printstring STRINGID_CANACTFASTERTHANKSTO diff --git a/include/battle.h b/include/battle.h index 8e1970d46..494e92b14 100644 --- a/include/battle.h +++ b/include/battle.h @@ -140,6 +140,8 @@ struct ProtectStruct u32 usedGravityPreventedMove:1; u32 powderSelfDmg:1; u32 usedThroatChopPreventedMove:1; + u32 micle:1; + u32 custap:1; // also quick claw u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; @@ -427,13 +429,6 @@ struct Illusion struct Pokemon *mon; }; -struct PinchBerry -{ - u8 micle:1; - u8 custap:1; // also quick claw - -}; - struct BattleStruct { u8 turnEffectsTracker; @@ -549,7 +544,6 @@ struct BattleStruct u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used. u16 moveEffect2; // For Knock Off u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon. - struct PinchBerry pinchBerry[MAX_BATTLERS_COUNT]; u8 quickClawBattlerId; }; diff --git a/src/battle_main.c b/src/battle_main.c index d069c3a4e..e0ae09681 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4353,7 +4353,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))) - gBattleStruct->pinchBerry[battler1].custap = TRUE; + gProtectStructs[battler1].custap = TRUE; speedBattler2 = GetBattlerTotalSpeedStat(battler2); holdEffectBattler2 = GetBattlerHoldEffect(battler2, TRUE); @@ -4361,7 +4361,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))) - gBattleStruct->pinchBerry[battler2].custap = TRUE; + gProtectStructs[battler2].custap = TRUE; if (!ignoreChosenMoves) { @@ -4377,9 +4377,9 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) // LAGGING TAIL - always last // STALL - always last - if (gBattleStruct->pinchBerry[battler1].custap && !gBattleStruct->pinchBerry[battler2].custap) + if (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap) strikesFirst = 0; - else if (gBattleStruct->pinchBerry[battler2].custap && !gBattleStruct->pinchBerry[battler1].custap) + else if (gProtectStructs[battler2].custap && !gProtectStructs[battler1].custap) strikesFirst = 1; else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) strikesFirst = 1; @@ -4630,12 +4630,14 @@ static void CheckQuickClaw_CustapBerryActivation(void) { gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId; gBattleStruct->quickClawBattlerId++; - if (gBattleStruct->pinchBerry[gActiveBattler].custap + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE + && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here + && gProtectStructs[gActiveBattler].custap && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) && !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gProtectStructs[gActiveBattler].noValidMoves)) { - gBattleStruct->pinchBerry[gActiveBattler].custap = FALSE; + gProtectStructs[gActiveBattler].custap = FALSE; gLastUsedItem = gBattleMons[gActiveBattler].item; if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 450ee74eb..cd8ac212c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1564,9 +1564,9 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move) else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)); calc = (calc * (100 + atkParam)) / 100; - if (gBattleStruct->pinchBerry[battlerAtk].micle) + if (gProtectStructs[battlerAtk].micle) { - gBattleStruct->pinchBerry[battlerAtk].micle = FALSE; + gProtectStructs[battlerAtk].micle = FALSE; if (atkAbility == ABILITY_RIPEN) calc = (calc * 140) / 100; // ripen gives 40% acc boost else diff --git a/src/battle_util.c b/src/battle_util.c index 6568ae2e4..fc9b4cab6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5221,7 +5221,7 @@ static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2) { if (HasEnoughHpToEatBerry(battlerId, 4, itemId)) { - gBattleStruct->pinchBerry[battlerId].micle = TRUE; // battler's next attack has increased accuracy + gProtectStructs[battlerId].micle = TRUE; // battler's next attack has increased accuracy if (end2) { From 6139b12a49a69d5933aa971913a8a61541d5a957 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 2 Feb 2021 23:30:08 -0700 Subject: [PATCH 11/26] fix hp boxes not dissapearing --- include/battle_interface.h | 2 +- src/battle_anim.c | 26 ++++++++++++++++++++++++-- src/battle_anim_throw.c | 6 +++--- src/battle_interface.c | 37 ++----------------------------------- 4 files changed, 30 insertions(+), 41 deletions(-) diff --git a/include/battle_interface.h b/include/battle_interface.h index d06c44e88..0bcadaaac 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -74,7 +74,7 @@ void SetHealthboxSpriteInvisible(u8 healthboxSpriteId); void SetHealthboxSpriteVisible(u8 healthboxSpriteId); void DestoryHealthboxSprite(u8 healthboxSpriteId); void DummyBattleInterfaceFunc(u8 healthboxSpriteId, bool8 isDoubleBattleBankOnly); -void UpdateOamPriorityInAllHealthboxes(u8 priority); +void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHpBoxes); void InitBattlerHealthboxCoords(u8 battler); void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent); void SwapHpBarsWithHpText(void); diff --git a/src/battle_anim.c b/src/battle_anim.c index cb7ea5bea..f20d30dab 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -18,6 +18,7 @@ #include "task.h" #include "constants/battle_anim.h" #include "constants/battle_config.h" +#include "constants/battle_moves.h" #define ANIM_SPRITE_INDEX_COUNT 8 @@ -2198,11 +2199,32 @@ void DoMoveAnim(u16 move) void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim) { s32 i; + bool32 hideHpBoxes = (tableId == MOVE_TRANSFORM) ? FALSE : TRUE; + + if (!isMoveAnim) + { + switch (tableId) + { + case B_ANIM_TURN_TRAP: + case B_ANIM_LEECH_SEED_DRAIN: + case B_ANIM_MON_HIT: + case B_ANIM_SNATCH_MOVE: + case B_ANIM_FUTURE_SIGHT_HIT: + case B_ANIM_DOOM_DESIRE_HIT: + case B_ANIM_WISH_HEAL: + case B_ANIM_MEGA_EVOLUTION: + hideHpBoxes = TRUE; + break; + default: + hideHpBoxes = FALSE; + break; + } + } if (!IsContest()) { sub_80A8278(); - UpdateOamPriorityInAllHealthboxes(0); + UpdateOamPriorityInAllHealthboxes(0, hideHpBoxes); for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (GetBattlerSide(i) != B_SIDE_PLAYER) @@ -2511,7 +2533,7 @@ static void ScriptCmd_end(void) if (!IsContest()) { sub_80A8278(); - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, TRUE); } gAnimScriptActive = FALSE; } diff --git a/src/battle_anim_throw.c b/src/battle_anim_throw.c index cd686af5c..869daf030 100755 --- a/src/battle_anim_throw.c +++ b/src/battle_anim_throw.c @@ -1332,7 +1332,7 @@ static void SpriteCB_Ball_Capture_Step(struct Sprite *sprite) else if (sprite->sTimer == 95) { gDoingBattleAnim = FALSE; - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, FALSE); m4aMPlayAllStop(); PlaySE(MUS_RG_CAUGHT_INTRO); } @@ -1515,7 +1515,7 @@ static void SpriteCB_Ball_Release_Wait(struct Sprite *sprite) sprite->sFrame = 0; sprite->callback = DestroySpriteAfterOneFrame; gDoingBattleAnim = 0; - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, FALSE); } } @@ -1557,7 +1557,7 @@ static void SpriteCB_Ball_Block_Step(struct Sprite *sprite) sprite->sFrame = 0; sprite->callback = DestroySpriteAfterOneFrame; gDoingBattleAnim = 0; - UpdateOamPriorityInAllHealthboxes(1); + UpdateOamPriorityInAllHealthboxes(1, FALSE); } } diff --git a/src/battle_interface.c b/src/battle_interface.c index 73b66a7ff..9cf708f37 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -944,39 +944,6 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8 u8 spriteIds[4] = {healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId}; int i; - switch (gBattleResources->bufferA[gBattleAnimAttacker][0]) - { - case CONTROLLER_MOVEANIMATION: - if (gBattleResources->bufferA[gBattleAnimAttacker][1] == MOVE_TRANSFORM) - return; - break; - case CONTROLLER_BALLTHROWANIM: - return; //throwing ball does not hide hp boxes - case CONTROLLER_BATTLEANIMATION: - //check special anims that hide health boxes - switch (gBattleResources->bufferA[gBattleAnimAttacker][1]) - { - case B_ANIM_TURN_TRAP: - case B_ANIM_LEECH_SEED_DRAIN: - case B_ANIM_MON_HIT: - case B_ANIM_SNATCH_MOVE: - case B_ANIM_FUTURE_SIGHT_HIT: - case B_ANIM_DOOM_DESIRE_HIT: - case B_ANIM_WISH_HEAL: - //new - case B_ANIM_MEGA_EVOLUTION: - case B_ANIM_TERRAIN_MISTY: - case B_ANIM_TERRAIN_GRASSY: - case B_ANIM_TERRAIN_ELECTRIC: - case B_ANIM_TERRAIN_PSYCHIC: - break; - } - return; //all other special anims dont hide - default: - return; - } - - // if we've reached here, we should hide hp boxes for (i = 0; i < NELEMS(spriteIds); i++) { if (spriteIds[i] == 0xFF) @@ -994,7 +961,7 @@ static void TryToggleHealboxVisibility(u8 priority, u8 healthboxLeftSpriteId, u8 } } -void UpdateOamPriorityInAllHealthboxes(u8 priority) +void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHPBoxes) { s32 i; @@ -1012,7 +979,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority) gSprites[indicatorSpriteId].oam.priority = priority; #if B_HIDE_HEALTHBOXES_DURING_ANIMS - if (IsBattlerAlive(i)) + if (hideHPBoxes && IsBattlerAlive(i)) TryToggleHealboxVisibility(priority, healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId); #endif } From 5e8c8a6aaf8b565072556e8b38e9905c34baa39e Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 7 Feb 2021 12:05:55 -0700 Subject: [PATCH 12/26] fix ghost types unable to escape from mean look/trap --- src/battle_util.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 8c55ba7ca..3aa869fad 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5071,10 +5071,16 @@ u32 IsAbilityPreventingEscape(u32 battlerId) bool32 CanBattlerEscape(u32 battlerId) // no ability check { - return (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_SHED_SHELL - || !((gBattleMons[battlerId].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED)) - || (gStatuses3[battlerId] & STATUS3_ROOTED) - || gFieldStatuses & STATUS_FIELD_FAIRY_LOCK)); + if (GetBattlerHoldEffect(battlerId, TRUE) == HOLD_EFFECT_SHED_SHELL) + return TRUE; + else if ((B_GHOSTS_ESCAPE >= GEN_6 && !IS_BATTLER_OF_TYPE(battlerId, TYPE_GHOST)) && gBattleMons[battlerId].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED)) + return FALSE; + else if (gStatuses3[battlerId] & STATUS3_ROOTED) + return FALSE; + else if (gFieldStatuses & STATUS_FIELD_FAIRY_LOCK) + return FALSE; + else + return TRUE; } void BattleScriptExecute(const u8 *BS_ptr) From 2b90c0b94557d88a575f096752715d122fa33c74 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Fri, 19 Feb 2021 13:57:29 +1300 Subject: [PATCH 13/26] Fix Spiky Shield/Jump Kick bug Spiky Shield no longer tries to hurt a Pokemon that has already fainted. Previously this would freeze the game if Jump Kick recoil fainted a Pokemon due to the target using Spiky Shield. --- data/battle_scripts_1.s | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b7be70429..e68326583 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7293,6 +7293,7 @@ BattleScript_RockyHelmetActivatesDmg: return BattleScript_SpikyShieldEffect:: + jumpifabsent BS_ATTACKER, BattleScript_SpikyShieldRet orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 bichalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT healthbarupdate BS_ATTACKER @@ -7300,6 +7301,7 @@ BattleScript_SpikyShieldEffect:: printstring STRINGID_PKMNHURTSWITH waitmessage 0x40 tryfaintmon BS_ATTACKER, FALSE, NULL +BattleScript_SpikyShieldRet:: return BattleScript_KingsShieldEffect:: From 3a30fe900ab2d7ce822e9c99de6092a7ebe28804 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:13:49 -0700 Subject: [PATCH 14/26] Update include/constants/hold_effects.h Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- include/constants/hold_effects.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index 0b3236db9..f4c810d96 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -111,7 +111,6 @@ #define HOLD_EFFECT_KEE_BERRY 105 #define HOLD_EFFECT_MARANGA_BERRY 106 - // Gen5 hold effects #define HOLD_EFFECT_FLOAT_STONE 115 #define HOLD_EFFECT_EVIOLITE 116 From 63b1a02c286d9bd6ed99971bb3111cbb288ed0fa Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:13:56 -0700 Subject: [PATCH 15/26] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index b9db48f79..3477e83eb 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5107,7 +5107,6 @@ enum bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) { bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES); - if (gBattleMons[battlerId].hp == 0) return FALSE; // Unnerve prevents consumption of opponents' berries. From bcb6fe154b82418fc87f7a5610d2939eeab90b5f Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:14:00 -0700 Subject: [PATCH 16/26] Update src/battle_main.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index e0ae09681..4b3fc53dd 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4631,11 +4631,11 @@ static void CheckQuickClaw_CustapBerryActivation(void) gActiveBattler = gBattlerAttacker = gBattleStruct->quickClawBattlerId; gBattleStruct->quickClawBattlerId++; if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE - && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here - && gProtectStructs[gActiveBattler].custap - && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) - && !(gDisableStructs[gBattlerAttacker].truantCounter) - && !(gProtectStructs[gActiveBattler].noValidMoves)) + && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here + && gProtectStructs[gActiveBattler].custap + && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) + && !(gDisableStructs[gBattlerAttacker].truantCounter) + && !(gProtectStructs[gActiveBattler].noValidMoves)) { gProtectStructs[gActiveBattler].custap = FALSE; gLastUsedItem = gBattleMons[gActiveBattler].item; From 0ee9425599768946039528f831bd395ddf1574b8 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:14:07 -0700 Subject: [PATCH 17/26] Update include/battle_scripts.h Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- include/battle_scripts.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 2cf8c95b4..812bd96a1 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -365,5 +365,4 @@ extern const u8 BattleScript_MicleBerryActivateEnd2[]; extern const u8 BattleScript_MicleBerryActivateRet[]; extern const u8 BattleScript_JabocaRowapBerryActivates[]; - #endif // GUARD_BATTLE_SCRIPTS_H From 43ec4e1041a18e98a6c786823f71ac0bcae19699 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:14:14 -0700 Subject: [PATCH 18/26] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 3477e83eb..e2fe56fbf 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5267,10 +5267,10 @@ static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2) static u8 DamagedStatBoostBerryEffect(u8 battlerId, u8 statId, u8 split) { if (IsBattlerAlive(battlerId) - && TARGET_TURN_DAMAGED - && gBattleMons[battlerId].statStages[statId] < MAX_STAT_STAGE - && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) - && GetBattleMoveSplit(gCurrentMove) == split) + && TARGET_TURN_DAMAGED + && gBattleMons[battlerId].statStages[statId] < MAX_STAT_STAGE + && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) + && GetBattleMoveSplit(gCurrentMove) == split) { PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); From 3edb7ede29a41de62b3ddf311313ee23a54b5008 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:14:20 -0700 Subject: [PATCH 19/26] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index e2fe56fbf..2f7e3e4a4 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6146,9 +6146,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_JABOCA_BERRY: // consume and damage attacker if used physical move if (IsBattlerAlive(battlerId) - && TARGET_TURN_DAMAGED - && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) - && IS_MOVE_PHYSICAL(gCurrentMove)) + && TARGET_TURN_DAMAGED + && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) + && IS_MOVE_PHYSICAL(gCurrentMove)) { gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) From 99c8bd19ca1bbc6582a8315f01779820cf0409b9 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:14:25 -0700 Subject: [PATCH 20/26] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 2f7e3e4a4..4bdd96f68 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6165,9 +6165,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_ROWAP_BERRY: // consume and damage attacker if used special move if (IsBattlerAlive(battlerId) - && TARGET_TURN_DAMAGED - && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) - && IS_MOVE_SPECIAL(gCurrentMove)) + && TARGET_TURN_DAMAGED + && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) + && IS_MOVE_SPECIAL(gCurrentMove)) { gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) From 64e3f7dc24987a89552f7b748d7f43e35b2497a5 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 10:47:59 -0700 Subject: [PATCH 21/26] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index 3dd0dd92f..f7def5b9a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5172,6 +5172,7 @@ enum bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) { bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES); + if (gBattleMons[battlerId].hp == 0) return FALSE; // Unnerve prevents consumption of opponents' berries. @@ -8298,4 +8299,3 @@ static bool32 IsUnnerveAbilityOnOpposingSide(u8 battlerId) return TRUE; return FALSE; } - From 6739433e9ec9c0372fd2e94aeb6411929f5f6bcf Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 10:48:05 -0700 Subject: [PATCH 22/26] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index f7def5b9a..cfc9bd836 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6215,7 +6215,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) && TARGET_TURN_DAMAGED && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) && IS_MOVE_PHYSICAL(gCurrentMove) - && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) From 5207d48b210499830a797f03e4d2b8a68fe4c136 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 10:48:11 -0700 Subject: [PATCH 23/26] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_util.c b/src/battle_util.c index cfc9bd836..33ee8644e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6235,7 +6235,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) && TARGET_TURN_DAMAGED && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) && IS_MOVE_SPECIAL(gCurrentMove) - && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) + && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) From f83e8b4f94b90b68dcda07f60000034425dd070f Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Wed, 3 Mar 2021 10:48:17 -0700 Subject: [PATCH 24/26] Update src/battle_message.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_message.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle_message.c b/src/battle_message.c index 67f83bbeb..05874c595 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -696,7 +696,6 @@ static const u8 sText_CuriousMedicineEnters[] = _("{B_EFF_NAME_WITH_PREFIX}'s\ns static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faster,\nthanks to {B_LAST_ITEM}!"); static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); - const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { [STRINGID_MICLEBERRYACTIVATES - 12] = sText_MicleBerryActivates, From 41d47a867e3ba813bd1274a1d0c4f500fb419a19 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 3 Mar 2021 10:48:57 -0700 Subject: [PATCH 25/26] format fixes --- include/battle_scripts.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 7bdaf1d18..2fc993b9c 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -368,5 +368,4 @@ extern const u8 BattleScript_MicleBerryActivateEnd2[]; extern const u8 BattleScript_MicleBerryActivateRet[]; extern const u8 BattleScript_JabocaRowapBerryActivates[]; - #endif // GUARD_BATTLE_SCRIPTS_H From d6e89a99ce46f831797c6cac9b9b401a42ee5957 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 14 Mar 2021 12:35:08 -0300 Subject: [PATCH 26/26] Corrected the name of an included header file include/constants/battle_moves.h doesn't exist. The right header file to include was include/constants/moves.h instead. --- src/battle_anim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_anim.c b/src/battle_anim.c index f20d30dab..6613c3639 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -18,7 +18,7 @@ #include "task.h" #include "constants/battle_anim.h" #include "constants/battle_config.h" -#include "constants/battle_moves.h" +#include "constants/moves.h" #define ANIM_SPRITE_INDEX_COUNT 8