Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch in ability bug when mulitply mons faint at the same time #5427

Closed
iriv24 opened this issue Sep 23, 2024 · 4 comments · Fixed by #5732
Closed

Switch in ability bug when mulitply mons faint at the same time #5427

iriv24 opened this issue Sep 23, 2024 · 4 comments · Fixed by #5732
Labels
bug Bug category: battle-mechanic Pertains to battle mechanics status: unconfirmed This bug has not been reproduced yet

Comments

@iriv24
Copy link

iriv24 commented Sep 23, 2024

Description

Ya know I was originally submitting this for Booster Energy/Protosynthesis not procing when it was supposed to, but I'm starting to think there's a more general "things that happen on throw in" issue, maybe related to #5425 as well.

Here's a vid that has a few bugs in it, taken on master. The bugs:
Roaring moon's protosynthesis gets activated by its booster energy, but the ability popup shows up in the wrong place and shows the wrong ability.
Torkoal's drought does not activate.
Gouging Fire's protosynthesis does not activate, it is holding a booster energy as well.
I was originally trying to capture what i thought was a bug if 2 mons with booster energies/protosynthesis were thrown in, only one would proc, but there's a lot goin on here.

throwinabilitybug.mp4

pokeemerald-1
pokeemerald-3
pokeemerald-4

Version

1.9.2 (Latest release)

Upcoming/master Version

No response

Discord contact info

iriv24

@iriv24 iriv24 added bug Bug category: battle-mechanic Pertains to battle mechanics status: unconfirmed This bug has not been reproduced yet labels Sep 23, 2024
@AlexOn1ine
Copy link
Collaborator

AlexOn1ine commented Sep 23, 2024

I did some investigation.

In function Cmd_switchineffects the case BS_FAINTED_MULTIPLE_2 only activates the ability for the fastest battler and jumps out of the function.

Both this and #5425 are the same issue

@AlexOn1ine AlexOn1ine changed the title Maybe General Throw-In Abilities Bug Switch in ability bug when mulitply mon faint at the same time Sep 23, 2024
@AlexOn1ine AlexOn1ine changed the title Switch in ability bug when mulitply mon faint at the same time Switch in ability bug when mulitply mons faint at the same time Sep 23, 2024
@PhallenTree
Copy link

PhallenTree commented Sep 23, 2024

The main issue here is battle scripts that use end2 cause BattleScript_HandleFaintedMon to end early. Some tests that fail due to this bug:

DOUBLE_BATTLE_TEST("Booster Energy triggers correctly for all battlers if multiple fainted the previous turn")
{
    GIVEN {
        PLAYER(SPECIES_WOBBUFFET);
        PLAYER(SPECIES_CATERPIE) { HP(1); }
        PLAYER(SPECIES_GOUGING_FIRE) { Item(ITEM_BOOSTER_ENERGY); }
        PLAYER(SPECIES_IRON_MOTH) { Item(ITEM_BOOSTER_ENERGY); }
        OPPONENT(SPECIES_CATERPIE) { HP(1); }
        OPPONENT(SPECIES_CATERPIE) { HP(1); }
        OPPONENT(SPECIES_FLUTTER_MANE) { Item(ITEM_BOOSTER_ENERGY); }
        OPPONENT(SPECIES_CATERPIE);
    } WHEN {
        TURN { MOVE(playerLeft, MOVE_EXPLOSION);
               SEND_OUT(opponentRight, 3);
               SEND_OUT(opponentLeft, 2);
               SEND_OUT(playerRight, 3);
               SEND_OUT(playerLeft, 2); }
    } SCENE {
        ANIMATION(ANIM_TYPE_MOVE, MOVE_EXPLOSION, playerLeft);
        ABILITY_POPUP(playerLeft, ABILITY_PROTOSYNTHESIS);
        ABILITY_POPUP(playerRight, ABILITY_QUARK_DRIVE);
        ABILITY_POPUP(opponentLeft, ABILITY_PROTOSYNTHESIS);
    }
}

DOUBLE_BATTLE_TEST("Lum Berry correctly cures all battlers if multiple fainted the previous turn")
{
    GIVEN {
        PLAYER(SPECIES_WOBBUFFET);
        PLAYER(SPECIES_CATERPIE) { HP(1); }
        PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_LUM_BERRY); Status1(STATUS1_BURN); }
        PLAYER(SPECIES_WOBBUFFET) { Item(ITEM_LUM_BERRY); Status1(STATUS1_POISON); }
        OPPONENT(SPECIES_CATERPIE) { HP(1); }
        OPPONENT(SPECIES_CATERPIE) { HP(1); }
        OPPONENT(SPECIES_WOBBUFFET) { Item(ITEM_LUM_BERRY); Status1(STATUS1_PARALYSIS); }
        OPPONENT(SPECIES_CATERPIE);
    } WHEN {
        TURN { MOVE(playerLeft, MOVE_EXPLOSION);
               SEND_OUT(opponentRight, 3);
               SEND_OUT(opponentLeft, 2);
               SEND_OUT(playerRight, 3);
               SEND_OUT(playerLeft, 2); }
    } SCENE {
        ANIMATION(ANIM_TYPE_MOVE, MOVE_EXPLOSION, playerLeft);
    } THEN {
        EXPECT_EQ(playerLeft->status1, STATUS1_NONE);
        EXPECT_EQ(playerRight->status1, STATUS1_NONE);
        EXPECT_EQ(opponentLeft->status1, STATUS1_NONE);

    }
}

@AlexOn1ine
Copy link
Collaborator

AlexOn1ine commented Sep 24, 2024

I think instead of doing all the ability effects in Cmd_switchineffects we should move the logic that happens after several mons fainted to HandleFaintedMonActions. Add a case for sorting battlers and a case for the switchineffects.

@AlexOn1ine
Copy link
Collaborator

AlexOn1ine commented Nov 11, 2024

Done some more testing. This is specific to item effects and how the battle scripts are executed. I fixed the specific issue above but stuff breaks in a different spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug category: battle-mechanic Pertains to battle mechanics status: unconfirmed This bug has not been reproduced yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants