Fix Shell Side Arm in battle test WITH_RNG (#7548)

This commit is contained in:
FosterProgramming 2025-08-13 21:27:59 +02:00 committed by GitHub
parent 2967074342
commit a5f569d4ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -444,7 +444,7 @@ u32 RandomWeightedArray(enum RandomTag tag, u32 sum, u32 n, const u8 *weights)
if (sum == 0)
Test_ExitWithResult(TEST_RESULT_ERROR, SourceLine(0), ":LRandomWeightedArray called with zero sum");
if (gCurrentTurnActionNumber < gBattlersCount)
if (gCurrentTurnActionNumber < gBattlersCount || tag == RNG_SHELL_SIDE_ARM)
{
u32 battlerId = gBattlerByTurnOrder[gCurrentTurnActionNumber];
turn = &DATA.battleRecordTurns[gBattleResults.battleTurnCounter][battlerId];
@ -2216,6 +2216,17 @@ void Move(u32 sourceLine, struct BattlePokemon *battler, struct MoveContext ctx)
DATA.battleRecordTurns[DATA.turns][battlerId].secondaryEffect = 1 + ctx.secondaryEffect;
if (ctx.explicitRNG)
DATA.battleRecordTurns[DATA.turns][battlerId].rng = ctx.rng;
u32 shellSideArmCount = 0;
for (u32 i = 0; i < STATE->battlersCount; i++)
{
if (DATA.battleRecordTurns[DATA.turns][i].rng.tag == RNG_SHELL_SIDE_ARM)
{
shellSideArmCount++;
if (shellSideArmCount > 1)
Test_ExitWithResult(TEST_RESULT_ERROR, SourceLine(0), ":L Tried to use fixed RNG for multiple Shell Side Arm moves in the same turn");
}
}
if (!(DATA.actionBattlers & (1 << battlerId)))
{