"Irrlichter haben keinen Effekt auf Einheiten, die sich mit FOLGE bewegen"

Irrlichter lenken jetzt _alle_ Durchreisenden Einheiten in die gleiche Richtung ab, wenn sie aus der selben Region kommen.
This commit is contained in:
Enno Rehling 2007-02-17 19:40:19 +00:00
parent 1fe02019cd
commit 8fe61a96f4
1 changed files with 24 additions and 7 deletions

View File

@ -3009,28 +3009,45 @@ wisps_name(const border * b, const region * r, const faction * f, int gflags)
return "Irrlichter"; return "Irrlichter";
} }
typedef struct wisps_data {
wall_data wall;
int rnd;
} wisps_data;
static region * static region *
wisps_move(const border * b, struct unit * u, struct region * from, struct region * next, boolean routing) wisps_move(const border * b, struct unit * u, struct region * from, struct region * next, boolean routing)
{ {
direction_t reldir = reldirection(from, next); direction_t reldir = reldirection(from, next);
wall_data * wd = (wall_data*)b->data.v; wisps_data * wd = (wisps_data*)b->data.v;
assert(reldir!=D_SPECIAL); assert(reldir!=D_SPECIAL);
if (routing && wd->active) { if (routing && wd->wall.active) {
/* pick left and right region: */
region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS)); region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS));
region * rr = rconnect(from, (direction_t)((reldir+1)%MAXDIRECTIONS)); region * rr = rconnect(from, (direction_t)((reldir+1)%MAXDIRECTIONS));
int j = rng_int() % 3; /* pick left and right region: */
if (j==1 && rl && fval(rl->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rl; if (wd->rnd<0) {
if (j==2 && rr && fval(rr->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rr; wd->rnd = rng_int() % 3;
}
if (wd->rnd == 1 && rl && fval(rl->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rl;
if (wd->rnd == 2 && rr && fval(rr->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rr;
} }
return next; return next;
} }
static void
wisps_init(border * b)
{
wisps_data * wd = (wisps_data*)calloc(sizeof(wisps_data), 1);
b->data.v = wd;
wd->rnd = -1;
}
border_type bt_wisps = { border_type bt_wisps = {
"wisps", VAR_VOIDPTR, "wisps", VAR_VOIDPTR,
b_transparent, /* transparent */ b_transparent, /* transparent */
wall_init, /* init */ wisps_init, /* init */
wall_destroy, /* destroy */ wall_destroy, /* destroy */
wall_read, /* read */ wall_read, /* read */
wall_write, /* write */ wall_write, /* write */