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

Fixed Bad Dream's ability popup message #2430

Merged

Conversation

AsparagusEduardo
Copy link
Collaborator

Description

Fixes #2429

Discord contact info

AsparagusEduardo#6051

@BuffelSaft
Copy link
Collaborator

BuffelSaft commented Nov 4, 2022

This shouldn't need to loop through all battlers, it's called in a while loop that already does that (see DoBattlerEndTurnEffects()). I think it's just checking the wrong battlers in the if statement:

if (gBattleMons[battler].status1 & STATUS1_SLEEP
    || gBattleMons[BATTLE_OPPOSITE(battler)].status1 & STATUS1_SLEEP
    || GetBattlerAbility(battler) == ABILITY_COMATOSE
    || GetBattlerAbility(BATTLE_OPPOSITE(battler)) == ABILITY_COMATOSE)

This should be checking the opposite battler and the opposite battler's ally, instead of the opposite battler and the battler that has Bad Dreams:

                if (gBattleMons[BATTLE_PARTNER(BATTLE_OPPOSITE(battler))].status1 & STATUS1_SLEEP
                    || gBattleMons[BATTLE_OPPOSITE(battler)].status1 & STATUS1_SLEEP
                    || GetBattlerAbility(BATTLE_PARTNER(BATTLE_OPPOSITE(battler))) == ABILITY_COMATOSE
                    || GetBattlerAbility(BATTLE_OPPOSITE(battler)) == ABILITY_COMATOSE)

It definitely needs the IsBattlerAlive() check added though.

@AsparagusEduardo
Copy link
Collaborator Author

It needs to loop through all of them because it should also affect allies.

At the end of each turn, each adjacent sleeping opponent takes damage equal to 1/8 of its maximum HP.

@LOuroboros
Copy link
Collaborator

The battle script also has a loop though, and it uses trygetbaddreamstarget which runs yet another loop.

Wouldn't this be a good chance to optimize the code for Bad Dreams' effect? 👀

@BuffelSaft
Copy link
Collaborator

Yeah, the battle script already loops and so does DoBattlerEndTurnEffects . DoBattlerEndTurnEffects loops through every battler to see if it should try to activate bad dreams, and then the battle script loop handles the damage part.
Both are needed, as it needs to loop through all battlers to try to trigger the ability, and then loop through both foes to damage them if the conditions are met (it doesn't affect the bad dream's mon's ally, just its opponents).

The changes to that if I suggested fix the issue, it doesn't need another loop added.

@AsparagusEduardo
Copy link
Collaborator Author

Going to confirm if Bad Dreams affect allies or not, one sec.

@AsparagusEduardo
Copy link
Collaborator Author

You're right, it doesn't affect allies. Will fix in a sec.
melonDS_2TldypXFzd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants