* mon-to-mon displacement is a deliberate "get out of my way" act, * not an accidental bump, so we don't consider mstun or mconf in * undesired_disp(). * * We do consider many other things about the target and its * location however. */
| 2274 | * location however. |
| 2275 | */ |
| 2276 | boolean |
| 2277 | undesirable_disp( |
| 2278 | struct monst *mtmp, /* barging creature */ |
| 2279 | coordxy x, |
| 2280 | coordxy y) /* spot 'mtmp' is considering moving to */ |
| 2281 | { |
| 2282 | boolean is_pet = (mtmp->mtame && !mtmp->isminion); |
| 2283 | struct trap *trap = t_at(x, y); |
| 2284 | |
| 2285 | if (is_pet) { |
| 2286 | /* Pets avoid a trap if you've seen it usually. */ |
| 2287 | if (trap && trap->tseen && rn2(40)) |
| 2288 | return TRUE; |
| 2289 | /* Pets avoid cursed locations */ |
| 2290 | if (cursed_object_at(x, y)) |
| 2291 | return TRUE; |
| 2292 | |
| 2293 | /* Monsters avoid a trap if they've seen that type before */ |
| 2294 | } else if (trap && rn2(40) |
| 2295 | && mon_knows_traps(mtmp, trap->ttyp)) { |
| 2296 | return TRUE; |
| 2297 | } |
| 2298 | |
| 2299 | /* oversimplification: creatures that bargethrough can't swap places |
| 2300 | when target monster is in rock or closed door or water (in particular, |
| 2301 | avoid moving to spots where mondied() won't leave a corpse; doesn't |
| 2302 | matter whether barger is capable of moving to such a target spot if |
| 2303 | it were unoccupied) */ |
| 2304 | if (!accessible(x, y) |
| 2305 | /* mondied() allows is_pool() as an exception to !accessible(), |
| 2306 | but we'll only do that if 'mtmp' is already at a water location |
| 2307 | so that we don't swap a water critter onto land */ |
| 2308 | && !(is_pool(x, y) && is_pool(mtmp->mx, mtmp->my))) |
| 2309 | return TRUE; |
| 2310 | |
| 2311 | return FALSE; |
| 2312 | } |
| 2313 | |
| 2314 | /* |
| 2315 | * Inventory prevents passage under door. |
no test coverage detected