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

Removes duplicate code in AI functions #5457

Merged
merged 15 commits into from
Oct 9, 2024

Conversation

AlexOn1ine
Copy link
Collaborator

@AlexOn1ine AlexOn1ine commented Oct 2, 2024

CanAbilityBlockMove, CanPartnerAbilityBlockMove and CanAbilityAbsorbMove to remove redundancy in AI_CheckBadMove and IsDamageMoveUnusable

Not that much code was removed but the important part was to unify both so we don't need to add those abilities to AI functions. We actually didn't have a check for Good As Gold, Wind Rider and we didn't check the opposing partner ability.

Closes #5454

@AlexOn1ine AlexOn1ine marked this pull request as ready for review October 3, 2024 22:44
@AlexOn1ine
Copy link
Collaborator Author

Ready for review.

@AlexOn1ine AlexOn1ine changed the title Removes duplicate code in battle_ai_main.c Removes duplicate code in AI functions Oct 3, 2024
Comment on lines 5382 to 5400
switch(gLastUsedAbility)
{
case ABILITY_MOTOR_DRIVE:
statId = STAT_SPEED;
break;
case ABILITY_LIGHTNING_ROD:
case ABILITY_STORM_DRAIN:
statId = STAT_SPATK;
break;
case ABILITY_SAP_SIPPER:
case ABILITY_WIND_RIDER:
statId = STAT_ATK;
break;
case ABILITY_WELL_BAKED_BODY:
statAmount = 2;
statId = STAT_DEF;
break;

}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This part is a bit scuffed but it was worse when I checked them in the function directly. It is cleaner isolated here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The enums look chef's kiss though, I'll try to make time to review tomorrow if no one beats me to it :)

@AlexOn1ine
Copy link
Collaborator Author

I found a potential bug in singles (present before the pr) but when I tried to fix it some tests started failing. Didn't want to go to deep into it so I left a comment.

include/config/general.h Outdated Show resolved Hide resolved
@hedara90 hedara90 added category: battle-ai Pertains to Battle Engine Upgrade's AI type: cleanup labels Oct 4, 2024
Pawkkie
Pawkkie previously approved these changes Oct 8, 2024
Copy link
Collaborator

@Pawkkie Pawkkie left a comment

Choose a reason for hiding this comment

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

I've read through this 3 times across a couple of days cuz it's kind of a chunky refactor and I'm trying to be careful, but this looks great to me. Happy to wait for another reviewer's approval as well if you like but I think this looks good to go :)

src/battle_main.c Outdated Show resolved Hide resolved
@AlexOn1ine
Copy link
Collaborator Author

Let's wait with merging until #5489 is merged

src/battle_util.c Outdated Show resolved Hide resolved
src/battle_util.c Outdated Show resolved Hide resolved
@AlexOn1ine
Copy link
Collaborator Author

Let's wait with merging until #5489 is merged

Ready for re-review. I think it is fine if this one is merged first, Someone will have to take care of conflicts anyways.

@DizzyEggg DizzyEggg merged commit 1454644 into rh-hideout:upcoming Oct 9, 2024
1 check passed
@AlexOn1ine AlexOn1ine deleted the absorbMoveCase branch November 21, 2024 22:38
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 type: cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants