return random hero attribute (by role's attr distribution). returns A_MAX if failed. */
| 679 | /* return random hero attribute (by role's attr distribution). |
| 680 | returns A_MAX if failed. */ |
| 681 | staticfn int |
| 682 | rnd_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. |
no test coverage detected