boolean inside_gas_cloud(genericptr, genericptr);
boolean expire_gas_cloud(genericptr, genericptr);
boolean inside_rect(NhRect *, int, int);
-boolean inside_region(NhRegion *, int, int);
NhRegion *create_region(NhRect *, int);
void add_rect_to_reg(NhRegion *, NhRect *);
void add_mon_to_reg(NhRegion *, struct monst *);
/* Check for monsters inside the region */
for (i = reg->bounding_box.lx; i <= reg->bounding_box.hx; i++)
for (j = reg->bounding_box.ly; j <= reg->bounding_box.hy; j++) {
+ boolean is_inside = inside_region(reg, i, j);
+
/* Some regions can cross the level boundaries */
if (!isok(i, j))
continue;
- if (MON_AT(i, j) && inside_region(reg, i, j))
+ if (is_inside && MON_AT(i, j))
add_mon_to_reg(reg, g.level.monsters[i][j]);
if (reg->visible) {
- /*block_point(i, j);*/
+ if (is_inside)
+ block_point(i, j);
if (cansee(i, j))
newsym(i, j);
}
register int i, j, k;
int f_indx;
+ /* reset some messaging variables */
+ g.gas_cloud_diss_within = FALSE;
+ g.gas_cloud_diss_seen = 0;
+
/* End of life ? */
/* Do it backward because the array will be modified */
for (i = g.n_regions - 1; i >= 0; i--) {
}
}
}
+
+ if (g.gas_cloud_diss_within)
+ pline_The("gas cloud around you dissipates.");
+ if (g.gas_cloud_diss_seen)
+ You_see("%s dissipate.",
+ g.gas_cloud_diss_seen == 1
+ ? "a gas cloud" : "some gas clouds");
}
/*
{
NhRegion *reg;
int damage;
+ xchar x, y;
reg = (NhRegion *) p1;
damage = reg->arg.a_int;
reg->ttl = 2L; /* Here's the trick : reset ttl */
return FALSE; /* THEN return FALSE, means "still there" */
}
+
+ /* The cloud no longer blocks vision. */
+ for (x = reg->bounding_box.lx; x <= reg->bounding_box.hx; x++) {
+ for (y = reg->bounding_box.ly; y <= reg->bounding_box.hy; y++) {
+ if (inside_region(reg, x, y)) {
+ if (!does_block(x, y, &levl[x][y]))
+ unblock_point(x, y);
+ if (x == u.ux && y == u.uy)
+ g.gas_cloud_diss_within = TRUE;
+ if (cansee(x, y))
+ g.gas_cloud_diss_seen++;
+ }
+ }
+ }
+
return TRUE; /* OK, it's gone, you can free it! */
}
/*
* does_block()
*
- * Returns true if the level feature, object, or monster at (x,y) blocks
- * sight.
+ * Returns true if something at (x,y) blocks sight.
*/
int
does_block(int x, int y, struct rm *lev)
{
struct obj *obj;
struct monst *mon;
+ int i;
/* Features that block . . */
if (IS_ROCK(lev->typ) || lev->typ == TREE
&& is_lightblocker_mappear(mon))
return 1;
+ /* Clouds (poisonous or not) block light. */
+ for (i = 0; i < g.n_regions; i++) {
+ /* Ignore regions with ttl == 0 - expire_gas_cloud must unblock its
+ * points prior to being removed itself. */
+ if (g.regions[i]->ttl > 0 && g.regions[i]->visible
+ && inside_region(g.regions[i], x, y)) {
+ return 1;
+ }
+ }
+
return 0;
}