permanent terrain move bgs

This commit is contained in:
Evan 2020-11-17 19:45:27 -07:00
parent 7dcc7dae23
commit c026f705b3
9 changed files with 52 additions and 3 deletions

View file

@ -815,6 +815,7 @@ gBattleAnims_General::
.4byte General_IllusionOff .4byte General_IllusionOff
.4byte General_FormChange .4byte General_FormChange
.4byte General_SlideOffScreen .4byte General_SlideOffScreen
.4byte General_RestoreBg
.align 2 .align 2
gBattleAnims_Special:: gBattleAnims_Special::
@ -8453,6 +8454,8 @@ Move_GRASSY_TERRAIN::
delay 4 delay 4
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(31, 24, 31) createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(31, 24, 31)
waitforvisualfinish waitforvisualfinish
restorebg
waitbgfadein
end end
Move_MISTY_TERRAIN:: Move_MISTY_TERRAIN::
@ -8491,6 +8494,8 @@ Move_MISTY_TERRAIN::
delay 4 delay 4
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 7, 0, RGB(31, 24, 31) createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 7, 0, RGB(31, 24, 31)
waitforvisualfinish waitforvisualfinish
restorebg
waitbgfadein
end end
Move_ELECTRIFY:: Move_ELECTRIFY::
@ -9374,6 +9379,8 @@ Move_ELECTRIC_TERRAIN::
delay 2 delay 2
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(28, 28, 0) createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(28, 28, 0)
waitforvisualfinish waitforvisualfinish
restorebg
waitbgfadein
end end
Move_DAZZLING_GLEAM:: Move_DAZZLING_GLEAM::
@ -11027,6 +11034,8 @@ Move_PSYCHIC_TERRAIN::
delay 4 delay 4
createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(27, 0, 13) createvisualtask AnimTask_BlendBattleAnimPal, 10, ANIM_PAL_BG, 3, 4, 0, RGB(27, 0, 13)
waitforvisualfinish waitforvisualfinish
restorebg
waitbgfadein
end end
Move_LUNGE:: Move_LUNGE::
@ -24320,6 +24329,11 @@ General_TerrainElectric:
General_TerrainPsychic: General_TerrainPsychic:
end end
General_RestoreBg:
restorebg
waitbgfadein
end
SnatchMoveTrySwapFromSubstitute: SnatchMoveTrySwapFromSubstitute:
createvisualtask AnimTask_IsAttackerBehindSubstitute, 2 createvisualtask AnimTask_IsAttackerBehindSubstitute, 2
jumprettrue SnatchMoveSwapSubstituteForMon jumprettrue SnatchMoveSwapSubstituteForMon

View file

@ -5426,21 +5426,25 @@ BattleScript_MagicRoomEnds::
BattleScript_ElectricTerrainEnds:: BattleScript_ElectricTerrainEnds::
printstring STRINGID_ELECTRICTERRAINENDS printstring STRINGID_ELECTRICTERRAINENDS
waitmessage 0x40 waitmessage 0x40
playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL
end2 end2
BattleScript_MistyTerrainEnds:: BattleScript_MistyTerrainEnds::
printstring STRINGID_MISTYTERRAINENDS printstring STRINGID_MISTYTERRAINENDS
waitmessage 0x40 waitmessage 0x40
playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL
end2 end2
BattleScript_GrassyTerrainEnds:: BattleScript_GrassyTerrainEnds::
printstring STRINGID_GRASSYTERRAINENDS printstring STRINGID_GRASSYTERRAINENDS
waitmessage 0x40 waitmessage 0x40
playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL
end2 end2
BattleScript_PsychicTerrainEnds:: BattleScript_PsychicTerrainEnds::
printstring STRINGID_PSYCHICTERRAINENDS printstring STRINGID_PSYCHICTERRAINENDS
waitmessage 0x40 waitmessage 0x40
playanimation BS_ATTACKER, B_ANIM_RESTORE_BG, NULL
end2 end2
BattleScript_MudSportEnds:: BattleScript_MudSportEnds::

View file

