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);
/* 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.
* Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone
* um seine Stufe */
force = sp->level * 20; /* Stufe 5 =~ 100 */
force = effect * 20; /* Stufe 5 =~ 100 */
/* Regionszauber auflösen */
while (*ap && force > 0) {

View file

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

View file

@ -165,6 +165,7 @@ static xmlNodePtr xml_inventory(report_context * ctx, item * items, unit * u)
return node;
}
#ifdef TODO /*spellbooks */
static xmlNodePtr
xml_spells(report_context * ctx, quicklist * slist, int maxlevel)
{
@ -183,6 +184,7 @@ xml_spells(report_context * ctx, quicklist * slist, int maxlevel)
}
return node;
}
#endif
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));
}
#ifdef TODO /*spellbooks */
/* spells */
if (is_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)));
}
}
#endif
}
/* 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)
{
spell *commonspells[MAXSPELLS];
spellbook_entry *commonspells[MAXSPELLS];
int qi, numspells = 0;
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)) {
spellbook_entry * sbe = (spellbook_entry *) ql_get(ql, qi);
spell * sp = sbe->sp;
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) {
int maxspell = numspells;
int spellno = -1;
spell *sp = 0;
while (!sp && maxspell>0) {
spellbook_entry *sbe = 0;
while (!sbe && maxspell>0) {
spellno = rng_int() % maxspell;
sp = commonspells[spellno];
if (sp->level>f->max_spelllevel) {
sbe = commonspells[spellno];
if (sbe->level>f->max_spelllevel) {
commonspells[spellno] = commonspells[--maxspell];
commonspells[maxspell] = sp;
sp = 0;
} else if (f->spellbook && spellbook_get(f->spellbook, sp)) {
commonspells[maxspell] = sbe;
sbe = 0;
} else if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) {
commonspells[spellno] = commonspells[--numspells];
if (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) {
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];
}
}
@ -948,7 +947,7 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
return false;
}
/* 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 */
cmistake(u, ord, 169, MSG_MAGIC);
return false;

View file

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

View file

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