earn_silver Zauber in script/xml ausgelagert.

bugfix snowman
avoid huge amounts of log-messages
handle renaming of spells.
This commit is contained in:
Enno Rehling 2006-02-05 15:48:52 +00:00
parent 77602d1316
commit 640652ef99
20 changed files with 251 additions and 267 deletions

View File

@ -1478,7 +1478,7 @@ do_combatmagic(battle *b, combatmagic_t was)
} }
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) { for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
for (co = cll[spellrank]; co; co = co->next) { for (co = cll[spellrank]; co; co = co->next) {
fighter * fig = (fighter*)co->magician; fighter * fig = co->magician.fig;
const spell * sp = co->sp; const spell * sp = co->sp;
int level = co->level; int level = co->level;
double power = co->force; double power = co->force;

View File

@ -202,6 +202,7 @@ static int
read_mage(attrib * a, FILE * F) read_mage(attrib * a, FILE * F)
{ {
int i, mtype; int i, mtype;
boolean update = false;
sc_mage * mage = (sc_mage*)a->data.v; sc_mage * mage = (sc_mage*)a->data.v;
char spname[64]; char spname[64];
@ -234,7 +235,11 @@ read_mage(attrib * a, FILE * F)
if (strcmp(spname, "end")==0) break; if (strcmp(spname, "end")==0) break;
sp = find_spell(mage->magietyp, spname); sp = find_spell(mage->magietyp, spname);
} }
if (sp==NULL) continue; if (sp==NULL) {
/* flag upstream to show that updatespellist() is necessary (hackish) */
mage->spellcount = -1;
continue;
}
add_spell(mage, sp); add_spell(mage, sp);
} }
return AT_READ_OK; return AT_READ_OK;
@ -373,7 +378,7 @@ read_seenspell(attrib * a, FILE * f)
sp = find_spell((magic_t)mtype, buf); sp = find_spell((magic_t)mtype, buf);
} }
if (sp==NULL) { if (sp==NULL) {
log_error(("could not find seenspell '%s'\n", buf)); /* log_error(("could not find seenspell '%s'\n", buf)); */
return AT_READ_FAIL; return AT_READ_FAIL;
} }
a->data.v = sp; a->data.v = sp;
@ -1275,7 +1280,7 @@ fumble(region * r, unit * u, const spell * sp, int cast_grade)
static void static void
patzer(castorder *co) patzer(castorder *co)
{ {
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
cmistake(mage, co->order, 180, MSG_MAGIC); cmistake(mage, co->order, 180, MSG_MAGIC);
@ -1290,7 +1295,7 @@ do_fumble(castorder *co)
{ {
curse * c; curse * c;
region * r = co->rt; region * r = co->rt;
unit * u = (unit*)co->magician; unit * u = co->magician.u;
const spell *sp = co->sp; const spell *sp = co->sp;
int level = co->level; int level = co->level;
int duration; int duration;
@ -1558,7 +1563,7 @@ verify_unit(region * r, unit * mage, const spell * sp, spllprm * spobj, order *
static int static int
verify_targets(castorder *co) verify_targets(castorder *co)
{ {
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
const spell *sp = co->sp; const spell *sp = co->sp;
region *target_r = co->rt; region *target_r = co->rt;
spellparameter *sa = co->par; spellparameter *sa = co->par;
@ -2009,7 +2014,7 @@ new_castorder(void *u, unit *u2, const spell *sp, region *r, int lev,
castorder *corder; castorder *corder;
corder = calloc(1, sizeof(castorder)); corder = calloc(1, sizeof(castorder));
corder->magician = u; corder->magician.u = u;
corder->familiar = u2; corder->familiar = u2;
corder->sp = sp; corder->sp = sp;
corder->level = lev; corder->level = lev;
@ -2680,7 +2685,7 @@ magic(void)
order * ord = co->order; order * ord = co->order;
int verify, cast_level = co->level; int verify, cast_level = co->level;
boolean fumbled = false; boolean fumbled = false;
unit * u = (unit *)co->magician; unit * u = co->magician.u;
const spell *sp = co->sp; const spell *sp = co->sp;
region * target_r = co->rt; region * target_r = co->rt;

View File

@ -124,7 +124,10 @@ typedef struct sc_mage {
typedef struct castorder { typedef struct castorder {
struct castorder *next; struct castorder *next;
void *magician; /* Magier (kann vom Typ struct unit oder fighter sein) */ union {
struct unit * u;
struct fighter * fig;
} magician; /* Magier (kann vom Typ struct unit oder fighter sein) */
struct unit *familiar; /* Vertrauter, gesetzt, wenn der Spruch durch struct unit *familiar; /* Vertrauter, gesetzt, wenn der Spruch durch
den Vertrauten gezaubert wird */ den Vertrauten gezaubert wird */
const struct spell *sp; /* Spruch */ const struct spell *sp; /* Spruch */

View File

@ -1110,8 +1110,8 @@ readunit(FILE * F)
if (i != -1){ if (i != -1){
attrib * a; attrib * a;
int csp = 0; int csp = 0;
sc_mage * mage = calloc(1, sizeof(sc_mage)); sc_mage * mage = calloc(1, sizeof(sc_mage));
mage->magietyp = (magic_t) i; mage->magietyp = (magic_t) i;
mage->spellpoints = ri(F); mage->spellpoints = ri(F);
mage->spchange = ri(F); mage->spchange = ri(F);
@ -1878,10 +1878,16 @@ readgame(const char * filename, int backup)
while (--p >= 0) { while (--p >= 0) {
unit * u = readunit(F); unit * u = readunit(F);
sc_mage * mage;
assert(u->region==NULL); assert(u->region==NULL);
u->region = r; u->region = r;
addlist2(up,u); addlist2(up,u);
update_interval(u->faction, u->region); update_interval(u->faction, u->region);
mage = get_mage(u);
if (mage && mage->spellcount<0) {
mage->spellcount = 0;
updatespelllist(u);
}
} }
} }
printf("\n"); printf("\n");

View File

@ -53,8 +53,6 @@ extern int lastturn(void);
extern void read_items(FILE *f, struct item **it); extern void read_items(FILE *f, struct item **it);
extern void write_items(FILE *f, struct item *it); extern void write_items(FILE *f, struct item *it);
extern void a_read(FILE * f, struct attrib ** attribs);
extern void a_write(FILE * f, const struct attrib * attribs);
extern const char * datapath(void); extern const char * datapath(void);

View File

@ -57,7 +57,7 @@ register_spell(spell * sp)
spelllist_add(&spells, sp); spelllist_add(&spells, sp);
} }
/** versucht einen Spruch über gebiet + bame zu identifizieren. /** versucht einen Spruch über gebiet + name zu identifizieren.
* gibt ansonsten NULL zurück */ * gibt ansonsten NULL zurück */
spell * spell *
find_spell(magic_t mtype, const char * name) find_spell(magic_t mtype, const char * name)

View File

@ -149,13 +149,8 @@ enum {
SPL_SPARKLE_CHAOS, SPL_SPARKLE_CHAOS,
SPL_SPARKLE_DREAM = 154, SPL_SPARKLE_DREAM = 154,
SPL_PULLASTRAL = 156, SPL_PULLASTRAL = 156,
SPL_FETCHASTRAL, SPL_FETCHASTRAL = 157,
SPL_ILLAUN_EARN_SILVER, SPL_SHOCKWAVE = 163,
SPL_GWYRRD_EARN_SILVER,
SPL_DRAIG_EARN_SILVER,
SPL_TYBIED_EARN_SILVER,
SPL_CERDDOR_EARN_SILVER,
SPL_SHOCKWAVE,
SPL_UNDEADHERO = 164, SPL_UNDEADHERO = 164,
SPL_BECOMEWYRM = 166, SPL_BECOMEWYRM = 166,
SPL_ETERNIZEWALL, SPL_ETERNIZEWALL,

View File

@ -1211,6 +1211,7 @@ parse_spells(xmlDocPtr doc)
if (xml_bvalue(node, "ship", false)) sp->sptyp |= ONSHIPCAST; if (xml_bvalue(node, "ship", false)) sp->sptyp |= ONSHIPCAST;
if (xml_bvalue(node, "ocean", false)) sp->sptyp |= OCEANCASTABLE; if (xml_bvalue(node, "ocean", false)) sp->sptyp |= OCEANCASTABLE;
if (xml_bvalue(node, "far", false)) sp->sptyp |= FARCASTING; if (xml_bvalue(node, "far", false)) sp->sptyp |= FARCASTING;
if (xml_bvalue(node, "variable", false)) sp->sptyp |= SPELLLEVEL;
if (gamecode_enabled) { if (gamecode_enabled) {
/* reading eressea/spells/spell/function */ /* reading eressea/spells/spell/function */

View File

@ -91,7 +91,7 @@ sp_summon_alp(struct castorder *co)
{ {
unit *alp, *opfer; unit *alp, *opfer;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;

View File

@ -569,7 +569,7 @@ sp_summon_familiar(castorder *co)
unit *familiar; unit *familiar;
region *r = co->rt; region *r = co->rt;
region *target_region = co->rt; region *target_region = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
const race * rc; const race * rc;
skill_t sk; skill_t sk;
@ -672,7 +672,7 @@ sp_summon_familiar(castorder *co)
static int static int
sp_destroy_magic(castorder *co) sp_destroy_magic(castorder *co)
{ {
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -763,7 +763,7 @@ static int
sp_transferaura(castorder *co) sp_transferaura(castorder *co)
{ {
int aura, gain, multi = 2; int aura, gain, multi = 2;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
unit * u; unit * u;
@ -831,7 +831,7 @@ static int
sp_goodwinds(castorder *co) sp_goodwinds(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = cast_level+1; int duration = cast_level+1;
@ -886,7 +886,7 @@ static int
sp_magicstreet(castorder *co) sp_magicstreet(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
if (!fval(r->terrain, LAND_REGION)) { if (!fval(r->terrain, LAND_REGION)) {
cmistake(mage, co->order, 186, MSG_MAGIC); cmistake(mage, co->order, 186, MSG_MAGIC);
@ -927,7 +927,7 @@ static int
sp_summonent(castorder *co) sp_summonent(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
unit *u; unit *u;
@ -982,7 +982,7 @@ sp_blessstonecircle(castorder *co)
{ {
building *b; building *b;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *p = co->par; spellparameter *p = co->par;
@ -1029,7 +1029,7 @@ static int
sp_maelstrom(castorder *co) sp_maelstrom(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
curse * c; curse * c;
double power = co->force; double power = co->force;
@ -1077,7 +1077,7 @@ sp_mallorn(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
int cast_level = co->level; int cast_level = co->level;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
if (!fval(r->terrain, LAND_REGION)) { if (!fval(r->terrain, LAND_REGION)) {
cmistake(mage, co->order, 290, MSG_MAGIC); cmistake(mage, co->order, 290, MSG_MAGIC);
@ -1122,7 +1122,7 @@ static int
sp_blessedharvest(castorder *co) sp_blessedharvest(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = (int)power+1; int duration = (int)power+1;
@ -1162,7 +1162,7 @@ sp_hain(castorder *co)
{ {
int trees; int trees;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
@ -1207,7 +1207,7 @@ sp_mallornhain(castorder *co)
{ {
int trees; int trees;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
@ -1241,7 +1241,7 @@ patzer_ents(castorder *co)
int ents; int ents;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
/* int cast_level = co->level; */ /* int cast_level = co->level; */
double force = co->force; double force = co->force;
@ -1306,7 +1306,7 @@ sp_rosthauch(castorder *co)
int n; int n;
int success = 0; int success = 0;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
int force = (int)co->force; int force = (int)co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -1401,7 +1401,7 @@ sp_kaelteschutz(castorder *co)
int n, i = 0; int n, i = 0;
int men; int men;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = max(cast_level, (int)force) + 1; int duration = max(cast_level, (int)force) + 1;
@ -1462,7 +1462,7 @@ static int
sp_sparkle(castorder *co) sp_sparkle(castorder *co)
{ {
unit *u; unit *u;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int duration = cast_level+1; int duration = cast_level+1;
@ -1522,7 +1522,7 @@ sp_create_irongolem(castorder *co)
unit *u2; unit *u2;
attrib *a; attrib *a;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int number = lovar(force*8*RESOURCE_QUANTITY); int number = lovar(force*8*RESOURCE_QUANTITY);
@ -1585,7 +1585,7 @@ sp_create_stonegolem(castorder *co)
unit *u2; unit *u2;
attrib *a; attrib *a;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
int number = lovar(co->force*5*RESOURCE_QUANTITY); int number = lovar(co->force*5*RESOURCE_QUANTITY);
if (number<1) number = 1; if (number<1) number = 1;
@ -1649,7 +1649,7 @@ sp_great_drought(castorder *co)
unit *u; unit *u;
boolean terraform = false; boolean terraform = false;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = 2; int duration = 2;
@ -1781,7 +1781,7 @@ static int
sp_treewalkenter(castorder *co) sp_treewalkenter(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
spellparameter *pa = co->par; spellparameter *pa = co->par;
double power = co->force; double power = co->force;
int cast_level = co->level; int cast_level = co->level;
@ -1874,7 +1874,7 @@ sp_treewalkexit(castorder *co)
int n; int n;
int erfolg = 0; int erfolg = 0;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int cast_level = co->level; int cast_level = co->level;
@ -1996,7 +1996,7 @@ static int
sp_holyground(castorder *co) sp_holyground(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
curse * c; curse * c;
@ -2032,7 +2032,7 @@ sp_homestone(castorder *co)
unit *u; unit *u;
curse * c; curse * c;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
variant effect; variant effect;
@ -2095,7 +2095,7 @@ sp_drought(castorder *co)
curse *c; curse *c;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = (int)power+1; int duration = (int)power+1;
@ -2163,7 +2163,7 @@ sp_fog_of_confusion(castorder *co)
{ {
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
double range; double range;
@ -2237,7 +2237,7 @@ sp_ironkeeper(castorder *co)
{ {
unit *keeper; unit *keeper;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
if (rterrain(r) != T_MOUNTAIN && rterrain(r) != T_GLACIER) { if (rterrain(r) != T_MOUNTAIN && rterrain(r) != T_GLACIER) {
@ -2290,7 +2290,7 @@ sp_stormwinds(castorder *co)
unit *u; unit *u;
int erfolg = 0; int erfolg = 0;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int n, force = (int)power; int n, force = (int)power;
@ -2373,7 +2373,7 @@ sp_earthquake(castorder *co)
building *burg; building *burg;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
for (burg = r->buildings; burg; burg = burg->next){ for (burg = r->buildings; burg; burg = burg->next){
@ -2430,7 +2430,7 @@ patzer_peasantmob(castorder *co)
unit *u; unit *u;
attrib *a; attrib *a;
region *r; region *r;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
if (mage->region->land){ if (mage->region->land){
r = mage->region; r = mage->region;
@ -2499,7 +2499,7 @@ sp_forest_fire(castorder *co)
region *nr; region *nr;
direction_t i; direction_t i;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double probability; double probability;
double percentage = (rand() % 8 + 1) * 0.1; /* 10 - 80% */ double percentage = (rand() % 8 + 1) * 0.1; /* 10 - 80% */
@ -2594,7 +2594,7 @@ sp_fumblecurse(castorder *co)
unit *target; unit *target;
int rx, sx; int rx, sx;
int duration; int duration;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
variant effect; variant effect;
@ -2628,7 +2628,7 @@ sp_fumblecurse(castorder *co)
void void
patzer_fumblecurse(castorder *co) patzer_fumblecurse(castorder *co)
{ {
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = (cast_level/2)+1; int duration = (cast_level/2)+1;
@ -2669,7 +2669,7 @@ static int
sp_summondragon(castorder *co) sp_summondragon(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
unit *u; unit *u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
@ -2954,7 +2954,7 @@ sp_firewall(castorder *co)
wall_data * fd; wall_data * fd;
attrib * a; attrib * a;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -3066,7 +3066,7 @@ sp_wisps(castorder *co)
region * r2; region * r2;
direction_t dir; direction_t dir;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -3116,7 +3116,7 @@ sp_wisps(castorder *co)
static int static int
sp_unholypower(castorder *co) sp_unholypower(castorder *co)
{ {
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int i; int i;
@ -3326,7 +3326,7 @@ static int
sp_deathcloud(castorder *co) sp_deathcloud(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
attrib *a = a_find(r->attribs, &at_deathcloud); attrib *a = a_find(r->attribs, &at_deathcloud);
@ -3343,7 +3343,7 @@ sp_deathcloud(castorder *co)
void void
patzer_deathcloud(castorder *co) patzer_deathcloud(castorder *co)
{ {
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int hp = (mage->hp - 2); int hp = (mage->hp - 2);
change_hitpoints(mage, -rand()%hp); change_hitpoints(mage, -rand()%hp);
@ -3369,7 +3369,7 @@ static int
sp_plague(castorder *co) sp_plague(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
plagues(r, true); plagues(r, true);
@ -3399,7 +3399,7 @@ static int
sp_summonshadow(castorder *co) sp_summonshadow(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
unit *u; unit *u;
@ -3442,7 +3442,7 @@ sp_summonshadowlords(castorder *co)
{ {
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
@ -3476,7 +3476,7 @@ sp_chaossuction(castorder *co)
region *rt; region *rt;
faction *f; faction *f;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
if (getplane(r)!=get_normalplane()) { if (getplane(r)!=get_normalplane()) {
@ -3547,7 +3547,7 @@ static int
sp_magicboost(castorder *co) sp_magicboost(castorder *co)
{ {
curse * c; curse * c;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
variant effect; variant effect;
@ -3608,7 +3608,7 @@ sp_magicboost(castorder *co)
static int static int
sp_bloodsacrifice(castorder *co) sp_bloodsacrifice(castorder *co)
{ {
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
int aura; int aura;
int skill = eff_skill(mage, SK_MAGIC, mage->region); int skill = eff_skill(mage, SK_MAGIC, mage->region);
@ -3666,7 +3666,7 @@ sp_summonundead(castorder *co)
int undead; int undead;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
int force = (int)(co->force*10); int force = (int)(co->force*10);
const race * race = new_race[RC_SKELETON]; const race * race = new_race[RC_SKELETON];
@ -3731,7 +3731,7 @@ sp_auraleak(castorder *co)
double lost; double lost;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
lost = min(0.95, cast_level * 0.05); lost = min(0.95, cast_level * 0.05);
@ -3786,7 +3786,7 @@ sp_babbler(castorder *co)
{ {
unit *target; unit *target;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -3841,7 +3841,7 @@ sp_analysesong_obj(castorder *co)
{ {
int obj; int obj;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -3891,7 +3891,7 @@ static int
sp_analysesong_unit(castorder *co) sp_analysesong_unit(castorder *co)
{ {
unit *u; unit *u;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -3941,7 +3941,7 @@ sp_charmingsong(castorder *co)
unit *target; unit *target;
int duration; int duration;
skill_t i; skill_t i;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -4027,7 +4027,7 @@ sp_song_resistmagic(castorder *co)
{ {
variant mr_bonus; variant mr_bonus;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = (int)force+1; int duration = (int)force+1;
@ -4059,7 +4059,7 @@ sp_song_susceptmagic(castorder *co)
{ {
variant mr_malus; variant mr_malus;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = (int)force+1; int duration = (int)force+1;
@ -4091,7 +4091,7 @@ sp_rallypeasantmob(castorder *co)
unit *u, *un; unit *u, *un;
int erfolg = 0; int erfolg = 0;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
/* TODO /* TODO
@ -4160,7 +4160,7 @@ sp_raisepeasantmob(castorder *co)
int n; int n;
variant anteil; variant anteil;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = (int)force+1; int duration = (int)force+1;
@ -4225,7 +4225,7 @@ sp_migranten(castorder *co)
order * ord; order * ord;
int kontaktiert = 0; int kontaktiert = 0;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
const spell *sp = co->sp; const spell *sp = co->sp;
@ -4332,7 +4332,7 @@ sp_song_of_peace(castorder *co)
{ {
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = 2 + lovar(force/2); int duration = 2 + lovar(force/2);
@ -4373,7 +4373,7 @@ sp_generous(castorder *co)
{ {
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = (int)force+1; int duration = (int)force+1;
@ -4424,7 +4424,7 @@ sp_recruit(castorder *co)
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
int n, maxp = rpeasants(r); int n, maxp = rpeasants(r);
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
faction *f = mage->faction; faction *f = mage->faction;
@ -4477,7 +4477,7 @@ sp_bigrecruit(castorder *co)
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
int n, maxp = rpeasants(r); int n, maxp = rpeasants(r);
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
faction *f = mage->faction; faction *f = mage->faction;
@ -4530,7 +4530,7 @@ sp_pump(castorder *co)
region *rt; region *rt;
boolean see = false; boolean see = false;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int cast_level = co->level; int cast_level = co->level;
const spell *sp = co->sp; const spell *sp = co->sp;
@ -4600,7 +4600,7 @@ sp_seduce(castorder *co)
int loot; int loot;
item **itmp; item **itmp;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int cast_level = co->level; int cast_level = co->level;
const spell *sp = co->sp; const spell *sp = co->sp;
@ -4682,7 +4682,7 @@ sp_calm_monster(castorder *co)
curse * c; curse * c;
unit *target; unit *target;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
@ -4737,7 +4737,7 @@ sp_headache(castorder *co)
int i; int i;
unit *target; unit *target;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
spellparameter *pa = co->par; spellparameter *pa = co->par;
int cast_level = co->level; int cast_level = co->level;
@ -4795,7 +4795,7 @@ sp_raisepeasants(castorder *co)
unit *u, *u2; unit *u, *u2;
attrib *a; attrib *a;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
@ -4847,7 +4847,7 @@ sp_depression(castorder *co)
{ {
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = (int)force+1; int duration = (int)force+1;
@ -4885,7 +4885,7 @@ static int
sp_dragonsong(castorder *co) sp_dragonsong(castorder *co)
{ {
region *r = co->rt; /* Zauberregion */ region *r = co->rt; /* Zauberregion */
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
unit *u; unit *u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
@ -4939,7 +4939,7 @@ static int
sp_songofAttraction(castorder *co) sp_songofAttraction(castorder *co)
{ {
region *r = co->rt; /* Zauberregion */ region *r = co->rt; /* Zauberregion */
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
/* double power = co->force; */ /* double power = co->force; */
@ -4971,7 +4971,7 @@ int
sp_puttorest(castorder *co) sp_puttorest(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int dead = deathcount(r); int dead = deathcount(r);
int laid_to_rest = dice((int)(co->force * 2), 100); int laid_to_rest = dice((int)(co->force * 2), 100);
message * seen = msg_message("puttorest", "mage", mage); message * seen = msg_message("puttorest", "mage", mage);
@ -5005,7 +5005,7 @@ sp_icastle(castorder *co)
const building_type * type; const building_type * type;
attrib *a; attrib *a;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5069,7 +5069,7 @@ sp_illusionary_shapeshift(castorder *co)
unit *u; unit *u;
const race * rc; const race * rc;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5129,7 +5129,7 @@ int
sp_readmind(castorder *co) sp_readmind(castorder *co)
{ {
unit *target; unit *target;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5171,7 +5171,7 @@ int
sp_analyseregionsdream(castorder *co) sp_analyseregionsdream(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
magicanalyse_region(r, mage, cast_level); magicanalyse_region(r, mage, cast_level);
@ -5195,7 +5195,7 @@ int
sp_analysedream(castorder *co) sp_analysedream(castorder *co)
{ {
unit *u; unit *u;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5229,7 +5229,7 @@ int
sp_baddreams(castorder *co) sp_baddreams(castorder *co)
{ {
int duration; int duration;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
region *r = co->rt; region *r = co->rt;
@ -5272,7 +5272,7 @@ sp_gooddreams(castorder *co)
int duration; int duration;
curse * c; curse * c;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
variant effect; variant effect;
@ -5310,7 +5310,7 @@ sp_clonecopy(castorder *co)
unit *clone; unit *clone;
region *r = co->rt; region *r = co->rt;
region *target_region = co->rt; region *target_region = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
if (get_clone(mage) != NULL ) { if (get_clone(mage) != NULL ) {
@ -5337,7 +5337,7 @@ sp_dreamreading(castorder *co)
{ {
unit *u,*u2; unit *u,*u2;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
double power = co->force; double power = co->force;
@ -5385,7 +5385,7 @@ int
sp_sweetdreams(castorder *co) sp_sweetdreams(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5432,7 +5432,7 @@ int
sp_disturbingdreams(castorder *co) sp_disturbingdreams(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = 1 + (int)(power/6); int duration = 1 + (int)(power/6);
@ -5456,7 +5456,7 @@ sp_dream_of_confusion(castorder *co)
unit *u; unit *u;
region_list *rl,*rl2; region_list *rl,*rl2;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
double range = (power-14)/2-1; double range = (power-14)/2-1;
@ -5522,7 +5522,7 @@ int
sp_analysemagic(castorder *co) sp_analysemagic(castorder *co)
{ {
int obj; int obj;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5572,7 +5572,7 @@ int
sp_itemcloak(castorder *co) sp_itemcloak(castorder *co)
{ {
unit *target; unit *target;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = (int)power+1; int duration = (int)power+1;
@ -5613,7 +5613,7 @@ sp_resist_magic_bonus(castorder *co)
int n, m, opfer; int n, m, opfer;
variant resistbonus; variant resistbonus;
int duration = 6; int duration = 6;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5676,7 +5676,7 @@ sp_enterastral(castorder *co)
int remaining_cap; int remaining_cap;
int n, w; int n, w;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5791,7 +5791,7 @@ sp_pullastral(castorder *co)
int remaining_cap; int remaining_cap;
int n, w; int n, w;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -5918,7 +5918,7 @@ sp_leaveastral(castorder *co)
int remaining_cap; int remaining_cap;
int n, w; int n, w;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -6033,7 +6033,7 @@ int
sp_fetchastral(castorder *co) sp_fetchastral(castorder *co)
{ {
int n; int n;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
double power = co->force; double power = co->force;
@ -6143,7 +6143,7 @@ sp_showastral(castorder *co)
int c = 0; int c = 0;
region_list *rl, *rl2; region_list *rl, *rl2;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
@ -6232,7 +6232,7 @@ sp_viewreality(castorder *co)
region_list *rl, *rl2; region_list *rl, *rl2;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
if(getplaneid(r) != 1) { if(getplaneid(r) != 1) {
@ -6273,7 +6273,7 @@ sp_disruptastral(castorder *co)
region *rt; region *rt;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = (int)(power/3)+1; int duration = (int)(power/3)+1;
@ -6379,7 +6379,7 @@ sp_eternizewall(castorder *co)
curse * c; curse * c;
building *b; building *b;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -6440,7 +6440,7 @@ sp_permtransfer(castorder *co)
int aura; int aura;
unit *tu; unit *tu;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
const spell *sp = co->sp; const spell *sp = co->sp;
@ -6490,7 +6490,7 @@ sp_movecastle(castorder *co)
region *target_region; region *target_region;
unit *u, *unext; unit *u, *unext;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
spellparameter *pa = co->par; spellparameter *pa = co->par;
const spell *sp = co->sp; const spell *sp = co->sp;
@ -6584,7 +6584,7 @@ sp_flying_ship(castorder *co)
ship *sh; ship *sh;
unit *u; unit *u;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -6649,7 +6649,7 @@ sp_stealaura(castorder *co)
{ {
int taura; int taura;
unit *u; unit *u;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -6720,7 +6720,7 @@ sp_antimagiczone(castorder *co)
double power; double power;
variant effect; variant effect;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = (int)force+1; int duration = (int)force+1;
@ -6779,7 +6779,7 @@ static int
sp_magicrunes(castorder *co) sp_magicrunes(castorder *co)
{ {
int duration; int duration;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -6840,7 +6840,7 @@ sp_speed2(castorder *co)
{ {
int n, maxmen, used = 0, dur, men; int n, maxmen, used = 0, dur, men;
unit *u; unit *u;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -6901,7 +6901,7 @@ sp_q_antimagie(castorder *co)
curse * c = NULL; curse * c = NULL;
int succ; int succ;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -6983,7 +6983,7 @@ sp_destroy_curse(castorder *co)
int obj; int obj;
curse * c; curse * c;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -7072,7 +7072,7 @@ sp_destroy_curse(castorder *co)
int int
sp_becomewyrm(castorder *co) sp_becomewyrm(castorder *co)
{ {
unit *u = (unit *)co->magician; unit *u = co->magician.u;
int wyrms_already_created = 0; int wyrms_already_created = 0;
int wyrms_allowed; int wyrms_allowed;
attrib *a; attrib *a;
@ -7115,7 +7115,7 @@ static int
sp_wdwpyramid(castorder *co) sp_wdwpyramid(castorder *co)
{ {
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
if(a_find(r->attribs, &at_wdwpyramid) != NULL) { if(a_find(r->attribs, &at_wdwpyramid) != NULL) {
@ -7149,32 +7149,6 @@ sp_wdwpyramid(castorder *co)
return cast_level; return cast_level;
} }
/* ------------------------------------------------------------- */
/* Name: Alltagszauber, hat je nach Gebiet anderen Namen
* Stufe: 1
* Gebiet: alle
* Wirkung: der Magier verdient $50 pro Spruchstufe
* Kosten: 1 SP pro Stufe
*/
#include "../gamecode/economy.h"
/* TODO: das ist scheisse, aber spells gehören eh nicht in den kernel */
int
sp_earn_silver(castorder *co)
{
unit *mage = (unit *)co->magician;
double force = co->force;
region *r = co->rt;
int wanted = (int)(force * 50);
int earned = min(rmoney(r), wanted);
rsetmoney(r, rmoney(r) - earned);
change_money(mage, earned);
/* TODO klären: ist das Silber damit schon reserviert? */
add_income(mage, IC_MAGIC, wanted, earned);
return co->level;
}
typedef struct spelldata { typedef struct spelldata {
spellid_t id; spellid_t id;
const char *sname; const char *sname;
@ -7211,21 +7185,6 @@ static spelldata spelldaten[] =
}, },
(spell_f)sp_blessedharvest, NULL (spell_f)sp_blessedharvest, NULL
}, },
{
SPL_GWYRRD_EARN_SILVER, "gwyrrdearnsilver", NULL,
NULL, NULL,
M_DRUIDE,
(SPELLLEVEL|ONSHIPCAST),
5, 1,
{
{ "aura", 1, SPC_LEVEL },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 }
},
(spell_f)sp_earn_silver, NULL
},
{ {
SPL_STONEGOLEM, "stonegolem", NULL, NULL, NULL, SPL_STONEGOLEM, "stonegolem", NULL, NULL, NULL,
M_DRUIDE, (SPELLLEVEL), 4, 1, M_DRUIDE, (SPELLLEVEL), 4, 1,
@ -7703,20 +7662,6 @@ static spelldata spelldaten[] =
}, },
(spell_f)sp_sparkle, NULL (spell_f)sp_sparkle, NULL
}, },
{
SPL_DRAIG_EARN_SILVER, "draigearnsilver", NULL,
NULL,
NULL,
M_CHAOS, (SPELLLEVEL|ONSHIPCAST), 5, 1,
{
{ "aura", 1, SPC_LEVEL },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 }
},
(spell_f)sp_earn_silver, NULL
},
{ {
SPL_FIREBALL, "fireball", NULL, NULL, NULL, SPL_FIREBALL, "fireball", NULL, NULL, NULL,
M_CHAOS, (COMBATSPELL | SPELLLEVEL), 5, 2, M_CHAOS, (COMBATSPELL | SPELLLEVEL), 5, 2,
@ -8027,20 +7972,6 @@ static spelldata spelldaten[] =
}, },
(spell_f)sp_sparkle, NULL (spell_f)sp_sparkle, NULL
}, },
{
SPL_ILLAUN_EARN_SILVER, "illaunearnsilver", NULL,
NULL,
NULL,
M_TRAUM, (SPELLLEVEL|ONSHIPCAST), 5, 1,
{
{ "aura", 1, SPC_LEVEL },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 }
},
(spell_f)sp_earn_silver, NULL
},
{ {
SPL_SHADOWKNIGHTS, "shadowknights", NULL, NULL, NULL, SPL_SHADOWKNIGHTS, "shadowknights", NULL, NULL, NULL,
M_TRAUM, (PRECOMBATSPELL | SPELLLEVEL), 4, 1, M_TRAUM, (PRECOMBATSPELL | SPELLLEVEL), 4, 1,
@ -8373,18 +8304,6 @@ static spelldata spelldaten[] =
}, },
(spell_f)sp_denyattack, NULL (spell_f)sp_denyattack, NULL
}, },
{
SPL_CERDDOR_EARN_SILVER, "jugglery", NULL, NULL, NULL,
M_BARDE, (SPELLLEVEL|ONSHIPCAST), 5, 1,
{
{ "aura", 1, SPC_LEVEL },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 }
},
(spell_f)sp_earn_silver, NULL
},
{ {
SPL_HEALINGSONG, "song_of_healing", NULL, NULL, NULL, SPL_HEALINGSONG, "song_of_healing", NULL, NULL, NULL,
M_BARDE, (POSTCOMBATSPELL | SPELLLEVEL), 5, 2, M_BARDE, (POSTCOMBATSPELL | SPELLLEVEL), 5, 2,
@ -8926,18 +8845,6 @@ static spelldata spelldaten[] =
}, },
(spell_f)sp_itemcloak, NULL (spell_f)sp_itemcloak, NULL
}, },
{
SPL_TYBIED_EARN_SILVER, "miracle_doctor", NULL, NULL, NULL,
M_ASTRAL, (SPELLLEVEL|ONSHIPCAST), 5, 1,
{
{ "aura", 1, SPC_LEVEL },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 },
{ 0, 0, 0 }
},
(spell_f)sp_earn_silver, NULL
},
{ {
SPL_TYBIED_FUMBLESHIELD, "tybiedfumbleshield", NULL, NULL, NULL, SPL_TYBIED_FUMBLESHIELD, "tybiedfumbleshield", NULL, NULL, NULL,
M_ASTRAL, (PRECOMBATSPELL | SPELLLEVEL), 2, 2, M_ASTRAL, (PRECOMBATSPELL | SPELLLEVEL), 2, 2,

View File

@ -247,18 +247,16 @@ a_age(attrib ** p)
return (*p!=NULL); return (*p!=NULL);
} }
void int
a_read(FILE * f, attrib ** attribs) a_read(FILE * f, attrib ** attribs)
{ {
int key; int key, retval = AT_READ_OK;
char zText[128]; char zText[128];
strcpy(zText, "unknown"); strcpy(zText, "unknown");
key = -1; key = -1;
fscanf(f, "%s", zText); fscanf(f, "%s", zText);
if (!strcmp(zText, "end")) return; if (strcmp(zText, "end")==0) return retval;
/* { fgets(zText, sizeof(zText), f); ENNO: was ist das? "always ends with \n" ? */
/* key=-1; }*/
else key = __at_hashkey(zText); else key = __at_hashkey(zText);
while(key!=-1) { while(key!=-1) {
@ -275,6 +273,7 @@ a_read(FILE * f, attrib ** attribs)
a_add(attribs, na); a_add(attribs, na);
break; break;
case AT_READ_FAIL: case AT_READ_FAIL:
retval = AT_READ_FAIL;
a_free(na); a_free(na);
break; break;
default: default:
@ -289,6 +288,7 @@ a_read(FILE * f, attrib ** attribs)
if (!strcmp(zText, "end")) break; if (!strcmp(zText, "end")) break;
key = __at_hashkey(zText); key = __at_hashkey(zText);
} }
return retval;
} }
void void

View File

@ -74,7 +74,7 @@ extern attrib * a_new(const attrib_type * at);
extern void a_free(attrib * a); extern void a_free(attrib * a);
extern int a_age(attrib ** attribs); extern int a_age(attrib ** attribs);
extern void a_read(FILE * f, attrib ** attribs); extern int a_read(FILE * f, attrib ** attribs);
extern void a_write(FILE * f, const attrib * attribs); extern void a_write(FILE * f, const attrib * attribs);
#define DEFAULT_AGE NULL #define DEFAULT_AGE NULL

View File

@ -13,6 +13,7 @@ without prior permission by the authors of Eressea.
#include "log.h" #include "log.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
@ -75,12 +76,38 @@ log_close(void)
logfile = 0; logfile = 0;
} }
static int
check_dupe(const char * format, const char * type)
{
static const char * last_type;
static char last_message[32];
static int dupes = 0;
if (strncmp(last_message, format, sizeof(last_message))==0) {
++dupes;
return 1;
}
if (dupes) {
fprintf(logfile, "%s: last error repeated %d times\n", last_type, dupes+1);
if (logfile!=stderr) {
if (flags & LOG_CPERROR) {
fprintf(stderr, "%s: last error repeated %d times\n", last_type, dupes+1);
}
}
dupes = 0;
}
strncpy(last_message, format, sizeof(last_message));
last_type = type;
return 0;
}
void void
_log_warn(const char * format, ...) _log_warn(const char * format, ...)
{ {
va_list marker;
fflush(stdout); fflush(stdout);
if (!logfile) logfile = stderr; if (!logfile) logfile = stderr;
if (!check_dupe(format, "WARNING")) {
va_list marker;
fputs("WARNING: ", logfile); fputs("WARNING: ", logfile);
va_start(marker, format); va_start(marker, format);
vfprintf(logfile, format, marker); vfprintf(logfile, format, marker);
@ -96,15 +123,17 @@ _log_warn(const char * format, ...)
log_flush(); log_flush();
} }
} }
}
} }
void void
_log_error(const char * format, ...) _log_error(const char * format, ...)
{ {
va_list marker;
fflush(stdout); fflush(stdout);
if (!logfile) logfile = stderr; if (!logfile) logfile = stderr;
if (!check_dupe(format, "ERROR")) {
va_list marker;
fputs("ERROR: ", logfile); fputs("ERROR: ", logfile);
va_start(marker, format); va_start(marker, format);
vfprintf(logfile, format, marker); vfprintf(logfile, format, marker);
@ -118,6 +147,7 @@ _log_error(const char * format, ...)
} }
log_flush(); log_flush();
} }
}
} }
void void

View File

@ -90,11 +90,17 @@ static int
lua_callspell(castorder *co) lua_callspell(castorder *co)
{ {
const char * fname = co->sp->sname; const char * fname = co->sp->sname;
unit * mage = (unit*)co->magician; unit * mage = co->familiar?co->familiar:co->magician.u;
int retval = -1; int retval = -1;
const char * hashpos = strchr(fname, '#');
char fbuf[64];
if (co->familiar) { if (hashpos!=NULL) {
mage = co->familiar; ptrdiff_t len = hashpos - fname;
assert(len<sizeof(buf));
strncpy(fbuf, fname, len);
fbuf[len] = '\0';
fname = fbuf;
} }
lua_State * L = (lua_State *)global.vm_state; lua_State * L = (lua_State *)global.vm_state;

View File

@ -192,7 +192,7 @@ unit_castspell(unit& u, const char * name)
co->familiar = NULL; co->familiar = NULL;
co->force = sp->level; co->force = sp->level;
co->level = sp->level; co->level = sp->level;
co->magician = &u; co->magician.u = &u;
co->order = NULL; co->order = NULL;
co->par = NULL; co->par = NULL;
co->rt = u.region; co->rt = u.region;

View File

@ -155,6 +155,7 @@ extern "C" {
static char * orders = NULL; static char * orders = NULL;
static int nowrite = 0; static int nowrite = 0;
static boolean g_writemap = false; static boolean g_writemap = false;
static boolean g_ignore_errors = false;
static boolean opt_reportonly = false; static boolean opt_reportonly = false;
static const char * luafile = "default.lua"; static const char * luafile = "default.lua";
static const char * script_path = "scripts"; static const char * script_path = "scripts";
@ -446,6 +447,7 @@ usage(const char * prog, const char * arg)
"-R : erstellt nur die Reports neu\n" "-R : erstellt nur die Reports neu\n"
"--lomem : keine Messages (RAM sparen)\n" "--lomem : keine Messages (RAM sparen)\n"
"--nobattle : keine Kämpfe\n" "--nobattle : keine Kämpfe\n"
"--ignore-errors : ignore errors in scripts (please don\'t)\n"
"--nomonsters : keine monster KI\n" "--nomonsters : keine monster KI\n"
"--nodebug : keine Logfiles für Kämpfe\n" "--nodebug : keine Logfiles für Kämpfe\n"
"--noreports : absolut keine Reporte schreiben\n" "--noreports : absolut keine Reporte schreiben\n"
@ -497,6 +499,7 @@ read_args(int argc, char **argv, lua_State * luaState)
nocr = true; nocr = true;
} }
else if (strcmp(argv[i]+2, "xml")==0) xmlfile = argv[++i]; else if (strcmp(argv[i]+2, "xml")==0) xmlfile = argv[++i];
else if (strcmp(argv[i]+2, "ignore-errors")==0) g_ignore_errors = true;
else if (strcmp(argv[i]+2, "dirtyload")==0) dirtyload = true; else if (strcmp(argv[i]+2, "dirtyload")==0) dirtyload = true;
else if (strcmp(argv[i]+2, "nonr")==0) nonr = true; else if (strcmp(argv[i]+2, "nonr")==0) nonr = true;
else if (strcmp(argv[i]+2, "nosh")==0) nosh = true; else if (strcmp(argv[i]+2, "nosh")==0) nosh = true;
@ -610,7 +613,7 @@ my_lua_error(lua_State * L)
log_error(("A LUA error occured: %s\n", error)); log_error(("A LUA error occured: %s\n", error));
lua_pop(L, 1); lua_pop(L, 1);
std::terminate(); if (!g_ignore_errors) std::terminate();
return 1; return 1;
} }

View File

@ -2299,6 +2299,10 @@
<string name="REPORT"> <string name="REPORT">
<text locale="de">REPORT</text> <text locale="de">REPORT</text>
</string> </string>
<string name="XML">
<text locale="de">XML</text>
<text locale="en">XML</text>
</string>
<string name="URSPRUNG"> <string name="URSPRUNG">
<text locale="de">URSPRUNG</text> <text locale="de">URSPRUNG</text>
</string> </string>
@ -4057,7 +4061,7 @@
<text locale="de">Schutz vor Magie</text> <text locale="de">Schutz vor Magie</text>
<text locale="en">Protection from Magic</text> <text locale="en">Protection from Magic</text>
</string> </string>
<string name="miracle_doctor"> <string name="earn_silver#tybied">
<text locale="de">Wunderdoktor</text> <text locale="de">Wunderdoktor</text>
<text locale="en">Miracle Doctor</text> <text locale="en">Miracle Doctor</text>
</string> </string>
@ -4121,7 +4125,7 @@
<text locale="de">Regentanz</text> <text locale="de">Regentanz</text>
<text locale="en">Rain Dance</text> <text locale="en">Rain Dance</text>
</string> </string>
<string name="jugglery"> <string name="earn_silver#cerddor">
<text locale="de">Gaukeleien</text> <text locale="de">Gaukeleien</text>
<text locale="en">Jugglery</text> <text locale="en">Jugglery</text>
</string> </string>
@ -4129,7 +4133,7 @@
<text locale="de">Friedenslied</text> <text locale="de">Friedenslied</text>
<text locale="en">Appeasing Song</text> <text locale="en">Appeasing Song</text>
</string> </string>
<string name="gwyrrdearnsilver"> <string name="earn_silver#gwyrrd">
<text locale="de">Viehheilung</text> <text locale="de">Viehheilung</text>
<text locale="en">Cattle Healing</text> <text locale="en">Cattle Healing</text>
</string> </string>
@ -4305,7 +4309,7 @@
<text locale="de">Verwünschung</text> <text locale="de">Verwünschung</text>
<text locale="en">Hex</text> <text locale="en">Hex</text>
</string> </string>
<string name="draigearnsilver"> <string name="earn_silver#draig">
<text locale="de">Kleine Flüche</text> <text locale="de">Kleine Flüche</text>
<text locale="en">Minor Curses</text> <text locale="en">Minor Curses</text>
</string> </string>
@ -4423,7 +4427,7 @@
<text locale="de">Traumsenden</text> <text locale="de">Traumsenden</text>
<text locale="en">Dream</text> <text locale="en">Dream</text>
</string> </string>
<string name="illaunearnsilver"> <string name="earn_silver#illaun">
<text locale="de">Wahrsagen</text> <text locale="de">Wahrsagen</text>
<text locale="en">Divination</text> <text locale="en">Divination</text>
</string> </string>
@ -4722,7 +4726,7 @@
spies. spies.
</text> </text>
</string> </string>
<string name="miracle_doctor"> <string name="earn_silver#tybied">
<text locale="de"> <text locale="de">
Wenn einem der Alchemist nicht weiterhelfen kann, geht man zu dem Wenn einem der Alchemist nicht weiterhelfen kann, geht man zu dem
gelehrten Tybiedmagier. Seine Tränke und Tinkturen helfen gegen gelehrten Tybiedmagier. Seine Tränke und Tinkturen helfen gegen
@ -4922,7 +4926,7 @@
enchanted will realize that they probably talked too enchanted will realize that they probably talked too
much.</text> much.</text>
</string> </string>
<string name="jugglery"> <string name="earn_silver#cerddor">
<text locale="de">Cerddormagier sind _die_ Gaukler unter <text locale="de">Cerddormagier sind _die_ Gaukler unter
den Magiern, sie lieben es das Volk zu unterhalten und den Magiern, sie lieben es das Volk zu unterhalten und
im Mittelpunkt zu stehen. Schon Anfänger lernen die im Mittelpunkt zu stehen. Schon Anfänger lernen die
@ -4939,7 +4943,7 @@
the end of the week, the bard will have earned 50 silver the end of the week, the bard will have earned 50 silver
per level. </text> per level. </text>
</string> </string>
<string name="gwyrrdearnsilver"> <string name="earn_silver#gwyrrd">
<text locale="de">Die Fähigkeiten der Gwyrrd-Magier in <text locale="de">Die Fähigkeiten der Gwyrrd-Magier in
der Viehzucht und Heilung sind bei den Bauern sehr der Viehzucht und Heilung sind bei den Bauern sehr
begehrt. Gerade auf Märkten sind ihre Dienste häufig sehr begehrt. Gerade auf Märkten sind ihre Dienste häufig sehr
@ -5533,7 +5537,7 @@
subject to a harmless curse. subject to a harmless curse.
</text> </text>
</string> </string>
<string name="draigearnsilver"> <string name="earn_silver#draig">
<text locale="de">In den dunkleren Gassen gibt es sie, <text locale="de">In den dunkleren Gassen gibt es sie,
die Flüche und Verhexungen auf Bestellung. Aber die Flüche und Verhexungen auf Bestellung. Aber
auch Gegenzauber hat der Jünger des Draigs auch Gegenzauber hat der Jünger des Draigs
@ -5990,7 +5994,7 @@
cible du sort. cible du sort.
</text> </text>
</string> </string>
<string name="illaunearnsilver"> <string name="earn_silver#illaun">
<text locale="fr">Personne n'interprète aussi bien les <text locale="fr">Personne n'interprète aussi bien les
rêves que les mages d'Illaun. Ils sont également rêves que les mages d'Illaun. Ils sont également
versés dans l'utilisation des objets utilisés versés dans l'utilisation des objets utilisés

View File

@ -8,6 +8,11 @@
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="earn_silver#draig" type="draig" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="create_aots" type="draig" ship="true" rank="5" level="6" index="125"> <spell name="create_aots" type="draig" ship="true" rank="5" level="6" index="125">
<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"/>
@ -37,6 +42,11 @@
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="earn_silver#gwyrrd" type="gwyrrd" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="create_aots" type="gwyrrd" ship="true" rank="5" level="6" index="124"> <spell name="create_aots" type="gwyrrd" ship="true" rank="5" level="6" index="124">
<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"/>
@ -59,6 +69,11 @@
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="earn_silver#illaun" type="illaun" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="create_aots" type="illaun" ship="true" rank="5" level="6" index="126"> <spell name="create_aots" type="illaun" ship="true" rank="5" level="6" index="126">
<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"/>
@ -87,6 +102,11 @@
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="earn_silver#cerddor" type="cerddor" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="create_aots" type="cerddor" ship="true" rank="5" level="6" index="127"> <spell name="create_aots" type="cerddor" ship="true" rank="5" level="6" index="127">
<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"/>
@ -109,6 +129,11 @@
<resource name="permaura" amount="1" cost="fixed"/> <resource name="permaura" amount="1" cost="fixed"/>
</spell> </spell>
<spell name="earn_silver#tybied" type="tybied" ship="true" variable="true" rank="5" level="1" index="159">
<function name="cast" value="lua_castspell"/>
<resource name="aura" amount="1" cost="level"/>
</spell>
<spell name="create_aots" type="tybied" ship="true" rank="5" level="6" index="128"> <spell name="create_aots" type="tybied" ship="true" rank="5" level="6" index="128">
<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"/>

View File

@ -1,4 +1,4 @@
function use_snomwan(u, amount) function use_snowman(u, amount)
if u.region.terrain == "glacier" then if u.region.terrain == "glacier" then
local man = add_unit(u.faction, u.region) local man = add_unit(u.faction, u.region)
u.race = "snowman" u.race = "snowman"

View File

@ -90,7 +90,7 @@ function create_bagofholding(r, mage, level, force)
end end
-- TODO: -- TODO:
function earnsilver(r, mage, level, force) function earn_silver(r, mage, level, force)
local money = r:get_resource("money") local money = r:get_resource("money")
local wanted = 50 * force local wanted = 50 * force
local amount = wanted local amount = wanted
@ -100,11 +100,12 @@ function earnsilver(r, mage, level, force)
r:set_resource("money", money - amount) r:set_resource("money", money - amount)
mage:add_item("money", amount) mage:add_item("money", amount)
msg = message("income") local msg = message("income")
msg:set_unit("unit", mage) msg:set_unit("unit", mage)
msg:set_region("region", r) msg:set_region("region", r)
msg:set_int("mode", 6) msg:set_int("mode", 6)
msg:set_int("wanted", wanted) msg:set_int("wanted", wanted)
msg:set_int("amount", amount) msg:set_int("amount", amount)
msg:send_faction(mage.faction) msg:send_faction(mage.faction)
return level
end end