summaryrefslogtreecommitdiff
path: root/src/lua_bind.c
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-05-29 06:25:07 +0200
committerBardur Arantsson <bardur@scientician.net>2012-05-29 18:18:10 +0200
commitd98a999477698bb0a304c4995df44f2b7ef5389d (patch)
treee0d30c7a705368f7991371a143a9c4c7b06faf60 /src/lua_bind.c
parent127f4d6985d998c65d958907758e474edb29ceec (diff)
Lua: Convert all the spell metadata to C code
(Yay automated translation!)
Diffstat (limited to 'src/lua_bind.c')
-rw-r--r--src/lua_bind.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/lua_bind.c b/src/lua_bind.c
index 456e653d..0c099c00 100644
--- a/src/lua_bind.c
+++ b/src/lua_bind.c
@@ -17,6 +17,11 @@
#include "tolua.h"
extern lua_State *L;
+s16b can_spell_random(s16b spell_idx)
+{
+ return spell_at(spell_idx)->random_type;
+}
+
magic_power *grab_magic_power(magic_power *m_ptr, int num)
{
return (&m_ptr[num]);
@@ -171,19 +176,6 @@ s16b new_school(int i, cptr name, s16b skill)
return (i);
}
-s16b new_spell(int i, cptr name)
-{
- school_spells[i].name = string_make(name);
- school_spells[i].level = 0;
- school_spells[i].level = 0;
- return (i);
-}
-
-spell_type *grab_spell_type(s16b num)
-{
- return (&school_spells[num]);
-}
-
school_type *grab_school_type(s16b num)
{
return (&schools[num]);
@@ -245,12 +237,10 @@ s32b get_level_device(s32b s, s32b max, s32b min)
return lvl;
}
-int get_mana(s32b s) {
- return exec_lua(format("return get_mana(%d)", s));
-}
-
-static int get_spell_stat(s32b s) {
- return exec_lua(format("return get_spell_stat(%d)", s));
+int get_mana(s32b s)
+{
+ spell_type *spell = spell_at(s);
+ return get_level(s, spell->mana_range.max, spell->mana_range.min);
}
/** Returns spell chance of failure for spell */
@@ -261,9 +251,9 @@ s32b spell_chance(s32b s)
/* Extract the base spell failure rate */
if (get_level_use_stick > -1) {
- return lua_spell_device_chance(s_ptr->fail, level, s_ptr->skill_level);
+ return lua_spell_device_chance(s_ptr->failure_rate, level, s_ptr->skill_level);
} else {
- return lua_spell_chance(s_ptr->fail, level, s_ptr->skill_level, get_mana(s), get_power(s), get_spell_stat(s));
+ return lua_spell_chance(s_ptr->failure_rate, level, s_ptr->skill_level, get_mana(s), get_power(s), s_ptr->casting_stat);
}
}
@@ -582,5 +572,8 @@ void timer_aggravate_evil_callback()
cptr get_spell_info(s32b s)
{
- return string_exec_lua(format("return __spell_info[" FMTs32b "]()", s));
+ spell_type *spell = spell_at(s);
+
+ assert(spell->info_func != NULL);
+ return spell->info_func();
}