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

Function setmangry

src/mon.c:4264–4318  ·  view source on GitHub ↗

Called whenever the player attacks mtmp; also called in other situations where mtmp gets annoyed at the player. Handles mtmp getting annoyed at the attack and any ramifications that might have. Useful also in situations where mtmp was already hostile; it checks for situations where the player shouldn't be attacking and any ramifications /that/ might have. */

Source from the content-addressed store, hash-verified

4262 where mtmp was already hostile; it checks for situations where the player
4263 shouldn't be attacking and any ramifications /that/ might have. */
4264void
4265setmangry(struct monst *mtmp, boolean via_attack)
4266{
4267 if (via_attack && sengr_at("Elbereth", u.ux, u.uy, TRUE)
4268 /* only hypocritical if monster is vulnerable to Elbereth (or
4269 peaceful--not vulnerable but attacking it is hypocritical) */
4270 && (onscary(u.ux, u.uy, mtmp) || mtmp->mpeaceful)) {
4271 You_feel("like a hypocrite.");
4272 /* AIS: Yes, I know alignment penalties and bonuses aren't balanced
4273 at the moment. This is about correct relative to other "small"
4274 penalties; it should be fairly large, as attacking while standing
4275 on an Elbereth means that you're requesting peace and then
4276 violating your own request. I know 5 isn't actually large, but
4277 it's intentionally larger than the 1s and 2s that are normally
4278 given for this sort of thing. */
4279 /* reduce to 3 (average) when alignment is already very low */
4280 adjalign((u.ualign.record > 5) ? -5 : -rnd(5));
4281
4282 if (!Blind)
4283 pline("The engraving beneath you fades.");
4284 del_engr_at(u.ux, u.uy);
4285 }
4286
4287 /* AIS: Should this be in both places, or just in wakeup()? */
4288 mtmp->mstrategy &= ~STRAT_WAITMASK;
4289 if (!mtmp->mpeaceful)
4290 return;
4291 /* [FIXME: this logic seems wrong; peaceful humanoids gasp or exclaim
4292 when they see you attack a peaceful monster but they just casually
4293 look the other way when you attack a pet?] */
4294 if (mtmp->mtame)
4295 return;
4296 mtmp->mpeaceful = 0;
4297 if (mtmp->ispriest) {
4298 if (p_coaligned(mtmp))
4299 adjalign(-5); /* very bad */
4300 else
4301 adjalign(2);
4302 } else
4303 adjalign(-1); /* attacking peaceful monsters is bad */
4304 if (humanoid(mtmp->data) || mtmp->isshk || mtmp->isgd) {
4305 if (couldsee(mtmp->mx, mtmp->my))
4306 pline_mon(mtmp, "%s gets angry!", Monnam(mtmp));
4307 } else {
4308 growl(mtmp);
4309 }
4310
4311 /* attacking your own quest leader will anger his or her guardians */
4312 if (mtmp->data == &mons[quest_info(MS_LEADER)])
4313 qst_guardians_respond();
4314
4315 /* make other peaceful monsters react */
4316 if (!svc.context.mon_moving)
4317 peacefuls_respond(mtmp);
4318}
4319
4320/* Indicate via message that a monster has awoken. */
4321void

Callers 15

quest_chatFunction · 0.85
hmon_hitmon_misc_objFunction · 0.85
flash_hits_monFunction · 0.85
inside_gas_cloudFunction · 0.85
hurtle_stepFunction · 0.85
dogazeFunction · 0.85
invaultFunction · 0.85
anger_quest_guardiansFunction · 0.85
wakeupFunction · 0.85
mintrapFunction · 0.85
kick_monsterFunction · 0.85
ghitmFunction · 0.85

Calls 14

sengr_atFunction · 0.85
onscaryFunction · 0.85
You_feelFunction · 0.85
adjalignFunction · 0.85
rndFunction · 0.85
del_engr_atFunction · 0.85
p_coalignedFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
growlFunction · 0.85
quest_infoFunction · 0.85
qst_guardians_respondFunction · 0.85

Tested by

no test coverage detected