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: properly handle the Spell Book artifacts on the Adventure Map #8702

Merged
merged 4 commits into from
May 25, 2024

Conversation

oleg-derevenetz
Copy link
Collaborator

close #8696

As far as I know, currently there is no way to place the Spell Book artifact inside an object other than OBJ_ARTIFACT (e.g. inside Shipwreck Survivor). If this is ever implemented in the Editor, it will be necessary to additionally redo the processing logic in a number of places: currently, if the hero's artifacts bag is full, when visiting such objects, hero receives money instead of the artifact, but he will not receive these money if his artifacts bag is not full, but he just already has a Spell Book.

@oleg-derevenetz oleg-derevenetz added improvement New feature, request or improvement AI Artificial intelligence behaviour labels May 20, 2024
@oleg-derevenetz oleg-derevenetz added this to the 1.1.0 milestone May 20, 2024
@oleg-derevenetz oleg-derevenetz marked this pull request as draft May 20, 2024 20:21
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

src/fheroes2/ai/ai_hero_action.cpp Show resolved Hide resolved
@oleg-derevenetz oleg-derevenetz marked this pull request as ready for review May 21, 2024 08:27
@ihhub
Copy link
Owner

ihhub commented May 21, 2024

I am moving this to 1.1.1 release as it is dangerous to push changes just a day before the release.

@ihhub ihhub modified the milestones: 1.1.0, 1.1.1 May 21, 2024
@ihhub
Copy link
Owner

ihhub commented May 25, 2024

Hi @oleg-derevenetz , I've checked the code. Is it correct that now neither human nor AI hero can pickup Magic Book if they have one?

@ihhub ihhub added the logic Things related to game logic label May 25, 2024
@oleg-derevenetz
Copy link
Collaborator Author

Hi @ihhub

Is it correct that now neither human nor AI hero can pickup Magic Book if they have one?

You see, in the master branch, both of them cannot actually pick it up, because Heroes::PickupArtifact() has corresponding checks and will not allow to do this. But nevertheless, in the master branch an AI-controlled hero will endlessly try to do this until no movement points left - with side effects: e.g. if the Spell Book is guarded, it also will endlessly fight the guards.

@ihhub ihhub merged commit 92237f0 into ihhub:master May 25, 2024
20 checks passed
@ihhub
Copy link
Owner

ihhub commented May 25, 2024

@oleg-derevenetz , thank you so much for this change!

@oleg-derevenetz oleg-derevenetz deleted the ai-magic-book-fix branch May 25, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Artificial intelligence behaviour improvement New feature, request or improvement logic Things related to game logic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI heroes will try to pickup Magic Books on the adventure map even though they have one
3 participants