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

Add AI_FLAG_SEQUENCE_SWITCHING #4878

Merged
merged 7 commits into from
Jul 1, 2024

Conversation

Pawkkie
Copy link
Collaborator

@Pawkkie Pawkkie commented Jun 27, 2024

Description

Floated this in Discord the other day and didn't get a lot of traction one way or the other so I thought I'd PR it and we can discuss from here if need be.

Recently Kasen from the Aqua discord was asking me how hard it'd be to make a flag where:

  • The AI always switches in mons after a KO in exactly their party order regardless of other factors (index 1, then 2, etc.)
  • U-Turn and other forced switches also always choose the lowest party index available
  • Mid-battle switches aren't triggered

This PR implements that functionality in AI_FLAG_SEQUENCE_SWITCHING. I can see five main utilities for a flag like this:

  • Battles where the designer wants a fully deterministic experience for both themselves and the user
  • Hacks where battles are constructed more in the form of puzzles
  • Hacks that balance low difficulty casual runs with deterministically solvable difficult nuzlocke runs
  • Hacks that want to approximate the experience of playing Gen 1, which uses this switching order
  • Battles with a "narrative", ie. switch in Machop -> Machoke -> Machamp even though Machamp would have been "better" to switch in first

I'm of the opinion that this is worth a flag slot as the behaviour is so radically different from existing AI flags, and it's applicable to niches that are not well served by existing flags. I fully understand though that we're tight on AI flags and need to be discerning about what we choose to add.

I've included tests to make sure the three intended features work correctly, as well as a safety net test to make sure this flag doesn't break forced random switching from Roar and effects like Dragon Tail.

People who collaborated with me in this PR

Kasen had the initial idea, psf came up with the flag name, and Egg had some helpful suggestions for overhauling some of the tests.

Discord contact info

@Pawkkie

Copy link
Collaborator

@DizzyEggg DizzyEggg left a comment

Choose a reason for hiding this comment

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

Looking good!

The requested changes are really nitpicks at this points, everything looks good.
Also about your worry here

I fully understand though that we're tight on AI flags and need to be discerning about what we choose to add.

I wouldn't worry about that, we could make it u64 instead of u32 and then you have additional 32 flags to work with.

src/battle_ai_switch_items.c Outdated Show resolved Hide resolved
src/battle_ai_switch_items.c Outdated Show resolved Hide resolved
test/battle/ai_flag_sequence_switching.c Outdated Show resolved Hide resolved
test/battle/ai_flag_sequence_switching.c Outdated Show resolved Hide resolved
test/battle/ai_flag_sequence_switching.c Outdated Show resolved Hide resolved
@Pawkkie
Copy link
Collaborator Author

Pawkkie commented Jun 29, 2024

I wouldn't worry about that, we could make it u64 instead of u32 and then you have additional 32 flags to work with.

Definitely thought this would mean a bitfield refactor, super good to know :D

Ready for re-review!

include/battle.h Outdated Show resolved Hide resolved
@DizzyEggg DizzyEggg merged commit 7e167f0 into rh-hideout:upcoming Jul 1, 2024
1 check passed
@Pawkkie Pawkkie mentioned this pull request Jul 4, 2024
@Pawkkie Pawkkie deleted the ai_flag_sequence_switching branch October 1, 2024 15:33
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