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

Added Dynamic Power and Accuracy in Move Descriptions #5327

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

Conversation

Flash1Lucky
Copy link

@Flash1Lucky Flash1Lucky commented Sep 5, 2024

Adds a configuration option to display the actual base power and accuracy of moves in battle move descriptions, factoring in ability, stat, and item modifiers. Additionally, it introduces individual configuration options to control which factors (abilities, stats, items, weather, terrain, etc.) affect these values. This extends the existing Move Descriptions feature introduced in PR #4152.

Screenshot 2024-09-05 180225

Known Issues

  • Earthquake/Magnitude in Grassy Terrain while opponent is semi-invulnerable and on the ground isn't displayed right currently.

People who collaborated with me in this PR

Code based on Move Descriptions feature from @PCG06 which was based on the implementation from Elite Redux.
Improved and reviewed by @AlexOn1ine.

Discord contact info

flash1lucky

Adds config to show the real base power and accuracy of moves after ability, stat and item modifier.
Copy link
Collaborator

@AlexOn1ine AlexOn1ine left a comment

Choose a reason for hiding this comment

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

Calcs are stored in simulatedDamage so instead of recalc'ing everything which will waste a lot of cycles you should fetch the damage from there.

Also the config should be off by default

Oh I understand. This doesn't show the actual damage. It just calcs MoveBasePower, hm.

@AlexOn1ine AlexOn1ine self-assigned this Sep 5, 2024
@AlexOn1ine AlexOn1ine added the category: battle-ai Pertains to Battle Engine Upgrade's AI label Sep 5, 2024
@AlexOn1ine
Copy link
Collaborator

In battle.h there is a struct called AiLogicData. There is already a field preset called moveAccuracy. Can you add this additional field to the struct:

u8 moveBasePower[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES];

Then in function DoMoveDamageCalcVars can you assign gBattleMovePower to that field?
then you can remove all the calcs you are doing and use both fields instead .

The problem with the current implementation is that it will recalc everything each time you open the move description but we already calc it at the beginning of the turn so there is no reason to do everything again

@kittenchilly
Copy link

kittenchilly commented Sep 8, 2024

Should be off by default anyways I think, no official game ever gives you this info

@Flash1Lucky
Copy link
Author

Should be off by default anyways I think, no official game gives ever you this info

Yeah, that's the plan

Refactored the calculation of move power and accuracy to improve efficiency and reduce redundant computations. In the first version, calculations were done directly within battle_controller_player.c every time the move selection menu was opened, using CalcMoveBasePowerAfterModifiers for each move. In this commit, we now calculate the power and accuracy of moves at the start of each turn and store the values in a new structure, MoveUIData. This reduces the computational load during menu interactions, as the precomputed values are retrieved directly rather than recalculated. This approach simplifies the logic and ensures that the power and accuracy values remain consistent throughout the turn. Additionally, the feature allows for flexibility, with calculations being enabled or disabled via config settings.
Refactored the calculation of move power and accuracy to improve efficiency and reduce redundant computations. In the first version, calculations were done directly within battle_controller_player.c every time the move selection menu was opened, using CalcMoveBasePowerAfterModifiers for each move. In this commit, we now calculate the power and accuracy of moves at the start of each turn and store the values in a new structure, MoveUIData. This reduces the computational load during menu interactions, as the precomputed values are retrieved directly rather than recalculated. This approach simplifies the logic and ensures that the power and accuracy values remain consistent throughout the turn. Additionally, the feature allows for flexibility, with calculations being enabled or disabled via config settings.
Changed the settings to off by default
Realized the for loop on the calls should be in the function and got rid of some remaining scraps of first attempt.
Got rid of a bunch of redundant calculations. Added a flag to CalcMoveBasePowerAfterModifiers and GetTotalAccuracy to check if it's being used for UI purposes. Changed the conditions within those for any section referencing battleDef to skip it instead.
Undid changes to CalcMoveBasePowerAfterModifiers and GetTotalAccuracy and fixed logic inside SetMoveUIDataForTurn.
src/battle_controller_player.c Outdated Show resolved Hide resolved
src/battle_util.c Outdated Show resolved Hide resolved
src/battle_util.c Outdated Show resolved Hide resolved
src/battle_main.c Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: battle-ai Pertains to Battle Engine Upgrade's AI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants