From 8c2b0f2729f29f3906a75e2fba72d2dad4a80ee2 Mon Sep 17 00:00:00 2001 From: Fate Date: Mon, 24 Nov 2008 12:41:04 -0700 Subject: Added spell_index and is_equipped operations, permitted coercions from invocations to strings --- src/map/magic-expr.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/map/magic-expr.c') 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 */ } -- cgit v1.2.3-60-g2f50