diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-04-23 23:36:09 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-26 22:56:46 +0200 |
commit | c2f00b2f3ba920cb25333d19a1d37d251342caf8 (patch) | |
tree | 5d782446b6679c9f74661d64a3c6d9f778136717 /src/scripting/luautil.cpp | |
parent | 10c33df8e5a13e7e7b4a3ea203516536582b2f4b (diff) | |
download | manaserv-c2f00b2f3ba920cb25333d19a1d37d251342caf8.tar.gz manaserv-c2f00b2f3ba920cb25333d19a1d37d251342caf8.tar.bz2 manaserv-c2f00b2f3ba920cb25333d19a1d37d251342caf8.tar.xz manaserv-c2f00b2f3ba920cb25333d19a1d37d251342caf8.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/scripting/luautil.cpp')
-rw-r--r-- | src/scripting/luautil.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp index f21e4895..f889aa6c 100644 --- a/src/scripting/luautil.cpp +++ b/src/scripting/luautil.cpp @@ -223,14 +223,16 @@ int checkSkill(lua_State *s, int p) return id; } -int checkAbility(lua_State *s, int p) +AbilityManager::AbilityInfo *checkAbility(lua_State *s, int p) { + AbilityManager::AbilityInfo *abilityInfo; if (lua_isnumber(s, p)) - return luaL_checkint(s, p); + abilityInfo = abilityManager->getAbilityInfo(luaL_checkint(s, p)); + else + abilityInfo = abilityManager->getAbilityInfo(luaL_checkstring(s, p)); - int id = abilityManager->getId(luaL_checkstring(s, p)); - luaL_argcheck(s, id != 0, p, "invalid ability name"); - return id; + luaL_argcheck(s, abilityInfo != nullptr, p, "invalid ability"); + return abilityInfo; } |