@ -68,6 +68,7 @@ s16 KeepPanInRange(s16 a, int oldPan);
s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan); s16 CalculatePanIncrement(s16 sourcePan, s16 targetPan, s16 incrementPan);
void sub_80A4720(u16 a, u16 *b, u32 c, u8 d); void sub_80A4720(u16 a, u16 *b, u32 c, u8 d);
void sub_80A477C(bool8); void sub_80A477C(bool8);
void LoadMoveBg(u16 bgId);
// battle_intro.c // battle_intro.c
void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value); void SetAnimBgAttribute(u8 bgId, u8 attributeId, u8 value);

View file

@ -9,5 +9,6 @@ void LoadBattleTextboxAndBackground(void);
void InitLinkBattleVsScreen(u8 taskId); void InitLinkBattleVsScreen(u8 taskId);
void DrawBattleEntryBackground(void); void DrawBattleEntryBackground(void);
bool8 LoadChosenBattleElement(u8 caseId); bool8 LoadChosenBattleElement(u8 caseId);
void DrawTerrainTypeBattleBackground(void);
#endif // GUARD_BATTLE_BG_H #endif // GUARD_BATTLE_BG_H

View file

@ -234,6 +234,8 @@
#define STATUS_FIELD_ION_DELUGE 0x400 #define STATUS_FIELD_ION_DELUGE 0x400
#define STATUS_FIELD_FAIRY_LOCK 0x800 #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 // Flags describing move's result
#define MOVE_RESULT_MISSED (1 << 0) #define MOVE_RESULT_MISSED (1 << 0)
#define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1) #define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1)

View file

@ -525,6 +525,7 @@
#define B_ANIM_ILLUSION_OFF 0x1C #define B_ANIM_ILLUSION_OFF 0x1C
#define B_ANIM_FORM_CHANGE 0x1D #define B_ANIM_FORM_CHANGE 0x1D
#define B_ANIM_SLIDE_OFFSCREEN 0x1E // for Emergency Exit #define B_ANIM_SLIDE_OFFSCREEN 0x1E // for Emergency Exit
#define B_ANIM_RESTORE_BG 0x1F // for Terrain Endings
// special animations table // special animations table
#define B_ANIM_LVL_UP 0x0 #define B_ANIM_LVL_UP 0x0

View file

@ -88,7 +88,6 @@ static void Task_PanFromInitialToTarget(u8 taskId);
static void Task_LoopAndPlaySE(u8 taskId); static void Task_LoopAndPlaySE(u8 taskId);
static void Task_WaitAndPlaySE(u8 taskId); static void Task_WaitAndPlaySE(u8 taskId);
static void LoadDefaultBg(void); static void LoadDefaultBg(void);
static void LoadMoveBg(u16 bgId);
// ewram // ewram
EWRAM_DATA static const u8 *sBattleAnimScriptPtr = NULL; 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()) if (IsContest())
{ {
@ -3205,6 +3204,8 @@ static void LoadDefaultBg(void)
{ {
if (IsContest()) if (IsContest())
LoadContestBgAfterMoveAnim(); LoadContestBgAfterMoveAnim();
else if (gFieldStatuses & STATUS_TERRAIN_ANY)
DrawTerrainTypeBattleBackground();
else else
DrawMainBattleBackground(); DrawMainBattleBackground();
} }

View file

@ -1,5 +1,6 @@
#include "global.h" #include "global.h"
#include "battle.h" #include "battle.h"
#include "battle_anim.h"
#include "battle_bg.h" #include "battle_bg.h"
#include "battle_main.h" #include "battle_main.h"
#include "battle_message.h" #include "battle_message.h"
@ -23,6 +24,7 @@
#include "constants/map_types.h" #include "constants/map_types.h"
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/trainers.h" #include "constants/trainers.h"
#include "constants/battle_anim.h"
struct BattleBackground struct BattleBackground
{ {
@ -1413,3 +1415,26 @@ bool8 LoadChosenBattleElement(u8 caseId)
return ret; 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;
}
}

View file

@ -6952,7 +6952,7 @@ static void HandleTerrainMove(u32 moveEffect)
} }
else else
{ {
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN | STATUS_FIELD_GRASSY_TERRAIN | STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_PSYCHIC_TERRAIN); gFieldStatuses &= ~STATUS_TERRAIN_ANY;
gFieldStatuses |= statusFlag; gFieldStatuses |= statusFlag;
if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER) if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_TERRAIN_EXTENDER)
*timer = 8; *timer = 8;