diff --git a/res/spells.xml b/res/spells.xml index b7866e016..4ec6f9fce 100644 --- a/res/spells.xml +++ b/res/spells.xml @@ -24,12 +24,12 @@ - + - + @@ -37,19 +37,19 @@ - + - + - + @@ -57,18 +57,18 @@ - + - + - + @@ -76,12 +76,12 @@ - + - + @@ -89,25 +89,25 @@ - + - + - + - + @@ -115,7 +115,7 @@ - + @@ -123,20 +123,20 @@ - + - + - + diff --git a/src/bindings/bind_unit.c b/src/bindings/bind_unit.c index 3b0198d2c..1184617d8 100644 --- a/src/bindings/bind_unit.c +++ b/src/bindings/bind_unit.c @@ -453,7 +453,7 @@ static int tolua_unit_addnotice(lua_State * L) return 0; } -static void unit_castspell(unit * u, const char *name) +static void unit_castspell(unit * u, const char *name, int level) { quicklist *ql = spells; int qi; @@ -465,7 +465,7 @@ static void unit_castspell(unit * u, const char *name) log_error("spell '%s' has no function.\n", sp->sname); } else { castorder co; - create_castorder(&co, u, 0, sp, u->region, sp->level, sp->level * MagicPower(), 0, 0, 0); + create_castorder(&co, u, 0, sp, u->region, level, level * MagicPower(), 0, 0, 0); sp->cast(&co); free_castorder(&co); } @@ -477,7 +477,9 @@ static int tolua_unit_castspell(lua_State * L) { unit *self = (unit *) tolua_tousertype(L, 1, 0); const char *str = tolua_tostring(L, 2, 0); - unit_castspell(self, str); + int level = (int)tolua_tonumber(L, 3, 1); + + unit_castspell(self, str, level); return 0; } diff --git a/src/kernel/battle.c b/src/kernel/battle.c index ad01108b5..d0d0f9a31 100644 --- a/src/kernel/battle.c +++ b/src/kernel/battle.c @@ -1896,7 +1896,9 @@ static void do_extra_spell(troop at, const att * a) if (sp->cast == NULL) { log_error("spell '%s' has no function.\n", sp->sname); } else { - cast_combatspell(at, sp, sp->level, sp->level * MagicPower()); + int level = a->level; + assert(a->level>0); + cast_combatspell(at, sp, level, level * MagicPower()); } } diff --git a/src/kernel/magic.h b/src/kernel/magic.h index b129368e9..5edefbd7d 100644 --- a/src/kernel/magic.h +++ b/src/kernel/magic.h @@ -165,7 +165,6 @@ typedef struct sc_mage { fumble_f patzer; /* this is not so much the spell's data, but the school's studying data */ - magic_t __magietyp; int level; /* Stufe des Zaubers */ } spell; diff --git a/src/kernel/race.h b/src/kernel/race.h index b1ec8f889..c2cafa01f 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -46,6 +46,7 @@ extern "C" { const struct spell *sp; } data; int flags; + int level; } att; struct param; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index bdeba293e..008c6a4d1 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1956,6 +1956,10 @@ static int parse_races(xmlDocPtr doc) xmlFree(propValue); } else { attack->data.sp = xml_spell(node, "spell"); + if (attack->data.sp) { + attack->level = xml_ivalue(node, "level", 0); + assert(attack->level > 0 || attack->data.sp->level > 0); /* magical attacks need a level */ + } } attack->type = xml_ivalue(node, "type", 0); attack->flags = xml_ivalue(node, "flags", 0);