summaryrefslogtreecommitdiff
path: root/src/game-server/being.cpp
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2009-07-17 14:11:30 -0400
committerChuck Miller <shadowmil@gmail.com>2009-07-17 14:11:30 -0400
commit1923fcab4fc9aefd3eaa97fd9ca9b1c507bb4bcb (patch)
tree9400828ce46de3dd8246f012d78af6bf8f4d744b /src/game-server/being.cpp
parent053d2fa151ae209fe15c0a38fddb10abf1f6ad8a (diff)
downloadmanaserv-1923fcab4fc9aefd3eaa97fd9ca9b1c507bb4bcb.tar.gz
manaserv-1923fcab4fc9aefd3eaa97fd9ca9b1c507bb4bcb.tar.bz2
manaserv-1923fcab4fc9aefd3eaa97fd9ca9b1c507bb4bcb.tar.xz
manaserv-1923fcab4fc9aefd3eaa97fd9ca9b1c507bb4bcb.zip
Adds scripted status effects
Diffstat (limited to 'src/game-server/being.cpp')
-rw-r--r--src/game-server/being.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index bbe3ac91..a68ed1f5 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -28,6 +28,8 @@
#include "game-server/eventlistener.hpp"
#include "game-server/mapcomposite.hpp"
#include "game-server/effect.hpp"
+#include "game-server/statuseffect.hpp"
+#include "game-server/statusmanager.hpp"
#include "utils/logger.h"
Being::Being(ThingType type):
@@ -294,6 +296,25 @@ int Being::getModifiedAttribute(int attr) const
return res <= 0 ? 0 : res;
}
+void Being::applyStatusEffect(int id, int timer)
+{
+ Status newStatus;
+ newStatus.status = StatusManager::getStatus(id);
+ newStatus.time = timer;
+ mStatus.push_back(newStatus);
+}
+
+bool Being::hasStatusEffect(int id)
+{
+ StatusEffects::iterator it = mStatus.begin();
+ while (it != mStatus.end())
+ {
+ if (it->status->getId() == id)
+ return true;
+ }
+ return false;
+}
+
void Being::update()
{
int oldHP = getModifiedAttribute(BASE_ATTR_HP);
@@ -333,6 +354,23 @@ void Being::update()
++i;
}
+ // Update and run status effects
+ StatusEffects::iterator it = mStatus.begin();
+ while (it != mStatus.end())
+ {
+ it->time--;
+ if (it->time > 0 && mAction != DEAD)
+ {
+ it->status->tick(this, it->time);
+ }
+ else
+ {
+ it = mStatus.erase(it);
+ continue;
+ }
+ it++;
+ }
+
// Check if being died
if (getModifiedAttribute(BASE_ATTR_HP) <= 0 && mAction != DEAD)
{