From c2f00b2f3ba920cb25333d19a1d37d251342caf8 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Tue, 23 Apr 2013 23:36:09 +0200 Subject: [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). --- src/game-server/abilitycomponent.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/game-server/abilitycomponent.h') diff --git a/src/game-server/abilitycomponent.h b/src/game-server/abilitycomponent.h index ae48e917..c44dcb7f 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 @@ -65,13 +66,19 @@ public: bool setAbilityMana(int id, int mana); + void startCooldown(Entity &entity, + const AbilityManager::AbilityInfo *abilityInfo); + int remainingCooldown() const; + sigc::signal signal_ability_changed; sigc::signal signal_ability_took; - + sigc::signal 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_ */ -- cgit v1.2.3-60-g2f50