specify levels with magic attacks (step one to removing spell->level)

This commit is contained in:
Enno Rehling 2012-05-24 01:44:43 -07:00
parent 3514218dba
commit 6417f55ec6
6 changed files with 31 additions and 23 deletions

View file

@ -24,12 +24,12 @@
</spell> </spell>
<!-- draig spells --> <!-- draig spells -->
<spell name="earn_silver#draig" type="draig" ship="true" variable="true" rank="5" level="1" index="159"> <spell name="earn_silver#draig" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/> <resource name="aura" amount="1" cost="level"/>
</spell> </spell>
<spell name="create_firesword" type="draig" ship="true" rank="5" level="12" index="148"> <spell name="create_firesword" ship="true" rank="5" level="12" index="148">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="100" cost="fixed"/> <resource name="aura" amount="100" cost="fixed"/>
<resource name="p10" amount="1" cost="fixed"/> <resource name="p10" amount="1" cost="fixed"/>
@ -37,19 +37,19 @@
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="create_trollbelt" type="draig" ship="true" rank="5" level="9" index="48"> <spell name="create_trollbelt" ship="true" rank="5" level="9" index="48">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="20" cost="fixed"/> <resource name="aura" amount="20" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<!-- gwyrrd spells --> <!-- gwyrrd spells -->
<spell name="earn_silver#gwyrrd" type="gwyrrd" ship="true" variable="true" rank="5" level="1" index="159"> <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/> <resource name="aura" amount="1" cost="level"/>
</spell> </spell>
<spell name="create_magicherbbag" type="gwyrrd" ship="true" rank="5" level="5" index="165"> <spell name="create_magicherbbag" ship="true" rank="5" level="5" index="165">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="30" cost="fixed"/> <resource name="aura" amount="30" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
@ -57,18 +57,18 @@
</spell> </spell>
<!-- illaun spells --> <!-- illaun spells -->
<spell name="earn_silver#illaun" type="illaun" ship="true" variable="true" rank="5" level="1" index="159"> <spell name="earn_silver#illaun" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/> <resource name="aura" amount="1" cost="level"/>
</spell> </spell>
<spell name="create_dreameye" type="illaun" ship="true" rank="5" level="14" index="149"> <spell name="create_dreameye" ship="true" rank="5" level="14" index="149">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="dragonhead" amount="1" cost="fixed"/> <resource name="dragonhead" amount="1" cost="fixed"/>
<resource name="permaura" amount="5" cost="fixed"/> <resource name="permaura" amount="5" cost="fixed"/>
</spell> </spell>
<spell name="create_invisibility_sphere" type="illaun" ship="true" rank="5" level="13" index="178"> <spell name="create_invisibility_sphere" ship="true" rank="5" level="13" index="178">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="150" cost="fixed"/> <resource name="aura" amount="150" cost="fixed"/>
<resource name="money" amount="30000" cost="fixed"/> <resource name="money" amount="30000" cost="fixed"/>
@ -76,12 +76,12 @@
</spell> </spell>
<!-- cerddor spells --> <!-- cerddor spells -->
<spell name="earn_silver#cerddor" type="cerddor" ship="true" variable="true" rank="5" level="1" index="159"> <spell name="earn_silver#cerddor" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/> <resource name="aura" amount="1" cost="level"/>
</spell> </spell>
<spell name="create_roqf" type="cerddor" ship="true" rank="5" level="11" index="63"> <spell name="create_roqf" ship="true" rank="5" level="11" index="63">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="20" cost="fixed"/> <resource name="aura" amount="20" cost="fixed"/>
<resource name="money" amount="1000" cost="fixed"/> <resource name="money" amount="1000" cost="fixed"/>
@ -89,25 +89,25 @@
</spell> </spell>
<!-- tybied spells --> <!-- tybied spells -->
<spell name="earn_silver#tybied" type="tybied" ship="true" variable="true" rank="5" level="1" index="159"> <spell name="earn_silver#tybied" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/> <resource name="aura" amount="1" cost="level"/>
</spell> </spell>
<spell name="create_antimagic" type="tybied" ship="true" rank="5" level="7" index="38"> <spell name="create_antimagic" ship="true" rank="5" level="7" index="38">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="50" cost="fixed"/> <resource name="aura" amount="50" cost="fixed"/>
<resource name="money" amount="3000" cost="fixed"/> <resource name="money" amount="3000" cost="fixed"/>
</spell> </spell>
<spell name="create_rop" type="tybied" ship="true" rank="5" level="9" index="1"> <spell name="create_rop" ship="true" rank="5" level="9" index="1">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="100" cost="fixed"/> <resource name="aura" amount="100" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
<resource name="money" amount="4000" cost="fixed"/> <resource name="money" amount="4000" cost="fixed"/>
</spell> </spell>
<spell name="create_bagofholding" type="tybied" ship="true" rank="5" level="10" index="155"> <spell name="create_bagofholding" ship="true" rank="5" level="10" index="155">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="30" cost="fixed"/> <resource name="aura" amount="30" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
@ -115,7 +115,7 @@
</spell> </spell>
<!-- gray magic --> <!-- gray magic -->
<spell name="create_runesword" type="gray" ship="true" rank="5" level="6" index="135"> <spell name="create_runesword" ship="true" rank="5" level="6" index="135">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="100" cost="fixed"/> <resource name="aura" amount="100" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
@ -123,20 +123,20 @@
<resource name="laensword" amount="1" cost="fixed"/> <resource name="laensword" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="create_chastitybelt" type="gray" ship="true" rank="5" level="7" index="134"> <spell name="create_chastitybelt" ship="true" rank="5" level="7" index="134">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="50" cost="fixed"/> <resource name="aura" amount="50" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
<resource name="money" amount="3000" cost="fixed"/> <resource name="money" amount="3000" cost="fixed"/>
</spell> </spell>
<spell name="create_focus" type="gray" ship="true" rank="5" level="9" index="2"> <spell name="create_focus" ship="true" rank="5" level="9" index="2">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="100" cost="fixed"/> <resource name="aura" amount="100" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="create_ror" type="gray" ship="true" rank="5" level="9" index="3"> <spell name="create_ror" ship="true" rank="5" level="9" index="3">
<function name="cast" value="lua_castspell"/> <function name="cast" value="lua_castspell"/>
<resource name="aura" amount="100" cost="fixed"/> <resource name="aura" amount="100" cost="fixed"/>
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>

