From 55c3e152cfd2ea94b285c0829aba1a933dbe01fa Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 14 Sep 2021 15:07:15 -0400 Subject: [PATCH] replace some BufferStatChange, fix room service and terrain seeds --- include/battle_util.h | 1 + src/battle_util.c | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index ad0c69534..4f250c7ea 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -150,6 +150,7 @@ bool32 IsBattlerAffectedByHazards(u8 battlerId, bool32 toxicSpikes); void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast); bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind); bool32 TryRoomService(u8 battlerId); +void BufferStatChange(u8 battlerId, u8 statId, u8 stringId); // ability checks bool32 IsRolePlayBannedAbilityAtk(u16 ability); diff --git a/src/battle_util.c b/src/battle_util.c index eb10bc896..4cec2160a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -557,6 +557,7 @@ void HandleAction_UseItem(void) } break; case AI_ITEM_X_STAT: + // TODO Contrary check gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STAT_ROSE_ITEM; if (*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1)) & (1 << AI_DIRE_HIT)) { @@ -5445,9 +5446,7 @@ static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2) { if (CompareStat(battlerId, statId, MAX_STAT_STAGE, CMP_LESS_THAN) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId)) { - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); - PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); - + BufferStatChange(battlerId, statId, STRINGID_STATROSE); gEffectBattler = battlerId; if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) SET_STATCHANGER(statId, 2, FALSE); @@ -5474,6 +5473,7 @@ static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2) static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2) { s32 i; + u16 stringId; for (i = 0; i < 5; i++) { @@ -5488,16 +5488,17 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2) } while (!CompareStat(battlerId, STAT_ATK + i, MAX_STAT_STAGE, CMP_LESS_THAN)); PREPARE_STAT_BUFFER(gBattleTextBuff1, i + 1); - + stringId = (GetBattlerAbility(battlerId) == ABILITY_CONTRARY) ? STRINGID_STATFELL : STRINGID_STATROSE; + gBattleTextBuff2[0] = B_BUFF_PLACEHOLDER_BEGIN; gBattleTextBuff2[1] = B_BUFF_STRING; gBattleTextBuff2[2] = STRINGID_STATSHARPLY; gBattleTextBuff2[3] = STRINGID_STATSHARPLY >> 8; gBattleTextBuff2[4] = B_BUFF_STRING; - gBattleTextBuff2[5] = STRINGID_STATROSE; - gBattleTextBuff2[6] = STRINGID_STATROSE >> 8; + gBattleTextBuff2[5] = stringId; + gBattleTextBuff2[6] = stringId >> 8; gBattleTextBuff2[7] = EOS; - + gEffectBattler = battlerId; if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) @@ -5550,9 +5551,7 @@ static u8 DamagedStatBoostBerryEffect(u8 battlerId, u8 statId, u8 split) && !DoesSubstituteBlockMove(gBattlerAttacker, battlerId, gCurrentMove) && GetBattleMoveSplit(gCurrentMove) == split) { - - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); - PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); + BufferStatChange(battlerId, statId, STRINGID_STATROSE); gEffectBattler = battlerId; if (GetBattlerAbility(battlerId) == ABILITY_RIPEN) @@ -5573,9 +5572,7 @@ u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 exec { if (gFieldStatuses & terrainFlag && CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN)) { - PREPARE_STAT_BUFFER(gBattleTextBuff1, statId); - PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); - + BufferStatChange(battler, statId, STRINGID_STATROSE); gLastUsedItem = itemId; // For surge abilities gEffectBattler = gBattleScripting.battler = battler; SET_STATCHANGER(statId, 1, FALSE);