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

Function make_familiar

src/dog.c:137–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137struct monst *
138make_familiar(struct obj *otmp, coordxy x, coordxy y, boolean quietly)
139{
140 struct permonst *pm;
141 struct monst *mtmp = 0;
142 int chance, trycnt = 100;
143 boolean reallytame = TRUE;
144
145 do {
146 mmflags_nht mmflags;
147 int cgend;
148
149 if (!(pm = pick_familiar_pm(otmp, quietly)))
150 break;
151
152 mmflags = MM_EDOG | MM_IGNOREWATER | NO_MINVENT | MM_NOMSG;
153 cgend = otmp ? (otmp->spe & CORPSTAT_GENDER) : 0;
154 mmflags |= ((cgend == CORPSTAT_FEMALE) ? MM_FEMALE
155 : (cgend == CORPSTAT_MALE) ? MM_MALE : 0L);
156
157 mtmp = makemon(pm, x, y, mmflags);
158 if (otmp) { /* figurine */
159 if (!mtmp) {
160 /* monster has been genocided or target spot is occupied */
161 if (!quietly)
162 pline_The(
163 "figurine writhes and then shatters into pieces!");
164 break;
165 } else if (mtmp->isminion) {
166 /* Fixup for figurine of an Angel: makemon() is willing to
167 create a random Angel as either an ordinary monster or as
168 a minion of random allegiance. We don't want the latter
169 here in case it successfully becomes a pet. */
170 mtmp->isminion = 0;
171 free_emin(mtmp);
172 /* [This could and possibly should be redone as a new
173 MM_flag passed to makemon() to suppress making a minion
174 so that no post-creation fixup would be needed.] */
175 }
176 }
177 } while (!mtmp && --trycnt > 0);
178
179 if (!mtmp)
180 return (struct monst *) 0;
181
182 if (is_pool(mtmp->mx, mtmp->my) && minliquid(mtmp))
183 return (struct monst *) 0;
184
185 if (otmp) { /* figurine; resulting monster might not become a pet */
186 chance = rn2(10); /* 0==tame, 1==peaceful, 2==hostile */
187 if (chance > 2)
188 chance = otmp->blessed ? 0 : !otmp->cursed ? 1 : 2;
189 /* 0,1,2: b=80%,10,10; nc=10%,80,10; c=10%,10,80 */
190 if (chance > 0) {
191 reallytame = FALSE; /* not tame after all */
192 if (chance == 2) { /* hostile (cursed figurine) */
193 if (!quietly)
194 You("get a bad feeling about this.");

Callers 3

spelleffectsFunction · 0.85
fig_transformFunction · 0.85
use_figurineFunction · 0.85

Calls 14

pick_familiar_pmFunction · 0.85
makemonFunction · 0.85
pline_TheFunction · 0.85
is_poolFunction · 0.85
minliquidFunction · 0.85
rn2Function · 0.85
YouFunction · 0.85
set_malignFunction · 0.85
christen_monstFunction · 0.85
initedogFunction · 0.85
newsymFunction · 0.85
attacktypeFunction · 0.85

Tested by

no test coverage detected