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

Behavior tree special attack integration #40555

Conversation

kevingranade
Copy link
Member

Summary

SUMMARY: None

Purpose of change

Continuing #39810
tl;dr the monster AI code is inflexible and difficult to extend, this is part of the process of migrating the whole thing to use behavior trees to make it more legible and flexible.

Describe the solution

This addresses most of the major blockers to onboarding special attacks to behavior trees.
Extends the behavior predicate API to accept an optional argument and use it to specify a special id to check for. This avoids having to add a predicate for each special, and I anticipate this sort of thing coming up repeatedly.
Adds predicates as needed to determine whether the target special is triggerable.
Added code to inject the behavior tree definition into monster types that have the special.
Added code to invoke the special attack if selected.

Testing

Extended the unit test I added previously.
Need to spawn in a locust and induce it to nibble some plants.

Additional context

Great resource for behavior trees: http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter06_The_Behavior_Tree_Starter_Kit.pdf

@kevingranade kevingranade force-pushed the behavior-tree-special-attack-integration branch 4 times, most recently from 1fbde55 to 73275e9 Compare May 15, 2020 22:26
@kevingranade kevingranade marked this pull request as ready for review May 15, 2020 22:32
@kevingranade
Copy link
Member Author

Tested out fine, the only thing I might add here is documentation on how behavior -> special attack correspondence works, but if you merge it before that goes in I'll just add it in another PR.

@kevingranade
Copy link
Member Author

Hooray, weird crash in tests I didn't encounter locally.

@kevingranade kevingranade force-pushed the behavior-tree-special-attack-integration branch from 73275e9 to 976567c Compare May 16, 2020 22:26
@kevingranade kevingranade force-pushed the behavior-tree-special-attack-integration branch from 976567c to 23551fe Compare May 17, 2020 02:48
@kevingranade
Copy link
Member Author

The crash is legit. I've resolved it now it was a data error and I've also corrected the issue that escalated the data issue to be a crash.

@ZhilkinSerg ZhilkinSerg added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. labels May 22, 2020
@ZhilkinSerg ZhilkinSerg merged commit 1813bfb into CleverRaven:master May 25, 2020
CHECK( monster_goals.tick( &oracle ) == "idle" );
for( const tripoint &near : g->m.points_in_radius( monster_location, 1 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Gah, yes I've seen that before, I need to add a lgtm filter or something to warn on this and other VS reserved words.

@kevingranade kevingranade deleted the behavior-tree-special-attack-integration branch June 28, 2020 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Monsters Monsters both friendly and unfriendly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants