Fixes Sticky Barb never getting transferred to attacker + tests

This commit is contained in:
PhallenTree 2025-11-01 19:01:18 +00:00 committed by GitHub
parent 4d60c9e83f
commit e62be0b3a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 1 deletions

View File

@ -588,7 +588,7 @@ static enum ItemEffect TryStickyBarbOnTargetHit(u32 battlerDef, u32 battlerAtk,
&& !DoesSubstituteBlockMove(battlerAtk, battlerDef, gCurrentMove)
&& IsBattlerAlive(battlerAtk)
&& CanStealItem(battlerAtk, battlerDef, item)
&& item == ITEM_NONE)
&& gBattleMons[battlerAtk].item == ITEM_NONE)
{
// No sticky hold checks.
gEffectBattler = battlerDef;

View File

@ -0,0 +1,48 @@
#include "global.h"
#include "test/battle.h"
ASSUMPTIONS
{
ASSUME(gItemsInfo[ITEM_STICKY_BARB].holdEffect == HOLD_EFFECT_STICKY_BARB);
}
SINGLE_BATTLE_TEST("Sticky Barb hurts its holder at the end of the turn", s16 damage)
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_STICKY_BARB); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { }
} SCENE {
HP_BAR(player, captureDamage: &results[i].damage);
} THEN {
EXPECT_EQ(results[0].damage, player->maxHP / 8);
}
}
SINGLE_BATTLE_TEST("Sticky Barb gets transferred if its holder is hit by a contact move")
{
u32 move;
PARAMETRIZE { move = MOVE_SCRATCH; }
PARAMETRIZE { move = MOVE_GROWL; }
PARAMETRIZE { move = MOVE_HYPER_VOICE; }
GIVEN {
ASSUME(MoveMakesContact(MOVE_SCRATCH));
PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_STICKY_BARB); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(opponent, move); }
} SCENE {
ANIMATION(ANIM_TYPE_MOVE, move, opponent);
if (MoveMakesContact(move))
{
MESSAGE("The Sticky Barb attached itself to the opposing Wobbuffet!");
MESSAGE("The opposing Wobbuffet was hurt by the Sticky Barb!");
}
else
{
NOT MESSAGE("The Sticky Barb attached itself to the opposing Wobbuffet!");
MESSAGE("Wobbuffet was hurt by the Sticky Barb!");
}
}
}