From bbd09fdcf7ad721542fd3d4b7eca93de0f9a8b14 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 12 Oct 2021 10:32:51 -0400 Subject: [PATCH 1/6] add wandering spirit --- asm/macros/battle_script.inc | 8 +++++ data/battle_scripts_1.s | 26 +++++++++++++++++ include/battle_interface.h | 1 + include/battle_scripts.h | 1 + include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 3 +- src/battle_interface.c | 14 +++++++-- src/battle_message.c | 2 ++ src/battle_script_commands.c | 3 ++ src/battle_util.c | 34 ++++++++++++++++++++++ 10 files changed, 90 insertions(+), 3 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4d8fe0365..651c59624 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1580,6 +1580,10 @@ .macro showabilitypopup battler:req various \battler, VARIOUS_ABILITY_POPUP .endm + + .macro updateabilitypopup battler:req + various \battler, VARIOUS_UPDATE_ABILITY_POPUP + .endm .macro defogclear battler:req, clear:req, ptr:req various \battler, VARIOUS_DEFOG @@ -1825,6 +1829,10 @@ various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER .endm + .macro swapabilities + various BS_ATTACKER, VARIOUS_SWAP_ABILITIES + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e1fb47930..f52493c49 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7676,6 +7676,32 @@ BattleScript_MummyActivates:: waitmessage B_WAIT_TIME_LONG return +BattleScript_WanderingSpiritActivates:: +.if B_ABILITY_POP_UP == TRUE + setbyte sFIXED_ABILITY_POPUP, TRUE + sethword sABILITY_OVERWRITE, ABILITY_WANDERING_SPIRIT + showabilitypopup BS_TARGET + pause 60 + sethword sABILITY_OVERWRITE, 0 + updateabilitypopup BS_TARGET + pause 20 + destroyabilitypopup + pause 40 + + setbyte sFIXED_ABILITY_POPUP, TRUE + copyhword sABILITY_OVERWRITE, gLastUsedAbility + showabilitypopup BS_ATTACKER + pause 60 + sethword sABILITY_OVERWRITE, 0 + updateabilitypopup BS_ATTACKER + pause 20 + destroyabilitypopup + pause 40 +.endif + printstring STRINGID_SWAPPEDABILITIES + waitmessage B_WAIT_TIME_LONG + return + BattleScript_TargetsStatWasMaxedOut:: call BattleScript_AbilityPopUp statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED | MOVE_EFFECT_CERTAIN, NULL diff --git a/include/battle_interface.h b/include/battle_interface.h index c852b776a..69bac05f3 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -97,5 +97,6 @@ bool32 CanThrowLastUsedBall(void); void TryHideLastUsedBall(void); void TryRestoreLastUsedBall(void); void TryAddLastUsedBallItemSprites(void); +void UpdateAbilityPopup(u8 battlerId); #endif // GUARD_BATTLE_INTERFACE_H diff --git a/include/battle_scripts.h b/include/battle_scripts.h index cd4600543..d7e8dd3b8 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -398,5 +398,6 @@ extern const u8 BattleScript_MysteriousAirCurrentBlowsOn[]; extern const u8 BattleScript_AttackWeakenedByStrongWinds[]; extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[]; extern const u8 BattleScript_BlockedByPrimalWeatherRet[]; +extern const u8 BattleScript_WanderingSpiritActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d61eabbf8..5f5c1d0a2 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -185,6 +185,7 @@ #define VARIOUS_REMOVE_TERRAIN 113 #define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 #define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 +#define VARIOUS_UPDATE_ABILITY_POPUP 116 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index e8fe7e359..bc8023035 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -592,8 +592,9 @@ #define STRINGID_STRONGWINDSDISSIPATED 588 #define STRINGID_MYSTERIOUSAIRCURRENTBLOWSON 589 #define STRINGID_ATTACKWEAKENEDBSTRONGWINDS 590 +#define STRINGID_SWAPPEDABILITIES 591 -#define BATTLESTRINGS_COUNT 591 +#define BATTLESTRINGS_COUNT 592 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/src/battle_interface.c b/src/battle_interface.c index 0e33455ac..35db3293e 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3065,8 +3065,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[battlerId][0] = spriteId1; + gBattleStruct->abilityPopUpSpriteIds[battlerId][1] = spriteId2; taskId = CreateTask(Task_FreeAbilityPopUpGfx, 5); gTasks[taskId].tSpriteId1 = spriteId1; @@ -3084,6 +3084,16 @@ void CreateAbilityPopUp(u8 battlerId, u32 ability, bool32 isDoubleBattle) RestoreOverwrittenPixels((void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32)); } +void UpdateAbilityPopup(u8 battlerId) +{ + u8 spriteId1 = gBattleStruct->abilityPopUpSpriteIds[battlerId][0]; + u8 spriteId2 = gBattleStruct->abilityPopUpSpriteIds[battlerId][1]; + u16 ability = (gBattleScripting.abilityPopupOverwrite != 0) ? gBattleScripting.abilityPopupOverwrite : gBattleMons[battlerId].ability; + + PrintAbilityOnAbilityPopUp(ability, spriteId1, spriteId2); + RestoreOverwrittenPixels((void*)(OBJ_VRAM0) + (gSprites[spriteId1].oam.tileNum * 32)); +} + #define FRAMES_TO_WAIT 48 static void SpriteCb_AbilityPopUp(struct Sprite *sprite) diff --git a/src/battle_message.c b/src/battle_message.c index 69463ce69..15ae916c1 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -718,9 +718,11 @@ static const u8 sText_MysteriousAirCurrent[] = _("A mysterious air current is\np static const u8 sText_StrongWindsDissipated[] = _("The mysterious strong winds\nhave dissipated!{PAUSE 64}"); static const u8 sText_MysteriousAirCurrentBlowsOn[] = _("The mysterious air current\nblows on regardless!"); static const u8 sText_AttackWeakenedByStrongWinds[] = _("The mysterious strong winds\nweakened the attack!"); +static const u8 sText_SwappedAbilities[] = _("{B_DEF_NAME_WITH_PREFIX} swapped Abilities\nwith its target!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_SWAPPEDABILITIES - 12] = sText_SwappedAbilities, [STRINGID_ATTACKWEAKENEDBSTRONGWINDS - 12] = sText_AttackWeakenedByStrongWinds, [STRINGID_MYSTERIOUSAIRCURRENTBLOWSON - 12] = sText_MysteriousAirCurrentBlowsOn, [STRINGID_STRONGWINDSDISSIPATED - 12] = sText_StrongWindsDissipated, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..4d767efc0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8317,6 +8317,9 @@ static void Cmd_various(void) case VARIOUS_ABILITY_POPUP: CreateAbilityPopUp(gActiveBattler, gBattleMons[gActiveBattler].ability, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0); break; + case VARIOUS_UPDATE_ABILITY_POPUP: + UpdateAbilityPopup(gActiveBattler); + break; case VARIOUS_DEFOG: if (T1_READ_8(gBattlescriptCurrInstr + 3)) // Clear { diff --git a/src/battle_util.c b/src/battle_util.c index 68e787698..bd655a5a1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4803,6 +4803,40 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move } } break; + case ABILITY_WANDERING_SPIRIT: + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && IsBattlerAlive(gBattlerAttacker) + && TARGET_TURN_DAMAGED + && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) + { + switch (gBattleMons[gBattlerAttacker].ability) + { + case ABILITY_DISGUISE: + case ABILITY_FLOWER_GIFT: + case ABILITY_GULP_MISSILE: + case ABILITY_ICE_FACE: + case ABILITY_ILLUSION: + case ABILITY_IMPOSTER: + case ABILITY_RECEIVER: + case ABILITY_RKS_SYSTEM: + case ABILITY_SCHOOLING: + case ABILITY_STANCE_CHANGE: + case ABILITY_WONDER_GUARD: + case ABILITY_ZEN_MODE: + break; + default: + gLastUsedAbility = gBattleMons[gBattlerAttacker].ability; + + gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability; + gBattleMons[gBattlerTarget].ability = gLastUsedAbility; + + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_WanderingSpiritActivates; + effect++; + break; + } + } + break; case ABILITY_ANGER_POINT: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gIsCriticalHit From 25a4da71fe003a1f068f5d87c4cc12d59097420e Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 12 Oct 2021 10:37:59 -0400 Subject: [PATCH 2/6] remove unused macro --- asm/macros/battle_script.inc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 651c59624..2c629d51b 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1828,11 +1828,7 @@ .macro trytoclearprimalweather various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER .endm - - .macro swapabilities - various BS_ATTACKER, VARIOUS_SWAP_ABILITIES - .endm - + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 From c0f3b7c3b4ef754ed190e8af169876f6512f4e65 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 12 Oct 2021 11:58:37 -0400 Subject: [PATCH 3/6] record abilities from wandering spirit --- src/battle_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index bd655a5a1..9e3c5ff8b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4826,10 +4826,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move break; default: gLastUsedAbility = gBattleMons[gBattlerAttacker].ability; - gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability; gBattleMons[gBattlerTarget].ability = gLastUsedAbility; - + RecordAbilityBattle(gBattlerAttacker, gBattleMons[gBattlerAttacker].ability); + RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WanderingSpiritActivates; effect++; From 3e364b4870603efca32bc9a1bd48475b0ae89a9b Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 30 Oct 2021 09:16:33 -0400 Subject: [PATCH 4/6] switchin abilities activate after wandering spirit --- data/battle_scripts_1.s | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 146c05c23..1211f9da9 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8001,6 +8001,8 @@ BattleScript_WanderingSpiritActivates:: .endif printstring STRINGID_SWAPPEDABILITIES waitmessage B_WAIT_TIME_LONG + switchinabilities BS_ATTACKER + switchinabilities BS_TARGET return BattleScript_TargetsStatWasMaxedOut:: From 1925874d355a3911c14e856a16eb7da92a1911a8 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 30 Oct 2021 11:18:50 -0400 Subject: [PATCH 5/6] hunger switch unaffected by wandering spirit --- src/battle_util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/battle_util.c b/src/battle_util.c index 07b7cd7e7..3453aac15 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4846,6 +4846,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_DISGUISE: case ABILITY_FLOWER_GIFT: case ABILITY_GULP_MISSILE: + case ABILITY_HUNGER_SWITCH: case ABILITY_ICE_FACE: case ABILITY_ILLUSION: case ABILITY_IMPOSTER: From d4638eaf1a0e501250260f2a09bb8886f4dabdbc Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 31 Oct 2021 19:50:31 -0300 Subject: [PATCH 6/6] Fixed Plasma Fists target --- src/data/battle_moves.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 714349eb2..97d61202a 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10446,7 +10446,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 100, .pp = 15, .secondaryEffectChance = 0, - .target = MOVE_TARGET_FOES_AND_ALLY, + .target = MOVE_TARGET_SELECTED, .priority = 0, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_IRON_FIST_BOOST, .split = SPLIT_PHYSICAL,