new spell lists for E2K9

new magic code for E2K9
This commit is contained in:
Enno Rehling 2009-05-26 18:11:20 +00:00
parent 591c85d4c7
commit 708a6ceb8e
29 changed files with 742 additions and 774 deletions

View File

@ -1324,7 +1324,7 @@ report_computer(const char * filename, report_context * ctx, const char * charse
} }
fprintf(F, "%d;Rekrutierungskosten\n", f->race->recruitcost); fprintf(F, "%d;Rekrutierungskosten\n", f->race->recruitcost);
fprintf(F, "%d;Anzahl Personen\n", count_all(f)); fprintf(F, "%d;Anzahl Personen\n", count_all(f));
fprintf(F, "\"%s\";Magiegebiet\n", magietypen[f->magiegebiet]); fprintf(F, "\"%s\";Magiegebiet\n", magic_school[f->magiegebiet]);
if (f->race == new_race[RC_HUMAN]) { if (f->race == new_race[RC_HUMAN]) {
fprintf(F, "%d;Anzahl Immigranten\n", count_migrants(f)); fprintf(F, "%d;Anzahl Immigranten\n", count_migrants(f));

View File

@ -370,13 +370,15 @@ give_unit(unit * u, unit * u2, order * ord)
} }
} }
if (has_skill(u, SK_MAGIC)) { if (has_skill(u, SK_MAGIC)) {
sc_mage * mage;
if (count_skill(u2->faction, SK_MAGIC) + u->number > if (count_skill(u2->faction, SK_MAGIC) + u->number >
skill_limit(u2->faction, SK_MAGIC)) skill_limit(u2->faction, SK_MAGIC))
{ {
cmistake(u, ord, 155, MSG_COMMERCE); cmistake(u, ord, 155, MSG_COMMERCE);
return; return;
} }
if (u2->faction->magiegebiet != find_magetype(u)) { mage = get_mage(u);
if (!mage || u2->faction->magiegebiet != mage->magietyp) {
cmistake(u, ord, 157, MSG_COMMERCE); cmistake(u, ord, 157, MSG_COMMERCE);
return; return;
} }

View File

@ -108,7 +108,7 @@ use_antimagiccrystal(unit * u, const struct item_type * itype, int amount, struc
for (i=0;i!=amount;++i) { for (i=0;i!=amount;++i) {
int effect, duration = 2; int effect, duration = 2;
double force; double force;
spell *sp = find_spell(M_GRAU, "antimagiczone"); spell *sp = find_spell(M_NONE, "antimagiczone");
attrib ** ap = &r->attribs; attrib ** ap = &r->attribs;
unused(ord); unused(ord);
assert(sp); assert(sp);

View File

@ -3409,7 +3409,7 @@ update_spells(void)
if (u->faction!=NULL && u->number>0) { if (u->faction!=NULL && u->number>0) {
sc_mage *m = get_mage(u); sc_mage *m = get_mage(u);
if (!is_monsters(u->faction) && m != NULL) { if (!is_monsters(u->faction) && m != NULL) {
if (m->magietyp == M_GRAU) continue; if (m->magietyp == M_GRAY) continue;
updatespelllist(u); updatespelllist(u);
} }
} }

View File

@ -1936,7 +1936,7 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
rnl(F); rnl(F);
sprintf(buf, "%s, %s/%s (%s)", factionname(f), sprintf(buf, "%s, %s/%s (%s)", factionname(f),
LOC(f->locale, rc_name(f->race, 1)), LOC(f->locale, rc_name(f->race, 1)),
LOC(f->locale, mkname("school", magietypen[f->magiegebiet])), LOC(f->locale, mkname("school", magic_school[f->magiegebiet])),
f->email); f->email);
centre(F, buf, true); centre(F, buf, true);
if (f->alliance!=NULL) { if (f->alliance!=NULL) {

View File

@ -67,10 +67,10 @@ spy_message(int spy, const unit *u, const unit *target)
ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u, target, str)); ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u, target, str));
if (spy > 20) { if (spy > 20) {
sc_mage * m = get_mage(target); sc_mage * mage = get_mage(target);
/* bei Magiern Zaubersprüche und Magiegebiet */ /* bei Magiern Zaubersprüche und Magiegebiet */
if (m) { if (mage) {
ADDMSG(&u->faction->msgs, msg_message("spyreport_mage", "target type", target, magietypen[find_magetype(target)])); ADDMSG(&u->faction->msgs, msg_message("spyreport_mage", "target type", target, magic_school[mage->magietyp]));
} }
} }
if (spy > 6) { if (spy > 6) {

View File

@ -435,8 +435,9 @@ teach_cmd(unit * u, struct order * ord)
if (sk == SK_MAGIC) { if (sk == SK_MAGIC) {
/* ist der Magier schon spezialisiert, so versteht er nur noch /* ist der Magier schon spezialisiert, so versteht er nur noch
* Lehrer seines Gebietes */ * Lehrer seines Gebietes */
if (find_magetype(u2) != 0 && find_magetype(u) != find_magetype(u2)) sc_mage * mage1 = get_mage(u);
{ sc_mage * mage2 = get_mage(u2);
if (!mage2 || !mage1 || mage1->magietyp!=mage2->magietyp) {
if (feedback) { if (feedback) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_different_magic", "target", u2)); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_different_magic", "target", u2));
} }
@ -549,7 +550,7 @@ learn_cmd(unit * u, order * ord)
if (is_familiar(u)){ if (is_familiar(u)){
/* Vertraute zählen nicht zu den Magiern einer Partei, /* Vertraute zählen nicht zu den Magiern einer Partei,
* können aber nur Graue Magie lernen */ * können aber nur Graue Magie lernen */
mtyp = M_GRAU; mtyp = M_GRAY;
if (!is_mage(u)) create_mage(u, mtyp); if (!is_mage(u)) create_mage(u, mtyp);
} else if (!has_skill(u, SK_MAGIC)) { } else if (!has_skill(u, SK_MAGIC)) {
int mmax = skill_limit(u->faction, SK_MAGIC); int mmax = skill_limit(u->faction, SK_MAGIC);
@ -560,7 +561,7 @@ learn_cmd(unit * u, order * ord)
return 0; return 0;
} }
mtyp = getmagicskill(u->faction->locale); mtyp = getmagicskill(u->faction->locale);
if (mtyp == M_NONE || mtyp == M_GRAU) { if (mtyp == M_NONE || mtyp == M_GRAY) {
/* wurde kein Magiegebiet angegeben, wird davon /* wurde kein Magiegebiet angegeben, wird davon
* ausgegangen, daß das normal gelernt werden soll */ * ausgegangen, daß das normal gelernt werden soll */
if(u->faction->magiegebiet != 0) { if(u->faction->magiegebiet != 0) {

View File

@ -93,12 +93,12 @@ out_faction(FILE *file, const struct faction *f)
if (alliances!=NULL) { if (alliances!=NULL) {
fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n", fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
f->name, itoa36(f->no), f->alliance?f->alliance->id:0, f->name, itoa36(f->no), f->alliance?f->alliance->id:0,
LOC(default_locale, rc_name(f->race, 0)), magietypen[f->magiegebiet], LOC(default_locale, rc_name(f->race, 0)), magic_school[f->magiegebiet],
f->no_units, f->num_total, f->money, turn - f->lastorders); f->no_units, f->num_total, f->money, turn - f->lastorders);
} else { } else {
fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n", fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d NMR\n",
factionname(f), LOC(default_locale, rc_name(f->race, 0)), factionname(f), LOC(default_locale, rc_name(f->race, 0)),
magietypen[f->magiegebiet], f->no_units, f->num_total, f->money, magic_school[f->magiegebiet], f->no_units, f->num_total, f->money,
turn - f->lastorders); turn - f->lastorders);
} }
} }

View File

@ -2057,9 +2057,25 @@ init_locale(const struct locale * lang)
#endif #endif
tokens = get_translations(lang, UT_MAGIC); tokens = get_translations(lang, UT_MAGIC);
if (tokens) {
const char * str = get_param(global.parameters, "rules.magic.playerschools");
char * sstr, * tok;
if (str==NULL) {
str = "gwyrrd illaun draig cerddor tybied";
}
sstr = strdup(str);
tok = strtok(sstr, " ");
while (tok) {
for (i=0;i!=MAXMAGIETYP;++i) { for (i=0;i!=MAXMAGIETYP;++i) {
if (strcmp(tok, magic_school[i])==0) break;
}
assert(i!=MAXMAGIETYP);
var.i = i; var.i = i;
addtoken(tokens, LOC(lang, mkname("school", magietypen[i])), var); addtoken(tokens, LOC(lang, mkname("school", tok)), var);
tok = strtok(NULL, " ");
}
free(sstr);
} }
tokens = get_translations(lang, UT_DIRECTIONS); tokens = get_translations(lang, UT_DIRECTIONS);

View File

@ -74,14 +74,15 @@
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
const char *magietypen[MAXMAGIETYP] = const char *magic_school[MAXMAGIETYP] =
{ {
"gray", "gray",
"illaun", "illaun",
"tybied", "tybied",
"cerddor", "cerddor",
"gwyrrd", "gwyrrd",
"draig" "draig",
"common"
}; };
attrib_type at_reportspell = { attrib_type at_reportspell = {
@ -219,11 +220,11 @@ void read_spellist(struct spell_list ** slistp, struct storage * store)
if (store->version<SPELLNAME_VERSION) { if (store->version<SPELLNAME_VERSION) {
int i = store->r_int(store); int i = store->r_int(store);
if (i < 0) break; if (i < 0) break;
sp = find_spellbyid(M_GRAU, (spellid_t)i); sp = find_spellbyid(M_NONE, (spellid_t)i);
} else { } else {
store->r_tok_buf(store, spname, sizeof(spname)); store->r_tok_buf(store, spname, sizeof(spname));
if (strcmp(spname, "end")==0) break; if (strcmp(spname, "end")==0) break;
sp = find_spell(M_GRAU, spname); sp = find_spell(M_NONE, spname);
} }
if (sp!=NULL) { if (sp!=NULL) {
add_spell(slistp, sp); add_spell(slistp, sp);
@ -327,20 +328,6 @@ get_mage(const unit * u)
return (sc_mage *) NULL; return (sc_mage *) NULL;
} }
magic_t
find_magetype(const unit * u)
{
sc_mage *m;
/* Null abfangen! */
m = get_mage(u);
if (!m)
return 0;
return m->magietyp;
}
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Ausgabe der Spruchbeschreibungen /* Ausgabe der Spruchbeschreibungen
* Anzeige des Spruchs nur, wenn die Stufe des besten Magiers vorher * Anzeige des Spruchs nur, wenn die Stufe des besten Magiers vorher
@ -360,7 +347,7 @@ read_seenspell(attrib * a, struct storage * store)
store->r_tok_buf(store, token, sizeof(token)); store->r_tok_buf(store, token, sizeof(token));
i = atoi(token); i = atoi(token);
if (i!=0) { if (i!=0) {
sp = find_spellbyid(M_GRAU, (spellid_t)i); sp = find_spellbyid(M_NONE, (spellid_t)i);
} else { } else {
int mtype; int mtype;
mtype = store->r_int(store); mtype = store->r_int(store);
@ -397,7 +384,23 @@ already_seen(const faction * f, const spell * sp)
return false; return false;
} }
#define GRAYSPELLS 2 /* number of new gray spells per level */ static boolean know_school(const faction * f, magic_t school)
{
static int common = MAXMAGIETYP;
if (f->magiegebiet==school) return true;
if (common==MAXMAGIETYP) {
const char * school = get_param(global.parameters, "rules.magic.common");
for (common=0;common!=MAXMAGIETYP;++common) {
if (strcmp(school, magic_school[common])==0) break;
}
if (common==MAXMAGIETYP) {
common = M_NONE;
}
}
return school==common;
}
#define COMMONSPELLS 1 /* number of new common spells per level */
#define MAXSPELLS 256 #define MAXSPELLS 256
/** update the spellbook with a new level /** update the spellbook with a new level
@ -406,16 +409,16 @@ already_seen(const faction * f, const spell * sp)
void void
update_spellbook(faction * f, int level) update_spellbook(faction * f, int level)
{ {
spell * grayspells[MAXSPELLS]; spell * commonspells[MAXSPELLS];
int numspells = 0; int numspells = 0;
spell_list * slist; spell_list * slist;
for (slist=spells;slist!=NULL;slist=slist->next) { for (slist=spells;slist!=NULL;slist=slist->next) {
spell * sp = slist->data; spell * sp = slist->data;
if (sp->magietyp == M_GRAU && level<f->max_spelllevel && sp->level<=level) { if (sp->magietyp == M_COMMON && level<f->max_spelllevel && sp->level<=level) {
grayspells[numspells++] = sp; commonspells[numspells++] = sp;
} else { } else {
if (sp->magietyp == f->magiegebiet && sp->level <= level) { if (know_school(f, sp->magietyp) && sp->level <= level) {
if (!has_spell(f->spellbook, sp)) { if (!has_spell(f->spellbook, sp)) {
add_spell(&f->spellbook, sp); add_spell(&f->spellbook, sp);
} }
@ -424,7 +427,7 @@ update_spellbook(faction * f, int level)
} }
while (numspells>0 && level>f->max_spelllevel) { while (numspells>0 && level>f->max_spelllevel) {
int i; int i;
for (i=0;i!=GRAYSPELLS;++i) { for (i=0;i!=COMMONSPELLS;++i) {
int maxspell = numspells; int maxspell = numspells;
int spellno = -1; int spellno = -1;
spell * sp; spell * sp;
@ -433,13 +436,13 @@ update_spellbook(faction * f, int level)
--maxspell; --maxspell;
} }
spellno = rng_int() % maxspell; spellno = rng_int() % maxspell;
sp = grayspells[spellno]; sp = commonspells[spellno];
} }
while (maxspell>0 && sp && sp->level<=f->max_spelllevel); while (maxspell>0 && sp && sp->level<=f->max_spelllevel);
if (sp) { if (sp) {
add_spell(&f->spellbook, sp); add_spell(&f->spellbook, sp);
grayspells[spellno] = 0; commonspells[spellno] = 0;
} }
} }
++f->max_spelllevel; ++f->max_spelllevel;
@ -451,10 +454,10 @@ void wyrm_update(unit * u, struct sc_mage * mage, int sk)
{ {
spell_list * slist, ** slistp; spell_list * slist, ** slistp;
/* Nur Wyrm-Magier bekommen den Wyrmtransformationszauber */ /* Nur Wyrm-Magier bekommen den Wyrmtransformationszauber */
spell * sp = find_spellbyid(M_GRAU, SPL_BECOMEWYRM); spell * sp = find_spellbyid(M_GRAY, SPL_BECOMEWYRM);
if (fspecial(u->faction, FS_WYRM) && !has_spell(u, sp) && sp->level<=sk) { if (fspecial(u->faction, FS_WYRM) && !has_spell(u, sp) && sp->level<=sk) {
add_spell(mage, find_spellbyid(M_GRAU, SPL_BECOMEWYRM)); add_spell(mage, find_spellbyid(M_GRAY, SPL_BECOMEWYRM));
} }
/* Transformierte Wyrm-Magier bekommen Drachenodem */ /* Transformierte Wyrm-Magier bekommen Drachenodem */
@ -463,19 +466,19 @@ void wyrm_update(unit * u, struct sc_mage * mage, int sk)
switch (urc) { switch (urc) {
/* keine breaks! Wyrme sollen alle drei Zauber können.*/ /* keine breaks! Wyrme sollen alle drei Zauber können.*/
case RC_WYRM: case RC_WYRM:
sp = find_spellbyid(M_GRAU, SPL_WYRMODEM); sp = find_spellbyid(M_GRAY, SPL_WYRMODEM);
slistp = get_spelllist(mage, u->faction); slistp = get_spelllist(mage, u->faction);
if (sp!=NULL && !has_spell(*slistp, sp) && sp->level<=sk) { if (sp!=NULL && !has_spell(*slistp, sp) && sp->level<=sk) {
add_spell(slistp, sp); add_spell(slistp, sp);
} }
case RC_DRAGON: case RC_DRAGON:
sp = find_spellbyid(M_GRAU, SPL_DRAGONODEM); sp = find_spellbyid(M_GRAY, SPL_DRAGONODEM);
slistp = get_spelllist(mage, u->faction); slistp = get_spelllist(mage, u->faction);
if (sp!=NULL && !has_spell(*slistp, sp) && sp->level<=sk) { if (sp!=NULL && !has_spell(*slistp, sp) && sp->level<=sk) {
add_spell(slistp, sp); add_spell(slistp, sp);
} }
case RC_FIREDRAGON: case RC_FIREDRAGON:
sp = find_spellbyid(M_GRAU, SPL_FIREDRAGONODEM); sp = find_spellbyid(M_GRAY, SPL_FIREDRAGONODEM);
slistp = get_spelllist(mage, u->faction); slistp = get_spelllist(mage, u->faction);
if (sp!=NULL && !has_spell(*slistp, sp) && sp->level<=sk) { if (sp!=NULL && !has_spell(*slistp, sp) && sp->level<=sk) {
add_spell(slistp, sp); add_spell(slistp, sp);
@ -493,15 +496,14 @@ updatespelllist(unit * u)
int sk = eff_skill(u, SK_MAGIC, u->region); int sk = eff_skill(u, SK_MAGIC, u->region);
spell_list * slist = spells; spell_list * slist = spells;
struct sc_mage * mage = get_mage(u); struct sc_mage * mage = get_mage(u);
magic_t gebiet = find_magetype(u);
boolean ismonster = is_monsters(u->faction); boolean ismonster = is_monsters(u->faction);
/* Magier mit keinem bzw M_GRAU bekommen weder Sprüche angezeigt noch /* Magier mit keinem bzw M_GRAY bekommen weder Sprüche angezeigt noch
* neue Sprüche in ihre List-of-known-spells. Das sind zb alle alten * neue Sprüche in ihre List-of-known-spells. Das sind zb alle alten
* Drachen, die noch den Skill Magie haben */ * Drachen, die noch den Skill Magie haben */
if (FactionSpells()) { if (FactionSpells()) {
spells = u->faction->spellbook; slist = u->faction->spellbook;
} }
for (;slist!=NULL;slist=slist->next) { for (;slist!=NULL;slist=slist->next) {
@ -509,7 +511,7 @@ updatespelllist(unit * u)
if (sp->level<=sk) { if (sp->level<=sk) {
boolean know = u_hasspell(u, sp); boolean know = u_hasspell(u, sp);
if (know || (gebiet!=M_GRAU && sp->magietyp == gebiet)) { if (know || know_school(u->faction, sp->magietyp)) {
faction * f = u->faction; faction * f = u->faction;
if (!know) add_spell(get_spelllist(mage, u->faction), sp); if (!know) add_spell(get_spelllist(mage, u->faction), sp);
@ -966,12 +968,14 @@ pay_spell(unit * u, const spell * sp, int cast_level, int range)
boolean boolean
knowsspell(const region * r, const unit * u, const spell * sp) knowsspell(const region * r, const unit * u, const spell * sp)
{ {
sc_mage * mage;
/* Ist überhaupt ein gültiger Spruch angegeben? */ /* Ist überhaupt ein gültiger Spruch angegeben? */
if (!sp || (sp->id == SPL_NOSPELL)) { if (!sp || (sp->id == SPL_NOSPELL)) {
return false; return false;
} }
/* Magier? */ /* Magier? */
if (get_mage(u) == NULL) { mage = get_mage(u);
if (mage == NULL) {
log_warning(("%s ist kein Magier, versucht aber zu zaubern.\n", log_warning(("%s ist kein Magier, versucht aber zu zaubern.\n",
unitname(u))); unitname(u)));
return false; return false;
@ -979,7 +983,7 @@ knowsspell(const region * r, const unit * u, const spell * sp)
/* steht der Spruch in der Spruchliste? */ /* steht der Spruch in der Spruchliste? */
if (!u_hasspell(u, sp)) { if (!u_hasspell(u, sp)) {
/* ist der Spruch aus einem anderen Magiegebiet? */ /* ist der Spruch aus einem anderen Magiegebiet? */
if (find_magetype(u) != sp->magietyp) { if (know_school(u->faction, sp->magietyp)) {
return false; return false;
} }
if (eff_skill(u, SK_MAGIC, u->region) >= sp->level) { if (eff_skill(u, SK_MAGIC, u->region) >= sp->level) {
@ -1326,7 +1330,7 @@ fumble(region * r, unit * u, const spell * sp, int cast_grade)
if (btype) patzer -= btype->fumblebonus; if (btype) patzer -= btype->fumblebonus;
/* CHAOSPATZERCHANCE 10 : +10% Chance zu Patzern */ /* CHAOSPATZERCHANCE 10 : +10% Chance zu Patzern */
if (sp->magietyp == M_CHAOS) { if (sp->magietyp == M_DRAIG) {
patzer += CHAOSPATZERCHANCE; patzer += CHAOSPATZERCHANCE;
} }
if (is_cursed(u->attribs, C_MBOOST, 0) == true) { if (is_cursed(u->attribs, C_MBOOST, 0) == true) {

View File

@ -83,16 +83,18 @@ typedef struct strarray {
/* typedef unsigned char magic_t; */ /* typedef unsigned char magic_t; */
enum { enum {
M_GRAU, /* none */ M_GRAY = 0, /* Gray */
M_TRAUM, /* Illaun */ M_ILLAUN = 1, /* Illaun */
M_ASTRAL, /* Tybied */ M_TYBIED = 2, /* Tybied */
M_BARDE, /* Cerddor */ M_CERDDOR = 3, /* Cerddor */
M_DRUIDE, /* Gwyrrd */ M_GWYRRD = 4, /* Gwyrrd */
M_CHAOS, /* Draig */ M_DRAIG = 5, /* Draig */
M_COMMON = 6, /* common spells */
MAXMAGIETYP, MAXMAGIETYP,
/* this enum is stored in the datafile, so do not change the numbers around */
M_NONE = (magic_t) -1 M_NONE = (magic_t) -1
}; };
extern const char *magietypen[MAXMAGIETYP]; extern const char *magic_school[MAXMAGIETYP];
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* Magier: /* Magier:
@ -262,8 +264,6 @@ sc_mage * create_mage(struct unit *u, magic_t mtyp);
* und initialisiert den Magiertypus mit mtyp. */ * und initialisiert den Magiertypus mit mtyp. */
sc_mage * get_mage(const struct unit *u); sc_mage * get_mage(const struct unit *u);
/* gibt u->mage zurück, bei nicht-Magiern *NULL */ /* gibt u->mage zurück, bei nicht-Magiern *NULL */
magic_t find_magetype(const struct unit *u);
/* gibt den Magietyp der struct unit zurück, bei nicht-Magiern 0 */
boolean is_mage(const struct unit *u); boolean is_mage(const struct unit *u);
/* gibt true, wenn u->mage gesetzt. */ /* gibt true, wenn u->mage gesetzt. */
boolean is_familiar(const struct unit *u); boolean is_familiar(const struct unit *u);

View File

@ -1323,7 +1323,7 @@ movement_speed(unit * u)
* Nicht kumulativ mit anderen Beschleunigungen! */ * Nicht kumulativ mit anderen Beschleunigungen! */
if (mp*dk <= BP_WALKING*u->race->speed && is_astral(u->region) && is_mage(u)) { if (mp*dk <= BP_WALKING*u->race->speed && is_astral(u->region) && is_mage(u)) {
sc_mage * mage = get_mage(u); sc_mage * mage = get_mage(u);
if (mage->magietyp == M_ASTRAL || mage->magietyp == M_TRAUM) { if (mage->magietyp == M_TYBIED || mage->magietyp == M_ILLAUN) {
mp *= 2; mp *= 2;
} }
} }

View File

@ -801,8 +801,9 @@ spskill(char * buffer, size_t size, const struct locale * lang, const struct uni
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
if (sv->id == SK_MAGIC){ if (sv->id == SK_MAGIC){
if (find_magetype(u) != M_GRAU){ sc_mage * mage = get_mage(u);
bytes = (int)strlcpy(bufp, LOC(lang, mkname("school", magietypen[find_magetype(u)])), size); if (mage && mage->magietyp != M_GRAY) {
bytes = (int)strlcpy(bufp, LOC(lang, mkname("school", magic_school[mage->magietyp])), size);
tsize += bytes; tsize += bytes;
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();

View File

@ -63,7 +63,7 @@ find_spell(magic_t mtype, const char * name)
while (slist) { while (slist) {
spell * sp = slist->data; spell * sp = slist->data;
if (strcmp(name, sp->sname)==0) { if (strcmp(name, sp->sname)==0) {
if (sp->magietyp==mtype) return sp; if (mtype==M_NONE || sp->magietyp==mtype) return sp;
spx = sp; spx = sp;
} }
slist = slist->next; slist = slist->next;
@ -180,7 +180,7 @@ find_spellbyid(magic_t mtype, spellid_t id)
spell* sp = slist->data; spell* sp = slist->data;
unsigned int hashid = hashstring(sp->sname); unsigned int hashid = hashstring(sp->sname);
if (hashid==id) { if (hashid==id) {
if (sp->magietyp==mtype || mtype==M_GRAU) { if (sp->magietyp==mtype || mtype==M_NONE) {
return sp; return sp;
} }
} }

View File

@ -1204,13 +1204,13 @@ add_spells(equipment * eq, xmlNodeSetPtr nsetItems)
for (i=0;i!=nsetItems->nodeNr;++i) { for (i=0;i!=nsetItems->nodeNr;++i) {
xmlNodePtr node = nsetItems->nodeTab[i]; xmlNodePtr node = nsetItems->nodeTab[i];
xmlChar * propValue; xmlChar * propValue;
magic_t mtype = M_GRAU; magic_t mtype = M_NONE;
struct spell * sp; struct spell * sp;
propValue = xmlGetProp(node, BAD_CAST "school"); propValue = xmlGetProp(node, BAD_CAST "school");
if (propValue!=NULL) { if (propValue!=NULL) {
for (mtype=0;mtype!=MAXMAGIETYP;++mtype) { for (mtype=0;mtype!=MAXMAGIETYP;++mtype) {
if (strcmp((const char*)propValue, magietypen[mtype])==0) break; if (strcmp((const char*)propValue, magic_school[mtype])==0) break;
} }
assert(mtype!=MAXMAGIETYP); assert(mtype!=MAXMAGIETYP);
xmlFree(propValue); xmlFree(propValue);
@ -1408,7 +1408,7 @@ parse_spells(xmlDocPtr doc)
propValue = xmlGetProp(node, BAD_CAST "type"); propValue = xmlGetProp(node, BAD_CAST "type");
assert(propValue!=NULL); assert(propValue!=NULL);
for (sp->magietyp=0;sp->magietyp!=MAXMAGIETYP;++sp->magietyp) { for (sp->magietyp=0;sp->magietyp!=MAXMAGIETYP;++sp->magietyp) {
if (strcmp(magietypen[sp->magietyp], (const char *)propValue)==0) break; if (strcmp(magic_school[sp->magietyp], (const char *)propValue)==0) break;
} }
assert(sp->magietyp!=MAXMAGIETYP); assert(sp->magietyp!=MAXMAGIETYP);
xmlFree(propValue); xmlFree(propValue);

View File

@ -200,7 +200,7 @@ age_hurting(attrib * a) {
if (b==NULL) return AT_AGE_REMOVE; if (b==NULL) return AT_AGE_REMOVE;
for (u=b->region->units;u;u=u->next) { for (u=b->region->units;u;u=u->next) {
if (u->building==b) { if (u->building==b) {
if (u->faction->magiegebiet==M_CHAOS) { if (u->faction->magiegebiet==M_DRAIG) {
active ++; active ++;
ADDMSG(&b->region->msgs, msg_message("praytoigjarjuk", "unit", u)); ADDMSG(&b->region->msgs, msg_message("praytoigjarjuk", "unit", u));
} }
@ -208,7 +208,7 @@ age_hurting(attrib * a) {
} }
if (active) for (u=b->region->units;u;u=u->next) if (playerrace(u->faction->race)) { if (active) for (u=b->region->units;u;u=u->next) if (playerrace(u->faction->race)) {
int i; int i;
if (u->faction->magiegebiet!=M_CHAOS) { if (u->faction->magiegebiet!=M_DRAIG) {
for (i=0;i!=active;++i) u->hp = (u->hp+1) / 2; /* make them suffer, but not die */ for (i=0;i!=active;++i) u->hp = (u->hp+1) / 2; /* make them suffer, but not die */
ADDMSG(&b->region->msgs, msg_message("cryinpain", "unit", u)); ADDMSG(&b->region->msgs, msg_message("cryinpain", "unit", u));
} }
@ -282,7 +282,7 @@ tower_init(void)
b->size = 10; b->size = 10;
if (i!=0) { if (i!=0) {
sprintf(buf, "Turm des %s", sprintf(buf, "Turm des %s",
LOC(default_locale, mkname("school", magietypen[i]))); LOC(default_locale, mkname("school", magic_school[i])));
} }
else sprintf(buf, "Turm der Ahnungslosen"); else sprintf(buf, "Turm der Ahnungslosen");
set_string(&b->name, buf); set_string(&b->name, buf);

View File

@ -38,7 +38,7 @@ oldfamiliars(unit * u)
/* these familiars have no special skills. /* these familiars have no special skills.
*/ */
snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]); snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]);
create_mage(u, M_GRAU); create_mage(u, M_GRAY);
equip_unit(u, get_equipment(fname)); equip_unit(u, get_equipment(fname));
} }

File diff suppressed because it is too large Load Diff

View File

@ -152,7 +152,7 @@ lua_initfamiliar(unit * u)
} }
snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]); snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]);
create_mage(u, M_GRAU); create_mage(u, M_GRAY);
equip_unit(u, get_equipment(fname)); equip_unit(u, get_equipment(fname));
} }

View File

@ -20,7 +20,7 @@ using namespace luabind;
static const char * static const char *
spell_getschool(const spell& sp) spell_getschool(const spell& sp)
{ {
return magietypen[sp.magietyp]; return magic_school[sp.magietyp];
} }
void void

View File

@ -422,7 +422,7 @@ static const char *
unit_getmagic(const unit * u) unit_getmagic(const unit * u)
{ {
sc_mage * mage = get_mage(u); sc_mage * mage = get_mage(u);
return mage?magietypen[mage->magietyp]:NULL; return mage?magic_school[mage->magietyp]:NULL;
} }
static void static void
@ -431,7 +431,7 @@ unit_setmagic(unit * u, const char * type)
sc_mage * mage = get_mage(u); sc_mage * mage = get_mage(u);
magic_t mtype; magic_t mtype;
for (mtype=0;mtype!=MAXMAGIETYP;++mtype) { for (mtype=0;mtype!=MAXMAGIETYP;++mtype) {
if (strcmp(magietypen[mtype], type)==0) break; if (strcmp(magic_school[mtype], type)==0) break;
} }
if (mtype==MAXMAGIETYP) return; if (mtype==MAXMAGIETYP) return;
if (mage==NULL) { if (mage==NULL) {

View File

@ -609,7 +609,7 @@ write_spells(void)
strcat(components, LOC(loc, spc->type->_name[0])); strcat(components, LOC(loc, spc->type->_name[0]));
strcat(components, ","); strcat(components, ",");
} }
fprintf(F, "%s;%d;%s;%s\n", LOC(loc, mkname("spell", sp->sname)), sp->level, LOC(loc, mkname("school", magietypen[sp->magietyp])), components); fprintf(F, "%s;%d;%s;%s\n", LOC(loc, mkname("spell", sp->sname)), sp->level, LOC(loc, mkname("school", magic_school[sp->magietyp])), components);
} }
fclose(F); fclose(F);
} }

View File

@ -218,7 +218,7 @@ static const char *
unit_getmagic(const unit * u) unit_getmagic(const unit * u)
{ {
sc_mage * mage = get_mage(u); sc_mage * mage = get_mage(u);
return mage?magietypen[mage->magietyp]:NULL; return mage?magic_school[mage->magietyp]:NULL;
} }
static int tolua_unit_get_magic(lua_State* tolua_S) static int tolua_unit_get_magic(lua_State* tolua_S)
@ -234,7 +234,7 @@ unit_setmagic(unit * u, const char * type)
sc_mage * mage = get_mage(u); sc_mage * mage = get_mage(u);
magic_t mtype; magic_t mtype;
for (mtype=0;mtype!=MAXMAGIETYP;++mtype) { for (mtype=0;mtype!=MAXMAGIETYP;++mtype) {
if (strcmp(magietypen[mtype], type)==0) break; if (strcmp(magic_school[mtype], type)==0) break;
} }
if (mtype==MAXMAGIETYP) return; if (mtype==MAXMAGIETYP) return;
if (mage==NULL) { if (mage==NULL) {

View File

@ -733,7 +733,7 @@ tolua_write_spells(lua_State* tolua_S)
if (sp->sp_function!=fun) { if (sp->sp_function!=fun) {
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST "spell"); xmlNodePtr node = xmlNewNode(NULL, BAD_CAST "spell");
xmlNewProp(node, BAD_CAST "name", BAD_CAST sp->sname); xmlNewProp(node, BAD_CAST "name", BAD_CAST sp->sname);
xmlNewProp(node, BAD_CAST "type", BAD_CAST magietypen[sp->magietyp]); xmlNewProp(node, BAD_CAST "type", BAD_CAST magic_school[sp->magietyp]);
xmlNewProp(node, BAD_CAST "rank", xml_i(sp->rank)); xmlNewProp(node, BAD_CAST "rank", xml_i(sp->rank));
xmlNewProp(node, BAD_CAST "level", xml_i(sp->level)); xmlNewProp(node, BAD_CAST "level", xml_i(sp->level));
xmlNewProp(node, BAD_CAST "index", xml_i(sp->id)); xmlNewProp(node, BAD_CAST "index", xml_i(sp->id));
@ -779,7 +779,7 @@ tolua_write_spells(lua_State* tolua_S)
static int static int
tolua_get_spell_text(lua_State *tolua_S) tolua_get_spell_text(lua_State *tolua_S)
{ {
const struct locale * loc = find_locale("en"); const struct locale * loc = default_locale;
spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0); spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0);
lua_pushstring(tolua_S, spell_info(self, loc)); lua_pushstring(tolua_S, spell_info(self, loc));
return 1; return 1;
@ -789,7 +789,7 @@ static int
tolua_get_spell_school(lua_State *tolua_S) tolua_get_spell_school(lua_State *tolua_S)
{ {
spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0); spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0);
lua_pushstring(tolua_S, magietypen[self->magietyp]); lua_pushstring(tolua_S, magic_school[self->magietyp]);
return 1; return 1;
} }
@ -804,8 +804,9 @@ tolua_get_spell_level(lua_State *tolua_S)
static int static int
tolua_get_spell_name(lua_State *tolua_S) tolua_get_spell_name(lua_State *tolua_S)
{ {
const struct locale * lang = default_locale;
spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0); spell * self = (spell *)tolua_tousertype(tolua_S, 1, 0);
lua_pushstring(tolua_S, self->sname); lua_pushstring(tolua_S, spell_name(self, lang));
return 1; return 1;
} }

View File

@ -244,7 +244,7 @@ lua_initfamiliar(unit * u)
lua_pop(L, 1); lua_pop(L, 1);
} }
create_mage(u, M_GRAU); create_mage(u, M_GRAY);
snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]); snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]);
equip_unit(u, get_equipment(fname)); equip_unit(u, get_equipment(fname));

View File

@ -4493,7 +4493,7 @@
</string> </string>
<string name="reanimate"> <string name="reanimate">
<text locale="de">Wiederbelebung</text> <text locale="de">Wiederbelebung</text>
<text locale="en">Ressurection</text> <text locale="en">Resurrection</text>
</string> </string>
<string name="analysedream"> <string name="analysedream">
<text locale="de">Traumbilder analysieren</text> <text locale="de">Traumbilder analysieren</text>
@ -4665,11 +4665,10 @@
</text> </text>
</string> </string>
<string name="song_of_slavery"> <string name="song_of_slavery">
<text locale="de"> <text locale="de">Dieser mächtige Bann raubt dem Opfer seinen freien Willen
Dieser mächtige Bann raubt dem Opfer seinen freien Willen und und unterwirft sie den Befehlen des Barden. Für einige Zeit wird das Opfer
unterwirft sie den Befehlen des Barden. Für einige Zeit wird das Opfer
sich völlig von seinen eigenen Leuten abwenden und der Partei des Barden sich völlig von seinen eigenen Leuten abwenden und der Partei des Barden
zugehörig fühlen." zugehörig fühlen.
</text> </text>
</string> </string>
<string name="song_of_peace"> <string name="song_of_peace">
@ -6668,6 +6667,10 @@
</namespace> </namespace>
<namespace name="school"> <namespace name="school">
<string name="common">
<text locale="de">Gemein</text>
<text locale="en">common</text>
</string>
<string name="nomagic"> <string name="nomagic">
<text locale="de">Kein Magiegebiet</text> <text locale="de">Kein Magiegebiet</text>
<text locale="en">no magic school yet</text> <text locale="en">no magic school yet</text>

View File

@ -126,6 +126,8 @@
<param name="rules.cavalry.skill" value="4"/> <param name="rules.cavalry.skill" value="4"/>
<param name="rules.cavalry.mode" value="1"/> <param name="rules.cavalry.mode" value="1"/>
<param name="rules.magic.factionlist" value="1"/> <param name="rules.magic.factionlist" value="1"/>
<param name="rules.magic.common" value="tybied"/> <!-- tybied spells can be cast by anyone -->
<param name="rules.magic.playerschools" value="gwyrrd illaun draig cerddor"/>
<param name="rules.economy.taxation" value="1"/> <param name="rules.economy.taxation" value="1"/>
<param name="rules.give" value="3"/> <!-- only self + peasants --> <param name="rules.give" value="3"/> <!-- only self + peasants -->
<param name="rules.help.mask" value="fight guard money"/> <param name="rules.help.mask" value="fight guard money"/>

File diff suppressed because it is too large Load Diff

View File

@ -255,7 +255,7 @@ local function test_spells()
u:clear_orders() u:clear_orders()
u:add_item("money", 10000) u:add_item("money", 10000)
u:set_skill("magic", 5) u:set_skill("magic", 5)
u:add_order("LERNE MAGIE Tybied") u:add_order("LERNE MAGIE Illaun")
process_orders() process_orders()
local sp local sp
local nums = 0 local nums = 0
@ -264,6 +264,7 @@ local function test_spells()
nums = nums + 1 nums = nums + 1
end end
end end
assert(nums>0)
for sp in u.spells do for sp in u.spells do
nums = nums - 1 nums = nums - 1
end end
@ -312,8 +313,6 @@ local function test_alliance()
assert(f1.alliance~=nil) assert(f1.alliance~=nil)
assert(f2.alliance~=nil) assert(f2.alliance~=nil)
assert(f2.alliance==f1.alliance) assert(f2.alliance==f1.alliance)
print(u1)
print(u2)
u1:clear_orders() u1:clear_orders()
u2:clear_orders() u2:clear_orders()
u2:add_order("ALLIANZ AUSSTOSSEN " .. itoa36(f1.id)) u2:add_order("ALLIANZ AUSSTOSSEN " .. itoa36(f1.id))
@ -337,6 +336,15 @@ local function test_alliance()
assert(f2.alliance~=nil) assert(f2.alliance~=nil)
end end
local function spells_csv()
local f = io.open("spells.csv", "w")
for sp in spells() do
f:write('"' .. sp.name .. '",' .. sp.level .. ',' .. sp.school .. ',"' .. sp.text .. '"\n')
end
f:close()
fail = 1
end
loadscript("extensions.lua") loadscript("extensions.lua")
tests = { tests = {
["alliance"] = test_alliance, ["alliance"] = test_alliance,
@ -356,7 +364,6 @@ tests = {
["spells"] = test_spells ["spells"] = test_spells
} }
mytests = { mytests = {
["spells"] = test_spells
} }
fail = 0 fail = 0
for k, v in pairs(tests) do for k, v in pairs(tests) do
@ -369,6 +376,8 @@ for k, v in pairs(tests) do
end end
end end
-- spells_csv()
if fail > 0 then if fail > 0 then
print(fail .. " tests failed.") print(fail .. " tests failed.")
io.stdin:read() io.stdin:read()