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/abilitymanager.cpp | |
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/abilitymanager.cpp')
-rw-r--r-- | src/game-server/abilitymanager.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/game-server/abilitymanager.cpp b/src/game-server/abilitymanager.cpp index eb828e8..0657c2c 100644 --- a/src/game-server/abilitymanager.cpp +++ b/src/game-server/abilitymanager.cpp @@ -100,6 +100,8 @@ void AbilityManager::readAbilityNode(xmlNodePtr abilityNode, int neededMana = XML::getProperty(abilityNode, "needed", 0); int rechargeAttribute = XML::getProperty(abilityNode, "rechargeattribute", 0); + int cooldownAttribute = XML::getProperty(abilityNode, + "cooldownattribute", 0); bool autoconsume = XML::getBoolProperty(abilityNode, "autoconsume", true); if (rechargeable && neededMana <= 0) @@ -118,6 +120,7 @@ void AbilityManager::readAbilityNode(xmlNodePtr abilityNode, newInfo->rechargeable = rechargeable; newInfo->neededPoints = neededMana; newInfo->rechargeAttribute = rechargeAttribute; + newInfo->cooldownAttribute = cooldownAttribute; newInfo->autoconsume = autoconsume; newInfo->target = getTargetByString(XML::getProperty(abilityNode, "target", @@ -177,8 +180,25 @@ const std::string AbilityManager::getCategoryName(int id) const return it != mAbilitiesInfo.end() ? it->second->categoryName : ""; } -AbilityManager::AbilityInfo *AbilityManager::getAbilityInfo(int id) +AbilityManager::AbilityInfo *AbilityManager::getAbilityInfo(int id) const { AbilitiesInfo::const_iterator it = mAbilitiesInfo.find(id); return it != mAbilitiesInfo.end() ? it->second : 0; } + +AbilityManager::AbilityInfo *AbilityManager::getAbilityInfo( + const std::string &category, + const std::string &name) const +{ + std::string key = utils::toLower(category) + "_" + utils::toLower(name); + return getAbilityInfo(key); +} + +AbilityManager::AbilityInfo *AbilityManager::getAbilityInfo( + const std::string &abilityName) const +{ + if (mNamedAbilitiesInfo.contains(abilityName)) + return mNamedAbilitiesInfo.value(abilityName); + else + return 0; +} |