Try to make a pit. */
| 218 | |
| 219 | /* Try to make a pit. */ |
| 220 | staticfn void |
| 221 | do_pit(coordxy x, coordxy y, unsigned tu_pit) |
| 222 | { |
| 223 | struct monst *mtmp; |
| 224 | struct obj *otmp; |
| 225 | struct trap *chasm; |
| 226 | schar filltype; |
| 227 | |
| 228 | chasm = maketrap(x, y, PIT); |
| 229 | if (!chasm) |
| 230 | return; /* no pit if portal at that location */ |
| 231 | chasm->tseen = 1; |
| 232 | |
| 233 | mtmp = m_at(x, y); /* (redundant?) */ |
| 234 | if ((otmp = sobj_at(BOULDER, x, y)) != 0) { |
| 235 | if (cansee(x, y)) |
| 236 | pline("KADOOM! The boulder falls into a chasm%s!", |
| 237 | u_at(x, y) ? " below you" : ""); |
| 238 | if (mtmp) |
| 239 | mtmp->mtrapped = 0; |
| 240 | obj_extract_self(otmp); |
| 241 | (void) flooreffects(otmp, x, y, ""); |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | /* Let liquid flow into the newly created chasm. |
| 246 | Adjust corresponding code in apply.c for exploding |
| 247 | wand of digging if you alter this sequence. */ |
| 248 | filltype = fillholetyp(x, y, FALSE); |
| 249 | if (filltype != ROOM) { |
| 250 | set_levltyp(x, y, filltype); /* levl[x][y] = filltype; */ |
| 251 | liquid_flow(x, y, filltype, chasm, (char *) 0); |
| 252 | /* liquid_flow() deletes trap, might kill mtmp */ |
| 253 | if ((chasm = t_at(x, y)) == NULL) |
| 254 | return; |
| 255 | } |
| 256 | |
| 257 | /* We have to check whether monsters or hero falls into a |
| 258 | new pit.... Note: if we get here, chasm is non-Null. */ |
| 259 | if (mtmp) { |
| 260 | if (!is_flyer(mtmp->data) && !is_clinger(mtmp->data)) { |
| 261 | boolean m_already_trapped = mtmp->mtrapped; |
| 262 | |
| 263 | mtmp->mtrapped = 1; |
| 264 | if (!m_already_trapped) { /* suppress messages */ |
| 265 | if (cansee(x, y)) { |
| 266 | pline("%s falls into a chasm!", Monnam(mtmp)); |
| 267 | } else if (humanoid(mtmp->data)) { |
| 268 | Soundeffect(se_scream, 50); |
| 269 | You_hear("a scream!"); |
| 270 | } |
| 271 | } |
| 272 | /* Falling is okay for falling down |
| 273 | within a pit from jostling too */ |
| 274 | mselftouch(mtmp, "Falling, ", TRUE); |
| 275 | if (!DEADMONSTER(mtmp)) { |
| 276 | mtmp->mhp -= rnd(m_already_trapped ? 4 : 6); |
| 277 | if (DEADMONSTER(mtmp)) { |
no test coverage detected