summaryrefslogtreecommitdiff
path: root/src/actormanager.cpp
diff options
context:
space:
mode:
authorJoseph Botosh <rumly111@gmail.com>2015-02-17 21:47:01 +0200
committerAndrei Karas <akaras@inbox.ru>2015-02-18 00:27:16 +0300
commit16b5c64933bf29d8e56e0d989ebab18ddae143a8 (patch)
tree47c04e88add47a5198a9f057930687f83afeb056 /src/actormanager.cpp
parent0d355e3126ab7e0a88bd8e54ce724498f6828c01 (diff)
downloadManaVerse-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.cpp34
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()