diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-04-27 18:11:13 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:46 +0200 |
commit | 960d40d819afb65387469591bdb02e6819d72294 (patch) | |
tree | 773a697bdd12ae28a717bf6087c3109fbfc1fb35 /src/game-server | |
parent | 163c438e4f373989a8a82e47f38ac67d70b5a1bf (diff) | |
download | manaserv-960d40d819afb65387469591bdb02e6819d72294.tar.gz manaserv-960d40d819afb65387469591bdb02e6819d72294.tar.bz2 manaserv-960d40d819afb65387469591bdb02e6819d72294.tar.xz manaserv-960d40d819afb65387469591bdb02e6819d72294.zip |
[Abilities] Added a add_hit_taken bind
This allows to display hit messages in the client for abilities
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/being.h | 33 | ||||
-rw-r--r-- | src/game-server/combatcomponent.cpp | 1 | ||||
-rw-r--r-- | src/game-server/combatcomponent.h | 25 | ||||
-rw-r--r-- | src/game-server/state.cpp | 7 |
4 files changed, 36 insertions, 30 deletions
diff --git a/src/game-server/being.h b/src/game-server/being.h index 5ccc8e89..5827ad17 100644 --- a/src/game-server/being.h +++ b/src/game-server/being.h @@ -47,6 +47,11 @@ struct Status typedef std::map< int, Status > StatusEffects; /** + * Type definition for a list of hits + */ +typedef std::vector<unsigned> Hits; + +/** * Generic being (living actor). Keeps direction, destination and a few other * relevant properties. Used for characters & monsters (all animated objects). */ @@ -280,6 +285,10 @@ class BeingComponent : public Component const Point ¤tPos, const Point &destPos); + void addHitTaken(unsigned damage); + const Hits &getHitsTaken() const; + void clearHitsTaken(); + protected: static const int TICKS_PER_HP_REGENERATION = 100; @@ -312,6 +321,8 @@ class BeingComponent : public Component /** The last being emote Id. Used when triggering a being emoticon. */ int mEmoteId; + Hits mHitsTaken; //List of punches taken since last update. + /** Called when derived attributes need to get calculated */ static Script::Ref mRecalculateDerivedAttributesCallback; @@ -319,4 +330,26 @@ class BeingComponent : public Component static Script::Ref mRecalculateBaseAttributeCallback; }; + +inline void BeingComponent::addHitTaken(unsigned damage) +{ + mHitsTaken.push_back(damage); +} + +/** + * Gets the damage list. + */ +inline const Hits &BeingComponent::getHitsTaken() const +{ + return mHitsTaken; +} + +/** + * Clears the damage list. + */ +inline void BeingComponent::clearHitsTaken() +{ + mHitsTaken.clear(); +} + #endif // BEING_H diff --git a/src/game-server/combatcomponent.cpp b/src/game-server/combatcomponent.cpp index 38c7716e..65eddc46 100644 --- a/src/game-server/combatcomponent.cpp +++ b/src/game-server/combatcomponent.cpp @@ -157,7 +157,6 @@ int CombatComponent::damage(Entity &target, if (HPloss > 0) { - mHitsTaken.push_back(HPloss); const Attribute *HP = beingComponent->getAttribute(ATTR_HP); LOG_DEBUG("Being " << target.getComponent<ActorComponent>()->getPublicID() diff --git a/src/game-server/combatcomponent.h b/src/game-server/combatcomponent.h index 168c08d7..1a4f3102 100644 --- a/src/game-server/combatcomponent.h +++ b/src/game-server/combatcomponent.h @@ -31,11 +31,6 @@ class Entity; -/** - * Type definition for a list of hits - */ -typedef std::vector<unsigned> Hits; - class CombatComponent: public Component { public: @@ -50,9 +45,6 @@ public: void removeAttack(AttackInfo *attackInfo); Attacks &getAttacks(); - const Hits &getHitsTaken() const; - void clearHitsTaken(); - int performAttack(Entity &source, const Damage &dmg); virtual int damage(Entity &target, Entity *source, const Damage &damage); @@ -72,7 +64,6 @@ protected: Entity *mTarget; Attacks mAttacks; Attack *mCurrentAttack; // Last used attack - Hits mHitsTaken; //List of punches taken since last update. }; @@ -82,22 +73,6 @@ inline Attacks &CombatComponent::getAttacks() } /** - * Gets the damage list. - */ -inline const Hits &CombatComponent::getHitsTaken() const -{ - return mHitsTaken; -} - -/** - * Clears the damage list. - */ -inline void CombatComponent::clearHitsTaken() -{ - mHitsTaken.clear(); -} - -/** * Gets the attack id the being is currently performing. * For being, this is defaulted to the first one (1). */ diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp index 2527207a..3e2e4ab7 100644 --- a/src/game-server/state.cpp +++ b/src/game-server/state.cpp @@ -255,9 +255,8 @@ static void informPlayer(MapComposite *map, Entity *p) // Send damage messages. if (o->canFight()) { - CombatComponent *combatComponent = - o->getComponent<CombatComponent>(); - const Hits &hits = combatComponent->getHitsTaken(); + auto *beingComponent = o->getComponent<BeingComponent>(); + const Hits &hits = beingComponent->getHitsTaken(); for (Hits::const_iterator j = hits.begin(), j_end = hits.end(); j != j_end; ++j) { @@ -517,7 +516,7 @@ void GameState::update(int tick) a->getComponent<ActorComponent>()->clearUpdateFlags(); if (a->canFight()) { - a->getComponent<CombatComponent>()->clearHitsTaken(); + a->getComponent<BeingComponent>()->clearHitsTaken(); } } } |