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

Battle Weather Refactor #5833

Open
wants to merge 14 commits into
base: upcoming
Choose a base branch
from

Conversation

AlexOn1ine
Copy link
Collaborator

Description

Battler Weather Refactor

Simplifies battle weather flags by removing perma and temp flags. Permanence is checked with weatherDuration > 0
The advantage is that it is much easier to add new weather flags and it cleans up some code.

Small problem I had that I couldn't solve:

-TryChangeBattleWeather(u32 battler, u32 battleWeatherId, bool32 viaAbility);
+TryChangeBattleWeather(u32 battler, enum BattleWeather battleWeatherId, bool32 viaAbility); 

The compiler didn't want to cooperate with this change with the following error message:

include/battle_util.h:204:49: error: 'enum BattleWeather' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
  204 | bool32 TryChangeBattleWeather(u32 battler, enum BattleWeather weatherEnumId, bool32 viaAbility);

ghoulslash
ghoulslash previously approved these changes Dec 21, 2024
@ghoulslash
Copy link
Collaborator

Hm looks like it messed up an AI calc

  - test/battle/ai/ai.c:286: Unmatched SCORE_EQ, got Psychic: 107, Solar Beam: 106 - AI chooses the safest option to faint the target, taking into account accuracy and move effect 3/5.

@AlexOn1ine
Copy link
Collaborator Author

Hm looks like it messed up an AI calc

  - test/battle/ai/ai.c:286: Unmatched SCORE_EQ, got Psychic: 107, Solar Beam: 106 - AI chooses the safest option to faint the target, taking into account accuracy and move effect 3/5.

Fixed.

For Some reason reordering flags caused the AI not seeing that Solar Beam can be used without a charge in weather.

.argument = TWO_TURN_ARG(STRINGID_PKMNTOOKSUNLIGHT, B_WEATHER_SUN)

This part was responsible. I hard-coded the solar beam check for sun and it passed fine.
I don't think this is an issue with the refactor though and would have been the same problem with the old flags reordered.

@AlexOn1ine
Copy link
Collaborator Author

@ghoulslash thoughts on consolidating

    ENDTURN_RAIN,
    ENDTURN_SANDSTORM,
    ENDTURN_SUN,
    ENDTURN_HAIL,
    ENDTURN_SNOW,
    ENDTURN_FOG,

into just ENDTURN_WEATHER?

@AlexOn1ine
Copy link
Collaborator Author

Pushed a draft version. Still need to clean up and handle damaging weather but let me know if this is acceptable.

#define BATTLE_WEATHER_MESSAGE_STOPPED 0
#define BATTLE_WEATHER_MESSAGE_TURN 1
#define BATTLE_WEATHER_ANIMATION 2
static const u32 sBattleWeatherAttributes[][3] =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better as a struct

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give me a hint on how I should structure it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to a struct. Let me know if this is what you imagined

(still no clean up)

BattleScript_RainContinuesOrEnds::
printfromtable gRainContinuesStringIds
@printfromtable gRainContinuesStringIds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those scripts are unused. I just commented stuff out that I already deleted but I didn't want to do any further clean up.

@AlexOn1ine
Copy link
Collaborator Author

Ready for re-review

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

Successfully merging this pull request may close these issues.

2 participants