E void FDECL(maybe_mnexto, (struct monst *));
E boolean FDECL(mnearto, (struct monst *, XCHAR_P, XCHAR_P, BOOLEAN_P));
E void FDECL(m_respond, (struct monst *));
-E void FDECL(setmangry, (struct monst *));
-E void FDECL(wakeup, (struct monst *));
+E void FDECL(setmangry, (struct monst *, boolean));
+E void FDECL(wakeup, (struct monst *, boolean));
E void NDECL(wake_nearby);
E void FDECL(wake_nearto, (int, int, int));
E void FDECL(seemimic, (struct monst *));
pline1(msg_slipsfree);
}
if (mtmp)
- wakeup(mtmp);
+ wakeup(mtmp, TRUE);
} else
pline1(msg_snap);
} else {
pline1(msg_slipsfree);
}
- wakeup(mtmp);
+ wakeup(mtmp, TRUE);
} else {
if (mtmp->m_ap_type && !Protection_from_shape_changers
&& !sensemon(mtmp))
}
mtmp->mburied = TRUE;
- wakeup(mtmp); /* at least give it a chance :-) */
+ wakeup(mtmp, FALSE); /* at least give it a chance :-) */
newsym(mtmp->mx, mtmp->my);
}
int i, j;
/* anger target even if wild miss will occur */
- setmangry(mon);
+ setmangry(mon, TRUE);
if (Levitation && !rn2(3) && verysmall(mon->data)
&& !is_flyer(mon->data)) {
if (!likes_gold(mtmp->data) && !mtmp->isshk && !mtmp->ispriest
&& !mtmp->isgd && !is_mercenary(mtmp->data)) {
- wakeup(mtmp);
+ wakeup(mtmp, TRUE);
} else if (!mtmp->mcanmove) {
/* too light to do real damage */
if (canseemon(mtmp)) {
mtmp->msleeping = 0;
finish_meating(mtmp);
if (!mtmp->isgd && !rn2(4)) /* not always pleasing */
- setmangry(mtmp);
+ setmangry(mtmp, TRUE);
/* greedy monsters catch gold */
if (cansee(mtmp->mx, mtmp->my))
pline("%s catches the gold.", Monnam(mtmp));
if ((mon = m_at(x, y)) != 0) {
You("bump into %s.", a_monnam(mon));
- wakeup(mon);
+ wakeup(mon, FALSE);
+ setmangry(mon, FALSE);
wake_nearto(x,y, 10);
return FALSE;
}
else
miss(missile, mon);
if (maybe_wakeup && !rn2(3))
- wakeup(mon);
+ wakeup(mon, TRUE);
return;
}
at leader... (kicked artifact is ok too; HMON_APPLIED could
occur if quest artifact polearm or grapnel ever gets added) */
if (hmode != HMON_APPLIED && quest_arti_hits_leader(obj, mon)) {
- /* not wakeup(), which angers non-tame monsters */
+ /* AIS: changes to wakeup() means that it's now less inappropriate here
+ than it used to be, but the manual version works just as well */
mon->msleeping = 0;
mon->mstrategy &= ~STRAT_WAITMASK;
} else {
tmiss(obj, mon, TRUE);
if (hmode == HMON_APPLIED)
- wakeup(mon);
+ wakeup(mon, TRUE);
}
} else if (otyp == HEAVY_IRON_BALL) {
}
} else if (guaranteed_hit) {
/* this assumes that guaranteed_hit is due to swallowing */
- wakeup(mon);
+ wakeup(mon, TRUE);
if (obj->otyp == CORPSE && touch_petrifies(&mons[obj->corpsenm])) {
if (is_animal(u.ustuck->data)) {
minstapetrify(u.ustuck, TRUE);
monkilled(mtmp, "", (int) adtyp);
} else if (!context.mon_moving) {
/* all affected monsters, even if mdef is set */
- setmangry(mtmp);
+ setmangry(mtmp, TRUE);
}
}
}
}
+/* 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. */
void
-setmangry(mtmp)
+setmangry(mtmp, via_attack)
struct monst *mtmp;
+boolean via_attack;
{
+ (void) via_attack; /* AIS: not used yet */
+ /* AIS: Should this be in both places, or just in wakeup()? */
mtmp->mstrategy &= ~STRAT_WAITMASK;
if (!mtmp->mpeaceful)
return;
}
-/* wake up a monster, usually making it angry in the process */
+/* wake up a monster, possibly making it angry in the process */
void
-wakeup(mtmp)
+wakeup(mtmp, via_attack)
register struct monst *mtmp;
+boolean via_attack;
{
mtmp->msleeping = 0;
finish_meating(mtmp);
- setmangry(mtmp);
+ if (via_attack)
+ setmangry(mtmp, TRUE);
if (mtmp->m_ap_type) {
seemimic(mtmp);
} else if (context.forcefight && !context.mon_moving
for (x = start_x; x <= end_x; x++)
for (y = start_y; y <= end_y; y++) {
if ((mtmp = m_at(x, y)) != 0) {
- wakeup(mtmp); /* peaceful monster will become hostile */
+ wakeup(mtmp, TRUE); /* peaceful monster will become hostile */
if (mtmp->mundetected && is_hider(mtmp->data)) {
mtmp->mundetected = 0;
if (cansee(x, y))
mon_nam(mtmp));
if (yn(qbuf) != 'y')
continue;
- setmangry(mtmp);
}
+ setmangry(mtmp, TRUE);
if (!mtmp->mcanmove || mtmp->mstun || mtmp->msleeping
|| !mtmp->mcansee || !haseyes(mtmp->data)) {
looked--;
/* target might have been killed */
if (mon->mhp > 0) {
if (angermon)
- wakeup(mon);
+ wakeup(mon, TRUE);
else
mon->msleeping = 0;
}
if ((priest = findpriest(temple_occupied(u.urooms))) != 0) {
struct epri *eprip = EPRI(priest);
- wakeup(priest);
+ wakeup(priest, FALSE);
+ setmangry(priest, FALSE);
/*
* If the altar has been destroyed or converted, let the
* priest run loose.
unsigned was_peaceful = mtmp->mpeaceful;
if (sobj->cursed) {
- setmangry(mtmp);
+ setmangry(mtmp, FALSE);
if (was_peaceful && !mtmp->mpeaceful)
return -1;
} else {
if (cansee(mtmp->mx, mtmp->my))
pline("%s coughs!", Monnam(mtmp));
if (heros_fault(reg))
- setmangry(mtmp);
+ setmangry(mtmp, TRUE);
if (haseyes(mtmp->data) && mtmp->mcansee) {
mtmp->mblinded = 1;
mtmp->mcansee = 0;
Recognizing who made the trap isn't completely
unreasonable; everybody has their own style. */
if (trap->madeby_u && rnl(5))
- setmangry(mtmp);
+ setmangry(mtmp, TRUE);
in_sight = canseemon(mtmp);
see_it = cansee(mtmp->mx, mtmp->my);
or if you sense the monster who becomes trapped */
*noticed = cansee(t->tx, t->ty) || canspotmon(mon);
/* monster will be angered; mintrap doesn't handle that */
- wakeup(mon);
+ wakeup(mon, TRUE);
++force_mintrap;
result = (mintrap(mon) != 0);
--force_mintrap;
if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK))
u.ustuck = mtmp;
}
- wakeup(mtmp); /* always necessary; also un-mimics mimics */
+ wakeup(mtmp, TRUE); /* always necessary; also un-mimics mimics */
return TRUE;
}
*/
if ((mtmp->mundetected || mtmp->m_ap_type) && sensemon(mtmp)) {
mtmp->mundetected = 0;
- wakeup(mtmp);
+ wakeup(mtmp, TRUE);
}
if (flags.confirm && mtmp->mpeaceful && !Confusion && !Hallucination
unconventional[0] = '\0';
saved_oname[0] = '\0';
- wakeup(mon);
+ wakeup(mon, TRUE);
if (!obj) { /* attack with bare hands */
if (mdat == &mons[PM_SHADE])
tmp = 0;
pline("%s %s over %s!", what,
vtense(what, "splash"), whom);
}
- setmangry(mon);
+ setmangry(mon, TRUE);
mon->mcansee = 0;
tmp = rn1(25, 21);
if (((int) mon->mblinded + tmp) > 127)
mon->mblinded += tmp;
} else {
pline(obj->otyp == CREAM_PIE ? "Splat!" : "Splash!");
- setmangry(mon);
+ setmangry(mon, TRUE);
}
if (thrown)
obfree(obj, (struct obj *) 0);
else
You("miss it.");
if (!mdef->msleeping && mdef->mcanmove)
- wakeup(mdef);
+ wakeup(mdef, TRUE);
}
/* attack monster as a monster. */
sum[i] = damageum(mon, mattk);
break;
}
- wakeup(mon);
+ wakeup(mon, TRUE);
/* maybe this check should be in damageum()? */
if (mon->data == &mons[PM_SHADE]
&& !(mattk->aatyp == AT_KICK && uarmf
* already grabbed in a previous attack
*/
dhit = 1;
- wakeup(mon);
+ wakeup(mon, TRUE);
if (mon->data == &mons[PM_SHADE])
Your("hug passes harmlessly through %s.", mon_nam(mon));
else if (!sticks(mon->data) && !u.uswallow) {
case AT_EXPL: /* automatic hit if next to */
dhit = -1;
- wakeup(mon);
+ wakeup(mon, TRUE);
sum[i] = explum(mon, mattk);
break;
tmp = find_roll_to_hit(mon, mattk->aatyp, (struct obj *) 0,
&attknum, &armorpenalty);
if ((dhit = (tmp > rnd(20 + i)))) {
- wakeup(mon);
+ wakeup(mon, TRUE);
if (mon->data == &mons[PM_SHADE])
Your("attempt to surround %s is harmless.", mon_nam(mon));
else {
if (what)
pline(fmt, what);
- wakeup(mtmp); /* clears mimicking */
+ wakeup(mtmp, FALSE); /* clears mimicking */
/* if hero is blind, wakeup() won't display the monster even though
it's no longer concealed */
if (!canspotmon(mtmp)
}
if (mtmp->mhp > 0) {
if (!context.mon_moving)
- setmangry(mtmp);
+ setmangry(mtmp, TRUE);
if (tmp < 9 && !mtmp->isshk && rn2(4))
monflee(mtmp, rn2(4) ? rnd(100) : 0, FALSE, TRUE);
mtmp->mcansee = 0;
}
mongone(guard);
} else {
- setmangry(guard);
+ setmangry(guard, FALSE);
if (Deaf) {
if (!Blind)
pline("%s mouths something and looks very angry!",
}
if (wake) {
if (mtmp->mhp > 0) {
- wakeup(mtmp);
+ wakeup(mtmp, TRUE);
m_respond(mtmp);
if (mtmp->isshk && !*u.ushops)
hot_pursuit(mtmp);
You("%s of smoke.", !Blind ? "see a puff" : "smell a whiff");
}
if ((mon = m_at(x, y)) != 0) {
- /* Cannot use wakeup() which also angers the monster */
- mon->msleeping = 0;
- if (mon->m_ap_type)
- seemimic(mon);
+ wakeup(mon, FALSE);
if (type >= 0) {
- setmangry(mon);
+ setmangry(mon, TRUE);
if (mon->ispriest && *in_rooms(mon->mx, mon->my, TEMPLE))
ghod_hitsu(mon);
if (mon->isshk && !*u.ushops)