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

Function maybe_gasp

src/sounds.c:545–610  ·  view source on GitHub ↗

hero has attacked a peaceful monster within 'mon's view */

Source from the content-addressed store, hash-verified

543
544/* hero has attacked a peaceful monster within 'mon's view */
545const char *
546maybe_gasp(struct monst *mon)
547{
548 static const char *const Exclam[] = {
549 "Gasp!", "Uh-oh.", "Oh my!", "What?", "Why?",
550 };
551 struct permonst *mptr = mon->data;
552 int msound = mptr->msound;
553 boolean dogasp = FALSE;
554
555 /* other roles' guardians and cross-aligned priests don't gasp */
556 if ((msound == MS_GUARDIAN && mptr != &mons[gu.urole.guardnum])
557 || (msound == MS_PRIEST && !p_coaligned(mon)))
558 msound = MS_SILENT;
559 /* co-aligned angels do gasp */
560 else if (msound == MS_CUSS && has_emin(mon)
561 && (p_coaligned(mon) ? !EMIN(mon)->renegade : EMIN(mon)->renegade))
562 msound = MS_HUMANOID;
563
564 /*
565 * Only called for humanoids so animal noise handling is ignored.
566 */
567 switch (msound) {
568 case MS_HUMANOID:
569 case MS_ARREST: /* Kops */
570 case MS_SOLDIER: /* solider, watchman */
571 case MS_GUARD: /* vault guard */
572 case MS_NURSE:
573 case MS_SEDUCE: /* nymph, succubus/incubus */
574 case MS_LEADER: /* quest leader */
575 case MS_GUARDIAN: /* leader's guards */
576 case MS_SELL: /* shopkeeper */
577 case MS_ORACLE:
578 case MS_PRIEST: /* temple priest, roaming aligned priest (not mplayer) */
579 case MS_BOAST: /* giants */
580 case MS_IMITATE: /* doppelganger, leocrotta, Aleax */
581 dogasp = TRUE;
582 break;
583 /* issue comprehensible word(s) if hero is similar type of creature */
584 case MS_ORC: /* used to be synonym for MS_GRUNT */
585 case MS_GRUNT: /* ogres, trolls, gargoyles, one or two others */
586 case MS_LAUGH: /* leprechaun, gremlin */
587 case MS_ROAR: /* dragon, xorn, owlbear */
588 case MS_BELLOW: /* crocodile */
589 /* capable of speech but only do so if hero is similar type */
590 case MS_DJINNI:
591 case MS_VAMPIRE: /* vampire in its own form */
592 case MS_WERE: /* lycanthrope in human form */
593 case MS_SPELL: /* titan, barrow wight, Nazgul, nalfeshnee */
594 dogasp = (mptr->mlet == gy.youmonst.data->mlet);
595 break;
596 /* capable of speech but don't care if you attack peacefuls */
597 case MS_BRIBE:
598 case MS_CUSS:
599 case MS_RIDER:
600 case MS_NEMESIS:
601 /* can't speak */
602 case MS_SILENT:

Callers 1

peacefuls_respondFunction · 0.85

Calls 1

p_coalignedFunction · 0.85

Tested by

no test coverage detected