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

AI calculates/stores minimum possible move damage and uses it with AI_FLAG_TRY_TO_FAINT #4760

Merged
merged 6 commits into from
Jun 11, 2024

Conversation

Sneed69
Copy link

@Sneed69 Sneed69 commented Jun 11, 2024

Description

This is done in addition to the default damage calculations and designed to work alongside them.
The main purpose of this is to make the AI prefer a guaranteed KO move over the highest expected damage move.
I can imagine this increased flexibility being useful for more future AI features.

Discord contact info

duke5614

normalDmg = CalculateMoveDamageVars(move, battlerAtk, battlerDef, moveType, fixedBasePower,
effectivenessMultiplier, weather, FALSE,
aiData->holdEffects[battlerAtk], aiData->holdEffects[battlerDef],
aiData->abilities[battlerAtk], aiData->abilities[battlerDef]);

critChanceIndex = CalcCritChanceStageArgs(battlerAtk, battlerDef, move, FALSE, aiData->abilities[battlerAtk], aiData->abilities[battlerDef], aiData->holdEffects[battlerAtk]);
if (critChanceIndex > 1) // Consider crit damage only if a move has at least +2 crit chance
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good but could you make a config for people who want to turn off crit calcs at plus two or lower?

Also unrelated to the config but right now I've noticed that if critChance is at +3 it will still calc as if it's the average. I think in this case it should be considered as it's always crit. Suggestion would be to check if critChance > 2 and assign -2 to it.

@Sneed69 Sneed69 changed the title AI caclulates/stores minimum possible move damage and uses it with AI_FLAG_TRY_TO_FAINT AI calculates/stores minimum possible move damage and uses it with AI_FLAG_TRY_TO_FAINT Jun 11, 2024
@AlexOn1ine AlexOn1ine merged commit 821d5dc into rh-hideout:upcoming Jun 11, 2024
1 check passed
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.

2 participants