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

Function create_mplayers

src/mplayer.c:326–353  ·  view source on GitHub ↗

create the indicated number (num) of monster-players, * randomly chosen, and in randomly chosen (free) locations * on the level. If "special", the size of num should not * be bigger than the number of _non-repeated_ names in the * developers array, otherwise a bunch of Adams and Eves will * fill up the overflow. */

Source from the content-addressed store, hash-verified

324 * fill up the overflow.
325 */
326void
327create_mplayers(int num, boolean special)
328{
329 int pm, x, y;
330 struct monst fakemon;
331
332 fakemon = cg.zeromonst;
333 while (num) {
334 int tryct = 0;
335
336 /* roll for character class */
337 pm = rn1(PM_WIZARD - PM_ARCHEOLOGIST + 1, PM_ARCHEOLOGIST);
338 set_mon_data(&fakemon, &mons[pm]);
339
340 /* roll for an available location */
341 do {
342 x = rn1(COLNO - 4, 2);
343 y = rnd(ROWNO - 2);
344 } while (!goodpos(x, y, &fakemon, 0) && tryct++ <= 50);
345
346 /* if pos not found in 50 tries, don't bother to continue */
347 if (tryct > 50)
348 return;
349
350 (void) mk_mplayer(&mons[pm], (coordxy) x, (coordxy) y, special);
351 num--;
352 }
353}
354
355void
356mplayer_talk(struct monst *mtmp)

Callers 1

final_levelFunction · 0.85

Calls 4

set_mon_dataFunction · 0.85
rndFunction · 0.85
goodposFunction · 0.85
mk_mplayerFunction · 0.85

Tested by

no test coverage detected