Merge branch 'battle_engine' of https://github.com/rh-hideout/pokeemerald-expansion into battle_engine

This commit is contained in:
Evan 2020-12-08 20:50:43 -07:00
commit a93a8b2194
12 changed files with 65 additions and 6 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::
@ -9451,6 +9458,7 @@ Move_BABY_DOLL_EYES::
loadspritegfx ANIM_TAG_PINK_CLOUD loadspritegfx ANIM_TAG_PINK_CLOUD
loadspritegfx ANIM_TAG_OPENING_EYE @eye loadspritegfx ANIM_TAG_OPENING_EYE @eye
setalpha 8, 8 setalpha 8, 8
monbg ANIM_DEF_PARTNER
launchtask AnimTask_BlendBattleAnimPal 0xa 0x5 ANIM_PAL_BG 0x0 0x0 0xA 0x7FFF launchtask AnimTask_BlendBattleAnimPal 0xa 0x5 ANIM_PAL_BG 0x0 0x0 0xA 0x7FFF
waitforvisualfinish waitforvisualfinish
launchtemplate gOpeningEyeSpriteTemplate 0x5 0x4 0x0 0x0 0x1 0x0 launchtemplate gOpeningEyeSpriteTemplate 0x5 0x4 0x0 0x0 0x1 0x0
@ -9463,6 +9471,7 @@ Move_BABY_DOLL_EYES::
launchtask AnimTask_ShakeMon2 0x2 0x5 0x3 0x1 0x0 0x9 0x1 launchtask AnimTask_ShakeMon2 0x2 0x5 0x3 0x1 0x0 0x9 0x1
launchtask AnimTask_BlendBattleAnimPal 0xa 0x5 ANIM_PAL_BG 0x0 0xA 0x0 0x7FFF launchtask AnimTask_BlendBattleAnimPal 0xa 0x5 ANIM_PAL_BG 0x0 0xA 0x0 0x7FFF
waitforvisualfinish waitforvisualfinish
clearmonbg ANIM_DEF_PARTNER
blendoff blendoff
end end
@ -11027,6 +11036,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 +24331,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

@ -5424,21 +5424,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

@ -165,5 +165,6 @@
#define B_NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette. #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 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 background until the effect fades.
#endif // GUARD_CONSTANTS_BATTLE_CONFIG_H #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H

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,10 @@ static void LoadDefaultBg(void)
{ {
if (IsContest()) if (IsContest())
LoadContestBgAfterMoveAnim(); LoadContestBgAfterMoveAnim();
#if B_TERRAIN_BG_CHANGE == TRUE
else if (gFieldStatuses & STATUS_TERRAIN_ANY)
DrawTerrainTypeBattleBackground();
#endif
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
{ {
@ -863,7 +865,11 @@ void LoadBattleTextboxAndBackground(void)
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40); LoadCompressedPalette(gBattleTextboxPalette, 0, 0x40);
LoadBattleMenuWindowGfx(); LoadBattleMenuWindowGfx();
#if B_TERRAIN_BG_CHANGE == TRUE
DrawTerrainTypeBattleBackground();
#else
DrawMainBattleBackground(); DrawMainBattleBackground();
#endif
} }
static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY) static void DrawLinkBattleParticipantPokeballs(u8 taskId, u8 multiplayerId, u8 bgId, u8 destX, u8 destY)
@ -1413,3 +1419,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

@ -3432,7 +3432,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
srcID += 2; srcID += 2;
break; break;
case B_BUFF_ABILITY: // ability names case B_BUFF_ABILITY: // ability names
StringAppend(dst, gAbilityNames[src[srcID + 1]]); StringAppend(dst, gAbilityNames[T1_READ_16(&src[srcID + 1])]);
srcID += 3; srcID += 3;
break; break;
case B_BUFF_ITEM: // item name case B_BUFF_ITEM: // item name

View File

@ -6973,7 +6973,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;

View File

@ -46,6 +46,7 @@ void FreeBattleResources(void)
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL)
FreeTrainerHillBattleStruct(); FreeTrainerHillBattleStruct();
gFieldStatuses = 0;
if (gBattleResources != NULL) if (gBattleResources != NULL)
{ {
FREE_AND_SET_NULL(gBattleStruct); FREE_AND_SET_NULL(gBattleStruct);