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

Function init_attr_role_redist

src/attrib.c:698–719  ·  view source on GitHub ↗

add or subtract np points from random attributes, adjusting the base and maximum values of the attributes. if subtracting, np must be negative. returns the left over points. */

Source from the content-addressed store, hash-verified

696 if subtracting, np must be negative.
697 returns the left over points. */
698staticfn int
699init_attr_role_redist(int np, boolean addition)
700{
701 int tryct = 0;
702 int adj = addition ? 1 : -1;
703
704 while ((addition ? (np > 0) : (np < 0)) && tryct < 100) {
705 int i = rnd_attr();
706
707 if (i >= A_MAX
708 || (addition ? (ABASE(i) >= ATTRMAX(i))
709 : (ABASE(i) <= ATTRMIN(i)))) {
710 tryct++;
711 continue;
712 }
713 tryct = 0;
714 ABASE(i) += adj;
715 AMAX(i) += adj;
716 np -= adj;
717 }
718 return np;
719}
720
721/* allocate hero's initial characteristics */
722void

Callers 1

init_attrFunction · 0.85

Calls 1

rnd_attrFunction · 0.85

Tested by

no test coverage detected