report volcano outbreaks in affected regions.

https://bugs.eressea.de/view.php?id=2049
This commit is contained in:
Enno Rehling 2014-12-08 21:19:18 +01:00
parent 7d5280196a
commit b30de914aa
1 changed files with 946 additions and 926 deletions

View File

@ -1,7 +1,7 @@
/* /*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de> Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de> Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@ -89,7 +89,8 @@ static void dissolve_units(void)
/* TODO: Durch einzelne Berechnung ersetzen */ /* TODO: Durch einzelne Berechnung ersetzen */
if (a->data.ca[1] == 100) { if (a->data.ca[1] == 100) {
n = u->number; n = u->number;
} else { }
else {
n = 0; n = 0;
for (i = 0; i < u->number; i++) { for (i = 0; i < u->number; i++) {
if (rng_int() % 100 < a->data.ca[1]) if (rng_int() % 100 < a->data.ca[1])
@ -117,7 +118,8 @@ static void dissolve_units(void)
msg = msg =
msg_message("dissolve_units_2", "unit region number race", u, r, msg_message("dissolve_units_2", "unit region number race", u, r,
n, u_race(u)); n, u_race(u));
} else { }
else {
msg = msg =
msg_message("dissolve_units_3", "unit region number race", u, r, msg_message("dissolve_units_3", "unit region number race", u, r,
n, u_race(u)); n, u_race(u));
@ -129,7 +131,8 @@ static void dissolve_units(void)
msg = msg =
msg_message("dissolve_units_4", "unit region number race", u, r, msg_message("dissolve_units_4", "unit region number race", u, r,
n, u_race(u)); n, u_race(u));
} else { }
else {
msg = msg =
msg_message("dissolve_units_5", "unit region number race", u, r, msg_message("dissolve_units_5", "unit region number race", u, r,
n, u_race(u)); n, u_race(u));
@ -285,7 +288,8 @@ static void get_allies(region * r, unit * u)
equip = "random_plain"; equip = "random_plain";
number = rng_int() % 8 + 2; number = rng_int() % 8 + 2;
break; break;
} else { }
else {
if (eff_skill(u, SK_LONGBOW, r) < 3 if (eff_skill(u, SK_LONGBOW, r) < 3
&& eff_skill(u, SK_HERBALISM, r) < 2 && eff_skill(u, SK_HERBALISM, r) < 2
&& eff_skill(u, SK_MAGIC, r) < 2) { && eff_skill(u, SK_MAGIC, r) < 2) {
@ -549,7 +553,8 @@ void chaos(region * r)
} }
terraform_region(r, newterrain(T_OCEAN)); terraform_region(r, newterrain(T_OCEAN));
} }
} else { }
else {
direction_t dir; direction_t dir;
for (dir = 0; dir != MAXDIRECTIONS; ++dir) { for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
region *rn = rconnect(r, dir); region *rn = rconnect(r, dir);
@ -641,7 +646,8 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
if (get_effect(u, oldpotiontype[P_HEAL]) > 0) { if (get_effect(u, oldpotiontype[P_HEAL]) > 0) {
change_effect(u, oldpotiontype[P_HEAL], -1); change_effect(u, oldpotiontype[P_HEAL], -1);
heiltrank = 1; heiltrank = 1;
} else if (i_get(u->items, oldpotiontype[P_HEAL]->itype) > 0) { }
else if (i_get(u->items, oldpotiontype[P_HEAL]->itype) > 0) {
i_change(&u->items, oldpotiontype[P_HEAL]->itype, -1); i_change(&u->items, oldpotiontype[P_HEAL]->itype, -1);
change_effect(u, oldpotiontype[P_HEAL], 3); change_effect(u, oldpotiontype[P_HEAL], 3);
heiltrank = 1; heiltrank = 1;
@ -653,7 +659,8 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
} }
} }
dead++; dead++;
} else { }
else {
hp_rem += hp[i]; hp_rem += hp[i];
} }
} }
@ -683,11 +690,13 @@ void drown(region * r)
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));
} }
@ -727,8 +736,7 @@ region *rrandneighbour(region * r)
} }
static void static void
volcano_destruction(region * volcano, region * r, region * rn, volcano_destruction(region * volcano, region * r, const char *damage)
const char *damage)
{ {
attrib *a; attrib *a;
unit **up; unit **up;
@ -741,7 +749,8 @@ volcano_destruction(region * volcano, region * r, region * rn,
a = a_find(r->attribs, &at_reduceproduction); a = a_find(r->attribs, &at_reduceproduction);
if (!a) { if (!a) {
a = make_reduceproduction(percent, time); a = make_reduceproduction(percent, time);
} else { }
else {
/* Produktion vierteln ... */ /* Produktion vierteln ... */
a->data.sa[0] = (short)percent; a->data.sa[0] = (short)percent;
/* Für 6-17 Runden */ /* Für 6-17 Runden */
@ -758,21 +767,21 @@ volcano_destruction(region * volcano, region * r, region * rn,
ADDMSG(&u->faction->msgs, msg_message("volcano_dead", ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
"unit region dead", u, volcano, dead)); "unit region dead", u, volcano, dead));
} }
if (r == volcano && !fval(u->faction, FFL_SELECT)) { if (!fval(u->faction, FFL_SELECT)) {
fset(u->faction, FFL_SELECT); fset(u->faction, FFL_SELECT);
if (rn) {
ADDMSG(&u->faction->msgs, msg_message("volcanooutbreak",
"regionv regionn", r, rn));
} else {
ADDMSG(&u->faction->msgs, msg_message("volcanooutbreaknn", ADDMSG(&u->faction->msgs, msg_message("volcanooutbreaknn",
"region", r)); "region", r));
} }
} }
} if (u == *up) {
if (u == *up)
up = &u->next; up = &u->next;
} }
}
if (r != volcano) {
ADDMSG(&r->msgs, msg_message("volcanooutbreak",
"regionv regionn", volcano, r));
}
remove_empty_units_in_region(r); remove_empty_units_in_region(r);
} }
@ -791,10 +800,9 @@ void volcano_outbreak(region * r)
/* Zufällige Nachbarregion verwüsten */ /* Zufällige Nachbarregion verwüsten */
rn = rrandneighbour(r); rn = rrandneighbour(r);
volcano_destruction(r, r, "4d10");
volcano_destruction(r, r, rn, "4d10");
if (rn) { if (rn) {
volcano_destruction(r, rn, NULL, "3d10"); volcano_destruction(r, rn, "3d10");
} }
} }
@ -837,14 +845,16 @@ static void move_iceberg(region * r)
a = a_find(r->attribs, &at_iceberg); a = a_find(r->attribs, &at_iceberg);
if (!a) { if (!a) {
dir = (direction_t) (rng_int() % MAXDIRECTIONS); dir = (direction_t)(rng_int() % MAXDIRECTIONS);
a = a_add(&r->attribs, make_iceberg(dir)); a = a_add(&r->attribs, make_iceberg(dir));
} else { }
else {
if (rng_int() % 100 < 20) { if (rng_int() % 100 < 20) {
dir = (direction_t) (rng_int() % MAXDIRECTIONS); dir = (direction_t)(rng_int() % MAXDIRECTIONS);
a->data.i = dir; a->data.i = dir;
} else { }
dir = (direction_t) a->data.i; else {
dir = (direction_t)a->data.i;
} }
} }
@ -927,7 +937,8 @@ static void move_iceberg(region * r)
"ship", sh)); "ship", sh));
} }
remove_ship(&sh->region->ships, sh); remove_ship(&sh->region->ships, sh);
} else if (u != NULL) { }
else if (u != NULL) {
ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg", ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg",
"ship", sh)); "ship", sh));
} }
@ -935,7 +946,8 @@ static void move_iceberg(region * r)
sh = shn; sh = shn;
} }
} else if (rng_int() % 100 < 20) { /* Eisberg bleibt als Gletscher liegen */ }
else if (rng_int() % 100 < 20) { /* Eisberg bleibt als Gletscher liegen */
unit *u; unit *u;
rsetterrain(r, T_GLACIER); rsetterrain(r, T_GLACIER);
@ -963,7 +975,8 @@ static void move_icebergs(void)
/* 4% chance */ /* 4% chance */
fset(r, RF_SELECT); fset(r, RF_SELECT);
melt_iceberg(r); melt_iceberg(r);
} else if (select < 64) { }
else if (select < 64) {
/* 60% chance */ /* 60% chance */
fset(r, RF_SELECT); fset(r, RF_SELECT);
move_iceberg(r); move_iceberg(r);
@ -1135,11 +1148,13 @@ static void demon_skillchanges(void)
/* demons should never forget below 1 */ /* demons should never forget below 1 */
set_level(u, sv->id, 1); set_level(u, sv->id, 1);
} }
} else { }
while (weeks--) else {
while (weeks--) {
learn_skill(u, sv->id, 1.0); learn_skill(u, sv->id, 1.0);
} }
} }
}
++sv; ++sv;
} }
} }
@ -1226,7 +1241,8 @@ void randomevents(void)
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) {
double probability = 0.0; double probability = 0.0;
@ -1237,7 +1253,8 @@ void randomevents(void)
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));
} else { }
else {
a->data.i -= _max(10, a->data.i / 10); a->data.i -= _max(10, a->data.i / 10);
if (a->data.i <= 0) if (a->data.i <= 0)
a_remove(&r->attribs, a); a_remove(&r->attribs, a);
@ -1252,15 +1269,18 @@ void randomevents(void)
if (a_find(r->attribs, &at_reduceproduction)) { if (a_find(r->attribs, &at_reduceproduction)) {
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
rsetterrain(r, T_VOLCANO); rsetterrain(r, T_VOLCANO);
} else { }
else {
if (rng_int() % 100 < 12) { if (rng_int() % 100 < 12) {
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r)); ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
rsetterrain(r, T_VOLCANO); rsetterrain(r, T_VOLCANO);
} else if (r->age > 20 && rng_int() % 100 < 8) { }
else if (r->age > 20 && rng_int() % 100 < 8) {
volcano_outbreak(r); volcano_outbreak(r);
} }
} }
} else if (r->terrain == newterrain(T_VOLCANO)) { }
else if (r->terrain == newterrain(T_VOLCANO)) {
if (rng_int() % 100 < 4) { if (rng_int() % 100 < 4) {
ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r)); ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r));
rsetterrain(r, T_VOLCANO_SMOKING); rsetterrain(r, T_VOLCANO_SMOKING);