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

Function m_initgrp

src/makemon.c:78–145  ·  view source on GitHub ↗

make a group just like mtmp */

Source from the content-addressed store, hash-verified

76
77/* make a group just like mtmp */
78staticfn void
79m_initgrp(
80 struct monst *mtmp,
81 coordxy x, coordxy y, int n,
82 mmflags_nht mmflags)
83{
84 coord mm;
85 int cnt = rnd(n);
86 struct monst *mon;
87#if defined(__GNUC__) && (defined(HPUX) || defined(DGUX))
88 /* There is an unresolved problem with several people finding that
89 * the game hangs eating CPU; if interrupted and restored, the level
90 * will be filled with monsters. Of those reports giving system type,
91 * there were two DG/UX and two HP-UX, all using gcc as the compiler.
92 * hcroft@hpopb1.cern.ch, using gcc 2.6.3 on HP-UX, says that the
93 * problem went away for him and another reporter-to-newsgroup
94 * after adding this debugging code. This has almost got to be a
95 * compiler bug, but until somebody tracks it down and gets it fixed,
96 * might as well go with the "but it went away when I tried to find
97 * it" code.
98 */
99 int cnttmp, cntdiv;
100
101 cnttmp = cnt;
102 debugpline4("init group call <%d,%d>, n=%d, cnt=%d.", x, y, n, cnt);
103 cntdiv = ((u.ulevel < 3) ? 4 : (u.ulevel < 5) ? 2 : 1);
104#endif
105 /* Tuning: cut down on swarming at low character levels [mrs] */
106 cnt /= (u.ulevel < 3) ? 4 : (u.ulevel < 5) ? 2 : 1;
107#if defined(__GNUC__) && (defined(HPUX) || defined(DGUX))
108 if (cnt != (cnttmp / cntdiv)) {
109 pline("cnt=%d using %d, cnttmp=%d, cntdiv=%d", cnt,
110 (u.ulevel < 3) ? 4 : (u.ulevel < 5) ? 2 : 1, cnttmp, cntdiv);
111 }
112#endif
113 if (!cnt)
114 cnt++;
115#if defined(__GNUC__) && (defined(HPUX) || defined(DGUX))
116 if (cnt < 0)
117 cnt = 1;
118 if (cnt > 10)
119 cnt = 10;
120#endif
121
122 mm.x = x;
123 mm.y = y;
124 while (cnt--) {
125 if (peace_minded(mtmp->data))
126 continue;
127 /* Don't create groups of peaceful monsters since they'll get
128 * in our way. If the monster has a percentage chance so some
129 * are peaceful and some are not, the result will just be a
130 * smaller group.
131 */
132 if (enexto_gpflags(&mm, mm.x, mm.y, mtmp->data, mmflags)) {
133 mon = makemon(mtmp->data, mm.x, mm.y, (mmflags | MM_NOGRP));
134 if (mon) {
135 mon->mpeaceful = FALSE;

Callers

nothing calls this directly

Calls 6

rndFunction · 0.85
peace_mindedFunction · 0.85
enexto_gpflagsFunction · 0.85
makemonFunction · 0.85
set_malignFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected