diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-02 23:30:17 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-02 23:30:17 +0000 |
commit | af1ce69940a9c0b46907402e7d69e6ac9ea96912 (patch) | |
tree | 016a6a8a4734f794e56093e1611530749eb7fab0 /src/game-server/being.cpp | |
parent | 07782116ae9158c20165dd4d60bdb96017ac009f (diff) | |
download | manaserv-af1ce69940a9c0b46907402e7d69e6ac9ea96912.tar.gz manaserv-af1ce69940a9c0b46907402e7d69e6ac9ea96912.tar.bz2 manaserv-af1ce69940a9c0b46907402e7d69e6ac9ea96912.tar.xz manaserv-af1ce69940a9c0b46907402e7d69e6ac9ea96912.zip |
Implemented being death, removal of dead mobs and sitting.
Diffstat (limited to 'src/game-server/being.cpp')
-rw-r--r-- | src/game-server/being.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index 7f2ec2f4..6924f3b9 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -29,13 +29,43 @@ void Being::damage(Damage damage) { + if (mAction == DEAD) return; + int HPloss; HPloss = damage; // TODO: Implement complex damage calculation here + if (HPloss > mHitpoints) HPloss = mHitpoints; + mHitpoints -= HPloss; mHitsTaken.push_back(HPloss); - LOG_DEBUG("Being " << getPublicID() << " got hit"); + LOG_INFO("Being " << getPublicID() << " got hit"); + + if (mHitpoints == 0) die(); +} + +void Being::die() +{ + LOG_INFO("Being " << getPublicID() << " died"); + setAction(DEAD); + // dead beings stay where they are + setDestination(getPosition()); +} + +void Being::move() +{ + MovingObject::move(); + if (mAction == WALK || mAction == STAND) + { + if (mActionTime) + { + mAction = WALK; + } + else + { + mAction = STAND; + } + } } void Being::performAttack(MapComposite *map) @@ -95,3 +125,13 @@ void Being::performAttack(MapComposite *map) } } } + +void Being::setAction(Action action) +{ + mAction = action; + if (action != Being::ATTACK && // The players are informed about these actions + action != Being::WALK) // by other messages + { + raiseUpdateFlags(UPDATEFLAG_ACTIONCHANGE); + } +} |