From c026f705b37009aa4db723114e63beedb690691d Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 17 Nov 2020 19:45:27 -0700 Subject: [PATCH 1/6] permanent terrain move bgs --- data/battle_anim_scripts.s | 14 ++++++++++++++ data/battle_scripts_1.s | 4 ++++ include/battle_anim.h | 1 + include/battle_bg.h | 1 + include/constants/battle.h | 2 ++ include/constants/battle_anim.h | 1 + src/battle_anim.c | 5 +++-- src/battle_bg.c | 25 +++++++++++++++++++++++++ src/battle_script_commands.c | 2 +- 9 files changed, 52 insertions(+), 3 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 70ed22c9e5..4042dcd0ed 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -815,6 +815,7 @@ gBattleAnims_General:: .4byte General_IllusionOff .4byte General_FormChange .4byte General_SlideOffScreen + .4byte General_RestoreBg .align 2 gBattleAnims_Special:: @@ -8453,6 +8454,8 @@ Move_GRASSY_TERRAIN:: delay 4 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(31, 24, 31) waitforvisualfinish + restorebg + waitbgfadein end Move_MISTY_TERRAIN:: @@ -8491,6 +8494,8 @@ Move_MISTY_TERRAIN:: delay 4 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 7, 0, RGB(31, 24, 31) waitforvisualfinish + restorebg + waitbgfadein end Move_ELECTRIFY:: @@ -9374,6 +9379,8 @@ Move_ELECTRIC_TERRAIN:: delay 2 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(28, 28, 0) waitforvisualfinish + restorebg + waitbgfadein end Move_DAZZLING_GLEAM:: @@ -11027,6 +11034,8 @@ Move_PSYCHIC_TERRAIN:: delay 4 createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(27, 0, 13) waitforvisualfinish + restorebg + waitbgfadein end Move_LUNGE:: @@ -24320,6 +24329,11 @@ General_TerrainElectric: General_TerrainPsychic: end +General_RestoreBg: + restorebg + waitbgfadein + end + SnatchMoveTrySwapFromSubstitute: createvisualtask AnimTask_IsAttackerBehindSubstitute, 2 jumprettrue SnatchMoveSwapSubstituteForMon diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 504896d63d..f8efc7e7da 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5426,21 +5426,25 @@ BattleScript_MagicRoomEnds:: BattleScript_ElectricTerrainEnds:: printstring STRINGID_ELECTRICTERRAINENDS waitmessage 0x40 + playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL end2 BattleScript_MistyTerrainEnds:: printstring STRINGID_MISTYTERRAINENDS waitmessage 0x40 + playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL end2 BattleScript_GrassyTerrainEnds:: printstring STRINGID_GRASSYTERRAINENDS waitmessage 0x40 + playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL end2 BattleScript_PsychicTerrainEnds:: printstring STRINGID_PSYCHICTERRAINENDS waitmessage 0x40 + playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL end2 BattleScript_MudSportEnds:: diff --git a/include/battle_anim.h b/include/battle_anim.h index 2f481c5f26..2b28e92fb1 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -68,6 +68,7 @@ s16 KeepPanInRange(s16 a, int oldPan); s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); void sub_80A4720(u16 a, u16 *b, u32 c, u8 d); void sub_80A477C(bool8); +void LoadMoveBg(u16 bgId); // battle_intro.c void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value); diff --git a/include/battle_bg.h b/include/battle_bg.h index 167ea5cf74..43295476f5 100644 --- a/include/battle_bg.h +++ b/include/battle_bg.h @@ -9,5 +9,6 @@ void LoadBattleTextboxAndBackground(void); void InitLinkBattleVsScreen(u8 taskId); void DrawBattleEntryBackground(void); bool8 LoadChosenBattleElement(u8 caseId); +void DrawTerrainTypeBattleBackground(void); #endif // GUARD_BATTLE_BG_H diff --git a/include/constants/battle.h b/include/constants/battle.h index 2c573dcbed..40c604c9ed 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -234,6 +234,8 @@ #define STATUS_FIELD_ION_DELUGE 0x400 #define STATUS_FIELD_FAIRY_LOCK 0x800 +#define STATUS_TERRAIN_ANY (STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN) + // Flags describing move's result #define MOVE_RESULT_MISSED (1 << 0) #define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1) diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 871aa1e351..4066060505 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -525,6 +525,7 @@ #define B_ANIM_ILLUSION_OFF 0x1C #define B_ANIM_FORM_CHANGE 0x1D #define B_ANIM_SLIDE_OFFSCREEN 0x1E // for Emergency Exit +#define B_ANIM_RESTORE_BG 0x1F // for Terrain Endings // special animations table #define B_ANIM_LVL_UP 0x0 diff --git a/src/battle_anim.c b/src/battle_anim.c index 6482ccc6ba..9f914f1e88 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -88,7 +88,6 @@ static void Task_PanFromInitialToTarget(u8 taskId); static void Task_LoopAndPlaySE(u8 taskId); static void Task_WaitAndPlaySE(u8 taskId); static void LoadDefaultBg(void); -static void LoadMoveBg(u16 bgId); // ewram EWRAM_DATA static const u8 *sBattleAnimScriptPtr = NULL; @@ -3177,7 +3176,7 @@ static void Task_FadeToBg(u8 taskId) } } -static void LoadMoveBg(u16 bgId) +void LoadMoveBg(u16 bgId) { if (IsContest()) { @@ -3205,6 +3204,8 @@ static void LoadDefaultBg(void) { if (IsContest()) LoadContestBgAfterMoveAnim(); + else if (gFieldStatuses & STATUS_TERRAIN_ANY) + DrawTerrainTypeBattleBackground(); else DrawMainBattleBackground(); } diff --git a/src/battle_bg.c b/src/battle_bg.c index d9d6bf87cc..7ae123c124 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -1,5 +1,6 @@ #include "global.h" #include "battle.h" +#include "battle_anim.h" #include "battle_bg.h" #include "battle_main.h" #include "battle_message.h" @@ -23,6 +24,7 @@ #include "constants/map_types.h" #include "constants/songs.h" #include "constants/trainers.h" +#include "constants/battle_anim.h" struct BattleBackground { @@ -1413,3 +1415,26 @@ bool8 LoadChosenBattleElement(u8 caseId) return ret; } + +void DrawTerrainTypeBattleBackground(void) +{ + switch (gFieldStatuses & STATUS_TERRAIN_ANY) + { + case STATUS_FIELD_GRASSY_TERRAIN: + LoadMoveBg(BG_GRASSY_TERRAIN); + break; + case STATUS_FIELD_MISTY_TERRAIN: + LoadMoveBg(BG_MISTY_TERRAIN); + break; + case STATUS_FIELD_ELECTRIC_TERRAIN: + LoadMoveBg(BG_ELECTRIC_TERRAIN); + break; + case STATUS_FIELD_PSYCHIC_TERRAIN: + LoadMoveBg(BG_PSYCHIC_TERRAIN); + break; + default: + DrawMainBattleBackground(); + break; + } +} + diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d0811e77de..d59d579d39 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6952,7 +6952,7 @@ static void HandleTerrainMove(u32 moveEffect) } else { - gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); + gFieldStatuses &= ~STATUS_TERRAIN_ANY; gFieldStatuses |= statusFlag; if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER) *timer = 8; From 5c658c695007a6ebb913bfb970e55a0ee2ee33aa Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 17 Nov 2020 20:26:09 -0700 Subject: [PATCH 2/6] config option for terrain bg change --- include/constants/battle_config.h | 1 + src/battle_anim.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index d7f1785709..fc1e0d54e4 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -164,5 +164,6 @@ #define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette. #define HIDE_HEALTHBOXES_DURING_ANIMS TRUE //if TRUE, hides healthboxes during move animations +#define B_TERRAIN_BG_CHANGE TRUE //if TRUE, terrain moves permanently change the default battle bg until the effect fades #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H diff --git a/src/battle_anim.c b/src/battle_anim.c index 9f914f1e88..cb7ea5bea0 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -3204,8 +3204,10 @@ static void LoadDefaultBg(void) { if (IsContest()) LoadContestBgAfterMoveAnim(); + #if B_TERRAIN_BG_CHANGE == TRUE else if (gFieldStatuses & STATUS_TERRAIN_ANY) DrawTerrainTypeBattleBackground(); + #endif else DrawMainBattleBackground(); } From 9ec67db8fa3ed8e200c506d5948b56012c328181 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 24 Nov 2020 17:03:40 -0500 Subject: [PATCH 3/6] keep permanent terrain bg from party menu, bag --- src/battle_bg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/battle_bg.c b/src/battle_bg.c index 7ae123c124..ca1893d652 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -865,7 +865,11 @@ void LoadBattleTextboxAndBackground(void) CopyBgTilemapBufferToVram(0); LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40); LoadBattleMenuWindowGfx(); - DrawMainBattleBackground(); + #if B_TERRAIN_BG_CHANGE == TRUE + DrawTerrainTypeBattleBackground(); + #else + DrawMainBattleBackground(); + #endif } static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY) From 7c6e74ab69ca4800b61d5f9006060ec3cb87e59e Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 24 Nov 2020 21:17:31 -0500 Subject: [PATCH 4/6] update terrain bg config option 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 fc1e0d54e4..55c62af987 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -164,6 +164,6 @@ #define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette. #define HIDE_HEALTHBOXES_DURING_ANIMS TRUE //if TRUE, hides healthboxes during move animations -#define B_TERRAIN_BG_CHANGE TRUE //if TRUE, terrain moves permanently change the default battle bg until the effect fades +#define B_TERRAIN_BG_CHANGE TRUE // If TRUE, terrain moves permanently change the default battle background until the effect fades. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H From 3102e499da6af188fff123edce7e36427112f2f2 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 2 Dec 2020 14:23:03 -0500 Subject: [PATCH 5/6] fix babydoll eyes anim priority --- data/battle_anim_scripts.s | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 70ed22c9e5..69c2fe6cf7 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -9451,6 +9451,7 @@ Move_BABY_DOLL_EYES:: loadspritegfx ANIM_TAG_PINK_CLOUD loadspritegfx ANIM_TAG_OPENING_EYE @eye setalpha 8, 8 + monbg ANIM_DEF_PARTNER launchtask AnimTask_BlendBattleAnimPal 0xa 0x5 ANIM_PAL_BG 0x0 0x0 0xA 0x7FFF waitforvisualfinish launchtemplate gOpeningEyeSpriteTemplate 0x5 0x4 0x0 0x0 0x1 0x0 @@ -9463,6 +9464,7 @@ Move_BABY_DOLL_EYES:: launchtask AnimTask_ShakeMon2 0x2 0x5 0x3 0x1 0x0 0x9 0x1 launchtask AnimTask_BlendBattleAnimPal 0xa 0x5 ANIM_PAL_BG 0x0 0xA 0x0 0x7FFF waitforvisualfinish + clearmonbg ANIM_DEF_PARTNER blendoff end From 5c72a89105c11918656f1b60004e7fcfc8739c21 Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 2 Dec 2020 15:03:49 -0500 Subject: [PATCH 6/6] fix B_BUFF_ABILITY --- src/battle_message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_message.c b/src/battle_message.c index 22561dd07c..35ccc6e268 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3432,7 +3432,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) srcID += 2; break; case B_BUFF_ABILITY: // ability names - StringAppend(dst, gAbilityNames[src[srcID + 1]]); + StringAppend(dst, gAbilityNames[T1_READ_16(&src[srcID + 1])]); srcID += 3; break; case B_BUFF_ITEM: // item name