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

Function target_on

src/wizard.c:235–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235staticfn unsigned long
236target_on(int mask, struct monst *mtmp)
237{
238 short otyp;
239 struct obj *otmp;
240 struct monst *mtmp2;
241
242 if (!M_Wants(mask))
243 return (unsigned long) STRAT_NONE;
244
245 otyp = which_arti(mask);
246 if (!mon_has_arti(mtmp, otyp)) {
247 if (you_have(mask)) {
248 mtmp->mgoal.x = u.ux;
249 mtmp->mgoal.y = u.uy;
250 return (STRAT_PLAYER | mask);
251 } else if ((otmp = on_ground(otyp))) {
252 mtmp->mgoal.x = otmp->ox;
253 mtmp->mgoal.y = otmp->oy;
254 return (STRAT_GROUND | mask);
255 } else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0
256 /* when seeking the Amulet, avoid targeting the Wizard
257 or temple priests (to protect Moloch's high priest) */
258 && (otyp != AMULET_OF_YENDOR
259 || (!mtmp2->iswiz && !inhistemple(mtmp2)))) {
260 mtmp->mgoal.x = mtmp2->mx;
261 mtmp->mgoal.y = mtmp2->my;
262 return (STRAT_MONSTR | mask);
263 }
264 }
265 mtmp->mgoal.x = mtmp->mgoal.y = 0;
266 return (unsigned long) STRAT_NONE;
267}
268
269staticfn unsigned long
270strategy(struct monst *mtmp)

Callers 1

strategyFunction · 0.85

Calls 6

which_artiFunction · 0.85
mon_has_artiFunction · 0.85
you_haveFunction · 0.85
on_groundFunction · 0.85
other_mon_has_artiFunction · 0.85
inhistempleFunction · 0.85

Tested by

no test coverage detected