summaryrefslogtreecommitdiffstats
path: root/src/game-server/abilitycomponent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game-server/abilitycomponent.cpp')
-rw-r--r--src/game-server/abilitycomponent.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/game-server/abilitycomponent.cpp b/src/game-server/abilitycomponent.cpp
index eac5f1c..5b27be1 100644
--- a/src/game-server/abilitycomponent.cpp
+++ b/src/game-server/abilitycomponent.cpp
@@ -77,6 +77,9 @@ bool AbilityComponent::takeAbility(int id)
bool AbilityComponent::abilityUseCheck(AbilityMap::iterator it)
{
+ if (!mCooldown.expired())
+ return false;
+
if (it == mAbilities.end())
{
LOG_INFO("Character uses ability " << it->first
@@ -123,6 +126,7 @@ void AbilityComponent::useAbilityOnBeing(Entity &user, int id, Entity *b)
if (ability.abilityInfo->autoconsume) {
ability.currentPoints = 0;
signal_ability_changed.emit(id);
+ startCooldown(user, ability.abilityInfo);
}
//tell script engine to cast the spell
@@ -151,6 +155,7 @@ void AbilityComponent::useAbilityOnPoint(Entity &user, int id, int x, int y)
if (ability.abilityInfo->autoconsume) {
ability.currentPoints = 0;
signal_ability_changed.emit(id);
+ startCooldown(user, ability.abilityInfo);
}
//tell script engine to cast the spell
@@ -201,6 +206,15 @@ bool AbilityComponent::setAbilityMana(int id, int mana)
return false;
}
+void AbilityComponent::startCooldown(
+ Entity &entity, const AbilityManager::AbilityInfo *abilityInfo)
+{
+ unsigned cooldownAttribute = abilityInfo->cooldownAttribute;
+ auto *bc = entity.getComponent<BeingComponent>();
+ mCooldown.set((int)bc->getModifiedAttribute(cooldownAttribute));
+ signal_cooldown_activated.emit();
+}
+
void AbilityComponent::attributeChanged(Entity *entity, unsigned attr)
{
for (auto &abilityIt : mAbilities)