View file

@ -453,7 +453,7 @@ static int tolua_unit_addnotice(lua_State * L)
return 0; 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; quicklist *ql = spells;
int qi; 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); log_error("spell '%s' has no function.\n", sp->sname);
} else { } else {
castorder co; 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); sp->cast(&co);
free_castorder(&co); free_castorder(&co);
} }
@ -477,7 +477,9 @@ static int tolua_unit_castspell(lua_State * L)
{ {
unit *self = (unit *) tolua_tousertype(L, 1, 0); unit *self = (unit *) tolua_tousertype(L, 1, 0);
const char *str = tolua_tostring(L, 2, 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; return 0;
} }

View file

@ -1896,7 +1896,9 @@ static void do_extra_spell(troop at, const att * a)
if (sp->cast == NULL) { if (sp->cast == NULL) {
log_error("spell '%s' has no function.\n", sp->sname); log_error("spell '%s' has no function.\n", sp->sname);
} else { } 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());
} }
} }

View file

@ -165,7 +165,6 @@ typedef struct sc_mage {
fumble_f patzer; fumble_f patzer;
/* this is not so much the spell's data, but the school's studying data */ /* this is not so much the spell's data, but the school's studying data */
magic_t __magietyp;
int level; /* Stufe des Zaubers */ int level; /* Stufe des Zaubers */
} spell; } spell;

View file

@ -46,6 +46,7 @@ extern "C" {
const struct spell *sp; const struct spell *sp;
} data; } data;
int flags; int flags;
int level;
} att; } att;
struct param; struct param;

View file

@ -1956,6 +1956,10 @@ static int parse_races(xmlDocPtr doc)
xmlFree(propValue); xmlFree(propValue);
} else { } else {
attack->data.sp = xml_spell(node, "spell"); 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->type = xml_ivalue(node, "type", 0);
attack->flags = xml_ivalue(node, "flags", 0); attack->flags = xml_ivalue(node, "flags", 0);