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

Function m_initinv

src/makemon.c:588–833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586}
587
588staticfn void
589m_initinv(struct monst *mtmp)
590{
591 int cnt;
592 struct obj *otmp;
593 struct permonst *ptr = mtmp->data;
594
595 if (Is_rogue_level(&u.uz))
596 return;
597 /*
598 * Soldiers get armour & rations - armour approximates their ac.
599 * Nymphs may get mirror or potion of object detection.
600 */
601 switch (ptr->mlet) {
602 case S_HUMAN:
603 if (is_mercenary(ptr)) {
604 int mac;
605
606 switch (monsndx(ptr)) {
607 case PM_GUARD:
608 mac = -1;
609 break;
610 case PM_SOLDIER:
611 mac = 3;
612 break;
613 case PM_SERGEANT:
614 mac = 0;
615 break;
616 case PM_LIEUTENANT:
617 mac = -2;
618 break;
619 case PM_CAPTAIN:
620 mac = -3;
621 break;
622 case PM_WATCHMAN:
623 mac = 3;
624 break;
625 case PM_WATCH_CAPTAIN:
626 mac = -2;
627 break;
628 default:
629 impossible("odd mercenary %d?", monsndx(ptr));
630 mac = 0;
631 break;
632 }
633
634#define add_ac(otmp) \
635 if (otmp) { mac += ARM_BONUS(otmp); } \
636 otmp = (struct obj *) 0;
637
638 /* round 1: give them body armor */
639 if (mac < -1 && rn2(5))
640 otmp = mongets(mtmp, (rn2(5)) ? PLATE_MAIL
641 : CRYSTAL_PLATE_MAIL);
642 else if (mac < 3 && rn2(5))
643 otmp = mongets(mtmp, (rn2(3)) ? SPLINT_MAIL : BANDED_MAIL);
644 else if (rn2(5))
645 otmp = mongets(mtmp, (rn2(3)) ? RING_MAIL

Callers 1

makemonFunction · 0.85

Calls 15

rn2Function · 0.85
mongetsFunction · 0.85
mksobjFunction · 0.85
curseFunction · 0.85
mpickobjFunction · 0.85
mkmonmoneyFunction · 0.85
rnd_classFunction · 0.85
weightFunction · 0.85
rndFunction · 0.85
set_corpsenmFunction · 0.85
stop_timerFunction · 0.85
obj_to_anyFunction · 0.85

Tested by

no test coverage detected