Anpassungen mehrerer Zauber daran, dass power double ist.

Crashfix falscher typecast.
Mehr Stellen auf Benutzung von float-wahrscheinlichkeiten und boolean chance(double) angepasst
This commit is contained in:
Enno Rehling 2004-02-09 22:20:40 +00:00
parent 567117932c
commit ac517da404
17 changed files with 194 additions and 296 deletions

View file

@ -19,7 +19,7 @@ extern "C" {
#endif #endif
extern struct attrib_type at_aggressive; extern struct attrib_type at_aggressive;
extern struct attrib * make_aggressive(int chance); extern struct attrib * make_aggressive(double probability);
extern void init_aggressive(void); extern void init_aggressive(void);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -1004,16 +1004,16 @@ plan_monsters(void)
boolean done = false; boolean done = false;
if((u->race->flags & RCF_ATTACKRANDOM) && is_moving == false) if((u->race->flags & RCF_ATTACKRANDOM) && is_moving == false)
{ {
int chance; double probability;
attrib *a = a_find(u->attribs, &at_aggressive); attrib *a = a_find(u->attribs, &at_aggressive);
if(a) { if (a) {
chance = a->data.i; probability = a->data.flt;
} else { } else {
chance = MONSTERATTACK; probability = MONSTERATTACK;
} }
if(rand()%100 < chance) { if(chance(probability)) {
done = random_attack_by_monster(r, u); done = random_attack_by_monster(r, u);
} }
} }

View file

@ -1213,22 +1213,22 @@ randomevents(void)
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
if (fval(r, RF_ORCIFIED)) { if (fval(r, RF_ORCIFIED)) {
direction_t dir; direction_t dir;
int chance = 0; double probability = 0.0;
for (dir = 0; dir < MAXDIRECTIONS; dir++) { for (dir = 0; dir < MAXDIRECTIONS; dir++) {
region *rc = rconnect(r, dir); region *rc = rconnect(r, dir);
if (rc && rpeasants(rc) > 0 && !fval(rc, RF_ORCIFIED)) chance += 2; if (rc && rpeasants(rc) > 0 && !fval(rc, RF_ORCIFIED)) probability += 0.02;
} }
if (rand()%100 < chance) { if (chance(probability)) {
ADDMSG(&r->msgs, msg_message("deorcified", "region", r)); ADDMSG(&r->msgs, msg_message("deorcified", "region", r));
freset(r, RF_ORCIFIED); freset(r, RF_ORCIFIED);
} }
} else { } else {
attrib *a = a_find(r->attribs, &at_orcification); attrib *a = a_find(r->attribs, &at_orcification);
if (a!=NULL) { if (a!=NULL) {
int chance = 0; double probability = 0.0;
if (rpeasants(r) <= 0) continue; if (rpeasants(r) <= 0) continue;
chance = (a->data.i*100)/rpeasants(r); probability = a->data.i/(double)rpeasants(r);
if (rand()%100 < chance) { if (chance(probability)) {
fset(r, RF_ORCIFIED); fset(r, RF_ORCIFIED);
a_remove(&r->attribs, a); a_remove(&r->attribs, a);
ADDMSG(&r->msgs, msg_message("orcified", "region", r)); ADDMSG(&r->msgs, msg_message("orcified", "region", r));

View file

@ -42,7 +42,8 @@
#include <attributes/racename.h> #include <attributes/racename.h>
/* util includes */ /* util includes */
#include "vset.h" #include <util/vset.h>
#include <util/rand.h>
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
@ -57,7 +58,8 @@ void
spy(region * r, unit * u) spy(region * r, unit * u)
{ {
unit *target; unit *target;
int spy, spychance, observe, observechance; int spy, observe;
double spychance, observechance;
target = getunit(r, u->faction); target = getunit(r, u->faction);
@ -77,9 +79,9 @@ spy(region * r, unit * u)
* Für jeden Talentpunkt, den das Spionagetalent das Tarnungstalent * Für jeden Talentpunkt, den das Spionagetalent das Tarnungstalent
* des Opfers übersteigt, erhöht sich dieses um 5%*/ * des Opfers übersteigt, erhöht sich dieses um 5%*/
spy = eff_skill(u, SK_SPY, r) - eff_skill(target, SK_STEALTH, r); spy = eff_skill(u, SK_SPY, r) - eff_skill(target, SK_STEALTH, r);
spychance = 10 + max(spy*5, 0); spychance = 0.1 + max(spy*0.05, 0.0);
if (rand()%100 < spychance){ if (chance(spychance)) {
spy_message(spy, u, target); spy_message(spy, u, target);
} else { } else {
add_message(&u->faction->msgs, new_message(u->faction, add_message(&u->faction->msgs, new_message(u->faction,
@ -101,10 +103,10 @@ spy(region * r, unit * u)
/* Anschließend wird - unabhängig vom Erfolg - gewürfelt, ob der /* Anschließend wird - unabhängig vom Erfolg - gewürfelt, ob der
* Spionageversuch bemerkt wurde. Die Wahrscheinlich dafür ist (100 - * Spionageversuch bemerkt wurde. Die Wahrscheinlich dafür ist (100 -
* SpionageSpion*5 + WahrnehmungOpfer*2)%. */ * SpionageSpion*5 + WahrnehmungOpfer*2)%. */
observechance = 100 - (eff_skill(u, SK_SPY, r) * 5) observechance = 1.0 - (eff_skill(u, SK_SPY, r) * 0.05)
+ (eff_skill(target, SK_OBSERVATION, r) * 2); + (eff_skill(target, SK_OBSERVATION, r) * 0.02);
if (rand()%100 < observechance){ if (chance(observechance)){
add_message(&target->faction->msgs, new_message(target->faction, add_message(&target->faction->msgs, new_message(target->faction,
"spydetect%u:spy%u:target", observe>0?u:NULL, target)); "spydetect%u:spy%u:target", observe>0?u:NULL, target));
} }
@ -375,7 +377,7 @@ sink_ship(region * r, ship * sh, const char *name, char spy, unit * saboteur)
int i; int i;
direction_t d; direction_t d;
unsigned int index; unsigned int index;
int chance; double probability = 0.0;
int money, count; int money, count;
char buffer[DISPLAYSIZE + 1]; char buffer[DISPLAYSIZE + 1];
vset informed; vset informed;
@ -385,14 +387,13 @@ sink_ship(region * r, ship * sh, const char *name, char spy, unit * saboteur)
vset_init(&survivors); vset_init(&survivors);
/* figure out what a unit's chances of survival are: */ /* figure out what a unit's chances of survival are: */
chance = 0;
if (rterrain(r) != T_OCEAN) if (rterrain(r) != T_OCEAN)
chance = CANAL_SWIMMER_CHANCE; probability = CANAL_SWIMMER_CHANCE;
else else
for (d = 0; d != MAXDIRECTIONS; ++d) for (d = 0; d != MAXDIRECTIONS; ++d)
if (rterrain(rconnect(r, d)) != T_OCEAN && !move_blocked(NULL, r, d)) { if (rterrain(rconnect(r, d)) != T_OCEAN && !move_blocked(NULL, r, d)) {
safety = rconnect(r, d); safety = rconnect(r, d);
chance = OCEAN_SWIMMER_CHANCE; probability = OCEAN_SWIMMER_CHANCE;
break; break;
} }
for (ui = &r->units; *ui; ui = &(*ui)->next) { for (ui = &r->units; *ui; ui = &(*ui)->next) {
@ -405,7 +406,7 @@ sink_ship(region * r, ship * sh, const char *name, char spy, unit * saboteur)
/* if this fails, I misunderstood something: */ /* if this fails, I misunderstood something: */
for (i = 0; i != u->number; ++i) for (i = 0; i != u->number; ++i)
if (rand() % 100 >= chance) if (chance(probability))
++dead; ++dead;
if (dead != u->number) if (dead != u->number)

View file

@ -1152,7 +1152,7 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
double res = 1.0; double res = 1.0;
/* magic_resistance gib x% Resistenzbonus zurück */ /* magic_resistance gib x% Resistenzbonus zurück */
res -= (double)((double)magic_resistance(du)/100.0)*3.0; res -= magic_resistance(du)*3.0;
if (du->race->battle_flags & BF_EQUIPMENT) { if (du->race->battle_flags & BF_EQUIPMENT) {
#ifdef TODO_RUNESWORD #ifdef TODO_RUNESWORD
@ -1433,7 +1433,6 @@ do_combatmagic(battle *b, combatmagic_t was)
{ {
void **fi; void **fi;
spell *sp; spell *sp;
fighter *fig;
region *r = b->region; region *r = b->region;
castorder *co; castorder *co;
castorder *cll[MAX_SPELLRANK]; castorder *cll[MAX_SPELLRANK];
@ -3838,7 +3837,7 @@ damage_unit(unit *u, const char *dam, boolean armor, boolean magic)
/* Schaden */ /* Schaden */
for (i=0; i<u->number; i++) { for (i=0; i<u->number; i++) {
int damage = dice_rand(dam); int damage = dice_rand(dam);
if (magic) damage = (int)(damage * (100.0 - magic_resistance(u))/100.0); if (magic) damage = (int)(damage * (1.0 - magic_resistance(u)));
if (armor) damage -= nb_armor(u, i); if (armor) damage -= nb_armor(u, i);
hp[i] -= damage; hp[i] -= damage;
} }

View file

@ -68,8 +68,8 @@ spell_damage(int sp)
} }
} }
static int static double
get_force(int power, int formel) get_force(double power, int formel)
{ {
switch (formel) { switch (formel) {
case 0: case 0:
@ -100,7 +100,7 @@ get_force(int power, int formel)
/* Generischer Kampfzauber */ /* Generischer Kampfzauber */
int int
sp_kampfzauber(fighter * fi, int level, int power, spell * sp) sp_kampfzauber(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
troop dt; troop dt;
@ -165,7 +165,7 @@ sp_kampfzauber(fighter * fi, int level, int power, spell * sp)
/* Versteinern */ /* Versteinern */
int int
sp_versteinern(fighter * fi, int level, int power, spell * sp) sp_versteinern(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;
@ -214,7 +214,7 @@ sp_versteinern(fighter * fi, int level, int power, spell * sp)
/* Benommenheit: eine Runde kein Angriff */ /* Benommenheit: eine Runde kein Angriff */
int int
sp_stun(fighter * fi, int level, int power, spell * sp) sp_stun(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;
@ -277,7 +277,7 @@ sp_stun(fighter * fi, int level, int power, spell * sp)
/* Rosthauch */ /* Rosthauch */
int int
sp_combatrosthauch(fighter * fi, int level, int power, spell * sp) sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
cvector *fgs; cvector *fgs;
@ -367,7 +367,7 @@ sp_combatrosthauch(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_sleep(fighter * fi, int level, int power, spell * sp) sp_sleep(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;
@ -444,7 +444,7 @@ select_ally_in_row(fighter * af, int minrow, int maxrow)
} }
int int
sp_speed(fighter * fi, int level, int power, spell * sp) sp_speed(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
int force; int force;
@ -513,7 +513,7 @@ random_skill(unit *u)
} }
int int
sp_mindblast(fighter * fi, int level, int power, spell * sp) sp_mindblast(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;
@ -596,7 +596,7 @@ sp_mindblast(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_dragonodem(fighter * fi, int level, int power, spell * sp) sp_dragonodem(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
troop dt; troop dt;
@ -647,7 +647,7 @@ sp_dragonodem(fighter * fi, int level, int power, spell * sp)
/* Feuersturm: Betrifft sehr viele Gegner (in der Regel alle), /* Feuersturm: Betrifft sehr viele Gegner (in der Regel alle),
* macht nur vergleichsweise geringen Schaden */ * macht nur vergleichsweise geringen Schaden */
int int
sp_immolation(fighter * fi, int level, int power, spell * sp) sp_immolation(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
troop dt; troop dt;
@ -695,7 +695,7 @@ sp_immolation(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_drainodem(fighter * fi, int level, int power, spell * sp) sp_drainodem(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
troop dt; troop dt;
@ -752,13 +752,13 @@ sp_drainodem(fighter * fi, int level, int power, spell * sp)
/* PRECOMBAT */ /* PRECOMBAT */
int int
sp_shadowcall(fighter * fi, int level, int power, spell * sp) sp_shadowcall(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
region *r = b->region; region *r = b->region;
unit *mage = fi->unit; unit *mage = fi->unit;
attrib *a; attrib *a;
int force = get_force(power, 3)/2; double force = get_force(power, 3)/2;
const race *rc = NULL; const race *rc = NULL;
int num; int num;
unit *u; unit *u;
@ -780,12 +780,12 @@ sp_shadowcall(fighter * fi, int level, int power, spell * sp)
break; break;
} }
u = createunit(r, mage->faction, force, rc); u = createunit(r, mage->faction, (int)force, rc);
u->status = ST_FIGHT; u->status = ST_FIGHT;
set_string(&u->name, racename(mage->faction->locale, u, u->race)); set_string(&u->name, racename(mage->faction->locale, u, u->race));
set_level(u, SK_WEAPONLESS, power/2); set_level(u, SK_WEAPONLESS, (int)(power/2));
set_level(u, SK_AUSDAUER, power/2); set_level(u, SK_AUSDAUER, (int)(power/2));
u->hp = u->number * unit_max_hp(u); u->hp = u->number * unit_max_hp(u);
if (fval(mage, UFL_PARTEITARNUNG)) if (fval(mage, UFL_PARTEITARNUNG))
@ -804,21 +804,21 @@ sp_shadowcall(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_wolfhowl(fighter * fi, int level, int power, spell * sp) sp_wolfhowl(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
region *r = b->region; region *r = b->region;
unit *mage = fi->unit; unit *mage = fi->unit;
attrib *a; attrib *a;
int force = get_force(power, 3)/2; double force = get_force(power, 3)/2;
unit *u = createunit(r, mage->faction, force, new_race[RC_WOLF]); unit *u = createunit(r, mage->faction, (int)force, new_race[RC_WOLF]);
unused(sp); unused(sp);
u->status = ST_FIGHT; u->status = ST_FIGHT;
set_string(&u->name, racename(mage->faction->locale, u, u->race)); set_string(&u->name, racename(mage->faction->locale, u, u->race));
set_level(u, SK_WEAPONLESS, power/3); set_level(u, SK_WEAPONLESS, (int)(power/3));
set_level(u, SK_AUSDAUER, power/3); set_level(u, SK_AUSDAUER, (int)(power/3));
u->hp = u->number * unit_max_hp(u); u->hp = u->number * unit_max_hp(u);
if (fval(mage, UFL_PARTEITARNUNG)) if (fval(mage, UFL_PARTEITARNUNG))
@ -837,19 +837,18 @@ sp_wolfhowl(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_shadowknights(fighter * fi, int level, int power, spell * sp) sp_shadowknights(fighter * fi, int level, double power, spell * sp)
{ {
unit *u; unit *u;
battle *b = fi->side->battle; battle *b = fi->side->battle;
region *r = b->region; region *r = b->region;
unit *mage = fi->unit; unit *mage = fi->unit;
attrib *a; attrib *a;
int force; double force = get_force(power, 3);
unused(sp);
force = get_force(power, 3); unused(sp);
u = createunit(r, mage->faction, force, new_race[RC_SHADOWKNIGHT]); u = createunit(r, mage->faction, (int)force, new_race[RC_SHADOWKNIGHT]);
u->status = ST_FIGHT; u->status = ST_FIGHT;
set_string(&u->name, "Schattenritter"); set_string(&u->name, "Schattenritter");
@ -871,12 +870,12 @@ sp_shadowknights(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_strong_wall(fighter * fi, int level, int force, spell * sp) 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;
int effect; int effect = (int)(power/4);
static boolean init = false; static boolean init = false;
static const curse_type * strongwall_ct; static const curse_type * strongwall_ct;
if (!init) { init = true; strongwall_ct = ct_find("strongwall"); } if (!init) { init = true; strongwall_ct = ct_find("strongwall"); }
@ -891,11 +890,9 @@ sp_strong_wall(fighter * fi, int level, int force, spell * sp)
} }
burg = mage->building; burg = mage->building;
effect = force/4; if (chance(power-effect)) ++effect;
if (rand()%4 < force%4)
effect++;
create_curse(mage, &burg->attribs, strongwall_ct, force, 1, effect, 0); create_curse(mage, &burg->attribs, strongwall_ct, power, 1, effect, 0);
sprintf(buf, "%s Mauern erglühen in einem unheimlichen magischen Licht.", sprintf(buf, "%s Mauern erglühen in einem unheimlichen magischen Licht.",
buildingname(burg)); buildingname(burg));
@ -904,14 +901,13 @@ sp_strong_wall(fighter * fi, int level, int force, spell * sp)
} }
int int
sp_chaosrow(fighter * fi, int level, int force, spell * sp) sp_chaosrow(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;
cvector *fgs; cvector *fgs;
void **fig; void **fig;
int n, enemies, row; int n, enemies, row;
int chance;
int k = 0; int k = 0;
int minrow = FIGHT_ROW; int minrow = FIGHT_ROW;
int maxrow = NUMROWS; int maxrow = NUMROWS;
@ -919,12 +915,12 @@ sp_chaosrow(fighter * fi, int level, int force, spell * sp)
switch (sp->id) { switch (sp->id) {
case SPL_CHAOSROW: case SPL_CHAOSROW:
sprintf(buf, "%s murmelt eine düster klingende Formel", unitname(mage)); sprintf(buf, "%s murmelt eine düster klingende Formel", unitname(mage));
force *= 40; power *= 40;
break; break;
case SPL_SONG_OF_CONFUSION: case SPL_SONG_OF_CONFUSION:
sprintf(buf, "%s stimmt einen seltsamen Gesang an", unitname(mage)); sprintf(buf, "%s stimmt einen seltsamen Gesang an", unitname(mage));
force = get_force(force,5); power = get_force(power, 5);
break; break;
} }
@ -942,18 +938,14 @@ sp_chaosrow(fighter * fi, int level, int force, spell * sp)
for (fig = fgs->begin; fig != fgs->end; ++fig) { for (fig = fgs->begin; fig != fgs->end; ++fig) {
fighter *df = *fig; fighter *df = *fig;
if (!force) if (power<=0.0) break;
break;
/* force sollte wegen des max(0,x) nicht unter 0 fallen können */ /* force sollte wegen des max(0,x) nicht unter 0 fallen können */
assert(force >= 0);
if (is_magic_resistant(mage, df->unit, 0)) if (is_magic_resistant(mage, df->unit, 0)) continue;
continue;
n = df->unit->number; n = df->unit->number;
chance = 100 * force/n; if (chance(power/n)) {
if (chance < 1 + rand()%100) {
row = statusrow(df->status)+FIRST_ROW; row = statusrow(df->status)+FIRST_ROW;
df->side->size[row] -= df->alive; df->side->size[row] -= df->alive;
if (df->unit->race->battle_flags & BF_NOBLOCK) { if (df->unit->race->battle_flags & BF_NOBLOCK) {
@ -982,14 +974,14 @@ sp_chaosrow(fighter * fi, int level, int force, spell * sp)
} }
k++; k++;
} }
force = max(0, force-n); power = max(0, power-n);
} }
cv_kill(fgs); cv_kill(fgs);
scat("Ein plötzlicher Tumult entsteht"); scat("Ein plötzlicher Tumult entsteht");
if (k > 0) { if (k > 0) {
scat(" und bringt die Kampfaufstellung durcheinander."); scat(" und bringt die Kampfaufstellung durcheinander.");
}else{ } else {
scat(", der sich jedoch schnell wieder legt."); scat(", der sich jedoch schnell wieder legt.");
} }
battlerecord(b, buf); battlerecord(b, buf);
@ -1000,7 +992,7 @@ sp_chaosrow(fighter * fi, int level, int force, spell * sp)
/* Panik (Präkampfzauber) */ /* Panik (Präkampfzauber) */
int int
sp_flee(fighter * fi, int level, int power, spell * sp) sp_flee(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;
@ -1015,18 +1007,18 @@ sp_flee(fighter * fi, int level, int power, spell * sp)
case SPL_FLEE: case SPL_FLEE:
sprintf(buf, "%s zaubert %s", unitname(mage), sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale)); spell_name(sp, default_locale));
force = get_force(power,4); force = (int)get_force(power,4);
break; break;
case SPL_SONG_OF_FEAR: case SPL_SONG_OF_FEAR:
sprintf(buf, "%s stimmt einen düsteren Gesang an", unitname(mage)); sprintf(buf, "%s stimmt einen düsteren Gesang an", unitname(mage));
force = get_force(power,3); force = (int)get_force(power,3);
break; break;
case SPL_AURA_OF_FEAR: case SPL_AURA_OF_FEAR:
sprintf(buf, "%s ist von dunklen Schatten umgeben", unitname(mage)); sprintf(buf, "%s ist von dunklen Schatten umgeben", unitname(mage));
force = get_force(power,5); force = (int)get_force(power,5);
break; break;
default: default:
force = get_force(power,10); force = (int)get_force(power,10);
} }
if (!count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow)) { if (!count_enemies(b, fi->side, FS_ENEMY, minrow, maxrow)) {
@ -1072,7 +1064,7 @@ sp_flee(fighter * fi, int level, int power, spell * sp)
/* Heldenmut */ /* Heldenmut */
int int
sp_hero(fighter * fi, int level, int power, spell * sp) sp_hero(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;
@ -1088,13 +1080,13 @@ sp_hero(fighter * fi, int level, int power, spell * sp)
spell_name(sp, default_locale)); spell_name(sp, default_locale));
switch(sp->id) { switch(sp->id) {
case SPL_HERO: case SPL_HERO:
df_bonus = power/5; df_bonus = (int)(power/5);
force = lovar(get_force(power,4)); force = lovar(get_force(power, 4));
break; break;
default: default:
df_bonus = 1; df_bonus = 1;
force = power; force = (int)power;
} }
scat(":"); scat(":");
battlerecord(b, buf); battlerecord(b, buf);
@ -1128,7 +1120,7 @@ sp_hero(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_berserk(fighter * fi, int level, int power, spell * sp) sp_berserk(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;
@ -1148,13 +1140,13 @@ sp_berserk(fighter * fi, int level, int power, spell * sp)
case SPL_BLOODTHIRST: case SPL_BLOODTHIRST:
at_bonus = max(1,level/3); at_bonus = max(1,level/3);
df_malus = 2; df_malus = 2;
force = get_force(power,2); force = (int)get_force(power,2);
break; break;
default: default:
at_bonus = 1; at_bonus = 1;
df_malus = 0; df_malus = 0;
force = power; force = (int)power;
} }
scat(":"); scat(":");
battlerecord(b, buf); battlerecord(b, buf);
@ -1189,7 +1181,7 @@ sp_berserk(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_frighten(fighter * fi, int level, int power, spell * sp) sp_frighten(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;
@ -1204,7 +1196,7 @@ sp_frighten(fighter * fi, int level, int power, spell * sp)
at_malus = max(1,level - 4); at_malus = max(1,level - 4);
df_malus = 2; df_malus = 2;
force = get_force(power, 2); force = (int)get_force(power, 2);
sprintf(buf, "%s zaubert %s", unitname(mage), sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale)); spell_name(sp, default_locale));
@ -1249,13 +1241,12 @@ sp_frighten(fighter * fi, int level, int power, spell * sp)
int int
sp_tiredsoldiers(fighter * fi, int level, int force, spell * sp) sp_tiredsoldiers(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;
int n = 0; int n = 0;
int force = (int)(power * power * 4);
force = force * force * 4;
sprintf(buf, "%s zaubert %s", unitname(mage), sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale)); spell_name(sp, default_locale));
@ -1298,7 +1289,7 @@ sp_tiredsoldiers(fighter * fi, int level, int force, spell * sp)
} }
int int
sp_windshield(fighter * fi, int level, int power, spell * sp) sp_windshield(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;
@ -1312,12 +1303,12 @@ sp_windshield(fighter * fi, int level, int power, spell * sp)
spell_name(sp, default_locale)); spell_name(sp, default_locale));
switch(sp->id) { switch(sp->id) {
case SPL_WINDSHIELD: case SPL_WINDSHIELD:
force = get_force(power,4); force = (int)get_force(power,4);
at_malus = level/4; at_malus = level/4;
break; break;
default: default:
force = power; force = (int)power;
at_malus = 2; at_malus = 2;
} }
enemies = count_enemies(b, fi->side, FS_ENEMY, enemies = count_enemies(b, fi->side, FS_ENEMY,
@ -1351,11 +1342,12 @@ sp_windshield(fighter * fi, int level, int power, spell * sp)
} }
int int
sp_reeling_arrows(fighter * fi, int level, int force, spell * sp) sp_reeling_arrows(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;
unused(force);
unused(power);
b->reelarrow = true; b->reelarrow = true;
sprintf(buf, "%s zaubert %s", unitname(mage), sprintf(buf, "%s zaubert %s", unitname(mage),
@ -1367,7 +1359,7 @@ sp_reeling_arrows(fighter * fi, int level, int force, spell * sp)
} }
int int
sp_denyattack(fighter * fi, int level, int power, spell * sp) sp_denyattack(fighter * fi, int level, double power, spell * sp)
{ {
/* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in /* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in
* eine Nachbarregion, wobei ein NACH berücksichtigt wird. Ansonsten * eine Nachbarregion, wobei ein NACH berücksichtigt wird. Ansonsten
@ -1430,7 +1422,7 @@ do_meffect(fighter * af, int typ, int effect, int duration)
} }
int int
sp_armorshield(fighter * fi, int level, int power, spell * sp) sp_armorshield(fighter * fi, int level, double power, spell * sp)
{ {
int effect; int effect;
int duration; int duration;
@ -1446,19 +1438,19 @@ sp_armorshield(fighter * fi, int level, int power, spell * sp)
switch(sp->id) { switch(sp->id) {
case SPL_ARMORSHIELD: case SPL_ARMORSHIELD:
effect = level/3; effect = level/3;
duration = 20*power*power; duration = (int)(20*power*power);
break; break;
default: default:
effect = level/4; effect = level/4;
duration = power*power; duration = (int)(power*power);
} }
do_meffect(fi, SHIELD_ARMOR, effect, duration); do_meffect(fi, SHIELD_ARMOR, effect, duration);
return level; return level;
} }
int int
sp_reduceshield(fighter * fi, int level, int power, spell * sp) sp_reduceshield(fighter * fi, int level, double power, spell * sp)
{ {
int effect; int effect;
int duration; int duration;
@ -1475,19 +1467,19 @@ sp_reduceshield(fighter * fi, int level, int power, spell * sp)
switch(sp->id) { switch(sp->id) {
case SPL_REDUCESHIELD: case SPL_REDUCESHIELD:
effect = 50; effect = 50;
duration = 50*power*power; duration = (int)(50*power*power);
break; break;
default: default:
effect = level*3; effect = level*3;
duration = get_force(power,5); duration = (int)get_force(power,5);
} }
do_meffect(fi, SHIELD_REDUCE, effect, duration); do_meffect(fi, SHIELD_REDUCE, effect, duration);
return level; return level;
} }
int int
sp_fumbleshield(fighter * fi, int level, int power, spell * sp) sp_fumbleshield(fighter * fi, int level, double power, spell * sp)
{ {
int effect; int effect;
int duration; int duration;
@ -1536,27 +1528,25 @@ count_healable(battle *b, fighter *df)
/* wiederbeleben */ /* wiederbeleben */
int int
sp_reanimate(fighter * fi, int level, int force, spell * sp) sp_reanimate(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;
int healable, k, j=0; int healable, j=0;
double c; double c = 0.50;
double k = EFFECT_HEALING_SPELL * power;
switch(sp->id) { switch(sp->id) {
case SPL_REANIMATE: case SPL_REANIMATE:
sprintf(buf, "%s beginnt ein Ritual der Wiederbelebung", sprintf(buf, "%s beginnt ein Ritual der Wiederbelebung",
unitname(mage)); unitname(mage));
k = EFFECT_HEALING_SPELL*force; c += 0.02 * power;
c = 0.50 + 0.02 * force;
break; break;
default: default:
sprintf(buf, "%s zaubert %s", sprintf(buf, "%s zaubert %s",
unitname(mage), unitname(mage),
spell_name(sp, default_locale)); spell_name(sp, default_locale));
k = EFFECT_HEALING_SPELL*force;
c = 0.50;
} }
if (get_item(mage, I_AMULET_OF_HEALING) > 0) { if (get_item(mage, I_AMULET_OF_HEALING) > 0) {
scat(" und benutzt das "); scat(" und benutzt das ");
@ -1567,8 +1557,8 @@ sp_reanimate(fighter * fi, int level, int force, spell * sp)
} }
healable = count_healable(b, fi); healable = count_healable(b, fi);
k = min(k, healable); healable = (int)min(k, healable);
while (k--) { while (healable--) {
troop t = select_corpse(b, fi); troop t = select_corpse(b, fi);
if (t.fighter if (t.fighter
&& t.fighter->side->casualties > 0 && t.fighter->side->casualties > 0
@ -1587,7 +1577,6 @@ sp_reanimate(fighter * fi, int level, int force, spell * sp)
++t.fighter->side->size[t.fighter->unit->status + 1]; ++t.fighter->side->size[t.fighter->unit->status + 1];
++t.fighter->side->healed; ++t.fighter->side->healed;
--t.fighter->side->casualties; --t.fighter->side->casualties;
--healable;
++j; ++j;
} }
} }
@ -1608,7 +1597,7 @@ sp_reanimate(fighter * fi, int level, int force, spell * sp)
} }
int int
sp_keeploot(fighter * fi, int level, int force, spell * sp) sp_keeploot(fighter * fi, int level, double power, spell * sp)
{ {
battle *b = fi->side->battle; battle *b = fi->side->battle;
@ -1616,13 +1605,13 @@ sp_keeploot(fighter * fi, int level, int force, spell * sp)
spell_name(sp, default_locale)); spell_name(sp, default_locale));
battlerecord(b, buf); battlerecord(b, buf);
b->keeploot = max(50, b->keeploot + 5*force); b->keeploot = (int)max(50, b->keeploot + 5*power);
return level; return level;
} }
int int
sp_healing(fighter * fi, int level, int force, spell * sp) sp_healing(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;
@ -1638,13 +1627,13 @@ sp_healing(fighter * fi, int level, int force, spell * sp)
/* bis zu 11 Personen pro Stufe (einen HP müssen sie ja noch /* bis zu 11 Personen pro Stufe (einen HP müssen sie ja noch
* haben, sonst wären sie tot) können geheilt werden */ * haben, sonst wären sie tot) können geheilt werden */
healhp = force * 200; power *= 200;
if (get_item(mage, I_AMULET_OF_HEALING) > 0) { if (get_item(mage, I_AMULET_OF_HEALING) > 0) {
scat(" und benutzt das "); scat(" und benutzt das ");
scat(locale_string(default_locale, resourcename(oldresourcetype[R_AMULET_OF_HEALING], 0))); scat(locale_string(default_locale, resourcename(oldresourcetype[R_AMULET_OF_HEALING], 0)));
scat(", um die Heilzauber zu verstärken"); scat(", um die Heilzauber zu verstärken");
healhp *= 2; power *= 2;
} }
/* gehe alle denen wir helfen der reihe nach durch, heile verwundete, /* gehe alle denen wir helfen der reihe nach durch, heile verwundete,
@ -1653,11 +1642,11 @@ sp_healing(fighter * fi, int level, int force, spell * sp)
fgs = fighters(b, fi, minrow, maxrow, FS_HELP); fgs = fighters(b, fi, minrow, maxrow, FS_HELP);
v_scramble(fgs->begin, fgs->end); v_scramble(fgs->begin, fgs->end);
healhp = (int)power;
for (fig = fgs->begin; fig != fgs->end; ++fig) { for (fig = fgs->begin; fig != fgs->end; ++fig) {
fighter *df = *fig; fighter *df = *fig;
if (!healhp) if (healhp<=0) break;
break;
/* wir heilen erstmal keine Monster */ /* wir heilen erstmal keine Monster */
if (!playerrace(df->unit->race)) if (!playerrace(df->unit->race))
@ -1722,7 +1711,7 @@ sp_healing(fighter * fi, int level, int force, spell * sp)
} }
int int
sp_undeadhero(fighter * fi, int level, int force, spell * sp) sp_undeadhero(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;
@ -1731,13 +1720,9 @@ sp_undeadhero(fighter * fi, int level, int force, spell * sp)
int maxrow = AVOID_ROW; int maxrow = AVOID_ROW;
cvector *fgs; cvector *fgs;
void **fig; void **fig;
int k, n, j; int n, j, undead = 0;
int undead = 0; int k = (int)get_force(power,0);
double c; double c = 0.50 + 0.02 * power;
/* maximal Stufe*4 Personen*/
k = get_force(force,0);
c = 0.50 + 0.02 * force;
/* Liste aus allen Kämpfern */ /* Liste aus allen Kämpfern */
fgs = fighters(b, fi, minrow, maxrow, FS_ENEMY | FS_HELP ); fgs = fighters(b, fi, minrow, maxrow, FS_ENEMY | FS_HELP );

View file

@ -37,6 +37,7 @@
/* util includes */ /* util includes */
#include <util/resolve.h> #include <util/resolve.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/rand.h>
#include <util/goodies.h> #include <util/goodies.h>
/* libc includes */ /* libc includes */
@ -590,14 +591,11 @@ do_transfer_curse(curse *c, unit * u, unit * u2, int n)
break; break;
} }
case CURSE_SPREADCHANCE: case CURSE_SPREADCHANCE:
{ if (chance(u2->number/(double)(u2->number + n))) {
int chance = u2->number * 100 / (u2->number + n);
if (rand()%100 > chance ){
men = u2->number + n; men = u2->number + n;
dogive = true; dogive = true;
} }
break; break;
}
case CURSE_SPREADNEVER: case CURSE_SPREADNEVER:
break; break;
} }

View file

@ -297,7 +297,7 @@ extern void plagues(struct region * r, boolean ismagic);
/** Monster */ /** Monster */
/* Chance für Monsterangriff */ /* Chance für Monsterangriff */
#define MONSTERATTACK 40 #define MONSTERATTACK 0.4
/** Gebäude */ /** Gebäude */
/* Chance für Einsturz bei unversorgtem Gebaeude */ /* Chance für Einsturz bei unversorgtem Gebaeude */

View file

@ -777,10 +777,9 @@ destroy_curse_crystal(attrib **alist, int cast_level, int force)
if (c->flag & CURSE_IMMUN); if (c->flag & CURSE_IMMUN);
if (cast_level < c->vigour) { /* Zauber ist nicht stark genug */ if (cast_level < c->vigour) { /* Zauber ist nicht stark genug */
int chance; /* pro Stufe Unterschied -20% */
/* pro Stufe Unterschied -20% */ double probability = 1 + (cast_level - c->vigour) * 0.2;
chance = (10 + (cast_level - c->vigour)*2); if (chance(probability)) {
if(rand()%10 >= chance){
if (c->type->change_vigour) if (c->type->change_vigour)
c->type->change_vigour(c, -2); c->type->change_vigour(c, -2);
force -= c->vigour; force -= c->vigour;

View file

@ -40,10 +40,6 @@
#include "pathfinder.h" #include "pathfinder.h"
#include "karma.h" #include "karma.h"
/* util includes */
#include <resolve.h>
#include <base36.h>
#include <event.h>
#include <triggers/timeout.h> #include <triggers/timeout.h>
#include <triggers/shock.h> #include <triggers/shock.h>
#include <triggers/killunit.h> #include <triggers/killunit.h>
@ -51,6 +47,12 @@
#include <triggers/changerace.h> #include <triggers/changerace.h>
#include <triggers/clonedied.h> #include <triggers/clonedied.h>
/* util includes */
#include <util/resolve.h>
#include <util/rand.h>
#include <util/base36.h>
#include <util/event.h>
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
@ -1179,29 +1181,28 @@ farcasting(unit *magician, region *r)
/* allgemeine Magieresistenz einer Einheit, /* allgemeine Magieresistenz einer Einheit,
* reduziert magischen Schaden */ * reduziert magischen Schaden */
int double
magic_resistance(unit *target) magic_resistance(unit *target)
{ {
attrib * a; attrib * a;
curse *c; curse *c;
int chance;
int n; int n;
/* Bonus durch Rassenmagieresistenz */ /* Bonus durch Rassenmagieresistenz */
chance = (int)(target->race->magres * 100); double probability = target->race->magres;
/* Magier haben einen Resistenzbonus vom Magietalent * 5%*/ /* Magier haben einen Resistenzbonus vom Magietalent * 5%*/
chance += effskill(target, SK_MAGIC)*5; probability += effskill(target, SK_MAGIC)*0.5;
/* Auswirkungen von Zaubern auf der Einheit */ /* Auswirkungen von Zaubern auf der Einheit */
c = get_curse(target->attribs, ct_find("magicresistance")); c = get_curse(target->attribs, ct_find("magicresistance"));
if (c) { if (c) {
chance += curse_geteffect(c) * get_cursedmen(target, c); probability += 0.01 * curse_geteffect(c) * get_cursedmen(target, c);
} }
/* Unicorn +10 */ /* Unicorn +10 */
n = get_item(target, I_UNICORN); n = get_item(target, I_UNICORN);
if (n) chance += (10*n)/target->number; if (n) probability += n*0.1/target->number;
/* Auswirkungen von Zaubern auf der Region */ /* Auswirkungen von Zaubern auf der Region */
a = a_find(target->region->attribs, &at_curse); a = a_find(target->region->attribs, &at_curse);
@ -1212,7 +1213,7 @@ magic_resistance(unit *target)
if (mage!=NULL) { if (mage!=NULL) {
if (c->type == ct_find("goodmagicresistancezone")) { if (c->type == ct_find("goodmagicresistancezone")) {
if (alliedunit(mage, target->faction, HELP_GUARD)) { if (alliedunit(mage, target->faction, HELP_GUARD)) {
chance += curse_geteffect(c); probability += curse_geteffect(c)*0.01;
break; break;
} }
} }
@ -1234,9 +1235,9 @@ magic_resistance(unit *target)
const struct building_type * btype = b?b->type:NULL; const struct building_type * btype = b?b->type:NULL;
/* gesegneter Steinkreis gibt 30% dazu */ /* gesegneter Steinkreis gibt 30% dazu */
if (btype) chance += btype->magresbonus; if (btype) probability += btype->magresbonus * 0.01;
} }
return chance; return (int)(probability*100);
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -1253,7 +1254,7 @@ magic_resistance(unit *target)
boolean boolean
target_resists_magic(unit *magician, void *obj, int objtyp, int t_bonus) target_resists_magic(unit *magician, void *obj, int objtyp, int t_bonus)
{ {
int chance = 0; double probability = 0.0;
if (magician == NULL) return true; if (magician == NULL) return true;
if (obj == NULL) return true; if (obj == NULL) return true;
@ -1274,47 +1275,39 @@ target_resists_magic(unit *magician, void *obj, int objtyp, int t_bonus)
} }
/* Contest */ /* Contest */
chance = 5*(pa+10 - at); probability = 0.05 * (10 + pa - at);
chance += magic_resistance((unit *)obj); probability += magic_resistance((unit *)obj);
break; break;
} }
case TYP_REGION: case TYP_REGION:
/* Bonus durch Zauber */ /* Bonus durch Zauber */
chance += get_curseeffect(((region *)obj)->attribs, C_RESIST_MAGIC, 0); probability += 0.01 * get_curseeffect(((region *)obj)->attribs, C_RESIST_MAGIC, 0);
break; break;
case TYP_BUILDING: case TYP_BUILDING:
/* Bonus durch Zauber */ /* Bonus durch Zauber */
chance += get_curseeffect(((building *)obj)->attribs, C_RESIST_MAGIC, 0); probability += 0.01 * get_curseeffect(((building *)obj)->attribs, C_RESIST_MAGIC, 0);
/* Bonus durch Typ */ /* Bonus durch Typ */
chance += ((building *)obj)->type->magres; probability += 0.01 * ((building *)obj)->type->magres;
break; break;
case TYP_SHIP: case TYP_SHIP:
/* Bonus durch Zauber */ /* Bonus durch Zauber */
chance += get_curseeffect(((ship *)obj)->attribs, C_RESIST_MAGIC, 0); probability += 0.01 * get_curseeffect(((ship *)obj)->attribs, C_RESIST_MAGIC, 0);
break; break;
case TYP_FACTION:
default:
chance = 0;
} }
chance = max(2, chance + t_bonus); probability = max(0.02, probability + t_bonus*0.01);
chance = min(98, chance); probability = min(0.98, probability);
/* gibt true, wenn die Zufallszahl kleiner als die chance ist und /* gibt true, wenn die Zufallszahl kleiner als die chance ist und
* false, wenn sie gleich oder größer ist, dh je größer die * false, wenn sie gleich oder größer ist, dh je größer die
* Magieresistenz (chance) desto eher gibt die Funktion true zurück */ * Magieresistenz (chance) desto eher gibt die Funktion true zurück */
if (rand()%100 < chance) { return chance(probability);
return true;
}
return false;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -3180,4 +3173,3 @@ spell_name(const struct spell * sp, const struct locale * lang)
} }
return sp->sname; return sp->sname;
} }

View file

@ -146,6 +146,15 @@ struct spell_ptr {
/* typedef struct fighter fighter; */ /* typedef struct fighter fighter; */
/* irgendwelche zauber: */
typedef void (*spell_f) (void*);
/* normale zauber: */
typedef int (*nspell_f)(castorder*);
/* kampfzauber: */
typedef int (*cspell_f) (struct fighter*, int, double, struct spell * sp);
/* zauber-patzer: */
typedef void (*pspell_f) (castorder *);
typedef struct spell { typedef struct spell {
spellid_t id; spellid_t id;
const char *sname; const char *sname;
@ -157,7 +166,7 @@ typedef struct spell {
char rank; /* Reihenfolge der Zauber */ char rank; /* Reihenfolge der Zauber */
int level; /* Stufe des Zaubers */ int level; /* Stufe des Zaubers */
resource_t komponenten[MAXINGREDIENT][3]; resource_t komponenten[MAXINGREDIENT][3];
void (*sp_function) (void*); spell_f sp_function;
void (*patzer) (castorder*); void (*patzer) (castorder*);
} spell; } spell;
@ -182,15 +191,6 @@ struct castorder {
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
/* irgendwelche zauber: */
typedef void (*spell_f) (void*);
/* normale zauber: */
typedef int (*nspell_f)(castorder*);
/* kampfzauber: */
typedef int (*cspell_f) (struct fighter*, int, double, struct spell * sp);
/* zauber-patzer: */
typedef void (*pspell_f) (castorder *);
/* besondere Spruchtypen */ /* besondere Spruchtypen */
#define FARCASTING (1<<0) /* ZAUBER [struct region x y] */ #define FARCASTING (1<<0) /* ZAUBER [struct region x y] */
#define SPELLLEVEL (1<<1) /* ZAUBER [STUFE x] */ #define SPELLLEVEL (1<<1) /* ZAUBER [STUFE x] */
@ -364,7 +364,7 @@ int eff_spelllevel(struct unit *u, spell * sp, int cast_level, int distance);
boolean is_magic_resistant(struct unit *magician, struct unit *target, int boolean is_magic_resistant(struct unit *magician, struct unit *target, int
resist_bonus); resist_bonus);
/* Mapperfunktion für target_resists_magic() vom Typ struct unit. */ /* Mapperfunktion für target_resists_magic() vom Typ struct unit. */
int magic_resistance(struct unit *target); extern double magic_resistance(struct unit *target);
/* gibt die Chance an, mit der einem Zauber widerstanden wird. Je /* gibt die Chance an, mit der einem Zauber widerstanden wird. Je
* größer, desto resistenter ist da Opfer */ * größer, desto resistenter ist da Opfer */
boolean target_resists_magic(struct unit *magician, void *obj, int objtyp, boolean target_resists_magic(struct unit *magician, void *obj, int objtyp,

View file

@ -44,7 +44,8 @@
#include "unit.h" #include "unit.h"
/* util includes */ /* util includes */
#include <goodies.h> #include <util/goodies.h>
#include <util/rand.h>
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
@ -700,11 +701,11 @@ bewegung_blockiert_von(unit * reisender, region * r)
} }
} }
if (!contact && guard) { if (!contact && guard) {
int chance = 30; /* 30% base chance */ double prob = 0.3; /* 30% base chance */
chance += 10 * (perception - eff_stealth(reisender, r)); prob += 0.1 * (perception - eff_stealth(reisender, r));
chance += 10 * max(guard->number, get_item(guard, I_AMULET_OF_TRUE_SEEING)); prob += 0.1 * max(guard->number, get_item(guard, I_AMULET_OF_TRUE_SEEING));
if (rand() % 100 < chance) { if (chance(prob)) {
return guard; return guard;
} }
} }

View file

@ -3321,7 +3321,7 @@ sp_deathcloud(castorder *co)
/* Jede Person verliert 18 HP */ /* Jede Person verliert 18 HP */
damage = 18 * u->number; damage = 18 * u->number;
/* Reduziert durch Magieresistenz */ /* Reduziert durch Magieresistenz */
damage *= (100.0 - magic_resistance(u))/100.0; damage *= (1.0 - magic_resistance(u));
change_hitpoints(u, -(int)damage); change_hitpoints(u, -(int)damage);
} }

View file

@ -228,35 +228,35 @@ extern double destr_curse(struct curse* c, int cast_level, double force);
/* Kampfzauber */ /* Kampfzauber */
extern int sp_fumbleshield(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_fumbleshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_shadowknights(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_shadowknights(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_combatrosthauch(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_combatrosthauch(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_kampfzauber(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_kampfzauber(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_healing(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_healing(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_keeploot(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_keeploot(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_reanimate(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_reanimate(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_chaosrow(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_chaosrow(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_flee(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_flee(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_berserk(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_berserk(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_tiredsoldiers(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_tiredsoldiers(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_reeling_arrows(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_reeling_arrows(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_denyattack(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_denyattack(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_sleep(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_sleep(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_windshield(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_windshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_strong_wall(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_strong_wall(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_versteinern(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_versteinern(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_hero(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_hero(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_frighten(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_frighten(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_mindblast(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_mindblast(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_speed(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_speed(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_wolfhowl(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_wolfhowl(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_dragonodem(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_dragonodem(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_reduceshield(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_reduceshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_armorshield(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_armorshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_stun(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_stun(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_undeadhero(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_undeadhero(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_shadowcall(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_shadowcall(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_immolation(struct fighter * fi, int level, int power, struct spell * sp); extern int sp_immolation(struct fighter * fi, int level, double power, struct spell * sp);
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */

View file

@ -35,8 +35,8 @@ void spy(struct region * r, struct unit * u);
void sabotage(struct region * r, struct unit * u); void sabotage(struct region * r, struct unit * u);
void spy_message(int spy, struct unit *u, struct unit *target); void spy_message(int spy, struct unit *u, struct unit *target);
#define OCEAN_SWIMMER_CHANCE 10 #define OCEAN_SWIMMER_CHANCE 0.1
#define CANAL_SWIMMER_CHANCE 90 #define CANAL_SWIMMER_CHANCE 0.9
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -95,6 +95,7 @@ ntimespprob(int n, double p, double mod)
boolean boolean
chance(double x) chance(double x)
{ {
if (x>=1.0) return true;
return (boolean) (rand() % RAND_MAX < RAND_MAX * x); return (boolean) (rand() % RAND_MAX < RAND_MAX * x);
} }

View file

@ -234,34 +234,6 @@ getgarbage(void)
#endif #endif
} }
#if 0
static void
writefactiondata(void)
{
FILE *F;
char zText[128];
sprintf(zText, "%s/faction-data.xml", basepath());
F = cfopen(zText, "w");
if(F) {
faction *f;
for(f = factions; f; f=f->next) {
fprintf(F,"<faction>\n");
fprintf(F,"\t<id>%s</id>\n",itoa36(f->no));
fprintf(F,"\t<name>%s</name>\n",f->name);
fprintf(F,"\t<email>%s</email>\n",f->email);
fprintf(F,"\t<password>%s</password>\n",f->passw);
fprintf(F,"\t<race>%s</race>\n",rc_name(f->race,1));
fprintf(F,"\t<magic>%s</magic>\n",neue_gebiete[f->magiegebiet]);
fprintf(F,"\t<nmrs>%d</nmrs>\n",turn-f->lastorders);
fprintf(F,"\t<score>%d</score>\n",f->score);
fprintf(F,"</faction>\n");
}
}
fclose(F);
}
#endif
#ifdef SHORTPWDS #ifdef SHORTPWDS
static void static void
readshortpwds() readshortpwds()
@ -473,56 +445,6 @@ init_malloc_debug(void)
} }
#endif #endif
#if 0
static void
write_stats(void)
{
FILE * F;
char zText[MAX_PATH];
strcat(strcpy(zText, resourcepath()), "/spells");
F = fopen(zText, "wt");
if (F) {
int i, m = -1;
for (i=0;spelldaten[i].id;++i) {
if (spelldaten[i].magietyp!=m) {
m=spelldaten[i].magietyp;
fprintf(F, "\n%s\n", magietypen[m]);
}
fprintf(F, "%d\t%s\n", spelldaten[i].level, spelldaten[i].name);
}
fclose(F);
} else {
sprintf(buf, "fopen(%s): ", zText);
perror(buf);
}
strcat(strcpy(zText, resourcepath()), "/bonus");
F = fopen(buf, "wt");
if (F) {
race_t r;
for (r=0;r!=MAXRACES;++r) {
skill_t sk;
int i = 0;
fprintf(F, "const bonus %s_bonus = {\n\t", race[r].name[0]);
for (sk=0;sk!=MAXSKILLS;sk++) {
if (race[r].bonus[sk]) {
if (i==8) {
i = 0;
fputs("\n\t", F);
}
fprintf(F, "{ SK_%s, %d }, ", skillname(sk, NULL), race[r].bonus[sk]);
++i;
}
}
fputs("{ SK_NONE, 0 }\n};\n", F);
}
fclose(F);
} else {
sprintf(buf, "fopen(%s): ", zText);
perror(zText);
}
}
#endif
static int static int
usage(const char * prog, const char * arg) usage(const char * prog, const char * arg)
{ {