diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-04-02 22:10:00 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-04-07 15:28:25 +0200 |
commit | 6b85af588b8ef4d219bc011b7c31df07a314ba0c (patch) | |
tree | 8a2d76f7256c412c1e75c812025c8baca9e59a61 /lib/mods/theme/core | |
parent | 7121520f1b7e564bd59287a11d4a8f89e999ea82 (diff) |
Lua: Move get_level_device() to C
Diffstat (limited to 'lib/mods/theme/core')
-rw-r--r-- | lib/mods/theme/core/s_aux.lua | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/lib/mods/theme/core/s_aux.lua b/lib/mods/theme/core/s_aux.lua index ec609b04..5e514081 100644 --- a/lib/mods/theme/core/s_aux.lua +++ b/lib/mods/theme/core/s_aux.lua @@ -200,35 +200,6 @@ function get_level_school(s, max, min) return lvl, nil end --- This is the function to use when casting through a stick -function get_level_device(s, max, min) - local lvl - - -- No max specified ? assume 50 - if not max then - max = 50 - end - - lvl = s_info[SKILL_DEVICE + 1].value - lvl = lvl + (get_level_use_stick * SKILL_STEP) - - -- Sticks are limited - if lvl - ((spell(s).skill_level + 1) * SKILL_STEP) >= get_level_max_stick * SKILL_STEP then - lvl = (get_level_max_stick + spell(s).skill_level - 1) * SKILL_STEP - end - - -- / 10 because otherwise we can overflow a s32b and we can use a u32b because the value can be negative - -- The loss of information should be negligible since 1 skill = 1000 internally - lvl = lvl / 10 - if not min then - lvl = lua_get_level(s, lvl, max, 1, 0) - else - lvl = lua_get_level(s, lvl, max, min, 0) - end - - return lvl -end - -- The real get_level, works for schooled magic and for innate powers get_level_use_stick = -1 get_level_max_stick = -1 @@ -236,6 +207,8 @@ function get_level(s, max, min) if type(s) == "number" then -- Ahah shall we use Magic device instead ? if get_level_use_stick > -1 then + if not max then max = 50 end + if not min then min = 1 end return get_level_device(s, max, min) else local lvl, na = get_level_school(s, max, min) |