summaryrefslogtreecommitdiff
path: root/src/map/magic-expr.c
diff options
context:
space:
mode:
authorFate <fate-tmw@googlemail.com>2008-11-24 12:41:04 -0700
committerFate <fate-tmw@googlemail.com>2008-11-24 12:41:04 -0700
commit8c2b0f2729f29f3906a75e2fba72d2dad4a80ee2 (patch)
tree49ec1cec95b6e6a4cfdaeda49b42afb140ac825d /src/map/magic-expr.c
parent5bb68970dece3052f5bf82d53bec8c6eeac60e15 (diff)
downloadtmwa-8c2b0f2729f29f3906a75e2fba72d2dad4a80ee2.tar.gz
tmwa-8c2b0f2729f29f3906a75e2fba72d2dad4a80ee2.tar.bz2
tmwa-8c2b0f2729f29f3906a75e2fba72d2dad4a80ee2.tar.xz
tmwa-8c2b0f2729f29f3906a75e2fba72d2dad4a80ee2.zip
Added spell_index and is_equipped operations, permitted coercions from invocations to strings
Diffstat (limited to 'src/map/magic-expr.c')
-rw-r--r--src/map/magic-expr.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/map/magic-expr.c b/src/map/magic-expr.c
index efdbb72..7cb1d3a 100644
--- a/src/map/magic-expr.c
+++ b/src/map/magic-expr.c
@@ -214,6 +214,20 @@ make_location(val_t *v)
}
}
+static void
+make_spell(val_t *v)
+{
+ if (v->ty == TY_INVOCATION) {
+ invocation_t *invoc = v->v.v_invocation; //(invocation_t *) map_id2bl(v->v.v_int);
+ if (!invoc)
+ v->ty = TY_FAIL;
+ else {
+ v->ty = TY_SPELL;
+ v->v.v_spell = invoc->spell;
+ }
+ }
+}
+
static int
fun_add(env_t *env, int args_nr, val_t *result, val_t *args)
{
@@ -923,6 +937,13 @@ fun_element_level(env_t *env, int args_nr, val_t *result, val_t *args)
return 0;
}
+static int
+fun_index(env_t *env, int args_nr, val_t *result, val_t *args)
+{
+ RESULTINT = ARGSPELL(0)->index;
+ return 0;
+}
+
#define BATTLE_RECORD2(sname, name) { sname, "e", 'i', fun_get_##name }
#define BATTLE_RECORD(name) BATTLE_RECORD2(#name, name)
static fun_t functions[] = {
@@ -983,6 +1004,7 @@ static fun_t functions[] = {
{ "element_level", "e", 'i', fun_element_level },
{ "has_shroud", "e", 'i', fun_has_shroud },
{ "equipped", "e.", 'i', fun_equipped },
+ { "spell_index", "S", 'i', fun_index },
{ NULL, NULL, '.', NULL }
};
@@ -1206,6 +1228,7 @@ magic_signature_check(char *opname, char *funname, char *signature, int args_nr,
case TY_STRING: stringify(arg, 1); break; /* 100% success rate */
case TY_AREA: make_area(arg); break; /* Only works for locations */
case TY_LOCATION: make_location(arg); break; /* Only works for some areas */
+ case TY_SPELL: make_spell(arg); break; /* Only works for still-active invocatoins */
default: break; /* We'll fail right below */
}