diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-04-23 23:36:09 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-05-08 14:02:51 +0200 |
commit | 1758acc8e845524071db8996f3dd5d1935a059e1 (patch) | |
tree | 713fef27549712cdb979b096bd82da66a904c672 /src/game-server/abilitycomponent.h | |
parent | 62f1e23dff18a00066ce9a9df67e058d5e5d7bbd (diff) | |
download | manaserv-1758acc8e845524071db8996f3dd5d1935a059e1.tar.gz manaserv-1758acc8e845524071db8996f3dd5d1935a059e1.tar.xz manaserv-1758acc8e845524071db8996f3dd5d1935a059e1.zip |
[Abilities] Added support for a global cooldown
Each ability can now define a cooldown that prevents the player from
using other abilities for a while. The time of this cooldown can be set
to any attribute. The modified value of the attribute is the value of
the cooldown in game ticks. The cooldown will be automatically started
if the ability has `autoconsume` set to true. Otherwise a script has to
call entity:cooldown_ability(ability).
Diffstat (limited to 'src/game-server/abilitycomponent.h')
-rw-r--r-- | src/game-server/abilitycomponent.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/game-server/abilitycomponent.h b/src/game-server/abilitycomponent.h index ae48e91..c44dcb7 100644 --- a/src/game-server/abilitycomponent.h +++ b/src/game-server/abilitycomponent.h @@ -23,6 +23,7 @@ #include "game-server/abilitymanager.h" #include "game-server/component.h" +#include "game-server/timeout.h" #include <sigc++/signal.h> @@ -65,13 +66,19 @@ public: bool setAbilityMana(int id, int mana); + void startCooldown(Entity &entity, + const AbilityManager::AbilityInfo *abilityInfo); + int remainingCooldown() const; + sigc::signal<void, int> signal_ability_changed; sigc::signal<void, int> signal_ability_took; - + sigc::signal<void> signal_cooldown_activated; private: bool abilityUseCheck(AbilityMap::iterator it); void attributeChanged(Entity *entity, unsigned attr); + Timeout mCooldown; + AbilityMap mAbilities; }; @@ -105,4 +112,9 @@ inline const AbilityMap &AbilityComponent::getAbilities() const return mAbilities; } +inline int AbilityComponent::remainingCooldown() const +{ + return mCooldown.remaining(); +} + #endif /* ABILITYCOMPONENT_H_ */ |