Bugfix Wolfsgeheul und sonstige Sprüche (Hamo's Tod)

Behebung der restlichen double->int conversion warnings
This commit is contained in:
Enno Rehling 2004-02-09 21:12:46 +00:00
parent afe4e48a30
commit 567117932c
17 changed files with 228 additions and 1276 deletions

View File

@ -3436,10 +3436,6 @@ defaultorders (void)
list_next(r);
}
#ifdef SKILLFIX_SAVE
void write_skillfix(void);
#endif
/* ************************************************************ */
/* GANZ WICHTIG! ALLE GEÄNDERTEN SPRÜCHE NEU ANZEIGEN */
/* GANZ WICHTIG! FÜGT AUCH NEUE ZAUBER IN DIE LISTE DER BEKANNTEN EIN */
@ -3675,9 +3671,6 @@ processorders (void)
puts(" - Attribute altern");
ageing();
#ifdef SKILLFIX_SAVE
write_skillfix();
#endif
/* immer ausführen, wenn neue Sprüche dazugekommen sind, oder sich
* Beschreibungen geändert haben */
update_spells();

View File

@ -654,7 +654,7 @@ eaten_by_monster(unit * u)
n = lovar(n);
n = min(rpeasants(u->region), n);
if(n > 0) {
if (n > 0) {
deathcounts(u->region, n);
rsetpeasants(u->region, rpeasants(u->region) - n);
add_message(&u->region->msgs, new_message(NULL,
@ -982,11 +982,7 @@ plan_monsters(void)
}
else a_remove(&u->attribs, ta);
}
#ifdef CONVERT_TRIGGER
ta = set_new_dragon_target(u, r, DRAGON_RANGE);
#else
ta = a_find(u->attribs, &at_targetregion);
#endif
if (ta!=NULL) {
tr = (region *) ta->data.v;
if (tr != r) is_moving = true;

View File

@ -434,10 +434,6 @@ teach(region * r, unit * u)
}
/* ------------------------------------------------------------- */
#ifdef SKILLFIX_SAVE
extern void skillfix(struct unit *, skill_t, int, int, int);
#endif
void
learn(void)
{
@ -668,13 +664,6 @@ learn(void)
if (is_cursed(r->attribs,C_BADLEARN,0)) {
teach->value -= u->number * 10;
}
#ifdef SKILLFIX_SAVE
if (teach && teach->value) {
int skill = get_skill(u, sk);
skillfix(u, sk, skill,
(int)(u->number * 30 * multi), teach->value);
}
#endif
days = (int)((u->number * 30 + teach->value) * multi);
if (fval(u, UFL_HUNGER)) days = days / 2;

View File

@ -1297,15 +1297,6 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
return true;
}
int
lovar(int n)
{
assert(n > 0);
if (n == 1) return rand()%2;
n /= 2;
return (rand() % n + 1) + (rand() % n + 1);
}
/* ------------------------------------------------------------- */
int
count_enemies(battle * b, side * as, int mask, int minrow, int maxrow)
@ -1446,7 +1437,7 @@ do_combatmagic(battle *b, combatmagic_t was)
region *r = b->region;
castorder *co;
castorder *cll[MAX_SPELLRANK];
int level, power;
int level;
int spellrank;
int sl;
@ -1464,6 +1455,7 @@ do_combatmagic(battle *b, combatmagic_t was)
level = eff_skill(mage, SK_MAGIC, r);
if (level > 0) {
double power;
const struct locale * lang = mage->faction->locale;
char cmd[128];
@ -1520,10 +1512,10 @@ do_combatmagic(battle *b, combatmagic_t was)
}
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
for (co = cll[spellrank]; co; co = co->next) {
fig = (fighter*)co->magician;
sp = co->sp;
level = co->level;
power = co->force;
fighter * fig = (fighter*)co->magician;
spell * sp = co->sp;
int level = co->level;
double power = co->force;
level = ((cspell_f)sp->sp_function)(fig, level, power, sp);
if (level > 0) {
@ -1548,7 +1540,8 @@ do_combatspell(troop at, int row)
unit *mage = fi->unit;
battle *b = fi->side->battle;
region *r = b->region;
int level, power;
int level;
double power;
int fumblechance = 0;
void **mg;
int sl;
@ -2747,7 +2740,7 @@ weapon_weight(const weapon * w, boolean missile)
}
fighter *
make_fighter(battle * b, unit * u, boolean attack)
make_fighter(battle * b, unit * u, side * s1, boolean attack)
{
#define WMAX 16
weapon weapons[WMAX];
@ -2758,7 +2751,7 @@ make_fighter(battle * b, unit * u, boolean attack)
item * itm;
fighter *fig = NULL;
int i, t = eff_skill(u, SK_TACTICS, r);
side *s2, *s1 = NULL;
side *s2;
int h;
int berserk;
int strongmen;
@ -2775,22 +2768,24 @@ make_fighter(battle * b, unit * u, boolean attack)
if (fval(u->race, RCF_ILLUSIONARY) || idle(u->faction))
return NULL;
cv_foreach(s2, b->sides) {
if (s2->bf->faction == u->faction
&& s2->stealth==stealth
&& s2->stealthfaction == stealthfaction
) {
if (s2->group==g) {
s1 = s2;
break;
}
}
} cv_next(s2);
if (s1==NULL) {
cv_foreach(s2, b->sides) {
if (s2->bf->faction == u->faction
&& s2->stealth==stealth
&& s2->stealthfaction == stealthfaction
) {
if (s2->group==g) {
s1 = s2;
break;
}
}
} cv_next(s2);
/* aliances are moved out of make_fighter and will be handled later */
if (!s1) s1 = make_side(b, u->faction, g, stealth, stealthfaction);
/* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit für noch
* keinen Kampf ausgewählt wurde (sonst würde ein fighter existieren) */
/* aliances are moved out of make_fighter and will be handled later */
if (!s1) s1 = make_side(b, u->faction, g, stealth, stealthfaction);
/* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit für noch
* keinen Kampf ausgewählt wurde (sonst würde ein fighter existieren) */
}
fig = calloc(1, sizeof(struct fighter));
cv_pushback(&s1->fighters, fig);
@ -3043,7 +3038,7 @@ join_battle(battle * b, unit * u, boolean attack)
}
}
cv_next(fig);
if (!c) c = make_fighter(b, u, attack);
if (!c) c = make_fighter(b, u, NULL, attack);
return c;
}
static const char *

View File

@ -227,7 +227,7 @@ extern boolean helping(struct side * as, struct side * ds);
extern void rmfighter(fighter *df, int i);
extern struct region * fleeregion(const struct unit * u);
extern struct troop select_corpse(struct battle * b, struct fighter * af);
extern fighter * make_fighter(struct battle * b, struct unit * u, boolean attack);
extern fighter * make_fighter(struct battle * b, struct unit * u, side * s, boolean attack);
extern int statusrow(int status);
extern void drain_exp(struct unit *u, int d);
extern void rmtroop(troop dt);

View File

@ -796,7 +796,7 @@ sp_shadowcall(fighter * fi, int level, int power, spell * sp)
a->data.ca[1] = 100;
a_add(&u->attribs, a);
make_fighter(b, u, true);
make_fighter(b, u, fi->side, fval(fi, FIG_ATTACKED));
sprintf(buf, "%s ruft %d %s zu Hilfe", unitname(mage), force,
racename(default_locale, u, u->race));
battlerecord(b, buf);
@ -829,7 +829,7 @@ sp_wolfhowl(fighter * fi, int level, int power, spell * sp)
a->data.ca[1] = 100;
a_add(&u->attribs, a);
make_fighter(b, u, true);
make_fighter(b, u, fi->side, fval(fi, FIG_ATTACKED));
sprintf(buf, "%s ruft %d %s zu Hilfe", unitname(mage), force,
racename(default_locale, u, u->race));
battlerecord(b, buf);
@ -863,7 +863,7 @@ sp_shadowknights(fighter * fi, int level, int power, spell * sp)
a->data.ca[1] = 100;
a_add(&u->attribs, a);
make_fighter(b, u, true);
make_fighter(b, u, fi->side, fval(fi, FIG_ATTACKED));
sprintf(buf, "%s beschwört Trugbilder herauf", unitname(mage));
battlerecord(b, buf);

View File

@ -2949,6 +2949,14 @@ produceexp(struct unit * u, skill_t sk, int n)
return 0;
}
int
lovar(double xpct_x2)
{
int n = (int)(xpct_x2 * 500)+1;
if (n==0) return 0;
return (rand() % n + rand() % n)/1000;
}
boolean
teure_talente (const struct unit * u)
{

View File

@ -977,7 +977,8 @@ boolean cansee_durchgezogen(const struct faction * f, const struct region * r, c
boolean seefaction(const struct faction * f, const struct region * r, const struct unit * u, int modifier);
extern int effskill(const struct unit * u, skill_t sk);
int lovar(int n);
extern int lovar(double xpct_x2);
/* returns a value between [0..xpct_2], generated with two dice */
int distribute(int old, int new_value, int n);

View File

@ -812,7 +812,8 @@ use_antimagiccrystal(region * r, unit * mage, int amount, strlist * cmdstrings)
{
int i;
for (i=0;i!=amount;++i) {
int effect, force, duration = 2;
int effect, duration = 2;
double force;
spell *sp = find_spellbyid(SPL_ANTIMAGICZONE);
attrib ** ap = &r->attribs;
unused(cmdstrings);

View File

@ -2361,7 +2361,7 @@ add_spellparameter(region *target_r, unit *u, const char *syntax,
castorder *
new_castorder(void *u, unit *u2, spell *sp, region *r, int lev,
int force, int range, char *cmd, spellparameter *p)
double force, int range, char *cmd, spellparameter *p)
{
castorder *corder;

View File

@ -168,15 +168,15 @@ typedef struct spell {
struct castorder {
castorder *next;
void *magician; /* Magier (kann vom Typ struct unit oder fighter sein) */
struct unit *familiar; /* Vertrauter, gesetzt, wenn der Spruch durch
den Vertrauten gezaubert wird */
struct spell *sp; /* Spruch */
int level; /* gewünschte Stufe oder Stufe des Magiers */
float force; /* Stärke des Zaubers */
struct region *rt; /* Zielregion des Spruchs */
int distance; /* Entfernung zur Zielregion */
char *order; /* Befehl */
void *magician; /* Magier (kann vom Typ struct unit oder fighter sein) */
struct unit *familiar; /* Vertrauter, gesetzt, wenn der Spruch durch
den Vertrauten gezaubert wird */
struct spell *sp; /* Spruch */
int level; /* gewünschte Stufe oder Stufe des Magiers */
double force; /* Stärke des Zaubers */
struct region *rt; /* Zielregion des Spruchs */
int distance; /* Entfernung zur Zielregion */
char *order; /* Befehl */
struct spellparameter *par; /* für weitere Parameter */
};
@ -187,7 +187,7 @@ typedef void (*spell_f) (void*);
/* normale zauber: */
typedef int (*nspell_f)(castorder*);
/* kampfzauber: */
typedef int (*cspell_f) (struct fighter*, int, int, struct spell * sp);
typedef int (*cspell_f) (struct fighter*, int, double, struct spell * sp);
/* zauber-patzer: */
typedef void (*pspell_f) (castorder *);
@ -335,7 +335,7 @@ boolean fumble (struct region *r, struct unit *u, spell *spruch, int cast_level)
/* */
castorder *new_castorder(void *u, struct unit *familiar, spell *sp, struct region *r,
int lev, int force, int distance, char *cmd, spellparameter *p);
int lev, double force, int distance, char *cmd, spellparameter *p);
/* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */
void add_castorder(castorder **cll, castorder *co);
/* Hänge c-order co an die letze c-order von cll an */

View File

@ -882,11 +882,7 @@ readgame(const char * filename, int backup)
global.data_version = ri(F);
assert(global.data_version>=MIN_VERSION || !"unsupported data format");
assert(global.data_version<=RELEASE_VERSION || !"unsupported data format");
#ifdef CONVERT_TRIGGER
assert(global.data_version < NEWSOURCE_VERSION);
#else
assert(global.data_version >= NEWSOURCE_VERSION);
#endif
if(global.data_version >= SAVEXMLNAME_VERSION) {
char basefile[1024];
const char *basearg = "(null)";

View File

@ -161,35 +161,34 @@ do_shock(unit *u, const char *reason)
/* Spruchanalyse - Ausgabe von curse->info und curse->name */
/* ------------------------------------------------------------- */
static int
curse_chance(const struct curse * c, int force)
static double
curse_chance(const struct curse * c, double force)
{
return 100 + (int)((force - c->vigour)*10);
return 1.0 + (force - c->vigour) * 0.1;
}
void
magicanalyse_region(region *r, unit *mage, int force)
static void
magicanalyse_region(region *r, unit *mage, double force)
{
attrib *a;
boolean found = false;
const struct locale * lang = mage->faction->locale;
for (a=r->attribs;a;a=a->next) {
curse * c;
int chance;
curse * c = (curse*)a->data.v;
double probability;
int mon;
if (!fval(a->type, ATF_CURSE)) continue;
c = (curse*)a->data.v;
if (!fval(a->type, ATF_CURSE)) continue;
/* ist der curse schwächer als der Analysezauber, so ergibt sich
* mehr als 100% chance und damit immer ein Erfolg. */
chance = curse_chance(c, force);
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rand()%10) - 5;
mon = max(1,mon);
mon = max(1, mon);
found = true;
if(rand()%100 < chance){ /* Analyse geglückt */
if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE) {
add_message(&mage->faction->msgs, new_message(mage->faction,
"analyse_region_noage%u:mage%r:region%s:spell",
@ -210,8 +209,8 @@ magicanalyse_region(region *r, unit *mage, int force)
}
}
void
magicanalyse_unit(unit *u, unit *mage, int force)
static void
magicanalyse_unit(unit *u, unit *mage, double force)
{
attrib *a;
boolean found = false;
@ -219,18 +218,18 @@ magicanalyse_unit(unit *u, unit *mage, int force)
for (a=u->attribs;a;a=a->next) {
curse * c;
int chance;
double probability;
int mon;
if (!fval(a->type, ATF_CURSE)) continue;
c = (curse*)a->data.v;
/* ist der curse schwächer als der Analysezauber, so ergibt sich
* mehr als 100% chance und damit immer ein Erfolg. */
chance = curse_chance(c, force);
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rand()%10) - 5;
mon = max(1,mon);
if(rand()%100 < chance){ /* Analyse geglückt */
if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE){
add_message(&mage->faction->msgs, new_message(mage->faction,
"analyse_unit_noage%u:mage%u:unit%s:spell",
@ -251,8 +250,8 @@ magicanalyse_unit(unit *u, unit *mage, int force)
}
}
void
magicanalyse_building(building *b, unit *mage, int force)
static void
magicanalyse_building(building *b, unit *mage, double force)
{
attrib *a;
boolean found = false;
@ -260,18 +259,19 @@ magicanalyse_building(building *b, unit *mage, int force)
for (a=b->attribs;a;a=a->next) {
curse * c;
int chance;
double probability;
int mon;
if (!fval(a->type, ATF_CURSE)) continue;
if (!fval(a->type, ATF_CURSE)) continue;
c = (curse*)a->data.v;
/* ist der curse schwächer als der Analysezauber, so ergibt sich
* mehr als 100% chance und damit immer ein Erfolg. */
chance = curse_chance(c, force);
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rand()%10) - 5;
mon = max(1,mon);
if(rand()%100 < chance){ /* Analyse geglückt */
if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE){
add_message(&mage->faction->msgs, new_message(mage->faction,
"analyse_building_age%u:mage%b:building%s:spell",
@ -293,8 +293,8 @@ magicanalyse_building(building *b, unit *mage, int force)
}
void
magicanalyse_ship(ship *sh, unit *mage, int force)
static void
magicanalyse_ship(ship *sh, unit *mage, double force)
{
attrib *a;
boolean found = false;
@ -302,18 +302,18 @@ magicanalyse_ship(ship *sh, unit *mage, int force)
for (a=sh->attribs;a;a=a->next) {
curse * c;
int chance;
double probability;
int mon;
if (!fval(a->type, ATF_CURSE)) continue;
c = (curse*)a->data.v;
/* ist der curse schwächer als der Analysezauber, so ergibt sich
* mehr als 100% chance und damit immer ein Erfolg. */
chance = curse_chance(c, force);
* mehr als 100% probability und damit immer ein Erfolg. */
probability = curse_chance(c, force);
mon = c->duration + (rand()%10) - 5;
mon = max(1,mon);
if(rand()%100 < chance){ /* Analyse geglückt */
if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE){
add_message(&mage->faction->msgs, new_message(mage->faction,
"analyse_ship_noage%u:mage%h:ship%s:spell",
@ -351,10 +351,9 @@ double
destr_curse(curse* c, int cast_level, double force)
{
if (cast_level < c->vigour) { /* Zauber ist nicht stark genug */
double chance;
double probability = 0.1 + (cast_level - c->vigour)*0.2;
/* pro Stufe Unterschied -20% */
chance = 0.1 + (cast_level - c->vigour)*0.2;
if (rand()%100 >= chance*100) {
if (chance(probability)) {
force -= c->vigour;
if (c->type->change_vigour){
c->type->change_vigour(c, -(cast_level+1/2));
@ -2232,7 +2231,7 @@ sp_fog_of_confusion(castorder *co)
regionlist *rl,*rl2;
range = (power-11)/3-1;
duration = ((power-11)/3)*2+1;
duration = (int)((power-11)/1.5)+1;
rl = all_in_range(r, (int)range);
@ -2341,21 +2340,18 @@ sp_stormwinds(castorder *co)
faction *f;
ship *sh;
unit *u;
int n, force;
int erfolg = 0;
region *r = co->rt;
unit *mage = (unit *)co->magician;
double power = co->force;
spellparameter *pa = co->par;
force = power;
int n, force = (int)power;
/* melden vorbereiten */
for(f = factions; f; f = f->next ) freset(f, FL_DH);
for (n = 0; n < pa->length; n++) {
if (!force)
break;
if (force<=0) break;
if(pa->param[n]->flag == TARGET_RESISTS
|| pa->param[n]->flag == TARGET_NOTFOUND)
@ -2552,35 +2548,32 @@ sp_forest_fire(castorder *co)
{
unit *u;
region *nr;
int prozent, chance, vernichtet;
#if GROWING_TREES
int vernichtet_schoesslinge;
#endif
direction_t i;
region *r = co->rt;
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double probability;
double percentage = (rand() % 8 + 1) * 0.1; /* 10 - 80% */
prozent = (rand() % 71) + 10; /* 10 - 80% */
#if GROWING_TREES
vernichtet = rtrees(r,2) * prozent / 100;
vernichtet_schoesslinge = rtrees(r,1) * prozent / 100;
int vernichtet_schoesslinge = (int)(rtrees(r, 1) * percentage);
int destroyed = (int)(rtrees(r, 2) * percentage);
#else
vernichtet = rtrees(r) * prozent / 100;
int destroyed = (int)(rtrees(r) * percentage);
#endif
if(!vernichtet ) {
if (destroyed<1) {
cmistake(mage, strdup(co->order), 198, MSG_MAGIC);
return 0;
}
#if GROWING_TREES
rsettrees(r, 2, rtrees(r,2) - vernichtet);
rsettrees(r, 2, rtrees(r,2) - destroyed);
rsettrees(r, 1, rtrees(r,1) - vernichtet_schoesslinge);
#else
rsettrees(r, rtrees(r) - vernichtet);
rsettrees(r, rtrees(r) - destroyed);
#endif
chance = vernichtet / 10; /* Chance, dass es sich ausbreitet */
probability = destroyed * 0.001; /* Chance, dass es sich ausbreitet */
/* melden, 1x pro Partei */
for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
@ -2591,20 +2584,20 @@ sp_forest_fire(castorder *co)
sprintf(buf, "%s erzeugt eine verheerende Feuersbrunst. %d %s "
"den Flammen zum Opfer.",
cansee(u->faction, r, mage, 0) ? unitname(mage) : "Jemand",
vernichtet,
vernichtet == 1 ? "Baum fiel" : "Bäume fielen");
destroyed,
destroyed == 1 ? "Baum fiel" : "Bäume fielen");
addmessage(r, u->faction, buf, MSG_EVENT, ML_INFO);
}
}
if(!fval(mage->faction, FL_DH)){
#if GROWING_TREES
sprintf(buf, "%s erzeugt eine verheerende Feuersbrunst. %d %s "
"den Flammen zum Opfer.", unitname(mage), vernichtet+vernichtet_schoesslinge,
vernichtet+vernichtet_schoesslinge == 1 ? "Baum fiel" : "Bäume fielen");
"den Flammen zum Opfer.", unitname(mage), destroyed+vernichtet_schoesslinge,
destroyed+vernichtet_schoesslinge == 1 ? "Baum fiel" : "Bäume fielen");
#else
sprintf(buf, "%s erzeugt eine verheerende Feuersbrunst. %d %s "
"den Flammen zum Opfer.", unitname(mage), vernichtet,
vernichtet == 1 ? "Baum fiel" : "Bäume fielen");
"den Flammen zum Opfer.", unitname(mage), destroyed,
destroyed == 1 ? "Baum fiel" : "Bäume fielen");
#endif
addmessage(0, mage->faction, buf, MSG_MAGIC, ML_INFO);
}
@ -2612,28 +2605,28 @@ sp_forest_fire(castorder *co)
for(i = 0; i < MAXDIRECTIONS; i++ ) {
nr = rconnect(r, i);
assert(nr);
vernichtet = 0;
destroyed = 0;
#if GROWING_TREES
if(rtrees(nr,2) + rtrees(nr,1) >= 800) {
if((rand() % 100) < chance ) {
vernichtet = rtrees(nr,2) * prozent / 200;
vernichtet_schoesslinge = rtrees(nr,1) * prozent / 200;
if (chance(probability)) {
destroyed = (int)(rtrees(nr,2) * percentage/2);
vernichtet_schoesslinge = (int)(rtrees(nr,1) * percentage/2);
}
} else if(rtrees(nr,2) + rtrees(nr,1) >= 600) {
if((rand() % 100) < chance / 2 ) {
vernichtet = rtrees(nr,2) * prozent / 400;
vernichtet_schoesslinge = rtrees(nr,1) * prozent / 400;
} else if (rtrees(nr,2) + rtrees(nr,1) >= 600) {
if (chance(probability/2)) {
destroyed = (int)(rtrees(nr,2) * percentage/4);
vernichtet_schoesslinge = (int)(rtrees(nr,1) * percentage/4);
}
}
if(vernichtet > 0 || vernichtet_schoesslinge > 0) {
rsettrees(nr, 2, rtrees(nr,2) - vernichtet);
if (destroyed > 0 || vernichtet_schoesslinge > 0) {
rsettrees(nr, 2, rtrees(nr,2) - destroyed);
rsettrees(nr, 1, rtrees(nr,1) - vernichtet_schoesslinge);
sprintf(buf, "Der Waldbrand in %s griff auch auf %s "
"über und %d %s.",
regionid(r), regionid(nr), vernichtet+vernichtet_schoesslinge,
vernichtet+vernichtet_schoesslinge == 1 ? "Baum verbrannte" : "Bäume verbrannten");
regionid(r), regionid(nr), destroyed+vernichtet_schoesslinge,
destroyed+vernichtet_schoesslinge == 1 ? "Baum verbrannte" : "Bäume verbrannten");
for (u = nr->units; u; u = u->next) freset(u->faction, FL_DH);
for(u = nr->units; u; u = u->next ) {
if(!fval(u->faction, FL_DH) ) {
@ -2646,18 +2639,18 @@ sp_forest_fire(castorder *co)
}
}
#else
if(rtrees(nr) >= 800) {
if((rand() % 100) < chance ) vernichtet = rtrees(nr) * prozent / 200;
} else if(rtrees(nr) >= 600) {
if((rand() % 100) < chance / 2 ) vernichtet = rtrees(nr) * prozent / 400;
if (rtrees(nr) >= 800) {
if (chance(probability)) destroyed = (int)(rtrees(nr) * percentage/2);
} else if (rtrees(nr) >= 600) {
if(chance(probability/2)) destroyed = (int)(rtrees(nr) * percentage/4);
}
if(vernichtet > 0 ) {
rsettrees(nr, rtrees(nr) - vernichtet);
if (destroyed > 0 ) {
rsettrees(nr, rtrees(nr) - destroyed);
sprintf(buf, "Der Waldbrand in %s griff auch auf %s "
"über und %d %s.",
regionid(r), regionid(nr), vernichtet,
vernichtet == 1 ? "Baum verbrannte" : "Bäume verbrannten");
regionid(r), regionid(nr), destroyed,
destroyed == 1 ? "Baum verbrannte" : "Bäume verbrannten");
for (u = nr->units; u; u = u->next) freset(u->faction, FL_DH);
for(u = nr->units; u; u = u->next ) {
if(!fval(u->faction, FL_DH) ) {
@ -2698,10 +2691,10 @@ sp_fumblecurse(castorder *co)
unit *target;
int rx, sx;
int duration;
int effect;
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int effect = (int)(force/2);
curse * c;
spellparameter *pa = co->par;
@ -2714,8 +2707,6 @@ sp_fumblecurse(castorder *co)
sx = cast_level - effskill(target, SK_MAGIC);
duration = max(sx, rx) + 1;
effect = force/2;
c = create_curse(mage, &target->attribs, ct_find("fumble"),
force, duration, effect, 0);
if (c == NULL) {
@ -2736,12 +2727,10 @@ patzer_fumblecurse(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int effect;
int effect = (int)(force/2);
curse * c;
int duration = (cast_level/2)+1;
effect = force/2;
c = create_curse(mage, &mage->attribs, ct_find("fumble"), force,
duration, effect, 0);
if (c!=NULL) {
@ -3079,12 +3068,12 @@ sp_firewall(castorder *co)
if (b==NULL) {
b = new_border(&bt_firewall, r, r2);
fd = (wall_data*)b->data;
fd->force = (force+1)/2;
fd->force = (int)(force/2+0.5);
fd->mage = mage;
fd->active = false;
} else {
fd = (wall_data*)b->data;
fd->force = max(fd->force, (force+1)/2);
fd->force = (int)max(fd->force, force/2+0.5);
}
a = a_find(b->attribs, &at_countdown);
@ -3166,7 +3155,7 @@ sp_wisps(castorder *co)
b = new_border(&bt_wisps, r, r2);
fd = (wall_data*)b->data;
fd->force = (force+1)/2;
fd->force = (int)(force/2+0.5);
fd->mage = mage;
fd->active = false;
@ -3216,7 +3205,7 @@ sp_unholypower(castorder *co)
int n;
int wounds;
n = dice(co->force, 10);
n = dice((int)co->force, 10);
for (i = 0; i < pa->length && n > 0; i++) {
const race * target_race;
@ -3465,7 +3454,7 @@ sp_summonshadow(castorder *co)
unit *u;
int val;
u = createunit(r, mage->faction, force*force, new_race[RC_SHADOW]);
u = createunit(r, mage->faction, (int)(force*force), new_race[RC_SHADOW]);
if (r==mage->region) {
u->building = mage->building;
u->ship = mage->ship;
@ -3512,7 +3501,7 @@ sp_summonshadowlords(castorder *co)
int cast_level = co->level;
double force = co->force;
u = createunit(r, mage->faction, force*force, new_race[RC_SHADOWLORD]);
u = createunit(r, mage->faction, (int)(force*force), new_race[RC_SHADOWLORD]);
if (r==mage->region) {
u->building = mage->building;
u->ship = mage->ship;
@ -3673,14 +3662,14 @@ sp_bloodsacrifice(castorder *co)
int cast_level = co->level;
int aura;
int skill = eff_skill(mage, SK_MAGIC, mage->region);
double hp = co->force*4;
int hp = (int)(co->force*8);
if (hp <= 0){
if (hp <= 0) {
report_failure(mage, co->order);
return 0;
}
aura = lovar(hp*2);
aura = lovar(hp);
if (skill < 8) {
aura /= 4;
@ -3729,7 +3718,7 @@ sp_summonundead(castorder *co)
region *r = co->rt;
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int force = (int)(co->force*10);
const race * race = new_race[RC_SKELETON];
if (!r->land || deathcount(r) == 0) {
@ -3739,7 +3728,7 @@ sp_summonundead(castorder *co)
return 0;
}
undead = min(deathcount(r), 2 + lovar(force * 10));
undead = min(deathcount(r), 2 + lovar(force));
if(cast_level <= 8) {
race = new_race[RC_SKELETON];
@ -3914,7 +3903,7 @@ sp_analysesong_obj(castorder *co)
obj = pa->param[0]->typ;
switch(obj){
switch(obj) {
case SPP_REGION:
magicanalyse_region(r, mage, force);
break;
@ -4027,7 +4016,7 @@ sp_charmingsong(castorder *co)
/* Magieresistensbonus für mehr als Stufe Personen */
if (target->number > force) {
resist_bonus += (target->number - force) * 10;
resist_bonus += (int)((target->number - force) * 10);
}
/* Magieresistensbonus für höhere Talentwerte */
for(i = 0; i < MAXSKILLS; i++){
@ -4039,7 +4028,7 @@ sp_charmingsong(castorder *co)
resist_bonus += tb * 15;
}
/* Magieresistenz */
if (target_resists_magic(mage, target, TYP_UNIT, resist_bonus)){
if (target_resists_magic(mage, target, TYP_UNIT, resist_bonus)) {
report_failure(mage, co->order);
sprintf(buf, "%s fühlt sich einen Moment lang benommen und desorientiert.",
unitname(target));
@ -4096,7 +4085,7 @@ sp_song_resistmagic(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int duration = force+1;
int duration = (int)force+1;
create_curse(mage, &r->attribs, ct_find("goodmagicresistancezone"),
force, duration, mr_bonus, 0);
@ -4127,7 +4116,7 @@ sp_song_susceptmagic(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int duration = force+1;
int duration = (int)force+1;
create_curse(mage, &r->attribs, ct_find("badmagicresistancezone"),
force, duration, mr_malus, 0);
@ -4227,7 +4216,7 @@ sp_raisepeasantmob(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int duration = force+1;
int duration = (int)force+1;
anteil += rand()%4;
@ -4406,10 +4395,8 @@ sp_song_of_peace(castorder *co)
int cast_level = co->level;
double force = co->force;
if(force < 2)
duration = 0;
else
duration = lovar(force/2);
if (force < 2) duration = 0;
else duration = lovar(force/2);
create_curse(mage,&r->attribs, ct_find("peacezone"), force, duration, 1,0);
@ -4450,7 +4437,7 @@ sp_generous(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int duration = force+1;
int duration = (int)force+1;
if(is_cursed(r->attribs, C_DEPRESSION, 0)){
sprintf(buf, "%s in %s: Die Stimmung in %s ist so schlecht, das "
@ -4559,13 +4546,11 @@ sp_bigrecruit(castorder *co)
}
/* Für vergleichbare Erfolge bei unterschiedlichen Rassen die
* Rekrutierungskosten mit einfliessen lassen. */
n = (int)((force * force * 1000)/f->race->recruitcost);
/* Zufälliger Wert mit n/2 Maximum, mindestens aber force Anzahl */
n = force+lovar(n);
n = (int)force + lovar((force * force * 1000)/f->race->recruitcost);
/* natürlich nur maximal soviele Bauern, wie auch in der Region sind */
n = min(rpeasants(r),n);
n = min(rpeasants(r), n);
if(n <= 0){
if (n <= 0) {
report_failure(mage, co->order);
return 0;
}
@ -4711,7 +4696,7 @@ sp_seduce(castorder *co)
loot += rand() % 2;
}
if (loot > 0) {
loot = min(loot, force * 5);
loot = (int)min(loot, force * 5);
scat(", ");
icat(loot);
scat(" ");
@ -4773,7 +4758,6 @@ sp_create_nimblefingerring(castorder *co)
static int
sp_calm_monster(castorder *co)
{
int duration;
curse * c;
unit *target;
region *r = co->rt;
@ -4783,8 +4767,6 @@ sp_calm_monster(castorder *co)
double force = co->force;
spell *sp = co->sp;
duration = force;
/* wenn kein Ziel gefunden, Zauber abbrechen */
if(pa->param[0]->flag == TARGET_NOTFOUND) return 0;
@ -4797,8 +4779,8 @@ sp_calm_monster(castorder *co)
return 0;
}
c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force, duration,
(int)mage->faction, 0);
c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force,
(int)force, (int)mage->faction, 0);
if (c==NULL) {
report_failure(mage, co->order);
return 0;
@ -4899,7 +4881,7 @@ sp_raisepeasants(castorder *co)
MSG_MAGIC, ML_MISTAKE);
return 0;
}
bauern = min(rpeasants(r),power*250);
bauern = (int)min(rpeasants(r), power*250);
rsetpeasants(r, rpeasants(r) - bauern);
u2 = create_unit(r,mage->faction, bauern, new_race[RC_PEASANT], 0,"Wilder Bauernmob",mage);
@ -4944,7 +4926,7 @@ sp_depression(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int duration = force+1;
int duration = (int)force+1;
create_curse(mage,&r->attribs, ct_find("depression"), force, duration, 0, 0);
@ -5066,9 +5048,9 @@ sp_puttorest(castorder *co)
{
region *r = co->rt;
unit *mage = (unit *)co->magician;
int laid_to_rest = 0;
laid_to_rest = dice(co->force * 2, 100);
laid_to_rest = max(laid_to_rest, deathcount(r));
int dead = deathcount(r);
int laid_to_rest = dice((int)(co->force * 2), 100);
laid_to_rest = max(laid_to_rest, dead);
deathcounts(r, -laid_to_rest);
@ -5191,7 +5173,7 @@ sp_illusionary_shapeshift(castorder *co)
}
{
trigger * trestore = trigger_changerace(u, NULL, u->irace);
add_trigger(&u->attribs, "timer", trigger_timeout(power+2, trestore));
add_trigger(&u->attribs, "timer", trigger_timeout((int)power+2, trestore));
}
u->irace = rc;
@ -5328,7 +5310,7 @@ sp_baddreams(castorder *co)
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */
duration = max(1, power/2); /* Stufe 1 macht sonst mist */
duration = (int)max(1, power/2); /* Stufe 1 macht sonst mist */
duration = 2 + rand()%duration;
/* Nichts machen als ein entsprechendes Attribut in die Region legen. */
@ -5367,7 +5349,7 @@ sp_gooddreams(castorder *co)
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */
duration = max(1, power/2); /* Stufe 1 macht sonst mist */
duration = (int)max(1, power/2); /* Stufe 1 macht sonst mist */
duration = 2 + rand()%duration;
c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, 1, 0);
curse_setflag(c, CURSE_ISNEW);
@ -5482,8 +5464,8 @@ sp_sweetdreams(castorder *co)
double power = co->force;
spellparameter *pa = co->par;
int men, n;
int duration = 1+(power/2);
int opfer = power*power;
int duration = (int)(power/2)+1;
int opfer = (int)(power*power);
/* Schleife über alle angegebenen Einheiten */
for (n = 0; n < pa->length; n++) {
@ -5533,7 +5515,7 @@ sp_disturbingdreams(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double power = co->force;
int duration = 1 + (power/6);
int duration = 1 + (int)(power/6);
curse * c = create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, 10, 0);
curse_setflag(c, CURSE_ISNEW);
@ -5554,7 +5536,7 @@ sp_dream_of_confusion(castorder *co)
int cast_level = co->level;
double power = co->force;
double range = (power-14)/2-1;
int duration = ((power-14)/2)*2+1;
int duration = (int)(power-14)+1;
rl = all_in_range(r, (int)range);
@ -5665,7 +5647,7 @@ sp_itemcloak(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double power = co->force;
int duration = power+1;
int duration = (int)power+1;
spellparameter *pa = co->par;
/* wenn kein Ziel gefunden, Zauber abbrechen */
@ -5709,7 +5691,7 @@ sp_resist_magic_bonus(castorder *co)
spellparameter *pa = co->par;
/* Pro Stufe können bis zu 5 Personen verzaubert werden */
opfer = power * 5;
opfer = (int)(power * 5);
/* Schleife über alle angegebenen Einheiten */
for (n = 0; n < pa->length; n++) {
@ -5802,7 +5784,7 @@ sp_enterastral(castorder *co)
return 0;
}
remaining_cap = (power-3) * 1500;
remaining_cap = (int)((power-3) * 1500);
/* für jede Einheit in der Kommandozeile */
for (n = 0; n < pa->length; n++) {
@ -5927,7 +5909,7 @@ sp_pullastral(castorder *co)
return 0;
}
remaining_cap = (power-3) * 1500;
remaining_cap = (int)((power-3) * 1500);
/* für jede Einheit in der Kommandozeile */
for (n = 1; n < pa->length; n++) {
@ -6010,47 +5992,45 @@ sp_leaveastral(castorder *co)
region *r = co->rt;
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double power = co->force;
spellparameter *pa = co->par;
double power = co->force;
spellparameter *pa = co->par;
switch(getplaneid(r)) {
case 1:
ro = r;
rt = pa->param[0]->data.r;
if(!rt) {
addmessage(r, mage->faction, "Dorthin führt kein Weg.",
MSG_MAGIC, ML_MISTAKE);
return 0;
}
rl = allinhab_in_range(r_astral_to_standard(r), TP_RADIUS);
rl2 = rl;
while(rl2) {
if(rl2->region == rt) break;
rl2 = rl2->next;
}
if(!rl2) {
addmessage(r, mage->faction, "Dorthin führt kein Weg.",
MSG_MAGIC, ML_MISTAKE);
free_regionlist(rl);
return 0;
}
free_regionlist(rl);
break;
default:
sprintf(buf, "Der Zauber funktioniert nur in der astralen Welt.");
addmessage(r, mage->faction, buf, MSG_MAGIC, ML_MISTAKE);
return 0;
}
switch(getplaneid(r)) {
case 1:
ro = r;
rt = pa->param[0]->data.r;
if(!rt) {
addmessage(r, mage->faction, "Dorthin führt kein Weg.",
MSG_MAGIC, ML_MISTAKE);
return 0;
}
rl = allinhab_in_range(r_astral_to_standard(r), TP_RADIUS);
rl2 = rl;
while(rl2) {
if(rl2->region == rt) break;
rl2 = rl2->next;
}
if(!rl2) {
addmessage(r, mage->faction, "Dorthin führt kein Weg.",
MSG_MAGIC, ML_MISTAKE);
free_regionlist(rl);
return 0;
}
free_regionlist(rl);
break;
default:
sprintf(buf, "Der Zauber funktioniert nur in der astralen Welt.");
addmessage(r, mage->faction, buf, MSG_MAGIC, ML_MISTAKE);
return 0;
}
if(!ro
|| is_cursed(ro->attribs, C_ASTRALBLOCK, 0)
|| is_cursed(rt->attribs, C_ASTRALBLOCK, 0)) {
sprintf(buf, "Die Wege aus dieser astralen Region sind blockiert.");
addmessage(r, mage->faction, buf, MSG_MAGIC, ML_MISTAKE);
return 0;
}
if (ro==NULL || is_cursed(ro->attribs, C_ASTRALBLOCK, 0) || is_cursed(rt->attribs, C_ASTRALBLOCK, 0)) {
sprintf(buf, "Die Wege aus dieser astralen Region sind blockiert.");
addmessage(r, mage->faction, buf, MSG_MAGIC, ML_MISTAKE);
return 0;
}
remaining_cap = (power-3) * 1500;
remaining_cap = (int)((power-3) * 1500);
/* für jede Einheit in der Kommandozeile */
for (n = 1; n < pa->length; n++) {
@ -6157,7 +6137,7 @@ sp_fetchastral(castorder *co)
return 0;
}
remaining_cap = (power-3) * 1500;
remaining_cap = (int)((power-3) * 1500);
/* für jede Einheit in der Kommandozeile */
for (n = 0; n < pa->length; n++) {
@ -6379,7 +6359,7 @@ sp_disruptastral(castorder *co)
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double power = co->force;
int duration = (power/3)+1;
int duration = (int)(power/3)+1;
switch(getplaneid(r)) {
case 0:
@ -6399,7 +6379,7 @@ sp_disruptastral(castorder *co)
return 0;
}
rl = all_in_range(rt, power/5);
rl = all_in_range(rt, (int)(power/5));
for(rl2=rl; rl; rl=rl->next) {
attrib *a, *a2;
@ -6848,13 +6828,13 @@ sp_create_antimagiccrystal(castorder *co)
int
sp_antimagiczone(castorder *co)
{
int power;
double power;
int effect;
region *r = co->rt;
unit *mage = (unit *)co->magician;
int cast_level = co->level;
double force = co->force;
int duration = force+1;
int duration = (int)force+1;
/* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus.
* Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone
@ -7111,7 +7091,6 @@ sp_destroy_curse(castorder *co)
attrib **ap;
int obj;
curse * c;
int succ = 0;
region *r = co->rt;
unit *mage = (unit *)co->magician;
int cast_level = co->level;
@ -7176,10 +7155,9 @@ sp_destroy_curse(castorder *co)
}
/* curse auflösen, wenn zauber stärker (force > vigour)*/
succ = c->vigour - force;
c->vigour = max(0, succ);
c->vigour -= force;
if(succ <= 0) {
if (c->vigour <= 0.0) {
remove_curse(ap, c);
add_message(&mage->faction->msgs, new_message(mage->faction,
@ -7192,7 +7170,7 @@ sp_destroy_curse(castorder *co)
mage, mage->region, strdup(co->order)));
}
}
if(ts != NULL) free(ts);
if (ts != NULL) free(ts);
return cast_level;
}
@ -7247,11 +7225,10 @@ sp_earn_silver(castorder *co)
unit *mage = (unit *)co->magician;
double force = co->force;
region *r = co->rt;
int wanted, earned;
int wanted = (int)(force * 50);
int earned = min(rmoney(r), wanted);
wanted = force * 50;
earned = min(rmoney(r), wanted);
rsetmoney(r, rmoney(r) - earned);
rsetmoney(r, rmoney(r) - earned);
change_money(mage, earned);
/* TODO klären: ist das Silber damit schon reserviert? */

View File

@ -33,7 +33,7 @@
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="4"
SuppressStartupBanner="FALSE"
SuppressStartupBanner="TRUE"
DebugInformationFormat="1"
CompileAs="0"/>
<Tool

View File

@ -40,7 +40,7 @@ typedef struct createcurse_data {
struct unit * mage;
struct unit * target;
const curse_type * type;
int vigour;
double vigour;
int duration;
int effect;
int men;
@ -81,7 +81,7 @@ createcurse_write(const trigger * t, FILE * F)
createcurse_data * td = (createcurse_data*)t->data.v;
fprintf(F, "%s ", itoa36(td->mage->no));
fprintf(F, "%s ", itoa36(td->target->no));
fprintf(F, "%s %d %d %d %d ", td->type->cname, td->vigour, td->duration, td->effect, td->men);
fprintf(F, "%s %lf %d %d %d ", td->type->cname, td->vigour, td->duration, td->effect, td->men);
}
static int
@ -103,11 +103,11 @@ createcurse_read(trigger * t, FILE * F)
if (global.data_version<CURSETYPE_VERSION) {
int id1, id2;
fscanf(F, "%d %d %d %d %d %d ", &id1, &id2, &td->vigour, &td->duration, &td->effect, &td->men);
fscanf(F, "%d %d %lf %d %d %d ", &id1, &id2, &td->vigour, &td->duration, &td->effect, &td->men);
assert(id2==0);
td->type = ct_find(oldcursename(id1));
} else {
fscanf(F, "%s %d %d %d %d ", zText, &td->vigour, &td->duration, &td->effect, &td->men);
fscanf(F, "%s %lf %d %d %d ", zText, &td->vigour, &td->duration, &td->effect, &td->men);
td->type = ct_find(zText);
}
return AT_READ_OK;
@ -124,7 +124,7 @@ trigger_type tt_createcurse = {
trigger *
trigger_createcurse(struct unit * mage, struct unit * target,
const curse_type * ct, int vigour, int duration,
const curse_type * ct, double vigour, int duration,
int effect, int men)
{
trigger * t = t_new(&tt_createcurse);

View File

@ -28,7 +28,7 @@ struct unit;
extern struct trigger_type tt_createcurse;
extern struct trigger * trigger_createcurse(struct unit * mage, struct unit * target, const struct curse_type * ct, int vigour, int duration, int effect, int men);
extern struct trigger * trigger_createcurse(struct unit * mage, struct unit * target, const struct curse_type * ct, double vigour, int duration, int effect, int men);
#ifdef __cplusplus
}

File diff suppressed because it is too large Load Diff