spells no longer have a level (or need one)

This commit is contained in:
Enno Rehling 2012-05-26 00:57:13 -07:00
parent d884446aea
commit 3b3343ae72
6 changed files with 29 additions and 32 deletions

View file

@ -124,12 +124,12 @@ use_antimagiccrystal(unit * u, const struct item_type *itype, int amount,
assert(sp); assert(sp);
/* Reduziert die Stärke jedes Spruchs um effect */ /* Reduziert die Stärke jedes Spruchs um effect */
effect = sp->level; effect = 5;
/* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus. /* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus.
* Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone * Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone
* um seine Stufe */ * um seine Stufe */
force = sp->level * 20; /* Stufe 5 =~ 100 */ force = effect * 20; /* Stufe 5 =~ 100 */
/* Regionszauber auflösen */ /* Regionszauber auflösen */
while (*ap && force > 0) { while (*ap && force > 0) {

View file

@ -280,15 +280,11 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
} else { } else {
if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { bytes = snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1)));
itemanz *= sp->level; if (wrptr(&bufp, &size, bytes) != 0) {
}
bytes =
snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype,
itemanz != 1)));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
}
*bufp = 0; *bufp = 0;
rparagraph(F, buf, 2, 2, '-'); rparagraph(F, buf, 2, 2, '-');
} }

View file

@ -165,6 +165,7 @@ static xmlNodePtr xml_inventory(report_context * ctx, item * items, unit * u)
return node; return node;
} }
#ifdef TODO /*spellbooks */
static xmlNodePtr static xmlNodePtr
xml_spells(report_context * ctx, quicklist * slist, int maxlevel) xml_spells(report_context * ctx, quicklist * slist, int maxlevel)
{ {
@ -183,6 +184,7 @@ xml_spells(report_context * ctx, quicklist * slist, int maxlevel)
} }
return node; return node;
} }
#endif
static xmlNodePtr xml_skills(report_context * ctx, unit * u) static xmlNodePtr xml_skills(report_context * ctx, unit * u)
{ {
@ -342,6 +344,7 @@ static xmlNodePtr xml_unit(report_context * ctx, unit * u, int mode)
xmlAddChild(node, xml_skills(ctx, u)); xmlAddChild(node, xml_skills(ctx, u));
} }
#ifdef TODO /*spellbooks */
/* spells */ /* spells */
if (is_mage(u)) { if (is_mage(u)) {
sc_mage *mage = get_mage(u); sc_mage *mage = get_mage(u);
@ -350,6 +353,7 @@ static xmlNodePtr xml_unit(report_context * ctx, unit * u, int mode)
xmlAddChild(node, xml_spells(ctx, slist, effskill(u, SK_MAGIC))); xmlAddChild(node, xml_spells(ctx, slist, effskill(u, SK_MAGIC)));
} }
} }
#endif
} }
/* faction information w/ visibiility */ /* faction information w/ visibiility */

View file

@ -438,7 +438,7 @@ void show_new_spells(faction * f, int level, const spellbook *book)
*/ */
void pick_random_spells(faction * f, int level, spellbook * book, int num_spells) void pick_random_spells(faction * f, int level, spellbook * book, int num_spells)
{ {
spell *commonspells[MAXSPELLS]; spellbook_entry *commonspells[MAXSPELLS];
int qi, numspells = 0; int qi, numspells = 0;
quicklist *ql; quicklist *ql;
@ -448,9 +448,8 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells
for (qi = 0, ql = book->spells; ql; ql_advance(&ql, &qi, 1)) { for (qi = 0, ql = book->spells; ql; ql_advance(&ql, &qi, 1)) {
spellbook_entry * sbe = (spellbook_entry *) ql_get(ql, qi); spellbook_entry * sbe = (spellbook_entry *) ql_get(ql, qi);
spell * sp = sbe->sp;
if (sbe->level <= level) { if (sbe->level <= level) {
commonspells[numspells++] = sp; commonspells[numspells++] = sbe;
} }
} }
@ -461,20 +460,20 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells
for (i = 0; i < num_spells; ++i) { for (i = 0; i < num_spells; ++i) {
int maxspell = numspells; int maxspell = numspells;
int spellno = -1; int spellno = -1;
spell *sp = 0; spellbook_entry *sbe = 0;
while (!sp && maxspell>0) { while (!sbe && maxspell>0) {
spellno = rng_int() % maxspell; spellno = rng_int() % maxspell;
sp = commonspells[spellno]; sbe = commonspells[spellno];
if (sp->level>f->max_spelllevel) { if (sbe->level>f->max_spelllevel) {
commonspells[spellno] = commonspells[--maxspell]; commonspells[spellno] = commonspells[--maxspell];
commonspells[maxspell] = sp; commonspells[maxspell] = sbe;
sp = 0; sbe = 0;
} else if (f->spellbook && spellbook_get(f->spellbook, sp)) { } else if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) {
commonspells[spellno] = commonspells[--numspells]; commonspells[spellno] = commonspells[--numspells];
if (maxspell>numspells) { if (maxspell>numspells) {
maxspell = numspells; maxspell = numspells;
} }
sp = 0; sbe = 0;
} }
} }
@ -482,7 +481,7 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells
if (!f->spellbook) { if (!f->spellbook) {
f->spellbook = create_spellbook(0); f->spellbook = create_spellbook(0);
} }
spellbook_add(f->spellbook, sp, f->max_spelllevel); spellbook_add(f->spellbook, sbe->sp, sbe->level);
commonspells[spellno] = commonspells[--numspells]; commonspells[spellno] = commonspells[--numspells];
} }
} }
@ -948,7 +947,7 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
return false; return false;
} }
/* reicht die Stufe aus? */ /* reicht die Stufe aus? */
if (eff_skill(u, SK_MAGIC, u->region) < sp->level) { if (eff_skill(u, SK_MAGIC, u->region) < level) {
/* die Einheit ist nicht erfahren genug für diesen Zauber */ /* die Einheit ist nicht erfahren genug für diesen Zauber */
cmistake(u, ord, 169, MSG_MAGIC); cmistake(u, ord, 169, MSG_MAGIC);
return false; return false;

View file

@ -36,9 +36,6 @@ extern "C" {
struct spell_component *components; struct spell_component *components;
spell_f cast; spell_f cast;
fumble_f patzer; fumble_f patzer;
/* this is not so much the spell's data, but the school's studying data */
int level; /* Stufe des Zaubers */
} spell; } spell;
int use_item_power(struct region *r, struct unit *u); int use_item_power(struct region *r, struct unit *u);

View file

@ -56,16 +56,17 @@ int spellbook_foreach(spellbook *sb, int (*callback)(spellbook_entry *, void *),
spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp) spellbook_entry * spellbook_get(spellbook *sb, const struct spell * sp)
{ {
if (sb) {
quicklist *ql; quicklist *ql;
int qi; int qi;
assert(sb);
for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) { for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) {
spellbook_entry *sbe = (spellbook_entry *) ql_get(ql, qi); spellbook_entry *sbe = (spellbook_entry *) ql_get(ql, qi);
if (sp==sbe->sp) { if (sp==sbe->sp) {
return sbe; return sbe;
} }
} }
}
return 0; return 0;
} }