E void FDECL(mhitm_ad_stck, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_wrap, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_plys, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
+E void FDECL(mhitm_ad_slee, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E int FDECL(damageum, (struct monst *, struct attack *, int));
E void FDECL(missum, (struct monst *, struct attack *, BOOLEAN_P));
E int FDECL(passive, (struct monst *, struct obj *, BOOLEAN_P, int,
return mhm.hitflags;
break;
case AD_SLEE:
- if (!cancelled && !mdef->msleeping
- && sleep_monst(mdef, rnd(10), -1)) {
- if (g.vis && canspotmon(mdef)) {
- Strcpy(buf, Monnam(mdef));
- pline("%s is put to sleep by %s.", buf, mon_nam(magr));
- }
- mdef->mstrategy &= ~STRAT_WAITFORU;
- slept_monst(mdef);
- }
+ mhitm_ad_slee(magr, mattk, mdef, &mhm);
+ if (mhm.done)
+ return mhm.hitflags;
break;
case AD_PLYS:
mhitm_ad_plys(magr, mattk, mdef, &mhm);
return mhm.hitflags;
break;
case AD_SLEE:
- hitmsg(mtmp, mattk);
- if (uncancelled && g.multi >= 0 && !rn2(5)) {
- if (Sleep_resistance)
- break;
- fall_asleep(-rnd(10), TRUE);
- if (Blind)
- You("are put to sleep!");
- else
- You("are put to sleep by %s!", mon_nam(mtmp));
- }
+ mhitm_ad_slee(mtmp, mattk, &g.youmonst, &mhm);
+ if (mhm.done)
+ return mhm.hitflags;
break;
case AD_BLND:
mhitm_ad_blnd(mtmp, mattk, &g.youmonst, &mhm);
}
}
+void
+mhitm_ad_slee(magr, mattk, mdef, mhm)
+struct monst *magr;
+struct attack *mattk;
+struct monst *mdef;
+struct mhitm_data *mhm;
+{
+ struct permonst *pd = mdef->data;
+
+ if (magr == &g.youmonst) {
+ /* uhitm */
+ int armpro = magic_negation(mdef);
+ /* since hero can't be cancelled, only defender's armor applies */
+ boolean negated = !(rn2(10) >= 3 * armpro);
+
+ if (!negated && !mdef->msleeping && sleep_monst(mdef, rnd(10), -1)) {
+ if (!Blind)
+ pline("%s is put to sleep by you!", Monnam(mdef));
+ slept_monst(mdef);
+ }
+ } else if (mdef == &g.youmonst) {
+ /* mhitu */
+ int armpro = magic_negation(mdef);
+ boolean uncancelled = !magr->mcan && (rn2(10) >= 3 * armpro);
+
+ hitmsg(magr, mattk);
+ if (uncancelled && g.multi >= 0 && !rn2(5)) {
+ if (Sleep_resistance)
+ return;
+ fall_asleep(-rnd(10), TRUE);
+ if (Blind)
+ You("are put to sleep!");
+ else
+ You("are put to sleep by %s!", mon_nam(magr));
+ }
+ } else {
+ /* mhitm */
+ int armpro = magic_negation(mdef);
+ boolean cancelled = magr->mcan || !(rn2(10) >= 3 * armpro);
+
+ if (!cancelled && !mdef->msleeping
+ && sleep_monst(mdef, rnd(10), -1)) {
+ if (g.vis && canspotmon(mdef)) {
+ char buf[BUFSZ];
+ Strcpy(buf, Monnam(mdef));
+ pline("%s is put to sleep by %s.", buf, mon_nam(magr));
+ }
+ mdef->mstrategy &= ~STRAT_WAITFORU;
+ slept_monst(mdef);
+ }
+ }
+}
+
/* Template for monster hits monster for AD_FOO.
return mhm.hitflags;
break;
case AD_SLEE:
- if (!negated && !mdef->msleeping && sleep_monst(mdef, rnd(10), -1)) {
- if (!Blind)
- pline("%s is put to sleep by you!", Monnam(mdef));
- slept_monst(mdef);
- }
+ mhitm_ad_slee(&g.youmonst, mattk, mdef, &mhm);
+ if (mhm.done)
+ return mhm.hitflags;
break;
case AD_SLIM:
if (negated)