From ef43596a7915e34d1339c289ca67af06c35e7588 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 19 Nov 2020 15:16:27 -0700 Subject: [PATCH 1/3] toggleable manual ability popup destruction --- asm/macros/battle_script.inc | 4 ++++ include/battle.h | 2 ++ include/battle_interface.h | 1 + include/constants/battle_script_commands.h | 2 ++ src/battle_interface.c | 13 ++++++++++++- src/battle_script_commands.c | 3 +++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 41a51efeb..1f0b6c807 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1755,6 +1755,10 @@ various \battler, VARIOUS_JUMP_IF_ABSENT .4byte \ptr .endm + + .macro destroyabilitypopup + various BS_ABILITY_BATTLER, VARIOUS_DESTROY_ABILITY_POPUP + .endm @ helpful macros .macro setstatchanger stat:req, stages:req, down:req diff --git a/include/battle.h b/include/battle.h index 13fe13171..1084d2bb9 100644 --- a/include/battle.h +++ b/include/battle.h @@ -520,6 +520,7 @@ struct BattleStruct u8 savedBattlerTarget; bool8 ateBoost[MAX_BATTLERS_COUNT]; u8 activeAbilityPopUps; // as bits for each battler + u8 abilityPopUpSpriteIds[MAX_BATTLERS_COUNT][2]; //two per battler bool8 throwingPokeBall; struct MegaEvolutionData mega; const u8 *trainerSlideMsg; @@ -611,6 +612,7 @@ struct BattleScripting u16 moveEffect; u16 multihitMoveEffect; u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN. + bool8 fixedPopup; // force ability popup to stick until manually called back }; // rom_80A5C6C diff --git a/include/battle_interface.h b/include/battle_interface.h index 32c679285..d06c44e88 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -92,5 +92,6 @@ s32 MoveBattleBar(u8 battler, u8 healthboxSpriteId, u8 whichBar, u8 arg3); u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); u8 GetHPBarLevel(s16 hp, s16 maxhp); void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle); +void DestroyAbilityPopUp(u8 battlerId); #endif // GUARD_BATTLE_INTERFACE_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index b081907ec..36165558b 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -35,6 +35,7 @@ #define sMOVE_EFFECT gBattleScripting + 0x2E #define sMULTIHIT_EFFECT gBattleScripting + 0x30 #define sILLUSION_NICK_HACK gBattleScripting + 0x32 +#define sFIXED_ABILITY_POPUP gBattleScripting + 0x33 #define cMULTISTRING_CHOOSER gBattleCommunication + 5 @@ -165,6 +166,7 @@ #define VARIOUS_SET_LAST_USED_ITEM 99 #define VARIOUS_PARALYZE_TYPE_IMMUNITY 100 #define VARIOUS_JUMP_IF_ABSENT 101 +#define VARIOUS_DESTROY_ABILITY_POPUP 102 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_interface.c b/src/battle_interface.c index d302cd646..c97705edf 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3062,6 +3062,9 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle) gSprites[spriteId1].tRightToLeft = FALSE; gSprites[spriteId2].tRightToLeft = FALSE; } + + gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][0] = spriteId1; + gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][1] = spriteId2; taskId = CreateTask(Task_FreeAbilityPopUpGfx, 5); gTasks[taskId].tSpriteId1 = spriteId1; @@ -3110,11 +3113,19 @@ static void SpriteCb_AbilityPopUp(struct Sprite *sprite) } else { - sprite->tFrames--; + if (!gBattleScripting.fixedPopup) + sprite->tFrames--; } } } +void DestroyAbilityPopUp(u8 battlerId) +{ + gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][0]].tFrames = 0; + gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][1]].tFrames = 0; + gBattleScripting.fixedPopup = FALSE; +} + static void Task_FreeAbilityPopUpGfx(u8 taskId) { if (!gSprites[gTasks[taskId].tSpriteId1].inUse diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index d0811e77d..ad3629cd6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8300,6 +8300,9 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; } return; + case VARIOUS_DESTROY_ABILITY_POPUP: + DestroyAbilityPopUp(gActiveBattler); + break; } gBattlescriptCurrInstr += 3; From 9472bc894f00768aa5a0ad78da12be57f595594a Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 20 Nov 2020 08:26:50 -0700 Subject: [PATCH 2/3] formatting --- src/battle_interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index c97705edf..267b06ece 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3063,8 +3063,8 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle) gSprites[spriteId2].tRightToLeft = FALSE; } - gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][0] = spriteId1; - gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][1] = spriteId2; + gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][0] = spriteId1; + gBattleStruct->abilityPopUpSpriteIds[gBattleAnimAttacker][1] = spriteId2; taskId = CreateTask(Task_FreeAbilityPopUpGfx, 5); gTasks[taskId].tSpriteId1 = spriteId1; @@ -3121,8 +3121,8 @@ static void SpriteCb_AbilityPopUp(struct Sprite *sprite) void DestroyAbilityPopUp(u8 battlerId) { - gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][0]].tFrames = 0; - gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][1]].tFrames = 0; + gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][0]].tFrames = 0; + gSprites[gBattleStruct->abilityPopUpSpriteIds[battlerId][1]].tFrames = 0; gBattleScripting.fixedPopup = FALSE; } From 426ea191ad06b91604441c015fac671f6bc678cb Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 5 Dec 2020 21:04:12 -0700 Subject: [PATCH 3/3] style fix --- include/battle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/battle.h b/include/battle.h index 4b7ad8d1d..488e0fc51 100644 --- a/include/battle.h +++ b/include/battle.h @@ -520,7 +520,7 @@ struct BattleStruct u8 savedBattlerTarget; bool8 ateBoost[MAX_BATTLERS_COUNT]; u8 activeAbilityPopUps; // as bits for each battler - u8 abilityPopUpSpriteIds[MAX_BATTLERS_COUNT][2]; //two per battler + u8 abilityPopUpSpriteIds[MAX_BATTLERS_COUNT][2]; // two per battler bool8 throwingPokeBall; struct MegaEvolutionData mega; const u8 *trainerSlideMsg;