summaryrefslogtreecommitdiff
path: root/src/lua_bind.c
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-04-02 22:10:00 +0200
committerBardur Arantsson <bardur@scientician.net>2012-04-07 15:28:25 +0200
commita77005060dac93cfdd5cdfdf7dc849e0f5207f60 (patch)
tree50fcc8d4f1ad5120547113f248e2ece67fc7dd5c /src/lua_bind.c
parent2d8ba33e34c0cbab8b7db8bbd972f1b18b28b199 (diff)
Lua: Move get_level_{use,max}_stick bits to C
Diffstat (limited to 'src/lua_bind.c')
-rw-r--r--src/lua_bind.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lua_bind.c b/src/lua_bind.c
index 05e1c743..82b802f2 100644
--- a/src/lua_bind.c
+++ b/src/lua_bind.c
@@ -267,8 +267,6 @@ s32b lua_get_level(s32b s, s32b lvl, s32b max, s32b min, s32b bonus)
s32b get_level_device(s32b s, s32b max, s32b min)
{
int lvl;
- int get_level_use_stick = exec_lua("return get_level_use_stick");
- int get_level_max_stick = exec_lua("return get_level_max_stick");
/* No max specified ? assume 50 */
if (max <= 0) {
@@ -297,10 +295,6 @@ s32b get_level_device(s32b s, s32b max, s32b min)
return lvl;
}
-static int get_level(s32b s) {
- return exec_lua(format("return get_level(%d, 50)", s));
-}
-
static int get_mana(s32b s) {
return exec_lua(format("return get_mana(%d)", s));
}
@@ -316,9 +310,8 @@ static int get_spell_stat(s32b s) {
/** Returns spell chance of failure for spell */
s32b spell_chance(s32b s)
{
- int get_level_use_stick = exec_lua("return get_level_use_stick");
spell_type *s_ptr = &school_spells[s];
- int level = get_level(s);
+ int level = get_level(s, 50, 1);
/* Extract the base spell failure rate */
if (get_level_use_stick > -1) {
@@ -328,6 +321,17 @@ s32b spell_chance(s32b s)
}
}
+s32b get_level(s32b s, s32b max, s32b min)
+{
+ /** Ahah shall we use Magic device instead ? */
+ if (get_level_use_stick > -1) {
+ return get_level_device(s, max, min);
+ } else {
+ int level = exec_lua(format("local lvl, na = get_level_school(%d, %d, %d); return lvl", s, max, min));
+ return level;
+ }
+}
+
s32b lua_spell_chance(s32b chance, int level, int skill_level, int mana, int cur_mana, int stat)
{