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

Function peacefuls_respond

src/mon.c:4162–4257  ·  view source on GitHub ↗

how other peacefuls react when you attack monster */

Source from the content-addressed store, hash-verified

4160
4161/* how other peacefuls react when you attack monster */
4162staticfn void
4163peacefuls_respond(struct monst *mtmp)
4164{
4165 struct monst *mon;
4166 int mndx = monsndx(mtmp->data);
4167
4168 for (mon = fmon; mon; mon = mon->nmon) {
4169 if (DEADMONSTER(mon))
4170 continue;
4171 if (mon == mtmp) /* the mpeaceful test catches this since mtmp */
4172 continue; /* is no longer peaceful, but be explicit... */
4173
4174 if (!mindless(mon->data) && mon->mpeaceful
4175 && couldsee(mon->mx, mon->my) && !mon->msleeping
4176 && mon->mcansee && m_canseeu(mon)) {
4177 char buf[BUFSZ];
4178 boolean exclaimed = FALSE, needpunct = FALSE, alreadyfleeing;
4179
4180 buf[0] = '\0';
4181 if (humanoid(mon->data) || mon->isshk || mon->ispriest) {
4182 if (is_watch(mon->data)) {
4183 SetVoice(mon, 0, 80, 0);
4184 verbalize("Halt! You're under arrest!");
4185 (void) angry_guards(!!Deaf);
4186 } else {
4187 if (!Deaf && !rn2(5)) {
4188 const char *gasp = maybe_gasp(mon);
4189
4190 if (gasp) {
4191 if (!strncmpi(gasp, "gasp", 4)) {
4192 Sprintf(buf, "%s gasps", Monnam(mon));
4193 needpunct = TRUE;
4194 } else {
4195 Sprintf(buf, "%s exclaims \"%s\"",
4196 Monnam(mon), gasp);
4197 }
4198 exclaimed = TRUE;
4199 }
4200 }
4201 /* shopkeepers and temple priests might gasp in
4202 surprise, but they won't become angry here;
4203 quest leader will only get angry if hero attacks
4204 own quest guardians */
4205 if (mon->isshk || mon->ispriest
4206 || (mon->data == &mons[quest_info(MS_LEADER)]
4207 && mtmp->data != &mons[gu.urole.guardnum])) {
4208 if (exclaimed)
4209 pline_mon(mon, "%s%s", buf, " then shrugs.");
4210 continue;
4211 }
4212
4213 if (mon->data->mlevel < rn2(10)
4214 /* don't have quest guardians turn to flee */
4215 && (mon->data != &mons[gu.urole.guardnum])) {
4216 alreadyfleeing = (mon->mflee || mon->mfleetim);
4217 monflee(mon, rn2(50) + 25, TRUE, !exclaimed);
4218 if (exclaimed) {
4219 if (flags.verbose && !alreadyfleeing) {

Callers 1

setmangryFunction · 0.85

Calls 13

verbalizeFunction · 0.85
angry_guardsFunction · 0.85
rn2Function · 0.85
maybe_gaspFunction · 0.85
MonnamFunction · 0.85
quest_infoFunction · 0.85
pline_monFunction · 0.85
monfleeFunction · 0.85
adjalignFunction · 0.85
big_little_matchFunction · 0.85
growlFunction · 0.85
strncmpiFunction · 0.70

Tested by

no test coverage detected