Skip to content

Commit

Permalink
Fix Symbiosis Needing battler Argument + Tests (#6039)
Browse files Browse the repository at this point in the history
Co-authored-by: ghoulslash <[email protected]>
  • Loading branch information
ghoulslash and ghoulslash authored Jan 18, 2025
1 parent 199760a commit 37cbae5
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 9 deletions.
3 changes: 2 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ BattleScript_EffectFlingConsumeBerry:
restorebattleritem BS_TARGET
BattleScript_FlingEnd:
tryfaintmon BS_TARGET
trysymbiosis
trysymbiosis BS_ATTACKER
goto BattleScript_MoveEnd

BattleScript_FlingFailConsumeItem::
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -1568,7 +1568,7 @@ BattleScript_EffectBestow::
waitanimation
printstring STRINGID_BESTOWITEMGIVING
waitmessage B_WAIT_TIME_LONG
trysymbiosis
trysymbiosis BS_ATTACKER
goto BattleScript_MoveEnd

BattleScript_EffectAfterYou::
Expand Down
2 changes: 1 addition & 1 deletion src/battle_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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!"),
Expand Down
10 changes: 6 additions & 4 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
113 changes: 113 additions & 0 deletions test/battle/ability/symbiosis.c
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 37cbae5

Please sign in to comment.