From 5f63060c28ed5a6dfe346fff52af73fa4fcb608b Mon Sep 17 00:00:00 2001 From: obligaron Date: Sun, 9 Oct 2022 20:40:20 +0200 Subject: [PATCH] Add FindUniqueMonster --- Source/monster.cpp | 11 +++++++++++ Source/monster.h | 1 + 2 files changed, 12 insertions(+) diff --git a/Source/monster.cpp b/Source/monster.cpp index 070961528..26ffec672 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4392,6 +4392,17 @@ Monster *FindMonsterAtPosition(Point position, bool ignoreMovingMonsters) return &Monsters[abs(monsterId) - 1]; } +Monster *FindUniqueMonster(UniqueMonsterType monsterType) +{ + for (size_t i = 0; i < ActiveMonsterCount; i++) { + int monsterId = ActiveMonsters[i]; + auto &monster = Monsters[monsterId]; + if (monster.uniqueType == monsterType) + return &monster; + } + return nullptr; +} + bool IsTileAvailable(const Monster &monster, Point position) { if (!IsTileAvailable(position)) diff --git a/Source/monster.h b/Source/monster.h index dd3000ec7..0d7ce3bb5 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -489,6 +489,7 @@ void PlayEffect(Monster &monster, MonsterSound mode); void MissToMonst(Missile &missile, Point position); Monster *FindMonsterAtPosition(Point position, bool ignoreMovingMonsters = false); +Monster *FindUniqueMonster(UniqueMonsterType monsterType); /** * @brief Check that the given tile is available to the monster