Use RandomWeighted; fix Test

This commit is contained in:
PhallenTree 2024-06-17 17:48:05 +01:00 committed by GitHub
parent 9b8c47ac5c
commit 161f61284a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View file

@ -183,6 +183,7 @@ enum RandomTag
RNG_SPEED_TIE,
RNG_STATIC,
RNG_STENCH,
RNG_TOXIC_CHAIN,
RNG_TRI_ATTACK,
RNG_QUICK_DRAW,
RNG_QUICK_CLAW,

View file

@ -5805,7 +5805,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& TARGET_TURN_DAMAGED // Need to actually hit the target
&& (Random() % 3) == 0)
&& RandomWeighted(RNG_TOXIC_CHAIN, 7, 3))
{
gBattleScripting.moveEffect = MOVE_EFFECT_TOXIC;
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility);

View file

@ -3,8 +3,10 @@
SINGLE_BATTLE_TEST("Toxic Chain inflicts bad poison when attacking")
{
PASSES_RANDOMLY(3, 10, RNG_TOXIC_CHAIN);
GIVEN {
ASSUME(gMovesInfo[MOVE_TACKLE].category != DAMAGE_CATEGORY_STATUS);
ASSUME(gMovesInfo[MOVE_TACKLE].power > 0);
PLAYER(SPECIES_OKIDOGI) { Ability(ABILITY_TOXIC_CHAIN); }
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
@ -24,6 +26,7 @@ SINGLE_BATTLE_TEST("Toxic Chain inflicts bad poison on any hit of a multi-hit mo
GIVEN {
ASSUME(gMovesInfo[MOVE_DOUBLE_SLAP].category != DAMAGE_CATEGORY_STATUS);
ASSUME(gMovesInfo[MOVE_DOUBLE_SLAP].effect == EFFECT_MULTI_HIT);
ASSUME(gMovesInfo[MOVE_DOUBLE_SLAP].power > 0);
ASSUME(gItemsInfo[ITEM_PECHA_BERRY].holdEffect == HOLD_EFFECT_CURE_PSN);
PLAYER(SPECIES_OKIDOGI) { Ability(ABILITY_TOXIC_CHAIN); }
OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_PECHA_BERRY); }
@ -48,14 +51,15 @@ SINGLE_BATTLE_TEST("Toxic Chain inflicts bad poison on any hit of a multi-hit mo
DOUBLE_BATTLE_TEST("Toxic Chain can inflict bad poison on both foes")
{
GIVEN {
ASSUME(gMovesInfo[MOVE_BLIZZARD].category != DAMAGE_CATEGORY_STATUS);
ASSUME(gMovesInfo[MOVE_BLIZZARD].target == MOVE_TARGET_BOTH);
ASSUME(gMovesInfo[MOVE_RAZOR_LEAF].category != DAMAGE_CATEGORY_STATUS);
ASSUME(gMovesInfo[MOVE_RAZOR_LEAF].target == MOVE_TARGET_BOTH);
ASSUME(gMovesInfo[MOVE_RAZOR_LEAF].power > 0);
PLAYER(SPECIES_OKIDOGI) { Ability(ABILITY_TOXIC_CHAIN); }
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WYNAUT);
} WHEN {
TURN { MOVE(playerLeft, MOVE_BLIZZARD); }
TURN { MOVE(playerLeft, MOVE_RAZOR_LEAF, WITH_RNG(RNG_TOXIC_CHAIN, TRUE)); }
} SCENE {
HP_BAR(opponentLeft);
ABILITY_POPUP(playerLeft, ABILITY_TOXIC_CHAIN);