Browse Source

♻️ Remove monsterId from AiPlanWalk (#5073)

pull/5068/head
Cesar Canassa 4 years ago committed by GitHub
parent
commit
f4fd4b1644
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      Source/monster.cpp

7
Source/monster.cpp

@ -1865,16 +1865,13 @@ bool IsTileAccessible(const Monster &monster, Point position)
return IsTileSafe(monster, position);
}
bool AiPlanWalk(int monsterId)
bool AiPlanWalk(Monster &monster)
{
int8_t path[MaxPathLength];
/** Maps from walking path step to facing direction. */
const Direction plr2monst[9] = { Direction::South, Direction::NorthEast, Direction::NorthWest, Direction::SouthEast, Direction::SouthWest, Direction::North, Direction::East, Direction::South, Direction::West };
assert(static_cast<size_t>(monsterId) < MaxMonsters);
auto &monster = Monsters[monsterId];
if (FindPath([&monster](Point position) { return IsTileAccessible(monster, position); }, monster.position.tile, monster.enemyPosition, path) == 0) {
return false;
}
@ -1941,7 +1938,7 @@ bool AiPlanPath(int monsterId)
monster.pathCount++;
if (monster.pathCount < 5)
return false;
if (AiPlanWalk(monsterId))
if (AiPlanWalk(monster))
return true;
}

Loading…
Cancel
Save