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

Function force_attack

src/uhitm.c:431–443  ·  view source on GitHub ↗

temporarily override 'safepet' (by faking use of 'F' prefix) when possibly unintentionally attacking peaceful monsters and optionally pets */

Source from the content-addressed store, hash-verified

429/* temporarily override 'safepet' (by faking use of 'F' prefix) when possibly
430 unintentionally attacking peaceful monsters and optionally pets */
431boolean
432force_attack(struct monst *mtmp, boolean pets_too)
433{
434 boolean attacked, save_Forcefight;
435
436 save_Forcefight = svc.context.forcefight;
437 /* always set forcefight On for hostiles and peacefuls, maybe for pets */
438 if (pets_too || !mtmp->mtame)
439 svc.context.forcefight = TRUE;
440 attacked = do_attack(mtmp);
441 svc.context.forcefight = save_Forcefight;
442 return attacked;
443}
444
445/* try to attack; return False if monster evaded;
446 u.dx and u.dy must be set */

Callers 1

use_whipFunction · 0.85

Calls 1

do_attackFunction · 0.85

Tested by

no test coverage detected