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

Function sleep_monst

src/mhitm.c:1222–1246  ·  view source on GitHub ↗

`mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */

Source from the content-addressed store, hash-verified

1220
1221/* `mon' is hit by a sleep attack; return 1 if it's affected, 0 otherwise */
1222int
1223sleep_monst(struct monst *mon, int amt, int how)
1224{
1225 /* reveal mimic unless already asleep or paralyzed (won't be 'busy') */
1226 if (how >= 0 && !mon->msleeping && !mon->mfrozen
1227 && mon->data->mlet == S_MIMIC && (M_AP_TYPE(mon) == M_AP_FURNITURE
1228 || M_AP_TYPE(mon) == M_AP_OBJECT))
1229 seemimic(mon);
1230
1231 if (resists_sleep(mon) || defended(mon, AD_SLEE)
1232 || (how >= 0 && resist(mon, (char) how, 0, NOTELL))) {
1233 shieldeff(mon->mx, mon->my);
1234 } else if (mon->mcanmove) {
1235 finish_meating(mon); /* terminate any meal-in-progress */
1236 amt += (int) mon->mfrozen;
1237 if (amt > 0) { /* sleep for N turns */
1238 mon->mcanmove = 0;
1239 mon->mfrozen = min(amt, 127);
1240 } else { /* sleep until awakened */
1241 mon->msleeping = 1;
1242 }
1243 return 1;
1244 }
1245 return 0;
1246}
1247
1248/* sleeping grabber releases, engulfer doesn't; don't use for paralysis! */
1249void

Callers 7

potionhitFunction · 0.85
mhitm_ad_sleeFunction · 0.85
put_monsters_to_sleepFunction · 0.85
trapeffect_slp_gas_trapFunction · 0.85
steedintrapFunction · 0.85
bhitmFunction · 0.85
zhitmFunction · 0.85

Calls 5

seemimicFunction · 0.85
defendedFunction · 0.85
resistFunction · 0.85
shieldeffFunction · 0.85
finish_meatingFunction · 0.85

Tested by

no test coverage detected