Monster displacing another monster out of the way */
| 2448 | |
| 2449 | /* Monster displacing another monster out of the way */ |
| 2450 | staticfn long |
| 2451 | mm_displacement( |
| 2452 | struct monst *magr, /* monster that is currently deciding where to move */ |
| 2453 | struct monst *mdef) /* another monster which is next to it */ |
| 2454 | { |
| 2455 | struct permonst *pa = magr->data, *pd = mdef->data; |
| 2456 | |
| 2457 | /* if attacker can't barge through, there's nothing to do; |
| 2458 | or if defender can barge through too and has a level at least |
| 2459 | as high as the attacker, don't let attacker do so, otherwise |
| 2460 | they might just end up swapping places again when defender |
| 2461 | gets its chance to move */ |
| 2462 | if (is_displacer(pa) && (!is_displacer(pd) || magr->m_lev > mdef->m_lev) |
| 2463 | /* no displacing grid bugs diagonally */ |
| 2464 | && !(magr->mx != mdef->mx && magr->my != mdef->my |
| 2465 | && NODIAG(monsndx(pd))) |
| 2466 | /* no displacing trapped monsters or multi-location longworms */ |
| 2467 | && !mdef->mtrapped && (!mdef->wormno || !count_wsegs(mdef)) |
| 2468 | /* riders can move anything; others, same size or smaller only */ |
| 2469 | && (is_rider(pa) || pa->msize >= pd->msize)) |
| 2470 | return ALLOW_MDISP; |
| 2471 | return 0L; |
| 2472 | } |
| 2473 | |
| 2474 | /* Is the square close enough for the monster to move or attack into? */ |
| 2475 | boolean |
no test coverage detected