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

Function rnd_attr

src/attrib.c:681–692  ·  view source on GitHub ↗

return random hero attribute (by role's attr distribution). returns A_MAX if failed. */

Source from the content-addressed store, hash-verified

679/* return random hero attribute (by role's attr distribution).
680 returns A_MAX if failed. */
681staticfn int
682rnd_attr(void)
683{
684 int i, x = rn2(100);
685
686 /* 5.0: the x -= ... calculation used to have an off by 1 error that
687 resulted in the values being biased toward Str and away from Cha */
688 for (i = 0; i < A_MAX; ++i)
689 if ((x -= gu.urole.attrdist[i]) < 0)
690 break;
691 return i;
692}
693
694/* add or subtract np points from random attributes,
695 adjusting the base and maximum values of the attributes.

Callers 1

init_attr_role_redistFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected