E void FDECL(mhitm_ad_cold, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_elec, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_acid, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
+E void FDECL(mhitm_ad_sgld, (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,
}
break;
case AD_SGLD:
- mhm.damage = 0;
- if (magr->mcan)
- break;
- /* technically incorrect; no check for stealing gold from
- * between mdef's feet...
- */
- {
- struct obj *gold = findgold(mdef->minvent);
-
- if (!gold)
- break;
- obj_extract_self(gold);
- add_to_minv(magr, gold);
- }
- mdef->mstrategy &= ~STRAT_WAITFORU;
- if (g.vis && canseemon(mdef)) {
- Strcpy(buf, Monnam(magr));
- pline("%s steals some gold from %s.", buf, mon_nam(mdef));
- }
- if (!tele_restrict(magr)) {
- boolean couldspot = canspotmon(magr);
-
- (void) rloc(magr, TRUE);
- if (g.vis && couldspot && !canspotmon(magr))
- pline("%s suddenly disappears!", buf);
- }
+ mhitm_ad_sgld(magr, mattk, mdef, &mhm);
+ if (mhm.done)
+ return mhm.hitflags;
break;
case AD_DRLI: /* drain life */
mhitm_ad_drli(magr, mattk, mdef, &mhm);
}
}
+void
+mhitm_ad_sgld(magr, mattk, mdef, mhm)
+struct monst *magr;
+struct attack *mattk;
+struct monst *mdef;
+struct mhitm_data *mhm;
+{
+ struct permonst *pa = magr->data;
+ struct permonst *pd = mdef->data;
+
+ if (magr == &g.youmonst) {
+ /* uhitm */
+ struct obj *mongold = findgold(mdef->minvent);
+
+ if (mongold) {
+ obj_extract_self(mongold);
+ if (merge_choice(g.invent, mongold) || inv_cnt(FALSE) < 52) {
+ addinv(mongold);
+ Your("purse feels heavier.");
+ } else {
+ You("grab %s's gold, but find no room in your knapsack.",
+ mon_nam(mdef));
+ dropy(mongold);
+ }
+ }
+ exercise(A_DEX, TRUE);
+ mhm->damage = 0;
+ } else if (mdef == &g.youmonst) {
+ /* mhitu */
+ hitmsg(magr, mattk);
+ if (pd->mlet == pa->mlet)
+ return;
+ if (!magr->mcan)
+ stealgold(magr);
+ } else {
+ /* mhitm */
+ char buf[BUFSZ];
+
+ mhm->damage = 0;
+ if (magr->mcan)
+ return;
+ /* technically incorrect; no check for stealing gold from
+ * between mdef's feet...
+ */
+ {
+ struct obj *gold = findgold(mdef->minvent);
+
+ if (!gold)
+ return;
+ obj_extract_self(gold);
+ add_to_minv(magr, gold);
+ }
+ mdef->mstrategy &= ~STRAT_WAITFORU;
+ if (g.vis && canseemon(mdef)) {
+ Strcpy(buf, Monnam(magr));
+ pline("%s steals some gold from %s.", buf, mon_nam(mdef));
+ }
+ if (!tele_restrict(magr)) {
+ boolean couldspot = canspotmon(magr);
+
+ (void) rloc(magr, TRUE);
+ if (g.vis && couldspot && !canspotmon(magr))
+ pline("%s suddenly disappears!", buf);
+ }
+ }
+}
+
+
/* Template for monster hits monster for AD_FOO.
- replace "break" with return
register struct permonst *pd = mdef->data;
int armpro;
boolean negated;
- struct obj *mongold;
struct mhitm_data mhm;
mhm.damage = d((int) mattk->damn, (int) mattk->damd);
mhm.hitflags = MM_MISS;
mhm.damage = 0;
break;
case AD_SGLD:
- /* This you as a leprechaun, so steal
- real gold only, no lesser coins */
- mongold = findgold(mdef->minvent);
- if (mongold) {
- obj_extract_self(mongold);
- if (merge_choice(g.invent, mongold) || inv_cnt(FALSE) < 52) {
- addinv(mongold);
- Your("purse feels heavier.");
- } else {
- You("grab %s's gold, but find no room in your knapsack.",
- mon_nam(mdef));
- dropy(mongold);
- }
- }
- exercise(A_DEX, TRUE);
- mhm.damage = 0;
+ mhitm_ad_sgld(&g.youmonst, mattk, mdef, &mhm);
+ if (mhm.done)
+ return mhm.hitflags;
break;
case AD_TLPT:
if (mhm.damage <= 0)