diff options
author | Joseph Botosh <rumly111@gmail.com> | 2015-02-17 21:47:01 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-18 00:27:16 +0300 |
commit | 16b5c64933bf29d8e56e0d989ebab18ddae143a8 (patch) | |
tree | 47c04e88add47a5198a9f057930687f83afeb056 /src/actormanager.cpp | |
parent | 0d355e3126ab7e0a88bd8e54ce724498f6828c01 (diff) | |
download | ManaVerse-16b5c64933bf29d8e56e0d989ebab18ddae143a8.tar.gz ManaVerse-16b5c64933bf29d8e56e0d989ebab18ddae143a8.tar.bz2 ManaVerse-16b5c64933bf29d8e56e0d989ebab18ddae143a8.tar.xz ManaVerse-16b5c64933bf29d8e56e0d989ebab18ddae143a8.zip |
Add key to heal most damaged player
Diffstat (limited to 'src/actormanager.cpp')
-rw-r--r-- | src/actormanager.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index ec9ec41ba..fb999ac68 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1280,6 +1280,40 @@ void ActorManager::heal(const Being *const target) const } } +Being* ActorManager::findMostDamagedPlayer() const +{ + if (!localPlayer) + return nullptr; + + int maxDamageTaken = 0; + Being *target = nullptr; + + for_actors + { + if ((*it)->getType() != ActorType::Player) + continue; + + Being *const being = static_cast<Being*>(*it); + + if ((!being) || (!being->isAlive()) || // don't heal dead + (player_relations.getRelation(being->getName()) == + PlayerRelation::ENEMY2) || // don't heal enemy + (localPlayer == being)) // don't heal self + { + continue; + } + + + if (being->getDamageTaken() > maxDamageTaken) + { + maxDamageTaken = being->getDamageTaken(); + target = being; + } + } + + return target; +} + void ActorManager::itenplz() const { if (!localPlayer || !chatWindow || !localPlayer->isAlive() |