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");
}
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);
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)
{
curse *c;
variant effect;
double effect;
ship * sh = u->ship;
if (!sh) {
cmistake(u, ord, 20, MSG_MOVE);
return -1;
}
effect.i = SPEEDSAIL_EFFECT;
effect = SPEEDSAIL_EFFECT;
c = create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, effect, 0);
c_setflag(c, CURSE_NOAGE);
@ -145,9 +145,7 @@ use_antimagiccrystal(unit * u, const struct item_type * itype, int amount, struc
}
if (force > 0) {
variant var ;
var.i = effect;
create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, var, 0);
create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, effect, 0);
}
}
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 money;
variant effect;
if (get_curse(u->region->attribs, ct_find("depression"))) {
cmistake(u, ord, 58, MSG_MAGIC);
@ -219,9 +216,8 @@ use_bagpipeoffear(struct unit * u, const struct item_type * itype,
change_money(u, money);
rsetmoney(u->region, rmoney(u->region) - money);
effect.i = 0;
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",
"unit region command money", u, u->region, ord, money));

View File

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

View File

@ -1038,10 +1038,10 @@ orc_growth(void)
int n;
int increase = 0;
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--) {
if (rng_int() % 100 < prob) {
if (chance(prob)) {
++increase;
}
}

View File

@ -67,11 +67,9 @@ use_hornofdancing(struct unit * u, const struct item_type * itype,
if(distance(u->region, r) < HORNRANGE) {
if(a_find(r->attribs, &at_peaceimmune) == NULL) {
attrib *a;
variant effect;
effect.i = 1;
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->data.i = HORNIMMUNITY;
@ -107,7 +105,6 @@ useonother_trappedairelemental(struct unit * u, int shipId,
{
curse *c;
ship *sh;
variant effect;
if (shipId <= 0) {
cmistake(u, ord, 20, MSG_MOVE);
@ -120,8 +117,7 @@ useonother_trappedairelemental(struct unit * u, int shipId,
return -1;
}
effect.i = SPEEDUP;
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, SPEEDUP, 0);
c_setflag(c, CURSE_NOAGE);
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);
if (curse_active(c)) {
/* wirkt auf alle Gebäude */
skdiff -= curse_geteffect(c);
skdiff -= curse_geteffect_int(c);
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);
if (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 {
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);
if (c->type==NULL) {
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_flt(store, (float)c->vigour);
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);
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)
{
if (c==NULL) 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 *
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;
attrib * a;
@ -532,7 +544,7 @@ make_curse(unit *mage, attrib **ap, const curse_type *ct, double vigour,
*/
curse *
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;
@ -555,10 +567,10 @@ create_curse(unit *magician, attrib **ap, const curse_type *ct, double vigour,
c->duration += duration;
}
if(ct->mergeflags & M_SUMEFFECT){
c->effect.i += effect.i;
c->effect += effect;
}
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){
c->vigour = MAX(vigour, c->vigour);

View File

@ -191,7 +191,7 @@ typedef struct curse {
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */
double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */
struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
variant effect;
double effect;
variant data; /* pointer auf spezielle curse-unterstructs*/
} 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,
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
* einen Zauber dieses Typs geben, so wird der neue dazuaddiert. Die
* 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.
*/
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
* Skillmodifiziernden Verzauberungen ist hier der Modifizierer
* gespeichert. Wird automatisch beim Anlegen eines neuen curse

View File

@ -636,7 +636,7 @@ ShipSpeedBonus(const unit * u)
int
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 boolean init;
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);
#endif
return k;
return (int)k;
}
#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);
int esize = 0;
curse * c;
int wage;
double wage;
attrib *a;
const building_type *artsculpture_type = bt_find("artsculpture");
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);
if (a) wage = (wage * a->data.sa[0])/100;
return wage;
return (int)wage;
}
static int
@ -3048,7 +3048,7 @@ default_order(const struct locale * lang)
int
entertainmoney(const region *r)
{
int n;
double n;
if (is_cursed(r->attribs, C_DEPRESSION, 0)) {
return 0;
@ -3060,7 +3060,7 @@ entertainmoney(const region *r)
n *= get_curseeffect(r->attribs, C_GENEROUS, 0);
}
return n;
return (int)n;
}
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,
der vor den Antimagiezaubern passiert */
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,
duration, effect, u->number);
c->data.i = SK_TACTICS;

View File

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

View File

@ -62,6 +62,7 @@
#define UIDHASH_VERSION 332 /* borders use the region.uid to store */
#define REGIONOWNER_VERSION 333 /* regions have owners and morale */
#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 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;
unit *mage = ad->mage;
unit *opfer = ad->target;
variant effect;
double effect;
message * msg;
assert(opfer);
@ -172,7 +172,7 @@ alp_findet_opfer(unit *alp, region *r)
a_removeall(&alp->attribs, &at_eventhandler);
/* Alp umwandeln in Curse */
effect.i = -2;
effect = -2;
c = create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect, opfer->number);
/* solange es noch keine spezielle alp-Antimagie gibt, reagiert der
* 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;
unit *mage = fi->unit;
building *burg;
variant effect;
double effect;
static boolean init = false;
message * msg;
static const curse_type * strongwall_ct;
@ -854,9 +854,7 @@ sp_strong_wall(fighter * fi, int level, double power, spell * sp)
}
burg = mage->building;
effect.i = (int)(power/4);
if (chance(power-effect.i)) ++effect.i;
effect = power*0.25;
create_curse(mage, &burg->attribs, strongwall_ct, power, 1, effect, 0);
msg = msg_message("sp_strongwalls_effect", "mage building", mage, mage->building);

View File

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

View File

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