Testen, das Einheiten noch am Leben sind, die eigentlich geloescht gehoeren.

This commit is contained in:
Enno Rehling 2006-10-08 22:15:49 +00:00
parent 8f78b586f7
commit cd35467899
1 changed files with 60 additions and 58 deletions

View File

@ -673,37 +673,37 @@ damage_unit(unit *u, const char *dam, boolean physical, boolean magic)
void void
drown(region *r) drown(region *r)
{ {
if (fval(r->terrain, SEA_REGION)) { if (fval(r->terrain, SEA_REGION)) {
unit ** up = up=&r->units; unit ** up = up=&r->units;
while (*up) { while (*up) {
unit *u = *up; unit *u = *up;
#ifdef KARMA_MODULE #ifdef KARMA_MODULE
int amphibian_level = fspecial(u->faction, FS_AMPHIBIAN); int amphibian_level = fspecial(u->faction, FS_AMPHIBIAN);
#else #else
int amphibian_level = 0; int amphibian_level = 0;
#endif #endif
if (u->ship || u->race == new_race[RC_SPELL] || u->number==0) { if (u->ship || u->race == new_race[RC_SPELL] || u->number==0) {
up=&u->next; up=&u->next;
continue; continue;
} }
if (amphibian_level) { if (amphibian_level) {
int dead = damage_unit(u, "5d1", false, false); int dead = damage_unit(u, "5d1", false, false);
if (dead) { if (dead) {
ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_dead", ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_dead",
"amount unit region", dead, u, r)); "amount unit region", dead, u, r));
} else { } else {
ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_nodead", ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_nodead",
"unit region",u, r)); "unit region",u, r));
} }
} else if (!(canswim(u) || canfly(u))) { } else if (!(canswim(u) || canfly(u))) {
scale_number(u, 0); scale_number(u, 0);
ADDMSG(&u->faction->msgs, msg_message("drown", "unit region", u, r)); ADDMSG(&u->faction->msgs, msg_message("drown", "unit region", u, r));
} }
if (*up==u) up=&u->next; if (*up==u) up=&u->next;
} }
remove_empty_units_in_region(r); remove_empty_units_in_region(r);
} }
} }
region * region *
@ -1263,7 +1263,7 @@ randomevents(void)
/* monster-einheiten desertieren */ /* monster-einheiten desertieren */
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) {
if (u->faction->no != MONSTER_FACTION if (u->faction && u->faction->no != MONSTER_FACTION
&& (u->race->flags & RCF_DESERT)) { && (u->race->flags & RCF_DESERT)) {
if (fval(u, UFL_ISNEW)) continue; if (fval(u, UFL_ISNEW)) continue;
if (rng_int()%100 < 5) { if (rng_int()%100 < 5) {
@ -1278,58 +1278,60 @@ randomevents(void)
#ifdef KARMA_MODULE #ifdef KARMA_MODULE
/* lycanthropen werden werwölfe */ /* lycanthropen werden werwölfe */
for (f = factions; f; f=f->next) { for (f = factions; f; f=f->next) {
int level = fspecial(f, FS_LYCANTROPE); if (f->alive) {
if (level > 0) { int level = fspecial(f, FS_LYCANTROPE);
for(u = f->units; u; u=u->nextF) { if (level > 0) {
if(rng_int()%100 < 2*level) { for(u = f->units; u; u=u->nextF) {
ADDMSG(&u->faction->msgs, msg_message("becomewere", if (rng_int()%100 < 2*level) {
"unit region", u, u->region)); ADDMSG(&u->faction->msgs,
fset(u, UFL_WERE); msg_message("becomewere", "unit region", u, u->region));
fset(u, UFL_WERE);
}
} }
} }
} }
} }
#endif #endif
/* Chaos */ /* Chaos */
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
int i; int i;
if (fval(r, RF_CHAOTIC)) { if (fval(r, RF_CHAOTIC)) {
chaos(r); chaos(r);
} }
i = chaoscount(r); i = chaoscount(r);
if (!i) continue; if (!i) continue;
chaoscounts(r, -(int) (i * ((double) (rng_int() % 10)) / 100.0)); chaoscounts(r, -(int) (i * ((double) (rng_int() % 10)) / 100.0));
} }
#ifdef HERBS_ROT #ifdef HERBS_ROT
/* Kräuter verrotten */ /* Kräuter verrotten */
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) {
item **itmp = &u->items, *hbag = *i_find(&u->items, olditemtype[I_SACK_OF_CONSERVATION]); item **itmp = &u->items, *hbag = *i_find(&u->items, olditemtype[I_SACK_OF_CONSERVATION]);
int rot_chance = HERBROTCHANCE; int rot_chance = HERBROTCHANCE;
if (hbag) rot_chance = (HERBROTCHANCE*2)/5; if (hbag) rot_chance = (HERBROTCHANCE*2)/5;
while (*itmp) { while (*itmp) {
item * itm = *itmp; item * itm = *itmp;
int n = itm->number; int n = itm->number;
double k = n*rot_chance/100.0; double k = n*rot_chance/100.0;
if (fval(itm->type, ITF_HERB)) { if (fval(itm->type, ITF_HERB)) {
double nv = normalvariate(k, k/4); double nv = normalvariate(k, k/4);
int inv = (int)nv; int inv = (int)nv;
int delta = min(n, inv); int delta = min(n, inv);
i_change(itmp, itm->type, -delta); i_change(itmp, itm->type, -delta);
} }
if (itm==*itmp) itmp=&itm->next; if (itm==*itmp) itmp=&itm->next;
} }
} }
} }
#endif #endif
dissolve_units(); dissolve_units();
check_split(); check_split();
#ifdef KARMA_MODULE #ifdef KARMA_MODULE
check_luck(); check_luck();
#endif /* KARMA_MODULE */ #endif /* KARMA_MODULE */
} }