Unify ad_ston

This commit is contained in:
Pasi Kallinen
2020-12-01 10:44:15 +02:00
parent 20b6ea602b
commit a6a676f720
4 changed files with 53 additions and 22 deletions

View File

@@ -2786,6 +2786,7 @@ E void FDECL(mhitm_ad_pest, (struct monst *, struct attack *, struct monst *, st
E void FDECL(mhitm_ad_deth, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_halu, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_phys, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_ston, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E boolean FDECL(do_stone_u, (struct monst *));
E void FDECL(do_stone_mon, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E int FDECL(damageum, (struct monst *, struct attack *, int));

View File

@@ -1007,9 +1007,7 @@ int dieroll;
return mhm.hitflags;
break;
case AD_STON:
if (magr->mcan)
break;
do_stone_mon(magr, mattk, mdef, &mhm);
mhitm_ad_ston(magr, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;

View File

@@ -1113,22 +1113,10 @@ register struct attack *mattk;
}
break;
}
case AD_STON: /* cockatrice */
hitmsg(mtmp, mattk);
if (!rn2(3)) {
if (mtmp->mcan) {
if (!Deaf)
You_hear("a cough from %s!", mon_nam(mtmp));
} else {
if (!Deaf)
You_hear("%s hissing!", s_suffix(mon_nam(mtmp)));
if (!rn2(10)
|| (flags.moonphase == NEW_MOON && !have_lizard())) {
if (do_stone_u(mtmp))
return MM_HIT;
}
}
}
case AD_STON:
mhitm_ad_ston(mtmp, mattk, &g.youmonst, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_STCK:
mhitm_ad_stck(mtmp, mattk, &g.youmonst, &mhm);

View File

@@ -3600,6 +3600,50 @@ struct mhitm_data *mhm;
}
}
void
mhitm_ad_ston(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 */
if (!munstone(mdef, TRUE))
minstapetrify(mdef, TRUE);
mhm->damage = 0;
} else if (mdef == &g.youmonst) {
/* mhitu */
hitmsg(magr, mattk);
if (!rn2(3)) {
if (magr->mcan) {
if (!Deaf)
You_hear("a cough from %s!", mon_nam(magr));
} else {
if (!Deaf)
You_hear("%s hissing!", s_suffix(mon_nam(magr)));
if (!rn2(10)
|| (flags.moonphase == NEW_MOON && !have_lizard())) {
if (do_stone_u(magr)) {
mhm->hitflags = MM_HIT;
mhm->done = TRUE;
return;
}
}
}
}
} else {
/* mhitm */
if (magr->mcan)
return;
do_stone_mon(magr, mattk, mdef, mhm);
if (mhm->done)
return;
}
}
/* Template for monster hits monster for AD_FOO.
- replace "break" with return
- replace "return" with mhm->done = TRUE
@@ -3704,9 +3748,9 @@ int specialdmg; /* blessed and/or silver bonus against various things */
return mhm.hitflags;
break;
case AD_STON:
if (!munstone(mdef, TRUE))
minstapetrify(mdef, TRUE);
mhm.damage = 0;
mhitm_ad_ston(&g.youmonst, mattk, mdef, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_SSEX:
case AD_SEDU: