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

Improved approach to reasoning about the attacked and followed Creature #4824

Merged
21 commits merged into from
Nov 17, 2024

Conversation

ramon-bernardo
Copy link
Contributor

@ramon-bernardo ramon-bernardo commented Nov 5, 2024

Pull Request Prelude

Changes Proposed

  • Improved approach to reasoning about the attacked and followerd Creature
  • boolean is no longer used; a new method has been created to handle remove and setCreature no longer accepts nullptr

src/monster.cpp Outdated
Comment on lines 648 to 657
if (isSummon()) {
if (!canAttack(creature)) {
removeAttackedCreature();
}
} else if (isHostile()) {
if (canAttack(creature)) {
setAttackedCreature(creature);
g_dispatcher.addTask([id = getID()]() { g_game.checkCreatureAttack(id); });
} else {
removeAttackedCreature();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part was complex to understand. Internally, setAttackedCreature would remove the target and return a false when the current creature couldn’t attack it (e.g., due to z != z and visibility checks with canSee).

@ghost ghost requested review from ranisalt, EvilHero90, nekiro and MillhioreBT November 5, 2024 01:40
@ramon-bernardo ramon-bernardo changed the title Improved approach to reasoning about the attackedCreature Improved approach to reasoning about the attacked and followed Creature Nov 5, 2024
ranisalt
ranisalt previously approved these changes Nov 7, 2024
@ghost ghost merged commit 173ab18 into otland:master Nov 17, 2024
16 checks passed
@ramon-bernardo ramon-bernardo deleted the improve-attacked-creature-logic branch November 17, 2024 00:19
This pull request was closed.
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