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

Function could_pole_mon

src/apply.c:3390–3412  ·  view source on GitHub ↗

return TRUE if hero is wielding a polearm and there's at least one monster they could hit with it */

Source from the content-addressed store, hash-verified

3388/* return TRUE if hero is wielding a polearm and there's
3389 at least one monster they could hit with it */
3390boolean
3391could_pole_mon(void)
3392{
3393 int min_range, max_range;
3394 coord cc;
3395 struct monst *hitm = svc.context.polearm.hitmon;
3396
3397 if (!uwep || !is_pole(uwep))
3398 return FALSE;
3399
3400 calc_pole_range(&min_range, &max_range);
3401
3402 cc.x = u.ux;
3403 cc.y = u.uy;
3404 if (!find_poleable_mon(&cc)) {
3405 if (hitm && !DEADMONSTER(hitm) && sensemon(hitm)
3406 && mdistu(hitm) <= max_range && mdistu(hitm) >= min_range)
3407 return TRUE;
3408 } else {
3409 return TRUE;
3410 }
3411 return FALSE;
3412}
3413
3414/* was Snickersnee used to attack at distance this turn already? */
3415staticfn boolean

Callers 1

dofireFunction · 0.85

Calls 3

calc_pole_rangeFunction · 0.85
find_poleable_monFunction · 0.85
sensemonFunction · 0.85

Tested by

no test coverage detected