From cbaae44f9f48453dc2ad085fa6142d7084d2f63a Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 29 Sep 2018 13:36:33 +0200 Subject: [PATCH] Add pop-up to battlescripts --- asm/macros/battle_script.inc | 2 +- data/battle_scripts_1.s | 53 ++++++++++++++++++++-- include/battle.h | 1 + include/constants/battle_script_commands.h | 1 + src/battle_interface.c | 8 +++- src/battle_main.c | 1 + src/battle_util.c | 8 +++- 7 files changed, 66 insertions(+), 8 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 7334d0d91..19755a579 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1502,7 +1502,7 @@ .4byte \ptr .endm - .macro testabilitypopup battler + .macro showabilitypopup battler various \battler, VARIOUS_ABILITY_POPUP .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index bcd5fa938..5e4b11218 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1296,7 +1296,7 @@ BattleScript_HitEscapeEnd: end BattleScript_EffectPlaceholder: - testabilitypopup BS_TARGET + showabilitypopup BS_TARGET attackcanceler printstring STRINGID_NOTDONEYET goto BattleScript_MoveEnd @@ -5351,13 +5351,21 @@ BattleScript_ItemSteal:: BattleScript_DrizzleActivates:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNMADEITRAIN waitstate playanimation BS_BATTLER_0, B_ANIM_RAIN_CONTINUES, NULL call BattleScript_WeatherFormChanges end3 + +BattleScript_AbilityPopUp: + showabilitypopup BS_ABILITY_BATTLER + recordability BS_ABILITY_BATTLER + pause 0x10 + return BattleScript_SpeedBoostActivates:: + call BattleScript_AbilityPopUp playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 printstring STRINGID_PKMNRAISEDSPEED waitmessage 0x40 @@ -5365,12 +5373,14 @@ BattleScript_SpeedBoostActivates:: BattleScript_TraceActivates:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNTRACED waitmessage 0x40 switchinabilities BS_ATTACKER end3 BattleScript_RainDishActivates:: + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXRESTOREDHPALITTLE2 waitmessage 0x40 orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE @@ -5380,12 +5390,14 @@ BattleScript_RainDishActivates:: BattleScript_HarvestActivates:: pause 0x5 + call BattleScript_AbilityPopUp printstring STRINGID_HARVESTBERRY waitmessage 0x40 end3 BattleScript_SolarPowerActivates:: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + call BattleScript_AbilityPopUp healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_SOLARPOWERHPDROP @@ -5395,6 +5407,7 @@ BattleScript_SolarPowerActivates:: BattleScript_SandstreamActivates:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXWHIPPEDUPSANDSTORM waitstate playanimation BS_BATTLER_0, B_ANIM_SANDSTORM_CONTINUES, NULL @@ -5402,6 +5415,7 @@ BattleScript_SandstreamActivates:: end3 BattleScript_ShedSkinActivates:: + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXCUREDYPROBLEM waitmessage 0x40 updatestatusicon BS_ATTACKER @@ -5420,6 +5434,7 @@ BattleScript_CastformChange:: end3 BattleScript_82DB4AF:: + call BattleScript_AbilityPopUp docastformchangeanimation waitstate printstring STRINGID_PKMNTRANSFORMED @@ -5435,6 +5450,7 @@ BattleScript_PauseIntimidateActivates: BattleScript_IntimidateActivates:: setbyte gBattlerTarget, 0x0 setstatchanger STAT_ATK, 1, TRUE + call BattleScript_AbilityPopUp BattleScript_IntimidateActivatesLoop: trygetintimidatetarget BattleScript_IntimidateActivatesReturn jumpifstatus2 BS_TARGET, STATUS2_SUBSTITUTE, BattleScript_IntimidateActivatesLoopIncrement @@ -5460,6 +5476,7 @@ BattleScript_IntimidatePrevented: BattleScript_DroughtActivates:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXINTENSIFIEDSUN waitstate playanimation BS_BATTLER_0, B_ANIM_SUN_CONTINUES, NULL @@ -5468,6 +5485,7 @@ BattleScript_DroughtActivates:: BattleScript_SnowWarningActivates:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_SNOWWARNINGHAIL waitstate playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES, NULL @@ -5476,6 +5494,7 @@ BattleScript_SnowWarningActivates:: BattleScript_BadDreamsActivates:: setbyte gBattlerTarget, 0 + call BattleScript_AbilityPopUp BattleScript_BadDreamsLoop: trygetbaddreamstarget BattleScript_BadDreamsEnd dmg_1_8_targethp @@ -5502,12 +5521,14 @@ BattleScript_TookAttack:: BattleScript_SturdyPreventsOHKO:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNPROTECTEDBY pause 0x40 goto BattleScript_MoveEnd BattleScript_DampStopsExplosion:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNPREVENTSUSAGE pause 0x40 goto BattleScript_MoveEnd @@ -5542,6 +5563,7 @@ BattleScript_MonMadeMoveUseless_PPLoss:: BattleScript_MonMadeMoveUseless:: attackstring pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXMADEYUSELESS waitmessage 0x40 orhalfword gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE @@ -5552,18 +5574,21 @@ BattleScript_FlashFireBoost_PPLoss:: BattleScript_FlashFireBoost:: attackstring pause 0x20 + call BattleScript_AbilityPopUp printfromtable gFlashFireStringIds waitmessage 0x40 goto BattleScript_MoveEnd BattleScript_AbilityPreventsPhasingOut:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNANCHORSITSELFWITH waitmessage 0x40 goto BattleScript_MoveEnd BattleScript_AbilityNoStatLoss:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNPREVENTSSTATLOSSWITH waitmessage 0x40 return @@ -5588,18 +5613,21 @@ BattleScript_PSNPrevention:: BattleScript_ObliviousPreventsAttraction:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNPREVENTSROMANCEWITH waitmessage 0x40 goto BattleScript_MoveEnd BattleScript_FlinchPrevention:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXPREVENTSFLINCHING waitmessage 0x40 goto BattleScript_MoveEnd BattleScript_OwnTempoPrevents:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNPREVENTSCONFUSIONWITH waitmessage 0x40 goto BattleScript_MoveEnd @@ -5608,12 +5636,14 @@ BattleScript_SoundproofProtected:: attackstring ppreduce pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXBLOCKSY waitmessage 0x40 goto BattleScript_MoveEnd BattleScript_AbilityNoSpecificStatLoss:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXPREVENTSYLOSS waitmessage 0x40 setbyte cMULTISTRING_CHOOSER, 0x3 @@ -5621,21 +5651,25 @@ BattleScript_AbilityNoSpecificStatLoss:: BattleScript_StickyHoldActivates:: pause 0x20 + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXMADEYINEFFECTIVE waitmessage 0x40 goto BattleScript_MoveEnd BattleScript_ColorChangeActivates:: + call BattleScript_AbilityPopUp printstring STRINGID_PKMNCHANGEDTYPEWITH waitmessage 0x40 return BattleScript_CursedBodyActivates:: + call BattleScript_AbilityPopUp printstring STRINGID_CUSEDBODYDISABLED waitmessage 0x40 return BattleScript_MummyActivates:: + call BattleScript_AbilityPopUp printstring STRINGID_ATTACKERACQUIREDABILITY waitmessage 0x40 return @@ -5643,6 +5677,7 @@ BattleScript_MummyActivates:: BattleScript_AngryPointActivates:: setbyte sB_ANIM_ARG1 0x38 setbyte sB_ANIM_ARG2 0x0 + call BattleScript_AbilityPopUp playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 printstring STRINGID_ANGRYPOINTACTIVATES waitmessage 0x40 @@ -5650,6 +5685,7 @@ BattleScript_AngryPointActivates:: BattleScript_TargetAbilityStatRaise:: setgraphicalstatchangevalues + call BattleScript_AbilityPopUp playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 waitanimation printstring STRINGID_TARGETABILITYSTATRAISE @@ -5658,6 +5694,7 @@ BattleScript_TargetAbilityStatRaise:: BattleScript_WeakArmorActivates:: setstatchanger STAT_DEF, 1, TRUE + call BattleScript_AbilityPopUp statbuffchange 0x1, BattleScript_WeakArmorActivatesSpeed jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, 0x2, BattleScript_WeakArmorDefAnim jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_WeakArmorActivatesSpeed @@ -5689,6 +5726,7 @@ BattleScript_WeakArmorActivatesEnd: BattleScript_AttackerAbilityStatRaise:: setgraphicalstatchangevalues + call BattleScript_AbilityPopUp playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 waitanimation printstring STRINGID_ATTACKERABILITYSTATRAISE @@ -5716,7 +5754,8 @@ BattleScript_SwitchInAbilityMsg:: BattleScript_ImposterActivates:: transformdataexecution - playmoveanimation BS_ATTACKER MOVE_TRANSFORM + call BattleScript_AbilityPopUp + playmoveanimation BS_ATTACKER, MOVE_TRANSFORM waitanimation printstring STRINGID_IMPOSTERTRANSFORM waitmessage 0x40 @@ -5724,6 +5763,7 @@ BattleScript_ImposterActivates:: BattleScript_RoughSkinActivates:: orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + call BattleScript_AbilityPopUp healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_PKMNHURTSWITH @@ -5732,6 +5772,7 @@ BattleScript_RoughSkinActivates:: return BattleScript_CuteCharmActivates:: + call BattleScript_AbilityPopUp status2animation BS_ATTACKER, STATUS2_INFATUATION printstring STRINGID_PKMNSXINFATUATEDY waitmessage 0x40 @@ -5744,6 +5785,7 @@ BattleScript_ApplySecondaryEffect:: BattleScript_SynchronizeActivates:: waitstate + call BattleScript_AbilityPopUp seteffectprimary return @@ -5754,6 +5796,7 @@ BattleScript_NoItemSteal:: return BattleScript_AbilityCuredStatus:: + call BattleScript_AbilityPopUp printstring STRINGID_PKMNSXCUREDITSYPROBLEM waitmessage 0x40 updatestatusicon BS_SCRIPTING @@ -5772,6 +5815,7 @@ BattleScript_IgnoresAndUsesRandomMove:: jumptocalledmove FALSE BattleScript_MoveUsedLoafingAround:: + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x0, BattleScript_TruantLoafingAround jumpifbyte CMP_NOT_EQUAL, cMULTISTRING_CHOOSER, 0x4, BattleScript_82DB6C7 setbyte gBattleCommunication, 0x0 various24 BS_ATTACKER @@ -5781,7 +5825,10 @@ BattleScript_82DB6C7:: waitmessage 0x40 setbyte sMOVEEND_STATE, 0x0 moveend 0x2, 0x10 - end + end +BattleScript_TruantLoafingAround: + call BattleScript_AbilityPopUp + goto BattleScript_82DB6C7 BattleScript_IgnoresAndFallsAsleep:: printstring STRINGID_PKMNBEGANTONAP diff --git a/include/battle.h b/include/battle.h index 46c52145c..f6e3066e1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -873,6 +873,7 @@ extern u16 gMoveToLearn; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u32 gFieldStatuses; extern struct FieldTimer gFieldTimers; +extern u8 gBattlerAbility; extern void (*gPreBattleCallback1)(void); extern void (*gBattleMainFunc)(void); diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 656bed8dd..90e72e717 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -48,6 +48,7 @@ #define BS_OPPONENT1 12 #define BS_PLAYER2 13 #define BS_OPPONENT2 14 +#define BS_ABILITY_BATTLER 15 // atk 01, accuracy calc #define NO_ACC_CALC_CHECK_LOCK_ON 0xFFFF diff --git a/src/battle_interface.c b/src/battle_interface.c index 00a40c336..69d38fc50 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -2824,6 +2824,7 @@ static void SafariTextIntoHealthboxObject(void *dest, u8 *windowTileData, u32 ar #define tFrames data[2] #define tRightToLeft data[3] #define tBattlerId data[4] +#define tIsMain data[5] // for task #define tSpriteId1 data[6] @@ -2907,9 +2908,9 @@ static const struct SpriteTemplate sSpriteTemplate_AbilityPopUp2 = static const s16 sAbilityPopUpCoordsDoubles[MAX_BATTLERS_COUNT][2] = { - {204, 23}, // player left + {29, 80}, // player left {204, 19}, // opponent left - {204, 23}, // player right + {29, 97}, // player right {204, 36}, // opponent right }; @@ -3162,6 +3163,7 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle) gTasks[taskId].tSpriteId1 = spriteId1; gTasks[taskId].tSpriteId2 = spriteId2; + gSprites[spriteId1].tIsMain = TRUE; gSprites[spriteId1].tBattlerId = battlerId; gSprites[spriteId2].tBattlerId = battlerId; @@ -3179,6 +3181,8 @@ static void SpriteCb_AbilityPopUp(struct Sprite *sprite) { if (!sprite->tHide) // Show { + if (sprite->tIsMain && ++sprite->tFrames == 4) + PlaySE(SE_SELECT); if ((!sprite->tRightToLeft && (sprite->pos1.x -= 3) <= sprite->tOriginalX) || (sprite->tRightToLeft && (sprite->pos1.x += 3) >= sprite->tOriginalX) ) diff --git a/src/battle_main.c b/src/battle_main.c index abcc543f5..ce500099f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -292,6 +292,7 @@ EWRAM_DATA u16 gMoveToLearn = 0; EWRAM_DATA u8 gBattleMonForms[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u32 gFieldStatuses = 0; EWRAM_DATA struct FieldTimer gFieldTimers = {0}; +EWRAM_DATA u8 gBattlerAbility = 0; // IWRAM common vars void (*gPreBattleCallback1)(void); diff --git a/src/battle_util.c b/src/battle_util.c index aca2a4dea..244c77cd3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -275,7 +275,6 @@ static const u16 sTypeEffectivenessTable[NUMBER_OF_MON_TYPES][NUMBER_OF_MON_TYPE {X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(0.5), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(2.0), X(1.0), X(0.0)}, // dragon {X(1.0), X(0.5), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(2.0), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(2.0), X(1.0), X(1.0), X(0.5), X(0.5)}, // dark {X(1.0), X(2.0), X(1.0), X(0.5), X(1.0), X(1.0), X(1.0), X(1.0), X(0.5), X(1.0), X(0.5), X(1.0), X(1.0), X(1.0), X(1.0), X(1.0), X(2.0), X(2.0), X(1.0)}, // fairy - }; #undef X @@ -323,6 +322,8 @@ u8 GetBattlerForBattleScript(u8 caseId) case BS_OPPONENT2: ret = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); break; + case BS_ABILITY_BATTLER: + ret = gBattlerAbility; } return ret; } @@ -2075,6 +2076,7 @@ u8 AtkCanceller_UnableToUseMove(void) CancelMultiTurnMoves(gBattlerAttacker); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gBattleCommunication[MULTISTRING_CHOOSER] = 0; + gBattlerAbility = gBattlerAttacker; gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; gMoveResultFlags |= MOVE_RESULT_MISSED; effect = 1; @@ -3301,7 +3303,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gLastUsedAbility = ABILITY_INTIMIDATE; gStatuses3[i] &= ~(STATUS3_INTIMIDATE_POKES); BattleScriptPushCursorAndCallback(BattleScript_IntimidateActivatesEnd3); - gBattleStruct->intimidateBattler = i; + gBattlerAbility = gBattleStruct->intimidateBattler = i; effect++; break; } @@ -3457,6 +3459,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if (effect && caseID < ABILITYEFFECT_CHECK_OTHER_SIDE && gLastUsedAbility != 0xFF) RecordAbilityBattle(battler, gLastUsedAbility); + if (effect && caseID <= ABILITYEFFECT_MOVE_END) + gBattlerAbility = battler; return effect; }