From 0dc5e1e6852fca11dd3dab5b3600b88a12ef5910 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 7 Feb 2023 13:01:56 +0100 Subject: [PATCH 1/2] aftermath damp pop-ups and string --- data/battle_scripts_1.s | 10 +++++++ include/battle_scripts.h | 1 + include/constants/battle_string_ids.h | 4 +-- src/battle_message.c | 3 +- src/battle_util.c | 41 ++++++++++++++++----------- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 833d01348..113318f1f 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7900,6 +7900,16 @@ BattleScript_AftermathDmg:: waitmessage B_WAIT_TIME_LONG tryfaintmon BS_ATTACKER return + +BattleScript_DampPreventsAftermath:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + pause 40 + copybyte gBattlerAbility, sBATTLER + call BattleScript_AbilityPopUp + printstring STRINGID_PKMNSABILITYPREVENTSABILITY + waitmessage B_WAIT_TIME_LONG + return BattleScript_MoveUsedIsAsleep:: printstring STRINGID_PKMNFASTASLEEP diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 8acf6e8ef..18c1911e5 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -451,6 +451,7 @@ extern const u8 BattleScript_EarthEaterActivates[]; extern const u8 BattleScript_MimicryActivates_End3[]; extern const u8 BattleScript_IceFaceNullsDamage[]; extern const u8 BattleScript_BattlerFormChangeWithStringEnd3[]; +extern const u8 BattleScript_DampPreventsAftermath[]; // zmoves extern const u8 BattleScript_ZMoveActivateDamaging[]; diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index f63aa79bc..3f8853024 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -638,8 +638,9 @@ #define STRINGID_ELECTRICTERRAINACTIVATEDABILITY 636 #define STRINGID_ABILITYWEAKENEDFSURROUNDINGMONSSTAT 637 #define STRINGID_ATTACKERGAINEDSTRENGTHFROMTHEFALLEN 638 +#define STRINGID_PKMNSABILITYPREVENTSABILITY 639 -#define BATTLESTRINGS_COUNT 639 +#define BATTLESTRINGS_COUNT 640 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, @@ -740,7 +741,6 @@ // gUproarAwakeStringIds #define B_MSG_CANT_SLEEP_UPROAR 0 #define B_MSG_UPROAR_KEPT_AWAKE 1 -#define B_MSG_STAYED_AWAKE_USING 2 // gUproarOverTurnStringIds #define B_MSG_UPROAR_CONTINUES 0 diff --git a/src/battle_message.c b/src/battle_message.c index 34542e58d..7ec079e72 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -306,6 +306,7 @@ static const u8 sText_PreventedFromWorking[] = _("{B_DEF_NAME_WITH_PREFIX}'s {B_ static const u8 sText_PkmnsXMadeItIneffective[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nmade it ineffective!"); static const u8 sText_PkmnsXPreventsFlinching[] = _("{B_EFF_NAME_WITH_PREFIX}'s {B_EFF_ABILITY}\nprevents flinching!"); static const u8 sText_PkmnsXPreventsYsZ[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\nprevents {B_DEF_NAME_WITH_PREFIX}'s\l{B_DEF_ABILITY} from working!"); +static const u8 sText_PkmnsAbilityPreventsAbility[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nprevents {B_DEF_NAME_WITH_PREFIX}'s\l{B_DEF_ABILITY} from working!"); static const u8 sText_PkmnsXCuredItsYProblem[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\ncured its {B_BUFF1} problem!"); static const u8 sText_PkmnsXHadNoEffectOnY[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX}'s {B_SCR_ACTIVE_ABILITY}\nhad no effect on {B_EFF_NAME_WITH_PREFIX}!"); const u8 gText_StatSharply[] = _("sharply "); @@ -1402,6 +1403,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_PKMNTOOKTARGETHIGH - BATTLESTRINGS_TABLE_START] = sText_PkmnTookTargetHigh, [STRINGID_TARGETTOOHEAVY - BATTLESTRINGS_TABLE_START] = sText_TargetTooHeavy, [STRINGID_ATTACKERLOSTELECTRICTYPE - BATTLESTRINGS_TABLE_START] = sText_AttackerLostElectricType, + [STRINGID_PKMNSABILITYPREVENTSABILITY - BATTLESTRINGS_TABLE_START] = sText_PkmnsAbilityPreventsAbility, }; const u16 gZEffectStringIds[] = @@ -1592,7 +1594,6 @@ const u16 gUproarAwakeStringIds[] = { [B_MSG_CANT_SLEEP_UPROAR] = STRINGID_PKMNCANTSLEEPINUPROAR2, [B_MSG_UPROAR_KEPT_AWAKE] = STRINGID_UPROARKEPTPKMNAWAKE, - [B_MSG_STAYED_AWAKE_USING] = STRINGID_PKMNSTAYEDAWAKEUSING, }; const u16 gStatUpStringIds[] = diff --git a/src/battle_util.c b/src/battle_util.c index 4333d0b44..b030b8563 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3814,7 +3814,7 @@ u8 AtkCanceller_UnableToUseMove(void) { SetRandomMultiHitCounter(); } - + PREPARE_BYTE_NUMBER_BUFFER(gBattleScripting.multihitString, 1, 0) } else if (gBattleMoves[gCurrentMove].flags & FLAG_TWO_STRIKES) @@ -3841,7 +3841,7 @@ u8 AtkCanceller_UnableToUseMove(void) party = gPlayerParty; else party = gEnemyParty; - + for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) @@ -5487,7 +5487,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move RecordItemEffectBattle(gBattlerAttacker, HOLD_EFFECT_ABILITY_SHIELD); break; } - + gLastUsedAbility = gBattleMons[gBattlerAttacker].ability; gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = gBattleMons[gBattlerTarget].ability; gBattleMons[gBattlerTarget].ability = gBattleStruct->overwrittenAbilities[gBattlerTarget] = gLastUsedAbility; @@ -5566,17 +5566,26 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } break; case ABILITY_AFTERMATH: - if (!IsAbilityOnField(ABILITY_DAMP) - && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBattlerTarget].hp == 0 && IsBattlerAlive(gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)) { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; - if (gBattleMoveDamage == 0) - gBattleMoveDamage = 1; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_AftermathDmg; + u8 battler; + if ((battler = IsAbilityOnField(ABILITY_DAMP))) + { + gBattleScripting.battler = battler - 1; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_DampPreventsAftermath; + } + else + { + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_AftermathDmg; + } effect++; } break; @@ -6858,7 +6867,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) { u8 effect = 0; u32 i; - + switch (holdEffect) { #if B_HP_BERRIES >= GEN_4 @@ -7027,7 +7036,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem)) { - gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY; + gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY; gBattleScripting.battler = battlerId; gPotentialItemEffectBattler = battlerId; BattleScriptPushCursor(); @@ -7036,7 +7045,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect) } break; } - + return effect; } @@ -7053,7 +7062,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) gLastUsedItem = gBattleMons[battlerId].item; battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE); } - + atkItem = gBattleMons[gBattlerAttacker].item; atkHoldEffect = GetBattlerHoldEffect(gBattlerAttacker, TRUE); atkHoldEffectParam = GetBattlerHoldEffectParam(gBattlerAttacker); @@ -8184,7 +8193,7 @@ u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating) return ItemId_GetHoldEffect(gBattleMons[battlerId].item); } -// +// static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item) { if (item == ITEM_ENIGMA_BERRY) @@ -8234,7 +8243,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) else if (gProtectStructs[battlerId].protected) return FALSE; } - + if (move == MOVE_TEATIME) { return FALSE; From 47ebf2e167d3616e78ce27fc836b750f982c0ed5 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 7 Feb 2023 13:33:43 +0100 Subject: [PATCH 2/2] hmm --- include/constants/battle_string_ids.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 3f8853024..636bcb94b 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -741,6 +741,7 @@ // gUproarAwakeStringIds #define B_MSG_CANT_SLEEP_UPROAR 0 #define B_MSG_UPROAR_KEPT_AWAKE 1 +#define B_MSG_STAYED_AWAKE_USING 2 // gUproarOverTurnStringIds #define B_MSG_UPROAR_CONTINUES 0