MCPcopy Create free account
hub / github.com/NetHack/NetHack / align_shift

Function align_shift

src/makemon.c:1610–1637  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

1608 * return an integer in the range of 0-5.
1609 */
1610staticfn int
1611align_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 */
1640staticfn int

Callers 1

rndmonst_adjFunction · 0.85

Calls 1

Is_specialFunction · 0.85

Tested by

no test coverage detected