summaryrefslogtreecommitdiffstats
path: root/src/game-server
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-11-04 17:09:57 +0000
committerDavid Athay <ko2fan@gmail.com>2008-11-04 17:09:57 +0000
commit19453b72070b4c96fa4d3cc69999dd452316c789 (patch)
tree70775a4499cc45d55cc1de7ce39faaf66918d593 /src/game-server
parent861fcef3203ffe32c3d8e9b62aa79e2a54934c09 (diff)
downloadmanaserv-19453b72070b4c96fa4d3cc69999dd452316c789.tar.gz
manaserv-19453b72070b4c96fa4d3cc69999dd452316c789.tar.xz
manaserv-19453b72070b4c96fa4d3cc69999dd452316c789.zip
Added updating party member health.
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/being.cpp1
-rw-r--r--src/game-server/character.hpp6
-rw-r--r--src/game-server/object.hpp3
-rw-r--r--src/game-server/state.cpp23
4 files changed, 32 insertions, 1 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index 2c549c9..56f0154 100644
--- a/src/game-server/being.cpp
+++ b/src/game-server/being.cpp
@@ -274,6 +274,7 @@ void Being::update()
if (newHP != oldHP)
{
applyModifier(BASE_ATTR_HP, newHP - oldHP);
+ raiseUpdateFlags(UPDATEFLAG_HEALTHCHANGE);
}
// Update lifetime of effects.
diff --git a/src/game-server/character.hpp b/src/game-server/character.hpp
index 6e31e33..75ef9ee 100644
--- a/src/game-server/character.hpp
+++ b/src/game-server/character.hpp
@@ -254,6 +254,12 @@ class Character : public Being
{ mExperience[skill] = 0; receiveExperience(skill + CHAR_SKILL_BEGIN , value) ; }
/**
+ * Shortcut to get being's health
+ */
+ int getHealth() const
+ { return getModifiedAttribute(CHAR_ATTR_VITALITY); }
+
+ /**
* Returns the exp needed to reach a specific skill level
*/
static int expForLevel(int level);
diff --git a/src/game-server/object.hpp b/src/game-server/object.hpp
index d94e28c..00d7e26 100644
--- a/src/game-server/object.hpp
+++ b/src/game-server/object.hpp
@@ -37,7 +37,8 @@ enum
UPDATEFLAG_ATTACK = 4,
UPDATEFLAG_ACTIONCHANGE = 8,
UPDATEFLAG_LOOKSCHANGE = 16,
- UPDATEFLAG_DIRCHANGE = 32
+ UPDATEFLAG_DIRCHANGE = 32,
+ UPDATEFLAG_HEALTHCHANGE = 64
};
/**
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index ee5fe55..bfba1d5 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -342,6 +342,29 @@ static void informPlayer(MapComposite *map, Character *p)
// Inform client about status change.
p->sendStatus();
+ // Inform client about health change of party members
+ for (CharacterIterator i(map->getWholeMapIterator()); i; ++i)
+ {
+ Character *c = *i;
+
+ // Make sure its not the same character
+ if (c == p)
+ continue;
+
+ // make sure they are in the same party
+ if (c->getParty() == p->getParty())
+ {
+ int cflags = c->getUpdateFlags();
+ if (cflags & UPDATEFLAG_HEALTHCHANGE)
+ {
+ MessageOut healthMsg(GPMSG_BEING_HEALTH_CHANGE);
+ healthMsg.writeShort(c->getPublicID());
+ healthMsg.writeShort(c->getHealth());
+ gameHandler->sendTo(p, healthMsg);
+ }
+ }
+ }
+
// Inform client about items on the ground around its character
MessageOut itemMsg(GPMSG_ITEMS);
for (FixedObjectIterator i(map->getAroundCharacterIterator(p, AROUND_AREA)); i; ++i)