Skip to content

Commit

Permalink
fix: adjust target reach assumption immediately after setting (#1902)
Browse files Browse the repository at this point in the history
This is a subtle bug, but it prevents the `challenge` spell from working most of the time. This is what occurs:

1. Monster attacks someone, it's their only option for a target when they do, so whether they can reach it, it sets it; it keeps trying to set it until it works.
2. Someone challenges it; it sets its target to the new person (which runs the code above)
3. `onThink` runs, `hasFollowPath` is still `false` because we haven't had time to run the path finding algo yet; we think it's unreachable and switch away to the other target (with we already had a path for)

Solution: by "assuming" we have a path, we let the pathfinding algo run, in the meantime, `onThink` assumes everything is OK.
  • Loading branch information
luan authored Nov 25, 2023
1 parent e4759c7 commit cdc68ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ bool Creature::setFollowCreature(std::shared_ptr<Creature> creature) {
onWalkAborted();
}

hasFollowPath = false;
hasFollowPath = true;
forceUpdateFollowPath = false;
m_followCreature = creature;
isUpdatingPath = true;
Expand Down

0 comments on commit cdc68ce

Please sign in to comment.