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

Function mk_mplayer

src/mplayer.c:117–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117struct monst *
118mk_mplayer(struct permonst *ptr, coordxy x, coordxy y, boolean special)
119{
120 struct monst *mtmp;
121 char nam[PL_NSIZ];
122
123 if (!is_mplayer(ptr))
124 return ((struct monst *) 0);
125
126 if (MON_AT(x, y))
127 (void) rloc(m_at(x, y), RLOC_ERR|RLOC_NOMSG); /* insurance */
128
129 if (!In_endgame(&u.uz))
130 special = FALSE;
131
132 if ((mtmp = makemon(ptr, x, y, special ? MM_NOMSG : NO_MM_FLAGS)) != 0) {
133 short weapon, armor, cloak, helm, shield;
134 int quan;
135 struct obj *otmp;
136
137 mtmp->m_lev = (special ? rn1(16, 15) : rnd(16));
138 mtmp->mhp = mtmp->mhpmax = d((int) mtmp->m_lev, 10)
139 + (special ? (30 + rnd(30)) : 30);
140 if (special) {
141 get_mplname(mtmp, nam);
142 mtmp = christen_monst(mtmp, nam);
143 /* that's why they are "stuck" in the endgame :-) */
144 (void) mongets(mtmp, FAKE_AMULET_OF_YENDOR);
145 }
146 mtmp->mpeaceful = 0;
147 set_malign(mtmp); /* peaceful may have changed again */
148
149 /* default equipment; much of it will be overridden below */
150 weapon = !rn2(2) ? LONG_SWORD : rnd_class(SPEAR, BULLWHIP);
151 armor = rnd_class(GRAY_DRAGON_SCALE_MAIL, YELLOW_DRAGON_SCALE_MAIL);
152 cloak = !rn2(8) ? STRANGE_OBJECT
153 : rnd_class(OILSKIN_CLOAK, CLOAK_OF_DISPLACEMENT);
154 helm = !rn2(8) ? STRANGE_OBJECT
155 : rnd_class(ELVEN_LEATHER_HELM, HELM_OF_TELEPATHY);
156 shield = !rn2(8) ? STRANGE_OBJECT
157 : rnd_class(ELVEN_SHIELD, SHIELD_OF_REFLECTION);
158
159 switch (monsndx(ptr)) {
160 case PM_ARCHEOLOGIST:
161 if (rn2(2))
162 weapon = BULLWHIP;
163 break;
164 case PM_BARBARIAN:
165 if (rn2(2)) {
166 weapon = rn2(2) ? TWO_HANDED_SWORD : BATTLE_AXE;
167 shield = STRANGE_OBJECT;
168 }
169 if (rn2(2))
170 armor = rnd_class(PLATE_MAIL, CHAIN_MAIL);
171 if (helm == HELM_OF_BRILLIANCE)
172 helm = STRANGE_OBJECT;
173 break;
174 case PM_CAVE_DWELLER:

Callers 2

create_mplayersFunction · 0.85
create_monsterFunction · 0.85

Calls 15

rlocFunction · 0.85
makemonFunction · 0.85
rndFunction · 0.85
dFunction · 0.85
get_mplnameFunction · 0.85
christen_monstFunction · 0.85
mongetsFunction · 0.85
set_malignFunction · 0.85
rn2Function · 0.85
rnd_classFunction · 0.85
mksobjFunction · 0.85
mk_artifactFunction · 0.85

Tested by

no test coverage detected