From 0d8f804194cbcacc9e2937f4c711b409763a6016 Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 15 Jan 2021 18:11:55 -0700 Subject: [PATCH] update mental herb to gen 5 --- data/battle_scripts_1.s | 13 +++++ include/battle_scripts.h | 2 + include/constants/battle_string_ids.h | 13 ++++- include/constants/hold_effects.h | 2 +- src/battle_message.c | 16 ++++++ src/battle_util.c | 74 ++++++++++++++++++++++----- src/data/items.h | 2 +- src/data/text/item_descriptions.h | 7 +++ 8 files changed, 114 insertions(+), 15 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index bff609d598..f256430ef1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7508,6 +7508,19 @@ BattleScript_BerryCureChosenStatusRet:: removeitem BS_SCRIPTING return +BattleScript_MentalHerbCureRet:: + playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL + printfromtable gMentalHerbCureStringIds + waitmessage 0x40 + updatestatusicon BS_SCRIPTING + removeitem BS_SCRIPTING + copybyte gBattlerAttacker, sSAVED_BATTLER @ restore the original attacker just to be safe + return + +BattleScript_MentalHerbCureEnd2:: + call BattleScript_MentalHerbCureRet + end2 + BattleScript_WhiteHerbEnd2:: call BattleScript_WhiteHerbRet end2 diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 009590f3a3..3b30d5bbd4 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -357,5 +357,7 @@ extern const u8 BattleScript_CottonDownActivates[]; extern const u8 BattleScript_BallFetch[]; extern const u8 BattleScript_SandSpitActivates[]; extern const u8 BattleScript_PerishBodyActivates[]; +extern const u8 BattleScript_MentalHerbCureRet[]; +extern const u8 BattleScript_MentalHerbCureEnd2[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 73b91c7087..9f02662e50 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -564,8 +564,11 @@ #define STRINGID_PKMNSWILLPERISHIN3TURNS 560 #define STRINGID_ABILITYRAISEDSTATDRASTICALLY 561 #define STRINGID_AURAFLAREDTOLIFE 562 +#define STRINGID_ATKGOTOVERINFATUATION 563 +#define STRINGID_TORMENTEDNOMORE 564 +#define STRINGID_HEALBLOCKEDNOMORE 565 -#define BATTLESTRINGS_COUNT 563 +#define BATTLESTRINGS_COUNT 566 //// multichoice message IDs // switch in ability message @@ -583,4 +586,12 @@ #define MULTI_SWITCHIN_COMATOSE 11 #define MULTI_SWITCHIN_SCREENCLEANER 12 +// mental herb +#define MULTI_CUREINFATUATION 0 +#define MULTI_CURETAUNT 1 +#define MULTI_CUREENCORE 2 +#define MULTI_CURETORMENT 3 +#define MULTI_CUREHEALBLOCK 4 +#define MULTI_CUREDISABLE 5 + #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/include/constants/hold_effects.h b/include/constants/hold_effects.h index 85017cb405..9afe5ef819 100644 --- a/include/constants/hold_effects.h +++ b/include/constants/hold_effects.h @@ -29,7 +29,7 @@ #define HOLD_EFFECT_EXP_SHARE 25 #define HOLD_EFFECT_QUICK_CLAW 26 #define HOLD_EFFECT_HAPPINESS_UP 27 -#define HOLD_EFFECT_CURE_ATTRACT 28 +#define HOLD_EFFECT_MENTAL_HERB 28 #define HOLD_EFFECT_CHOICE_BAND 29 #define HOLD_EFFECT_FLINCH 30 #define HOLD_EFFECT_BUG_POWER 31 diff --git a/src/battle_message.c b/src/battle_message.c index 90e8c89671..ee97ffbba0 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -691,9 +691,15 @@ static const u8 sText_BattlerAbilityRaisedStat[] = _("{B_SCR_ACTIVE_NAME_WITH_PR static const u8 sText_ASandstormKickedUp[] = _("A sandstorm kicked up!"); static const u8 sText_PkmnsWillPerishIn3Turns[] = _("Both Pokémon will perish\nin three turns!"); static const u8 sText_AbilityRaisedStatDrastically[] = _("{B_DEF_ABILITY} raised {B_DEF_NAME_WITH_PREFIX}'s\n{B_BUFF1} drastically!"); +static const u8 sText_AttackerGotOverInfatuation[] =_("{B_ATK_NAME_WITH_PREFIX} got over\nits infatuation!"); +static const u8 sText_TormentedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is\ntormented no more!"); +static const u8 sText_HealBlockedNoMore[] = _("{B_ATK_NAME_WITH_PREFIX} is cured of\nits heal block!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_HEALBLOCKEDNOMORE - 12] = sText_HealBlockedNoMore, + [STRINGID_TORMENTEDNOMORE - 12] = sText_TormentedNoMore, + [STRINGID_ATKGOTOVERINFATUATION - 12] = sText_AttackerGotOverInfatuation, [STRINGID_ABILITYRAISEDSTATDRASTICALLY - 12] = sText_AbilityRaisedStatDrastically, [STRINGID_PKMNSWILLPERISHIN3TURNS - 12] = sText_PkmnsWillPerishIn3Turns, [STRINGID_ASANDSTORMKICKEDUP - 12] = sText_ASandstormKickedUp, @@ -1247,6 +1253,16 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_SCREENCLEANERENTERS - 12] = sText_ScreenCleanerActivates, }; +const u16 gMentalHerbCureStringIds[] = +{ + [MULTI_CUREINFATUATION] = STRINGID_ATKGOTOVERINFATUATION, + [MULTI_CURETAUNT] = STRINGID_BUFFERENDS, + [MULTI_CUREENCORE] = STRINGID_PKMNENCOREENDED, + [MULTI_CURETORMENT] = STRINGID_TORMENTEDNOMORE, + [MULTI_CUREHEALBLOCK] = STRINGID_HEALBLOCKEDNOMORE, + [MULTI_CUREDISABLE] = STRINGID_PKMNMOVEDISABLEDNOMORE, +}; + const u16 gTerrainStringIds[] = { STRINGID_TERRAINBECOMESMISTY, STRINGID_TERRAINBECOMESGRASSY, STRINGID_TERRAINBECOMESELECTRIC, STRINGID_TERRAINBECOMESPSYCHIC diff --git a/src/battle_util.c b/src/battle_util.c index 210f00b270..a0633f6cfe 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5202,6 +5202,58 @@ static bool32 UnnerveOn(u32 battlerId, u32 itemId) return FALSE; } +static bool32 GetMentalHerbEffect(u8 battlerId) +{ + bool32 ret = FALSE; + // check infatuation + if (gBattleMons[battlerId].status2 & STATUS2_INFATUATION) + { + gBattleMons[battlerId].status2 &= ~(STATUS2_INFATUATION); + gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_CUREINFATUATION; //STRINGID_TARGETGOTOVERINFATUATION + StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); + ret = TRUE; + } + // check taunt + if (gDisableStructs[gBattlerTarget].tauntTimer != 0) + { + gDisableStructs[gBattlerTarget].tauntTimer = gDisableStructs[gBattlerTarget].tauntTimer2 = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_CURETAUNT; + PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_TAUNT); + ret = TRUE; + } + // check encore + if (gDisableStructs[gBattlerTarget].encoreTimer != 0) + { + gDisableStructs[gActiveBattler].encoredMove = 0; + gDisableStructs[gBattlerTarget].encoreTimerStartValue = gDisableStructs[gBattlerTarget].encoreTimer = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_CUREENCORE; //STRINGID_PKMNENCOREENDED + ret = TRUE; + } + // check torment + if (gBattleMons[battlerId].status2 & STATUS2_TORMENT) + { + gBattleMons[battlerId].status2 &= ~(STATUS2_TORMENT); + gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_CURETORMENT; + ret = TRUE; + } + // check heal block + if (gStatuses3[battlerId] & STATUS3_HEAL_BLOCK) + { + gStatuses3[battlerId] & ~(STATUS3_HEAL_BLOCK); + gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_CUREHEALBLOCK; + ret = TRUE; + } + // disable + if (gDisableStructs[gBattlerTarget].disableTimer != 0) + { + gDisableStructs[gBattlerTarget].disableTimer = gDisableStructs[gBattlerTarget].disableTimerStartValue = 0; + gDisableStructs[gBattlerTarget].disabledMove = 0; + gBattleCommunication[MULTISTRING_CHOOSER] = MULTI_CUREDISABLE; + ret = TRUE; + } + return ret; +} + u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) { int i = 0, moveType; @@ -5658,13 +5710,12 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) effect = ITEM_STATUS_CHANGE; } break; - case HOLD_EFFECT_CURE_ATTRACT: - if (gBattleMons[battlerId].status2 & STATUS2_INFATUATION) + case HOLD_EFFECT_MENTAL_HERB: + if (GetMentalHerbEffect(battlerId)) { - gBattleMons[battlerId].status2 &= ~(STATUS2_INFATUATION); - StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); - BattleScriptExecute(BattleScript_BerryCureChosenStatusEnd2); - gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gBattleScripting.savedBattler = gBattlerAttacker; + gBattlerAttacker = battlerId; + BattleScriptExecute(BattleScript_MentalHerbCureEnd2); effect = ITEM_EFFECT_OTHER; } break; @@ -5757,14 +5808,13 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) effect = ITEM_EFFECT_OTHER; } break; - case HOLD_EFFECT_CURE_ATTRACT: - if (gBattleMons[battlerId].status2 & STATUS2_INFATUATION) + case HOLD_EFFECT_MENTAL_HERB: + if (GetMentalHerbEffect(battlerId)) { - gBattleMons[battlerId].status2 &= ~(STATUS2_INFATUATION); - StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); + gBattleScripting.savedBattler = gBattlerAttacker; + gBattlerAttacker = battlerId; BattleScriptPushCursor(); - gBattleCommunication[MULTISTRING_CHOOSER] = 0; - gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet; + gBattlescriptCurrInstr = BattleScript_MentalHerbCureRet; effect = ITEM_EFFECT_OTHER; } break; diff --git a/src/data/items.h b/src/data/items.h index 30beb53528..aa06dea339 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -2423,7 +2423,7 @@ const struct Item gItems[] = .name = _("MENTAL HERB"), .itemId = ITEM_MENTAL_HERB, .price = 100, - .holdEffect = HOLD_EFFECT_CURE_ATTRACT, + .holdEffect = HOLD_EFFECT_MENTAL_HERB, .description = sMentalHerbDesc, .pocket = POCKET_ITEMS, .type = 4, diff --git a/src/data/text/item_descriptions.h b/src/data/text/item_descriptions.h index 5f79efc57a..d47152f7f7 100644 --- a/src/data/text/item_descriptions.h +++ b/src/data/text/item_descriptions.h @@ -743,10 +743,17 @@ static const u8 sSootheBellDesc[] = _( "calms spirits and\n" "fosters friendship."); +#if B_MENTAL_HERB < GEN_5 static const u8 sMentalHerbDesc[] = _( "A hold item that\n" "snaps POKéMON out\n" "of infatuation."); +#else +static const u8 sMentalHerbDesc[] = _( + "Snaps Pokémon out\n" + "of move-binding\n" + "effects."); +#endif static const u8 sChoiceBandDesc[] = _( "Raises a move's\n"