MCPcopy Index your code
hub / github.com/NetHack/NetHack / u_init_role

Function u_init_role

src/u_init.c:636–788  ·  view source on GitHub ↗

role-specific initializations, mostly inventory other things may be initialised here, but the function might run more than once, so any non-inventory initialisations should be nonrandom and idempotent (i.e. doing them twice is OK) */

Source from the content-addressed store, hash-verified

634 once, so any non-inventory initialisations should be nonrandom and
635 idempotent (i.e. doing them twice is OK) */
636staticfn void
637u_init_role(void)
638{
639 int i;
640
641 /* the program used to check moves<=1 && invent==NULL do decide whether
642 a new game has started, but due to the 'pauper' option/conduct, can't
643 rely on invent becoming non-Null anymore; instead, initialize moves
644 to 0 instead of 1, then set it to 1 here, where invent init occurs */
645 svm.moves = 1L;
646
647 switch (Role_switch) {
648 /* rn2(100) > 50 necessary for some choices because some
649 * random number generators are bad enough to seriously
650 * skew the results if we use rn2(2)... --KAA
651 */
652 case PM_ARCHEOLOGIST:
653 ini_inv(Archeologist);
654 if (!rn2(10))
655 ini_inv(Tinopener);
656 else if (!rn2(4))
657 ini_inv(Lamp);
658 else if (!rn2(5))
659 ini_inv(Magicmarker);
660 knows_object(SACK, FALSE);
661 knows_object(TOUCHSTONE, FALSE); /* FALSE: don't override pauper here,
662 * but TOUCHSTONE will be made known
663 * in pauper_reinit() */
664 break;
665 case PM_BARBARIAN:
666 if (rn2(100) >= 50) { /* see above comment */
667 ini_inv(Barbarian_0);
668 } else {
669 ini_inv(Barbarian_1);
670 }
671 if (!rn2(6))
672 ini_inv(Lamp);
673 knows_class(WEAPON_CLASS); /* excluding polearms */
674 knows_class(ARMOR_CLASS);
675 break;
676 case PM_CAVE_DWELLER:
677 ini_inv(Cave_man);
678 break;
679 case PM_HEALER:
680 u.umoney0 = rn1(1000, 1001);
681 ini_inv(Healer);
682 if (!rn2(25))
683 ini_inv(Lamp);
684 knows_object(POT_FULL_HEALING, FALSE);
685 break;
686 case PM_KNIGHT:
687 ini_inv(Knight);
688 knows_class(WEAPON_CLASS); /* all weapons */
689 knows_class(ARMOR_CLASS);
690 /* give knights chess-like mobility--idea from wooledge@..cwru.edu */
691 HJumping |= FROMOUTSIDE;
692 break;
693 case PM_MONK: {

Callers 1

u_init_inventory_attrsFunction · 0.85

Calls 6

ini_invFunction · 0.85
rn2Function · 0.85
knows_objectFunction · 0.85
knows_classFunction · 0.85
Japanese_item_nameFunction · 0.85
rndFunction · 0.85

Tested by

no test coverage detected