From b447add4c3220a96fff0022eb9de37a0674610c9 Mon Sep 17 00:00:00 2001 From: Nephrite Date: Mon, 12 Feb 2024 22:27:58 +0900 Subject: [PATCH] Minor fixes to RNG and additional effect count --- include/pokemon.h | 2 +- src/battle_script_commands.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 2e305d446e..7d78f4dbe9 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -525,7 +525,7 @@ struct MoveInfo }; #define EFFECTS_ARR(...) (const struct AdditionalEffect[]) {__VA_ARGS__} -#define ADDITIONAL_EFFECTS(...) ((ARRAY_COUNT(EFFECTS_ARR( __VA_ARGS__ )) % 0xF) << 28) + (uintptr_t)(EFFECTS_ARR( __VA_ARGS__ )) +#define ADDITIONAL_EFFECTS(...) ((min(ARRAY_COUNT(EFFECTS_ARR( __VA_ARGS__ )), 15)) << 28) + (uintptr_t)(EFFECTS_ARR( __VA_ARGS__ )) // Retrieve a move's additional effects and the count thereof #define GET_ADDITIONAL_EFFECTS_AND_COUNT(move, _count, _effects) u32 _count = GET_ADDITIONAL_EFFECTS_COUNT(move); const struct AdditionalEffect *_effects = GET_ADDITIONAL_EFFECTS(move) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 179516d6ab..90117df685 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3865,7 +3865,7 @@ static void Cmd_setadditionaleffects(void) percentChance = CalcSecondaryEffectChance(gBattlerAttacker, GetBattlerAbility(gBattlerAttacker), &additionalEffects[i]); // Activate effect if it's primary (chance == 0) or if RNGesus says so - if ((percentChance == 0) || RandomPercentage(RNG_SECONDARY_EFFECT + i, percentChance)) + if ((percentChance == 0) || RandomPercentage(RNG_SECONDARY_EFFECT + (i % 3), percentChance)) { gBattleScripting.moveEffect = additionalEffects[i].moveEffect | (MOVE_EFFECT_AFFECTS_USER * (additionalEffects[i].self));