summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-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
5 files changed, 35 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index fe823bd5..3c677158 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* src/chat-server/chathandler.cpp, src/chat-server/chathandler.hpp,
src/defines.h: Added notifying party members when a player joins or
quits.
+ * src/game-server/state.cpp, src/game-server/being.cpp,
+ src/game-server/character.hpp, src/game-server/object.hpp: Added
+ updating party member health.
2008-11-03 David Athay <ko2fan@gmail.com>
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp
index 2c549c9f..56f0154f 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 6e31e33b..75ef9ee1 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 d94e28c6..00d7e269 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 ee5fe55f..bfba1d57 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)