From 37cbae5e54af5778b5b6ca3d0f72309c3fa7d452 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Sat, 18 Jan 2025 08:44:07 -0500 Subject: [PATCH] Fix Symbiosis Needing battler Argument + Tests (#6039) Co-authored-by: ghoulslash --- asm/macros/battle_script.inc | 3 +- data/battle_scripts_1.s | 6 +- src/battle_message.c | 2 +- src/battle_script_commands.c | 10 +-- test/battle/ability/symbiosis.c | 113 ++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 test/battle/ability/symbiosis.c diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index dbab37af2ca9..a5e21af674e6 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1461,8 +1461,9 @@ .endm @ Used by effects that may proc Symbiosis but do not call removeitem. - .macro trysymbiosis + .macro trysymbiosis battler:req callnative BS_TrySymbiosis + .byte \battler .endm @ returns B_SIDE_x to gBattleCommunication[0] diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0cd20c75430b..0703dc09c010 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -777,7 +777,7 @@ BattleScript_EffectFlingConsumeBerry: restorebattleritem BS_TARGET BattleScript_FlingEnd: tryfaintmon BS_TARGET - trysymbiosis + trysymbiosis BS_ATTACKER goto BattleScript_MoveEnd BattleScript_FlingFailConsumeItem:: @@ -1238,8 +1238,8 @@ BattleScript_MoveEffectBugBite:: consumeberry BS_ATTACKER, FALSE bicword gHitMarker, HITMARKER_DISABLE_ANIMATION setbyte sBERRY_OVERRIDE, 0 - trysymbiosis restoretarget + trysymbiosis BS_TARGET return BattleScript_MoveEffectCoreEnforcer:: @@ -1568,7 +1568,7 @@ BattleScript_EffectBestow:: waitanimation printstring STRINGID_BESTOWITEMGIVING waitmessage B_WAIT_TIME_LONG - trysymbiosis + trysymbiosis BS_ATTACKER goto BattleScript_MoveEnd BattleScript_EffectAfterYou:: diff --git a/src/battle_message.c b/src/battle_message.c index 32a0c017f38d..a70cfd872f24 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -631,7 +631,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_LASTABILITYRAISEDSTAT] = COMPOUND_STRING("{B_ATK_NAME_WITH_PREFIX}'s {B_LAST_ABILITY} raised its {B_BUFF1}!"), [STRINGID_MAGICBOUNCEACTIVATES] = COMPOUND_STRING("{B_DEF_NAME_WITH_PREFIX} bounced the {B_ATK_NAME_WITH_PREFIX2} back!"), [STRINGID_PROTEANTYPECHANGE] = COMPOUND_STRING("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY} transformed it into the {B_BUFF1} type!"), - [STRINGID_SYMBIOSISITEMPASS] = COMPOUND_STRING("{B_SCR_NAME_WITH_PREFIX} passed its {B_LAST_ITEM} to {B_ATK_NAME_WITH_PREFIX2} through {B_LAST_ABILITY}!"), + [STRINGID_SYMBIOSISITEMPASS] = COMPOUND_STRING("{B_SCR_NAME_WITH_PREFIX} passed its {B_LAST_ITEM} to {B_EFF_NAME_WITH_PREFIX2} through {B_LAST_ABILITY}!"), [STRINGID_STEALTHROCKDMG] = COMPOUND_STRING("Pointed stones dug into {B_SCR_NAME_WITH_PREFIX2}!"), [STRINGID_TOXICSPIKESABSORBED] = COMPOUND_STRING("The poison spikes disappeared from the ground around {B_ATK_TEAM2} team!"), [STRINGID_TOXICSPIKESPOISONED] = COMPOUND_STRING("{B_SCR_NAME_WITH_PREFIX} was poisoned!"), diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bbc58f430d14..42b1b86c8495 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -16207,14 +16207,16 @@ void BS_GetBattlerSide(void) void BS_TrySymbiosis(void) { - NATIVE_ARGS(); + NATIVE_ARGS(u8 battler); + u32 battler = GetBattlerForBattleScript(cmd->battler); //called by Bestow, Fling, and Bug Bite, which don't work with Cmd_removeitem. - u32 partner = BATTLE_PARTNER(gBattlerAttacker); - if (SYMBIOSIS_CHECK(gBattlerAttacker, partner)) + u32 partner = BATTLE_PARTNER(battler); + if (SYMBIOSIS_CHECK(battler, partner)) { - BestowItem(partner, gBattlerAttacker); + BestowItem(partner, battler); gLastUsedAbility = gBattleMons[partner].ability; gBattleScripting.battler = gBattlerAbility = partner; + gEffectBattler = battler; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SymbiosisActivates; return; diff --git a/test/battle/ability/symbiosis.c b/test/battle/ability/symbiosis.c new file mode 100644 index 000000000000..5c55370fe4ee --- /dev/null +++ b/test/battle/ability/symbiosis.c @@ -0,0 +1,113 @@ +#include "global.h" +#include "test/battle.h" + +DOUBLE_BATTLE_TEST("Symbiosis transfers its item to an ally after it consumes an item") +{ + GIVEN { + ASSUME(gItemsInfo[ITEM_ROOM_SERVICE].holdEffect == HOLD_EFFECT_ROOM_SERVICE); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_ROOM_SERVICE); } + PLAYER(SPECIES_ORANGURU) { Ability(ABILITY_SYMBIOSIS); Item(ITEM_TOXIC_ORB); } + OPPONENT(SPECIES_KIRLIA); + OPPONENT(SPECIES_SHUCKLE); + } WHEN { + TURN { MOVE(opponentLeft, MOVE_TRICK_ROOM); } + } SCENE { + MESSAGE("The opposing Kirlia used Trick Room!"); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_HELD_ITEM_EFFECT, playerLeft); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, playerLeft); + MESSAGE("Using Room Service, the Speed of Wobbuffet fell!"); + // symbiosis triggers + ABILITY_POPUP(playerRight, ABILITY_SYMBIOSIS); + MESSAGE("Oranguru passed its Toxic Orb to Wobbuffet through Symbiosis!"); + // end of turn, wobb gets poisoned + MESSAGE("Wobbuffet was badly poisoned!"); + STATUS_ICON(playerLeft, STATUS1_TOXIC_POISON); + } THEN { + EXPECT_EQ(playerLeft->item, ITEM_TOXIC_ORB); + EXPECT_EQ(playerRight->item, ITEM_NONE); + } +} + + +DOUBLE_BATTLE_TEST("Symbiosis triggers after partners berry eaten from bug bite") +{ + GIVEN { + ASSUME(gItemsInfo[ITEM_LIECHI_BERRY].holdEffect == HOLD_EFFECT_ATTACK_UP); + PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_LIECHI_BERRY); } + PLAYER(SPECIES_ORANGURU) { Ability(ABILITY_SYMBIOSIS); Item(ITEM_TOXIC_ORB); } + OPPONENT(SPECIES_STARAVIA); + OPPONENT(SPECIES_SHUCKLE); + } WHEN { + TURN { MOVE(opponentLeft, MOVE_BUG_BITE, target: playerLeft); } + } SCENE { + MESSAGE("The opposing Staravia used Bug Bite!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_BUG_BITE, opponentLeft); + HP_BAR(playerLeft); + ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_STATS_CHANGE, opponentLeft); + MESSAGE("Using Liechi Berry, the Attack of the opposing Staravia rose!"); + // symbiosis triggers + ABILITY_POPUP(playerRight, ABILITY_SYMBIOSIS); + MESSAGE("Oranguru passed its Toxic Orb to Wobbuffet through Symbiosis!"); + // end of turn, wobb gets poisoned + MESSAGE("Wobbuffet was badly poisoned!"); + STATUS_ICON(playerLeft, STATUS1_TOXIC_POISON); + } THEN { + EXPECT_EQ(playerLeft->item, ITEM_TOXIC_ORB); + EXPECT_EQ(playerRight->item, ITEM_NONE); + } +} + +DOUBLE_BATTLE_TEST("Symbiosis triggers after partner bestows its item") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Speed(100); Item(ITEM_FLAME_ORB); } + PLAYER(SPECIES_ORANGURU) { Speed(75); Ability(ABILITY_SYMBIOSIS); Item(ITEM_TOXIC_ORB); } + OPPONENT(SPECIES_STARAVIA) { Speed(50); } + OPPONENT(SPECIES_SHUCKLE) { Speed(25); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_BESTOW, target: opponentLeft); } + } SCENE { + MESSAGE("Wobbuffet used Bestow!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_BESTOW, playerLeft); + MESSAGE("The opposing Staravia received Flame Orb from Wobbuffet!"); + // symbiosis triggers + ABILITY_POPUP(playerRight, ABILITY_SYMBIOSIS); + MESSAGE("Oranguru passed its Toxic Orb to Wobbuffet through Symbiosis!"); + // end of turn, wobb gets poisoned + MESSAGE("Wobbuffet was badly poisoned!"); + STATUS_ICON(playerLeft, STATUS1_TOXIC_POISON); + // staravia gets burned + MESSAGE("The opposing Staravia was burned!"); + STATUS_ICON(opponentLeft, STATUS1_BURN); + } THEN { + EXPECT_EQ(playerLeft->item, ITEM_TOXIC_ORB); + EXPECT_EQ(playerRight->item, ITEM_NONE); + EXPECT_EQ(opponentLeft->item, ITEM_FLAME_ORB); + } +} + +DOUBLE_BATTLE_TEST("Symbiosis triggers after partner flings its item") +{ + GIVEN { + PLAYER(SPECIES_WOBBUFFET) { Speed(100); Item(ITEM_FLAME_ORB); } + PLAYER(SPECIES_ORANGURU) { Speed(75); Ability(ABILITY_SYMBIOSIS); Item(ITEM_TOXIC_ORB); } + OPPONENT(SPECIES_STARAVIA) { Speed(50); } + OPPONENT(SPECIES_SHUCKLE) { Speed(25); } + } WHEN { + TURN { MOVE(playerLeft, MOVE_FLING, target: opponentLeft); } + } SCENE { + MESSAGE("Wobbuffet used Fling!"); + ANIMATION(ANIM_TYPE_MOVE, MOVE_FLING, playerLeft); + MESSAGE("The opposing Staravia was burned!"); + STATUS_ICON(opponentLeft, STATUS1_BURN); + // symbiosis triggers + ABILITY_POPUP(playerRight, ABILITY_SYMBIOSIS); + MESSAGE("Oranguru passed its Toxic Orb to Wobbuffet through Symbiosis!"); + // end of turn, wobb gets poisoned + MESSAGE("Wobbuffet was badly poisoned!"); + STATUS_ICON(playerLeft, STATUS1_TOXIC_POISON); + } THEN { + EXPECT_EQ(playerLeft->item, ITEM_TOXIC_ORB); + EXPECT_EQ(playerRight->item, ITEM_NONE); + } +}