implemented global warming (glacier belts with age > 200 can melt)

This commit is contained in:
Enno Rehling 2005-09-03 08:54:19 +00:00
parent b7ebf40866
commit 118230a737
2 changed files with 100 additions and 49 deletions

View File

@ -909,8 +909,7 @@ melt_iceberg(region *r)
for (u=r->units; u; u=u->next) freset(u->faction, FL_DH); for (u=r->units; u; u=u->next) freset(u->faction, FL_DH);
for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) { for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) {
fset(u->faction, FL_DH); fset(u->faction, FL_DH);
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("iceberg_melt", "region", r));
"iceberg_melt%r:region", r));
} }
/* driftrichtung löschen */ /* driftrichtung löschen */
@ -1049,13 +1048,18 @@ move_icebergs(void)
{ {
region *r; region *r;
for (r=regions; r; r=r->next) if (rterrain(r) == T_ICEBERG && !fval(r, RF_DH)) { for (r=regions; r; r=r->next) {
if (rand()%100 < 60) { if (rterrain(r) == T_ICEBERG && !fval(r, RF_DH)) {
fset(r, RF_DH); int select = rand() % 10;
move_iceberg(r); if (select < 4) {
} else if (rand()%100 < 10){ /* 4% chance */
fset(r, RF_DH); fset(r, RF_DH);
melt_iceberg(r); melt_iceberg(r);
} else if (select<64) {
/* 60% chance */
fset(r, RF_DH);
move_iceberg(r);
}
} }
} }
} }
@ -1065,32 +1069,38 @@ create_icebergs(void)
{ {
region *r; region *r;
for (r=regions; r; r=r->next) if (rterrain(r) == T_ICEBERG_SLEEP && rand()%100 < 5) { for (r=regions; r; r=r->next) {
boolean has_ocean_neighbour = false; if (rterrain(r) == T_ICEBERG_SLEEP && chance(0.05)) {
direction_t dir; boolean has_ocean_neighbour = false;
region *rc; direction_t dir;
unit *u; region *rc;
unit *u;
freset(r, RF_DH); freset(r, RF_DH);
for (dir=0; dir < MAXDIRECTIONS; dir++) { for (dir=0; dir < MAXDIRECTIONS; dir++) {
rc = rconnect(r, dir); rc = rconnect(r, dir);
if (rc && rterrain(rc) == T_OCEAN) { if (rc && rterrain(rc) == T_OCEAN) {
has_ocean_neighbour = true; has_ocean_neighbour = true;
break; break;
} }
} }
if (!has_ocean_neighbour) continue; if (!has_ocean_neighbour) continue;
rsetterrain(r, T_ICEBERG); rsetterrain(r, T_ICEBERG);
fset(r, RF_DH); fset(r, RF_DH);
move_iceberg(r); move_iceberg(r);
for (u=r->units; u; u=u->next) freset(u->faction, FL_DH); for (u=r->units; u; u=u->next) {
for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) { freset(u->faction, FL_DH);
fset(u->faction, FL_DH); }
ADDMSG(&u->faction->msgs, msg_message("iceberg_create", "region", r)); for (u=r->units; u; u=u->next) {
} if (!fval(u->faction, FL_DH)) {
fset(u->faction, FL_DH);
ADDMSG(&u->faction->msgs, msg_message("iceberg_create", "region", r));
}
}
}
} }
} }

View File

@ -24,8 +24,9 @@
/* misc includes */ /* misc includes */
#include <attributes/key.h> #include <attributes/key.h>
#include <attributes/otherfaction.h> #include <attributes/otherfaction.h>
#include <modules/xecmd.h> #include <attributes/targetregion.h>
#include <modules/autoseed.h> #include <modules/autoseed.h>
#include <modules/xecmd.h>
/* gamecode includes */ /* gamecode includes */
#include <gamecode/economy.h> #include <gamecode/economy.h>
@ -57,16 +58,17 @@
#include <kernel/unit.h> #include <kernel/unit.h>
/* util includes */ /* util includes */
#include <attrib.h> #include <util/attrib.h>
#include <language.h> #include <util/base36.h>
#include <base36.h> #include <util/cvector.h>
#include <log.h>
#include <cvector.h>
#include <util/event.h> #include <util/event.h>
#include <goodies.h> #include <util/goodies.h>
#include <resolve.h> #include <util/language.h>
#include <sql.h> #include <util/log.h>
#include <vset.h> #include <util/rand.h>
#include <util/resolve.h>
#include <util/sql.h>
#include <util/vset.h>
/* libc includes */ /* libc includes */
#include <stdio.h> #include <stdio.h>
@ -74,10 +76,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/* attributes includes */
#include <attributes/targetregion.h>
#include <attributes/key.h>
#undef XMAS1999 #undef XMAS1999
#undef XMAS2000 #undef XMAS2000
#undef XMAS2001 #undef XMAS2001
@ -749,7 +747,7 @@ fix_gates(void)
static void static void
frame_regions(void) frame_regions(void)
{ {
unsigned short ocean_age = turn; unsigned short ocean_age = (unsigned short)turn;
region * r = regions; region * r = regions;
for (r=regions;r;r=r->next) { for (r=regions;r;r=r->next) {
direction_t d; direction_t d;
@ -785,6 +783,46 @@ frame_regions(void)
} }
} }
#define GLOBAL_WARMING 200
#ifdef GLOBAL_WARMING
static void
global_warming(void)
{
region * r;
for (r=regions;r;r=r->next) {
if (r->age<GLOBAL_WARMING) continue;
if (r->terrain==T_GLACIER) {
/* 1% chance that an existing glacier gets unstable */
if (chance(0.01)) {
direction_t d;
for (d=0;d!=MAXDIRECTIONS;++d) {
region * rn = rconnect(r, d);
if (rn!=NULL) {
terrain_t rt = rn->terrain;
if (rt!=T_ICEBERG && rt!=T_ICEBERG_SLEEP && rt!=T_GLACIER && rt!=T_OCEAN) {
break;
}
}
}
if (d==MAXDIRECTIONS) {
terraform(r, T_ICEBERG_SLEEP);
}
}
} else if (r->terrain==T_ICEBERG || r->terrain==T_ICEBERG_SLEEP) {
direction_t d;
for (d=0;d!=MAXDIRECTIONS;++d) {
region * rn = rconnect(r, d);
if (rn && rn->terrain==T_GLACIER && chance(0.10)) {
/* 10% chance that a glacier next to an iceberg gets unstable */
terraform(rn, T_ICEBERG_SLEEP);
}
}
}
}
}
#endif
static int static int
fix_astralplane(void) fix_astralplane(void)
{ {
@ -949,10 +987,10 @@ check_phoenix(void)
return; return;
} }
} }
} }
f = findfaction(MONSTER_FACTION); f = findfaction(MONSTER_FACTION);
if (f==NULL) return; if (f==NULL) return;
/* it is not, so we create it */ /* it is not, so we create it */
r = random_land_region(); r = random_land_region();
@ -1131,6 +1169,9 @@ korrektur(void)
do_once("atrx", fix_attribflags()); do_once("atrx", fix_attribflags());
do_once("asfi", fix_astral_firewalls()); do_once("asfi", fix_astral_firewalls());
frame_regions(); frame_regions();
#ifdef GLOBAL_WARMING
global_warming();
#endif
fix_astralplane(); fix_astralplane();
fix_firewalls(); fix_firewalls();
fix_gates(); fix_gates();