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

Function m_initweap

src/makemon.c:160–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160staticfn void
161m_initweap(struct monst *mtmp)
162{
163 struct permonst *ptr = mtmp->data;
164 int mm = monsndx(ptr);
165 struct obj *otmp;
166 int bias, w1, w2;
167
168 if (Is_rogue_level(&u.uz))
169 return;
170 /*
171 * First a few special cases:
172 * giants get a boulder to throw sometimes
173 * ettins get clubs
174 * kobolds get darts to throw
175 * centaurs get some sort of bow & arrows or bolts
176 * soldiers get all sorts of things
177 * kops get clubs & cream pies.
178 */
179 switch (ptr->mlet) {
180 case S_GIANT:
181 if (rn2(2))
182 (void) mongets(mtmp, (mm != PM_ETTIN) ? BOULDER : CLUB);
183 if ((mm != PM_ETTIN) && !rn2(5))
184 (void) mongets(mtmp, rn2(2) ? TWO_HANDED_SWORD : BATTLE_AXE);
185 break;
186 case S_HUMAN:
187 if (is_mercenary(ptr)) {
188 w1 = w2 = 0;
189 switch (mm) {
190 case PM_WATCHMAN:
191 case PM_SOLDIER:
192 if (!rn2(3)) {
193 /* lance and dwarvish mattock used to be in midst of
194 the polearms but use different skills from polearms
195 and aren't appropriates choices for human soldiers */
196 do {
197 w1 = rn1(BEC_DE_CORBIN - PARTISAN + 1, PARTISAN);
198 } while (objects[w1].oc_skill != P_POLEARMS);
199 w2 = rn2(2) ? DAGGER : KNIFE;
200 } else
201 w1 = rn2(2) ? SPEAR : SHORT_SWORD;
202 break;
203 case PM_SERGEANT:
204 w1 = rn2(2) ? FLAIL : MACE;
205 break;
206 case PM_LIEUTENANT:
207 w1 = rn2(2) ? BROADSWORD : LONG_SWORD;
208 break;
209 case PM_CAPTAIN:
210 case PM_WATCH_CAPTAIN:
211 w1 = rn2(2) ? LONG_SWORD : SILVER_SABER;
212 break;
213 default:
214 if (!rn2(4))
215 w1 = DAGGER;
216 if (!rn2(7))
217 w2 = SPEAR;

Callers 1

makemonFunction · 0.85

Calls 11

rn2Function · 0.85
mongetsFunction · 0.85
m_initthrowFunction · 0.85
mksobjFunction · 0.85
rndFunction · 0.85
curseFunction · 0.85
mpickobjFunction · 0.85
sgnFunction · 0.85
onameFunction · 0.85
blessFunction · 0.85
rnd_offensive_itemFunction · 0.85

Tested by

no test coverage detected