curses use floating-point everywhere (variants go home!)

This commit is contained in:
Enno Rehling 2009-07-23 06:19:37 +00:00
parent 3a74778bba
commit c175a8dcea
19 changed files with 130 additions and 132 deletions

View File

@ -3066,7 +3066,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
blessedharvest_ct = ct_find("blessedharvest"); blessedharvest_ct = ct_find("blessedharvest");
} }
if (blessedharvest_ct) { if (blessedharvest_ct) {
int happy = curse_geteffect(get_curse(r->attribs, blessedharvest_ct)); int happy = (int)curse_geteffect(get_curse(r->attribs, blessedharvest_ct));
happy = MIN(happy, jobs); happy = MIN(happy, jobs);
earnings += happy; earnings += happy;
} }

View File

@ -73,14 +73,14 @@ static int
use_speedsail(struct unit * u, const struct item_type * itype, int amount, struct order * ord) use_speedsail(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
{ {
curse *c; curse *c;
variant effect; double effect;
ship * sh = u->ship; ship * sh = u->ship;
if (!sh) { if (!sh) {
cmistake(u, ord, 20, MSG_MOVE); cmistake(u, ord, 20, MSG_MOVE);
return -1; return -1;
} }
effect.i = SPEEDSAIL_EFFECT; effect = SPEEDSAIL_EFFECT;
c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, effect, 0); c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, effect, 0);
c_setflag(c, CURSE_NOAGE); c_setflag(c, CURSE_NOAGE);
@ -145,9 +145,7 @@ use_antimagiccrystal(unit * u, const struct item_type * itype, int amount, struc
} }
if (force > 0) { if (force > 0) {
variant var ; create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, effect, 0);
var.i = effect;
create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, var, 0);
} }
} }
use_pooled(u, rt_crystal, GET_DEFAULT, amount); use_pooled(u, rt_crystal, GET_DEFAULT, amount);
@ -208,7 +206,6 @@ use_bagpipeoffear(struct unit * u, const struct item_type * itype,
int amount, struct order * ord) int amount, struct order * ord)
{ {
int money; int money;
variant effect;
if (get_curse(u->region->attribs, ct_find("depression"))) { if (get_curse(u->region->attribs, ct_find("depression"))) {
cmistake(u, ord, 58, MSG_MAGIC); cmistake(u, ord, 58, MSG_MAGIC);
@ -219,9 +216,8 @@ use_bagpipeoffear(struct unit * u, const struct item_type * itype,
change_money(u, money); change_money(u, money);
rsetmoney(u->region, rmoney(u->region) - money); rsetmoney(u->region, rmoney(u->region) - money);
effect.i = 0;
create_curse(u, &u->region->attribs, ct_find("depression"), create_curse(u, &u->region->attribs, ct_find("depression"),
20, BAGPIPEDURATION, effect, 0); 20, BAGPIPEDURATION, 0.0, 0);
ADDMSG(&u->faction->msgs, msg_message("bagpipeoffear_faction", ADDMSG(&u->faction->msgs, msg_message("bagpipeoffear_faction",
"unit region command money", u, u->region, ord, money)); "unit region command money", u, u->region, ord, money));

View File

@ -3034,8 +3034,8 @@ age_building(building * b)
if (c==NULL) { if (c==NULL) {
if (mage!=NULL) { if (mage!=NULL) {
int sk = effskill(mage, SK_MAGIC); int sk = effskill(mage, SK_MAGIC);
variant effect; double effect;
effect.i = 100; effect = 100;
/* the mage reactivates the circle */ /* the mage reactivates the circle */
c = create_curse(mage, &rt->attribs, ct_astralblock, c = create_curse(mage, &rt->attribs, ct_astralblock,
(float)sk, sk/2, effect, 0); (float)sk, sk/2, effect, 0);
@ -3134,7 +3134,7 @@ ageing(void)
if (is_cursed(u->attribs, C_OLDRACE, 0)){ if (is_cursed(u->attribs, C_OLDRACE, 0)){
curse *c = get_curse(u->attribs, ct_find("oldrace")); curse *c = get_curse(u->attribs, ct_find("oldrace"));
if (c->duration == 1 && !(c_flags(c) & CURSE_NOAGE)) { if (c->duration == 1 && !(c_flags(c) & CURSE_NOAGE)) {
u->race = new_race[curse_geteffect(c)]; u->race = new_race[curse_geteffect_int(c)];
u->irace = NULL; u->irace = NULL;
} }
} }
@ -3444,7 +3444,7 @@ monthly_healing(void)
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit *u; unit *u;
int healingcurse = 0; double healingcurse = 0;
if (heal_ct!=NULL) { if (heal_ct!=NULL) {
/* bonus zurücksetzen */ /* bonus zurücksetzen */

View File

@ -1038,10 +1038,10 @@ orc_growth(void)
int n; int n;
int increase = 0; int increase = 0;
int num = get_cursedmen(u, c); int num = get_cursedmen(u, c);
int prob = curse_geteffect(c); double prob = curse_geteffect(c);
for (n = (num - get_item(u, I_CHASTITY_BELT)); n > 0; n--) { for (n = (num - get_item(u, I_CHASTITY_BELT)); n > 0; n--) {
if (rng_int() % 100 < prob) { if (chance(prob)) {
++increase; ++increase;
} }
} }

View File

@ -67,11 +67,9 @@ use_hornofdancing(struct unit * u, const struct item_type * itype,
if(distance(u->region, r) < HORNRANGE) { if(distance(u->region, r) < HORNRANGE) {
if(a_find(r->attribs, &at_peaceimmune) == NULL) { if(a_find(r->attribs, &at_peaceimmune) == NULL) {
attrib *a; attrib *a;
variant effect;
effect.i = 1;
create_curse(u, &r->attribs, ct_find("peacezone"), create_curse(u, &r->attribs, ct_find("peacezone"),
20, HORNDURATION, effect, 0); 20, HORNDURATION, 1.0, 0);
a = a_add(&r->attribs, a_new(&at_peaceimmune)); a = a_add(&r->attribs, a_new(&at_peaceimmune));
a->data.i = HORNIMMUNITY; a->data.i = HORNIMMUNITY;
@ -107,7 +105,6 @@ useonother_trappedairelemental(struct unit * u, int shipId,
{ {
curse *c; curse *c;
ship *sh; ship *sh;
variant effect;
if (shipId <= 0) { if (shipId <= 0) {
cmistake(u, ord, 20, MSG_MOVE); cmistake(u, ord, 20, MSG_MOVE);
@ -120,8 +117,7 @@ useonother_trappedairelemental(struct unit * u, int shipId,
return -1; return -1;
} }
effect.i = SPEEDUP; c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, SPEEDUP, 0);
c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, effect, 0);
c_setflag(c, CURSE_NOAGE); c_setflag(c, CURSE_NOAGE);
ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success", ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success",

View File

@ -1928,7 +1928,7 @@ skilldiff(troop at, troop dt, int dist)
curse * c = get_curse(df->building->attribs, strongwall_ct); curse * c = get_curse(df->building->attribs, strongwall_ct);
if (curse_active(c)) { if (curse_active(c)) {
/* wirkt auf alle Gebäude */ /* wirkt auf alle Gebäude */
skdiff -= curse_geteffect(c); skdiff -= curse_geteffect_int(c);
is_protected = 2; is_protected = 2;
} }
} }
@ -3275,7 +3275,7 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
curse *c = get_curse(u->attribs, speed_ct); curse *c = get_curse(u->attribs, speed_ct);
if (c) { if (c) {
speeded = get_cursedmen(u, c); speeded = get_cursedmen(u, c);
speed = curse_geteffect(c); speed = curse_geteffect_int(c);
} }
} }
} }

View File

@ -206,7 +206,11 @@ curse_read(attrib * a, struct storage * store)
} else { } else {
ur = read_reference(&c->magician, store, read_unit_reference, resolve_unit); ur = read_reference(&c->magician, store, read_unit_reference, resolve_unit);
} }
c->effect.i = store->r_int(store); if (store->version<CURSEFLOAT_VERSION) {
c->effect = (double)store->r_int(store);
} else {
c->effect = store->r_flt(store);
}
c->type = ct_find(cursename); c->type = ct_find(cursename);
if (c->type==NULL) { if (c->type==NULL) {
int result = read_ccompat(cursename, store); int result = read_ccompat(cursename, store);
@ -257,7 +261,7 @@ curse_write(const attrib * a, struct storage * store)
store->w_int(store, c->duration); store->w_int(store, c->duration);
store->w_flt(store, (float)c->vigour); store->w_flt(store, (float)c->vigour);
write_unit_reference(mage, store); write_unit_reference(mage, store);
store->w_int(store, c->effect.i); store->w_flt(store, (float)c->effect);
if (c->type->write) c->type->write(store, c); if (c->type->write) c->type->write(store, c);
else if (c->type->typ == CURSETYP_UNIT) { else if (c->type->typ == CURSETYP_UNIT) {
@ -435,12 +439,20 @@ curse_changevigour(attrib **ap, curse *c, double vigour)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
int double
curse_geteffect(const curse *c) curse_geteffect(const curse *c)
{ {
if (c==NULL) return 0; if (c==NULL) return 0;
if (c_flags(c) & CURSE_ISNEW) return 0; if (c_flags(c) & CURSE_ISNEW) return 0;
return c->effect.i; return c->effect;
}
int
curse_geteffect_int(const curse *c)
{
double effect = curse_geteffect(c);
assert(effect-(int)effect == 0);
return (int)effect;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -491,7 +503,7 @@ set_cursedmen(curse *c, int cursedmen)
*/ */
static curse * static curse *
make_curse(unit *mage, attrib **ap, const curse_type *ct, double vigour, make_curse(unit *mage, attrib **ap, const curse_type *ct, double vigour,
int duration, variant effect, int men) int duration, double effect, int men)
{ {
curse *c; curse *c;
attrib * a; attrib * a;
@ -532,7 +544,7 @@ make_curse(unit *mage, attrib **ap, const curse_type *ct, double vigour,
*/ */
curse * curse *
create_curse(unit *magician, attrib **ap, const curse_type *ct, double vigour, create_curse(unit *magician, attrib **ap, const curse_type *ct, double vigour,
int duration, variant effect, int men) int duration, double effect, int men)
{ {
curse *c; curse *c;
@ -555,10 +567,10 @@ create_curse(unit *magician, attrib **ap, const curse_type *ct, double vigour,
c->duration += duration; c->duration += duration;
} }
if(ct->mergeflags & M_SUMEFFECT){ if(ct->mergeflags & M_SUMEFFECT){
c->effect.i += effect.i; c->effect += effect;
} }
if(ct->mergeflags & M_MAXEFFECT){ if(ct->mergeflags & M_MAXEFFECT){
c->effect.i = MAX(c->effect.i, effect.i); c->effect = MAX(c->effect, effect);
} }
if(ct->mergeflags & M_VIGOUR){ if(ct->mergeflags & M_VIGOUR){
c->vigour = MAX(vigour, c->vigour); c->vigour = MAX(vigour, c->vigour);

View File

@ -191,7 +191,7 @@ typedef struct curse {
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */ int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */
double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */ double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */
struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */ struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
variant effect; double effect;
variant data; /* pointer auf spezielle curse-unterstructs*/ variant data; /* pointer auf spezielle curse-unterstructs*/
} curse; } curse;
@ -240,7 +240,7 @@ extern int curse_read(struct attrib * a, struct storage * store);
*/ */
curse * create_curse(struct unit *magician, struct attrib**ap, const curse_type * ctype, curse * create_curse(struct unit *magician, struct attrib**ap, const curse_type * ctype,
double vigour, int duration, variant ceffect, int men); double vigour, int duration, double ceffect, int men);
/* Verzweigt automatisch zum passenden struct-typ. Sollte es schon /* Verzweigt automatisch zum passenden struct-typ. Sollte es schon
* einen Zauber dieses Typs geben, so wird der neue dazuaddiert. Die * einen Zauber dieses Typs geben, so wird der neue dazuaddiert. Die
* Zahl der verzauberten Personen sollte beim Aufruf der Funktion * Zahl der verzauberten Personen sollte beim Aufruf der Funktion
@ -257,7 +257,8 @@ extern void remove_curse(struct attrib **ap, const struct curse * c);
/* löscht einen konkreten Spruch auf einem Objekt. /* löscht einen konkreten Spruch auf einem Objekt.
*/ */
extern int curse_geteffect(const struct curse * c); extern int curse_geteffect_int(const struct curse * c);
extern double curse_geteffect(const struct curse * c);
/* gibt die Auswirkungen der Verzauberungen zurück. zB bei /* gibt die Auswirkungen der Verzauberungen zurück. zB bei
* Skillmodifiziernden Verzauberungen ist hier der Modifizierer * Skillmodifiziernden Verzauberungen ist hier der Modifizierer
* gespeichert. Wird automatisch beim Anlegen eines neuen curse * gespeichert. Wird automatisch beim Anlegen eines neuen curse

View File

@ -636,7 +636,7 @@ ShipSpeedBonus(const unit * u)
int int
shipspeed(const ship * sh, const unit * u) shipspeed(const ship * sh, const unit * u)
{ {
int k = sh->type->range; double k = sh->type->range;
static const curse_type * stormwind_ct, * nodrift_ct; static const curse_type * stormwind_ct, * nodrift_ct;
static boolean init; static boolean init;
attrib *a; attrib *a;
@ -686,7 +686,7 @@ shipspeed(const ship * sh, const unit * u)
if (sh->damage) k = (k * (sh->size * DAMAGE_SCALE - sh->damage) + sh->size * DAMAGE_SCALE- 1) / (sh->size*DAMAGE_SCALE); if (sh->damage) k = (k * (sh->size * DAMAGE_SCALE - sh->damage) + sh->size * DAMAGE_SCALE- 1) / (sh->size*DAMAGE_SCALE);
#endif #endif
return k; return (int)k;
} }
#define FMAXHASH 2039 #define FMAXHASH 2039
@ -2654,7 +2654,7 @@ default_wage(const region *r, const faction * f, const race * rc)
building *b = largestbuilding(r, &is_castle, false); building *b = largestbuilding(r, &is_castle, false);
int esize = 0; int esize = 0;
curse * c; curse * c;
int wage; double wage;
attrib *a; attrib *a;
const building_type *artsculpture_type = bt_find("artsculpture"); const building_type *artsculpture_type = bt_find("artsculpture");
static const curse_type * drought_ct, * blessedharvest_ct; static const curse_type * drought_ct, * blessedharvest_ct;
@ -2717,7 +2717,7 @@ default_wage(const region *r, const faction * f, const race * rc)
a = a_find(r->attribs, &at_reduceproduction); a = a_find(r->attribs, &at_reduceproduction);
if (a) wage = (wage * a->data.sa[0])/100; if (a) wage = (wage * a->data.sa[0])/100;
return wage; return (int)wage;
} }
static int static int
@ -3048,7 +3048,7 @@ default_order(const struct locale * lang)
int int
entertainmoney(const region *r) entertainmoney(const region *r)
{ {
int n; double n;
if (is_cursed(r->attribs, C_DEPRESSION, 0)) { if (is_cursed(r->attribs, C_DEPRESSION, 0)) {
return 0; return 0;
@ -3060,7 +3060,7 @@ entertainmoney(const region *r)
n *= get_curseeffect(r->attribs, C_GENEROUS, 0); n *= get_curseeffect(r->attribs, C_GENEROUS, 0);
} }
return n; return (int)n;
} }
int rule_give(void) int rule_give(void)

View File

@ -693,9 +693,9 @@ use_tacticcrystal(unit * u, const struct item_type * itype, int amount, struct o
Fall egal, da der curse für den Kampf gelten soll, Fall egal, da der curse für den Kampf gelten soll,
der vor den Antimagiezaubern passiert */ der vor den Antimagiezaubern passiert */
curse * c; curse * c;
variant effect; double effect;
effect.i = rng_int()%6 - 1; effect = rng_int()%6 - 1;
c = create_curse(u, &u->attribs, ct_find("skillmod"), power, c = create_curse(u, &u->attribs, ct_find("skillmod"), power,
duration, effect, u->number); duration, effect, u->number);
c->data.i = SK_TACTICS; c->data.i = SK_TACTICS;

View File

@ -772,8 +772,8 @@ use_item_aura(const region * r, const unit * u)
int int
max_spellpoints(const region * r, const unit * u) max_spellpoints(const region * r, const unit * u)
{ {
int sk, n; int sk;
double msp; double n, msp;
double potenz = 2.1; double potenz = 2.1;
double divisor = 1.2; double divisor = 1.2;
@ -1387,7 +1387,7 @@ do_fumble(castorder *co)
const spell *sp = co->sp; const spell *sp = co->sp;
int level = co->level; int level = co->level;
int duration; int duration;
variant effect; double effect;
ADDMSG(&u->faction->msgs, msg_message("patzer", "unit region spell", ADDMSG(&u->faction->msgs, msg_message("patzer", "unit region spell",
u, r, sp)); u, r, sp));
@ -1429,7 +1429,7 @@ do_fumble(castorder *co)
case 2: case 2:
/* temporärer Stufenverlust */ /* temporärer Stufenverlust */
duration = MAX(rng_int()%level/2, 2); duration = MAX(rng_int()%level/2, 2);
effect.i = -(level/2); effect = -0.5*level;
c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, duration, c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, duration,
effect, 1); effect, 1);
c->data.i = SK_MAGIC; c->data.i = SK_MAGIC;
@ -1517,7 +1517,7 @@ regeneration_magiepunkte(void)
int aura, auramax; int aura, auramax;
double reg_aura; double reg_aura;
int regen; int regen;
int n; double mod;
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
@ -1534,9 +1534,9 @@ regeneration_magiepunkte(void)
if (btype) reg_aura *= btype->auraregen; if (btype) reg_aura *= btype->auraregen;
/* Bonus/Malus durch Zauber */ /* Bonus/Malus durch Zauber */
n = get_curseeffect(u->attribs, C_AURA, 0); mod = get_curseeffect(u->attribs, C_AURA, 0);
if (n>0) { if (mod>0) {
reg_aura = (reg_aura*n)/100; reg_aura = (reg_aura*mod)/100.0;
} }
/* Einfluss von Artefakten */ /* Einfluss von Artefakten */

View File

@ -62,6 +62,7 @@
#define UIDHASH_VERSION 332 /* borders use the region.uid to store */ #define UIDHASH_VERSION 332 /* borders use the region.uid to store */
#define REGIONOWNER_VERSION 333 /* regions have owners and morale */ #define REGIONOWNER_VERSION 333 /* regions have owners and morale */
#define ALLIANCELEADER_VERSION 333 /* alliances have a leader */ #define ALLIANCELEADER_VERSION 333 /* alliances have a leader */
#define CURSEFLOAT_VERSION 334 /* all curse-effects are float */
#define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */ #define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */
#define RELEASE_VERSION ALLIANCELEADER_VERSION /* current datafile */ #define RELEASE_VERSION CURSEFLOAT_VERSION /* current datafile */

View File

@ -152,7 +152,7 @@ alp_findet_opfer(unit *alp, region *r)
alp_data * ad = (alp_data*)a->data.v; alp_data * ad = (alp_data*)a->data.v;
unit *mage = ad->mage; unit *mage = ad->mage;
unit *opfer = ad->target; unit *opfer = ad->target;
variant effect; double effect;
message * msg; message * msg;
assert(opfer); assert(opfer);
@ -172,7 +172,7 @@ alp_findet_opfer(unit *alp, region *r)
a_removeall(&alp->attribs, &at_eventhandler); a_removeall(&alp->attribs, &at_eventhandler);
/* Alp umwandeln in Curse */ /* Alp umwandeln in Curse */
effect.i = -2; effect = -2;
c = create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect, opfer->number); c = create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect, opfer->number);
/* solange es noch keine spezielle alp-Antimagie gibt, reagiert der /* solange es noch keine spezielle alp-Antimagie gibt, reagiert der
* auch auf normale */ * auch auf normale */

View File

@ -841,7 +841,7 @@ sp_strong_wall(fighter * fi, int level, double power, spell * sp)
battle *b = fi->side->battle; battle *b = fi->side->battle;
unit *mage = fi->unit; unit *mage = fi->unit;
building *burg; building *burg;
variant effect; double effect;
static boolean init = false; static boolean init = false;
message * msg; message * msg;
static const curse_type * strongwall_ct; static const curse_type * strongwall_ct;
@ -854,9 +854,7 @@ sp_strong_wall(fighter * fi, int level, double power, spell * sp)
} }
burg = mage->building; burg = mage->building;
effect.i = (int)(power/4); effect = power*0.25;
if (chance(power-effect.i)) ++effect.i;
create_curse(mage, &burg->attribs, strongwall_ct, power, 1, effect, 0); create_curse(mage, &burg->attribs, strongwall_ct, power, 1, effect, 0);
msg = msg_message("sp_strongwalls_effect", "mage building", mage, mage->building); msg = msg_message("sp_strongwalls_effect", "mage building", mage, mage->building);

View File

@ -96,7 +96,7 @@
#include <attributes/hate.h> #include <attributes/hate.h>
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static variant zero_effect = { 0 }; static double zero_effect = 0.0;
attrib_type at_unitdissolve = { attrib_type at_unitdissolve = {
"unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars "unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars
@ -996,7 +996,7 @@ sp_maelstrom(castorder *co)
int cast_level = co->level; int cast_level = co->level;
curse * c; curse * c;
double power = co->force; double power = co->force;
variant effect; double effect = co->force;
int duration = (int)power+1; int duration = (int)power+1;
if (!fval(r->terrain, SEA_REGION)) { if (!fval(r->terrain, SEA_REGION)) {
@ -1008,7 +1008,6 @@ sp_maelstrom(castorder *co)
/* Attribut auf Region. /* Attribut auf Region.
* Existiert schon ein curse, so wird dieser verstärkt * Existiert schon ein curse, so wird dieser verstärkt
* (Max(Dauer), Max(Stärke))*/ * (Max(Dauer), Max(Stärke))*/
effect.i = (int)power;
c = create_curse(mage, &r->attribs, ct_find("maelstrom"), power, duration, effect, 0); c = create_curse(mage, &r->attribs, ct_find("maelstrom"), power, duration, effect, 0);
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
@ -1087,25 +1086,25 @@ sp_blessedharvest(castorder *co)
unit *mage = co->magician.u; 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; double effect;
int rule = rule_blessed_harvest(); int rule = rule_blessed_harvest();
/* Attribut auf Region. /* Attribut auf Region.
* Existiert schon ein curse, so wird dieser verstärkt * Existiert schon ein curse, so wird dieser verstärkt
* (Max(Dauer), Max(Stärke))*/ * (Max(Dauer), Max(Stärke))*/
if (rule==HARVEST_WORK) { if (rule==HARVEST_WORK) {
int duration = (int)power+1; int duration = (int)power+1;
effect.i = 1; effect = 1;
create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0); create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0);
} else if (rule==HARVEST_TAXES) { } else if (rule==HARVEST_TAXES) {
int duration = (int)(power*2); int duration = (int)(power*2);
if (co->sp->id!=SPL_BLESSEDHARVEST) { if (co->sp->id!=SPL_BLESSEDHARVEST) {
effect.i = (int)(100 * power); effect = (int)(100 * power);
create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0); create_curse(mage, &r->attribs, ct_find("blessedharvest"), power, duration, effect, 0);
} else { } else {
int d; int d;
region * rn[MAXDIRECTIONS]; region * rn[MAXDIRECTIONS];
get_neighbours(r, rn); get_neighbours(r, rn);
effect.i = (int)(50 * power); effect = (int)(50 * power);
for (d=0;d!=MAXDIRECTIONS;++d) { for (d=0;d!=MAXDIRECTIONS;++d) {
region * rx = rn[d]; region * rx = rn[d];
if (rx && rx->land) { if (rx && rx->land) {
@ -1387,7 +1386,7 @@ sp_kaelteschutz(castorder *co)
double force = co->force; double force = co->force;
int duration = MAX(cast_level, (int)force) + 1; int duration = MAX(cast_level, (int)force) + 1;
spellparameter *pa = co->par; spellparameter *pa = co->par;
variant effect; double effect;
force*=10; /* 10 Personen pro Force-Punkt */ force*=10; /* 10 Personen pro Force-Punkt */
@ -1408,7 +1407,7 @@ sp_kaelteschutz(castorder *co)
men = u->number; men = u->number;
} }
effect.i = 1; effect = 1;
create_curse(mage, &u->attribs, ct_find("insectfur"), cast_level, create_curse(mage, &u->attribs, ct_find("insectfur"), cast_level,
duration, effect, men); duration, effect, men);
@ -1447,7 +1446,7 @@ sp_sparkle(castorder *co)
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;
variant effect; double effect;
/* wenn kein Ziel gefunden, Zauber abbrechen */ /* wenn kein Ziel gefunden, Zauber abbrechen */
if (pa->param[0]->flag == TARGET_NOTFOUND) return 0; if (pa->param[0]->flag == TARGET_NOTFOUND) return 0;
@ -1457,7 +1456,7 @@ sp_sparkle(castorder *co)
if (pa->param[0]->flag == TARGET_RESISTS) return cast_level; if (pa->param[0]->flag == TARGET_RESISTS) return cast_level;
u = pa->param[0]->data.u; u = pa->param[0]->data.u;
effect.i = rng_int(); effect = rng_int() % 0xffffff;
create_curse(mage, &u->attribs, ct_find("sparkle"), cast_level, create_curse(mage, &u->attribs, ct_find("sparkle"), cast_level,
duration, effect, u->number); duration, effect, u->number);
@ -1632,7 +1631,7 @@ sp_great_drought(castorder *co)
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = 2; int duration = 2;
variant effect; double effect;
if (fval(r->terrain, SEA_REGION) ) { if (fval(r->terrain, SEA_REGION) ) {
cmistake(mage, co->order, 189, MSG_MAGIC); cmistake(mage, co->order, 189, MSG_MAGIC);
@ -1648,7 +1647,7 @@ sp_great_drought(castorder *co)
rsethorses(r, rhorses(r)/2); rsethorses(r, rhorses(r)/2);
/* Arbeitslohn = 1/4 */ /* Arbeitslohn = 1/4 */
effect.i = 4; effect = 4.0; /* curses: higher is stronger */
create_curse(mage, &r->attribs, ct_find("drought"), force, duration, effect, 0); create_curse(mage, &r->attribs, ct_find("drought"), force, duration, effect, 0);
/* terraforming */ /* terraforming */
@ -2031,7 +2030,7 @@ sp_homestone(castorder *co)
unit *mage = co->magician.u; 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; double effect;
message * msg; message * msg;
if (!mage->building || mage->building->type != bt_find("castle")) { if (!mage->building || mage->building->type != bt_find("castle")) {
cmistake(mage, co->order, 197, MSG_MAGIC); cmistake(mage, co->order, 197, MSG_MAGIC);
@ -2048,7 +2047,7 @@ sp_homestone(castorder *co)
c_setflag(c, CURSE_NOAGE|CURSE_ONLYONE); c_setflag(c, CURSE_NOAGE|CURSE_ONLYONE);
/* Magieresistenz der Burg erhöht sich um 50% */ /* Magieresistenz der Burg erhöht sich um 50% */
effect.i = 50; effect = 50;
c = create_curse(mage, &mage->building->attribs, c = create_curse(mage, &mage->building->attribs,
ct_find("magicresistance"), force*force, 1, effect, 0); ct_find("magicresistance"), force*force, 1, effect, 0);
c_setflag(c, CURSE_NOAGE); c_setflag(c, CURSE_NOAGE);
@ -2115,14 +2114,14 @@ sp_drought(castorder *co)
c->vigour = MAX(c->vigour, power); c->vigour = MAX(c->vigour, power);
c->duration = MAX(c->duration, (int)power); c->duration = MAX(c->duration, (int)power);
} else { } else {
variant effect; double effect;
/* Baeume und Pferde sterben */ /* Baeume und Pferde sterben */
rsettrees(r, 2, rtrees(r,2)/2); rsettrees(r, 2, rtrees(r,2)/2);
rsettrees(r, 1, rtrees(r,1)/2); rsettrees(r, 1, rtrees(r,1)/2);
rsettrees(r, 0, rtrees(r,0)/2); rsettrees(r, 0, rtrees(r,0)/2);
rsethorses(r, rhorses(r)/2); rsethorses(r, rhorses(r)/2);
effect.i = 4; effect = 4.0;
create_curse(mage, &r->attribs, ct_find("drought"), power, duration, effect, 0); create_curse(mage, &r->attribs, ct_find("drought"), power, duration, effect, 0);
} }
return cast_level; return cast_level;
@ -2486,7 +2485,7 @@ sp_fumblecurse(castorder *co)
unit *mage = co->magician.u; 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; double effect;
curse * c; curse * c;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -2499,7 +2498,7 @@ sp_fumblecurse(castorder *co)
sx = cast_level - effskill(target, SK_MAGIC); sx = cast_level - effskill(target, SK_MAGIC);
duration = MAX(sx, rx) + 1; duration = MAX(sx, rx) + 1;
effect.i = (int)(force/2); effect = force*0.5;
c = create_curse(mage, &target->attribs, ct_find("fumble"), c = create_curse(mage, &target->attribs, ct_find("fumble"),
force, duration, effect, 0); force, duration, effect, 0);
if (c == NULL) { if (c == NULL) {
@ -2520,10 +2519,10 @@ patzer_fumblecurse(castorder *co)
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;
variant effect; double effect;
curse * c; curse * c;
effect.i = (int)(force/2); effect = force*0.5;
c = create_curse(mage, &mage->attribs, ct_find("fumble"), force, c = create_curse(mage, &mage->attribs, ct_find("fumble"), force,
duration, effect, 0); duration, effect, 0);
if (c!=NULL) { if (c!=NULL) {
@ -3135,7 +3134,7 @@ dc_age(struct curse * c)
up = &r->units; up = &r->units;
if (curse_active(c)) while (*up!=NULL) { if (curse_active(c)) while (*up!=NULL) {
unit * u = *up; unit * u = *up;
double damage = c->effect.f * u->number; double damage = c->effect * u->number;
freset(u->faction, FFL_SELECT); freset(u->faction, FFL_SELECT);
if (u->number<=0 || target_resists_magic(mage, u, TYP_UNIT, 0)) { if (u->number<=0 || target_resists_magic(mage, u, TYP_UNIT, 0)) {
@ -3160,10 +3159,10 @@ static struct curse_type ct_deathcloud = {
static curse * static curse *
mk_deathcloud(unit * mage, region * r, double force, int duration) mk_deathcloud(unit * mage, region * r, double force, int duration)
{ {
variant effect; double effect;
curse * c; curse * c;
effect.f = (float)force/2; effect = force * 0.5;
c = create_curse(mage, &r->attribs, &ct_deathcloud, force, duration, effect, 0); c = create_curse(mage, &r->attribs, &ct_deathcloud, force, duration, effect, 0);
c->data.v = r; c->data.v = r;
return c; return c;
@ -3191,10 +3190,10 @@ dc_read_compat(struct attrib * a, storage * store)
r = findregion(rx, ry); r = findregion(rx, ry);
if (r!=NULL) { if (r!=NULL) {
variant effect; double effect;
curse * c; curse * c;
effect.f = (float)strength; effect = strength;
c = create_curse(u, &r->attribs, &ct_deathcloud, strength * 2, duration, effect, 0); c = create_curse(u, &r->attribs, &ct_deathcloud, strength * 2, duration, effect, 0);
c->data.v = r; c->data.v = r;
if (u==NULL) { if (u==NULL) {
@ -3469,7 +3468,7 @@ sp_magicboost(castorder *co)
unit *mage = co->magician.u; 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; double effect;
trigger * tsummon; trigger * tsummon;
static const curse_type * ct_auraboost; static const curse_type * ct_auraboost;
static const curse_type * ct_magicboost; static const curse_type * ct_magicboost;
@ -3486,11 +3485,11 @@ sp_magicboost(castorder *co)
return 0; return 0;
} }
effect.i = 6; effect = 6;
c = create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1); c = create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1);
/* one aura boost with 200% aura now: */ /* one aura boost with 200% aura now: */
effect.i = 200; effect = 200;
c = create_curse(mage, &mage->attribs, ct_auraboost, power, 4, effect, 1); c = create_curse(mage, &mage->attribs, ct_auraboost, power, 4, effect, 1);
/* and one aura boost with 50% aura in 5 weeks: */ /* and one aura boost with 50% aura in 5 weeks: */
@ -3912,16 +3911,14 @@ sp_charmingsong(castorder *co)
static int static int
sp_song_resistmagic(castorder *co) sp_song_resistmagic(castorder *co)
{ {
variant mr_bonus;
region *r = co->rt; region *r = co->rt;
unit *mage = co->magician.u; 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;
mr_bonus.i = 15;
create_curse(mage, &r->attribs, ct_find("goodmagicresistancezone"), create_curse(mage, &r->attribs, ct_find("goodmagicresistancezone"),
force, duration, mr_bonus, 0); force, duration, 15, 0);
/* Erfolg melden */ /* Erfolg melden */
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
@ -3944,16 +3941,14 @@ sp_song_resistmagic(castorder *co)
static int static int
sp_song_susceptmagic(castorder *co) sp_song_susceptmagic(castorder *co)
{ {
variant mr_malus;
region *r = co->rt; region *r = co->rt;
unit *mage = co->magician.u; 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;
mr_malus.i = 15;
create_curse(mage, &r->attribs, ct_find("badmagicresistancezone"), create_curse(mage, &r->attribs, ct_find("badmagicresistancezone"),
force, duration, mr_malus, 0); force, duration, 15, 0);
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"regionmagic_effect", "unit region command", mage, "regionmagic_effect", "unit region command", mage,
@ -4030,7 +4025,7 @@ sp_raisepeasantmob(castorder *co)
unit *u; unit *u;
attrib *a; attrib *a;
int n; int n;
variant anteil; int anteil;
region *r = co->rt; region *r = co->rt;
unit *mage = co->magician.u; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
@ -4039,9 +4034,9 @@ sp_raisepeasantmob(castorder *co)
faction * monsters = get_monsters(); faction * monsters = get_monsters();
message * msg; message * msg;
anteil.i = 6 + (rng_int()%4); anteil = 6 + (rng_int()%4);
n = rpeasants(r) * anteil.i / 10; n = rpeasants(r) * anteil / 10;
n = MAX(0, n); n = MAX(0, n);
n = MIN(n, rpeasants(r)); n = MIN(n, rpeasants(r));
@ -4061,7 +4056,7 @@ sp_raisepeasantmob(castorder *co)
a->data.ca[1] = 15; /* 15% */ a->data.ca[1] = 15; /* 15% */
a_add(&u->attribs, a); a_add(&u->attribs, a);
create_curse(mage, &r->attribs, ct_find("riotzone"), cast_level, duration, anteil, 0); create_curse(mage, &r->attribs, ct_find("riotzone"), cast_level, duration, (double)anteil, 0);
msg = msg_message("sp_raisepeasantmob_effect", "mage region", mage, r); msg = msg_message("sp_raisepeasantmob_effect", "mage region", mage, r);
report_spell(mage, r, msg); report_spell(mage, r, msg);
@ -4204,7 +4199,7 @@ sp_generous(castorder *co)
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;
variant effect; double effect;
message * msg[2] = { NULL, NULL }; message * msg[2] = { NULL, NULL };
if (is_cursed(r->attribs, C_DEPRESSION, 0)) { if (is_cursed(r->attribs, C_DEPRESSION, 0)) {
@ -4212,7 +4207,7 @@ sp_generous(castorder *co)
return 0; return 0;
} }
effect.i = 2; effect = 2;
create_curse(mage,&r->attribs, ct_find("generous"), force, duration, effect, 0); create_curse(mage,&r->attribs, ct_find("generous"), force, duration, effect, 0);
for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT); for (u = r->units; u; u = u->next) freset(u->faction, FFL_SELECT);
@ -4491,7 +4486,7 @@ sp_calm_monster(castorder *co)
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;
variant effect; double effect;
message * msg; message * msg;
/* wenn kein Ziel gefunden, Zauber abbrechen */ /* wenn kein Ziel gefunden, Zauber abbrechen */
@ -4505,7 +4500,7 @@ sp_calm_monster(castorder *co)
return 0; return 0;
} }
effect.i = mage->faction->subscription; effect = mage->faction->subscription;
c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force, c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force,
(int)force, effect, 0); (int)force, effect, 0);
if (c==NULL) { if (c==NULL) {
@ -4992,7 +4987,7 @@ sp_baddreams(castorder *co)
double power = co->force; double power = co->force;
region *r = co->rt; region *r = co->rt;
curse * c; curse * c;
variant effect; double effect;
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */ * also duration+2 */
@ -5000,7 +4995,7 @@ sp_baddreams(castorder *co)
duration = 2 + rng_int()%duration; duration = 2 + rng_int()%duration;
/* Nichts machen als ein entsprechendes Attribut in die Region legen. */ /* Nichts machen als ein entsprechendes Attribut in die Region legen. */
effect.i = -1; effect = -1;
c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0); c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0);
/* Erfolg melden*/ /* Erfolg melden*/
@ -5032,13 +5027,13 @@ sp_gooddreams(castorder *co)
unit *mage = co->magician.u; 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; double effect;
/* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken,
* also duration+2 */ * also duration+2 */
duration = (int)MAX(1, power/2); /* Stufe 1 macht sonst mist */ duration = (int)MAX(1, power/2); /* Stufe 1 macht sonst mist */
duration = 2 + rng_int()%duration; duration = 2 + rng_int()%duration;
effect.i = 1; effect = 1;
c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0); c = create_curse(mage, &r->attribs, ct_find("gbdream"), power, duration, effect, 0);
/* Erfolg melden*/ /* Erfolg melden*/
@ -5153,7 +5148,7 @@ sp_sweetdreams(castorder *co)
for (n = 0; n < pa->length; n++) { for (n = 0; n < pa->length; n++) {
curse * c; curse * c;
unit *u; unit *u;
variant effect; double effect;
message * msg; message * msg;
/* sollte nie negativ werden */ /* sollte nie negativ werden */
if (opfer < 1) break; if (opfer < 1) break;
@ -5173,7 +5168,7 @@ sp_sweetdreams(castorder *co)
opfer -= men; opfer -= men;
/* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */ /* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */
effect.i = 5; effect = 0.05;
c = create_curse(mage,&u->attribs, ct_find("orcish"), power, duration, effect, men); c = create_curse(mage,&u->attribs, ct_find("orcish"), power, duration, effect, men);
msg = msg_message("sp_sweetdreams_effect", "mage unit region", mage, u, r); msg = msg_message("sp_sweetdreams_effect", "mage unit region", mage, u, r);
@ -5195,10 +5190,10 @@ sp_disturbingdreams(castorder *co)
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);
variant effect; double effect;
curse * c; curse * c;
effect.i = 10; effect = 10;
c = create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0); c = create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0);
ADDMSG(&mage->faction->msgs, msg_message("sp_disturbingdreams_effect", "mage region", mage, r)); ADDMSG(&mage->faction->msgs, msg_message("sp_disturbingdreams_effect", "mage region", mage, r));
@ -5317,7 +5312,6 @@ sp_resist_magic_bonus(castorder *co)
{ {
unit *u; unit *u;
int n, m; int n, m;
variant resistbonus;
int duration = 6; int duration = 6;
unit *mage = co->magician.u; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
@ -5349,9 +5343,8 @@ sp_resist_magic_bonus(castorder *co)
m = MIN(u->number,victims); m = MIN(u->number,victims);
victims -= m; victims -= m;
resistbonus.i = 20;
create_curse(mage, &u->attribs, ct_find("magicresistance"), create_curse(mage, &u->attribs, ct_find("magicresistance"),
power, duration, resistbonus, m); power, duration, 20, m);
msg = msg_message("magicresistance_effect", "unit", u); msg = msg_message("magicresistance_effect", "unit", u);
add_message(&u->faction->msgs, msg); add_message(&u->faction->msgs, msg);
@ -5982,7 +5975,7 @@ sp_disruptastral(castorder *co)
for (rl2=rl; rl2!=NULL; rl2=rl2->next) { for (rl2=rl; rl2!=NULL; rl2=rl2->next) {
attrib *a; attrib *a;
variant effect; double effect;
region * r2 = rl2->data; region * r2 = rl2->data;
spec_direction *sd; spec_direction *sd;
int inhab_regions = 0; int inhab_regions = 0;
@ -6034,7 +6027,7 @@ sp_disruptastral(castorder *co)
} }
/* Kontakt unterbinden */ /* Kontakt unterbinden */
effect.i = 100; effect = 100;
create_curse(mage, &rl2->data->attribs, ct_find("astralblock"), create_curse(mage, &rl2->data->attribs, ct_find("astralblock"),
power, duration, effect, 0); power, duration, effect, 0);
} }
@ -6422,7 +6415,7 @@ int
sp_antimagiczone(castorder *co) sp_antimagiczone(castorder *co)
{ {
double power; double power;
variant effect; double effect;
region *r = co->rt; region *r = co->rt;
unit *mage = co->magician.u; unit *mage = co->magician.u;
int cast_level = co->level; int cast_level = co->level;
@ -6435,7 +6428,7 @@ sp_antimagiczone(castorder *co)
power = force * 10; power = force * 10;
/* Reduziert die Stärke jedes Spruchs um effect */ /* Reduziert die Stärke jedes Spruchs um effect */
effect.i = cast_level; effect = cast_level;
create_curse(mage, &r->attribs, ct_find("antimagiczone"), power, duration, create_curse(mage, &r->attribs, ct_find("antimagiczone"), power, duration,
effect, 0); effect, 0);
@ -6487,10 +6480,10 @@ sp_magicrunes(castorder *co)
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;
variant effect; double effect;
duration = 3 + rng_int()%cast_level; duration = 3 + rng_int()%cast_level;
effect.i = 20; effect = 20;
switch(pa->param[0]->typ) { switch(pa->param[0]->typ) {
case SPP_BUILDING: case SPP_BUILDING:
@ -6553,7 +6546,7 @@ sp_speed2(castorder *co)
dur = MAX(1, cast_level/2); dur = MAX(1, cast_level/2);
for (n = 0; n < pa->length; n++) { for (n = 0; n < pa->length; n++) {
variant effect; double effect;
/* sollte nie negativ werden */ /* sollte nie negativ werden */
if (maxmen < 1) if (maxmen < 1)
break; break;
@ -6565,7 +6558,7 @@ sp_speed2(castorder *co)
u = pa->param[n]->data.u; u = pa->param[n]->data.u;
men = MIN(maxmen,u->number); men = MIN(maxmen,u->number);
effect.i = 2; effect = 2;
create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men); create_curse(mage, &u->attribs, ct_find("speed"), force, dur, effect, men);
maxmen -= men; maxmen -= men;
used += men; used += men;

View File

@ -243,7 +243,7 @@ cinfo_sparkle(const void * obj, typ_t typ, const curse *c, int self)
while (effects[end]!=NULL) ++end; while (effects[end]!=NULL) ++end;
if (end==begin) return NULL; if (end==begin) return NULL;
else { else {
int index = begin + curse_geteffect(c) % (end-begin); int index = begin + curse_geteffect_int(c) % (end-begin);
return msg_message(mkname("curseinfo", effects[index]), "unit id", u, c->no); return msg_message(mkname("curseinfo", effects[index]), "unit id", u, c->no);
} }
} }
@ -327,9 +327,9 @@ cinfo_skillmod(const void * obj, typ_t typ, const curse *c, int self)
if (self != 0) { if (self != 0) {
unit *u = (unit *)obj; unit *u = (unit *)obj;
int sk = c->data.i; int sk = c->data.i;
if (c->effect.i>0) { if (c->effect>0) {
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no); return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
} else if (c->effect.i<0) { } else if (c->effect<0) {
return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no); return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no);
} }
} }

View File

@ -46,7 +46,7 @@ typedef struct createcurse_data {
const curse_type * type; const curse_type * type;
double vigour; double vigour;
int duration; int duration;
int effect; double effect;
int men; int men;
} createcurse_data; } createcurse_data;
@ -70,10 +70,8 @@ createcurse_handle(trigger * t, void * data)
*/ */
createcurse_data * td = (createcurse_data*)t->data.v; createcurse_data * td = (createcurse_data*)t->data.v;
if (td->mage && td->target && td->mage->number && td->target->number) { if (td->mage && td->target && td->mage->number && td->target->number) {
variant var;
var.i = td->effect;
create_curse(td->mage, &td->target->attribs, create_curse(td->mage, &td->target->attribs,
td->type, td->vigour, td->duration, var, td->men); td->type, td->vigour, td->duration, td->effect, td->men);
} else { } else {
log_error(("could not perform createcurse::handle()\n")); log_error(("could not perform createcurse::handle()\n"));
} }
@ -90,7 +88,7 @@ createcurse_write(const trigger * t, struct storage * store)
store->w_tok(store, td->type->cname); store->w_tok(store, td->type->cname);
store->w_flt(store, (float)td->vigour); store->w_flt(store, (float)td->vigour);
store->w_int(store, td->duration); store->w_int(store, td->duration);
store->w_int(store, td->effect); store->w_flt(store, (float)td->effect);
store->w_int(store, td->men); store->w_int(store, td->men);
} }
@ -118,7 +116,11 @@ createcurse_read(trigger * t, struct storage * store)
td->type = ct_find(zText); td->type = ct_find(zText);
td->vigour = store->r_flt(store); td->vigour = store->r_flt(store);
td->duration = store->r_int(store); td->duration = store->r_int(store);
td->effect = store->r_int(store); if (store->version<CURSEFLOAT_VERSION) {
td->effect = (double)store->r_int(store);
} else {
td->effect = store->r_flt(store);
}
td->men = store->r_int(store); td->men = store->r_int(store);
} }
return AT_READ_OK; return AT_READ_OK;
@ -136,7 +138,7 @@ trigger_type tt_createcurse = {
trigger * trigger *
trigger_createcurse(struct unit * mage, struct unit * target, trigger_createcurse(struct unit * mage, struct unit * target,
const curse_type * ct, double vigour, int duration, const curse_type * ct, double vigour, int duration,
int effect, int men) double effect, int men)
{ {
trigger * t = t_new(&tt_createcurse); trigger * t = t_new(&tt_createcurse);
createcurse_data * td = (createcurse_data*)t->data.v; createcurse_data * td = (createcurse_data*)t->data.v;

View File

@ -28,7 +28,7 @@ struct unit;
extern struct trigger_type tt_createcurse; extern struct trigger_type tt_createcurse;
extern struct trigger * trigger_createcurse(struct unit * mage, struct unit * target, const struct curse_type * ct, double 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, double effect, int men);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -115,9 +115,8 @@ curse_emptiness(void)
} }
} }
if (d!=MAXDIRECTIONS) { if (d!=MAXDIRECTIONS) {
variant effect; double effect = 0.0;
curse * c; curse * c;
effect.i = 0;
c = create_curse(NULL, &r->attribs, ct, 100, 100, effect, 0); c = create_curse(NULL, &r->attribs, ct, 100, 100, effect, 0);
} }
freset(r, RF_MARK); freset(r, RF_MARK);