* shift the probability of a monster's generation by * comparing the dungeon alignment and monster alignment. * return an integer in the range of 0-5. */
| 1608 | * return an integer in the range of 0-5. |
| 1609 | */ |
| 1610 | staticfn int |
| 1611 | align_shift(struct permonst *ptr) |
| 1612 | { |
| 1613 | static NEARDATA long oldmoves = 0L; /* != 1, starting value of moves */ |
| 1614 | static NEARDATA s_level *lev; |
| 1615 | int alshift; |
| 1616 | |
| 1617 | if (oldmoves != svm.moves) { |
| 1618 | lev = Is_special(&u.uz); |
| 1619 | oldmoves = svm.moves; |
| 1620 | } |
| 1621 | switch ((lev) ? lev->flags.align : svd.dungeons[u.uz.dnum].flags.align) { |
| 1622 | default: /* just in case */ |
| 1623 | case AM_NONE: |
| 1624 | alshift = 0; |
| 1625 | break; |
| 1626 | case AM_LAWFUL: |
| 1627 | alshift = (ptr->maligntyp + 20) / (2 * ALIGNWEIGHT); |
| 1628 | break; |
| 1629 | case AM_NEUTRAL: |
| 1630 | alshift = (20 - abs(ptr->maligntyp)) / ALIGNWEIGHT; |
| 1631 | break; |
| 1632 | case AM_CHAOTIC: |
| 1633 | alshift = (-(ptr->maligntyp - 20)) / (2 * ALIGNWEIGHT); |
| 1634 | break; |
| 1635 | } |
| 1636 | return alshift; |
| 1637 | } |
| 1638 | |
| 1639 | /* return larger value if monster prefers the level temperature */ |
| 1640 | staticfn int |
no test coverage detected