Unify ad_deth

This commit is contained in:
Pasi Kallinen
2020-12-04 09:30:19 +02:00
parent 2999233332
commit 36bb52466d
5 changed files with 69 additions and 42 deletions
+1
View File
@@ -2783,6 +2783,7 @@ E void FDECL(mhitm_ad_conf, (struct monst *, struct attack *, struct monst *, st
E void FDECL(mhitm_ad_poly, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_poly, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_famn, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_famn, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_pest, (struct monst *, struct attack *, struct monst *, struct mhitm_data *)); E void FDECL(mhitm_ad_pest, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E void FDECL(mhitm_ad_deth, (struct monst *, struct attack *, struct monst *, struct mhitm_data *));
E int FDECL(damageum, (struct monst *, struct attack *, int)); E int FDECL(damageum, (struct monst *, struct attack *, int));
E void FDECL(missum, (struct monst *, struct attack *, BOOLEAN_P)); E void FDECL(missum, (struct monst *, struct attack *, BOOLEAN_P));
E int FDECL(passive, (struct monst *, struct obj *, BOOLEAN_P, int, E int FDECL(passive, (struct monst *, struct obj *, BOOLEAN_P, int,
+1
View File
@@ -90,6 +90,7 @@ struct mhitm_data {
int damage; int damage;
int hitflags; /* MM_DEF_DIED | MM_AGR_DIED | ... */ int hitflags; /* MM_DEF_DIED | MM_AGR_DIED | ... */
boolean done; boolean done;
boolean permdmg;
}; };
/* /*
+1
View File
@@ -863,6 +863,7 @@ int dieroll;
struct mhitm_data mhm; struct mhitm_data mhm;
mhm.damage = d((int) mattk->damn, (int) mattk->damd); mhm.damage = d((int) mattk->damn, (int) mattk->damd);
mhm.hitflags = MM_MISS; mhm.hitflags = MM_MISS;
mhm.permdmg = 0;
if ((touch_petrifies(pd) /* or flesh_petrifies() */ if ((touch_petrifies(pd) /* or flesh_petrifies() */
|| (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA])) || (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA]))
+12 -42
View File
@@ -967,12 +967,13 @@ register struct attack *mattk;
{ {
struct permonst *mdat = mtmp->data; struct permonst *mdat = mtmp->data;
int uncancelled, ptmp; int uncancelled, ptmp;
int armpro, permdmg, tmphp; int armpro, tmphp;
char buf[BUFSZ]; char buf[BUFSZ];
struct permonst *olduasmon = g.youmonst.data; struct permonst *olduasmon = g.youmonst.data;
int res; int res;
struct mhitm_data mhm; struct mhitm_data mhm;
mhm.hitflags = MM_MISS; mhm.hitflags = MM_MISS;
mhm.permdmg = 0;
if (!canspotmon(mtmp)) if (!canspotmon(mtmp))
map_invisible(mtmp->mx, mtmp->my); map_invisible(mtmp->mx, mtmp->my);
@@ -1012,7 +1013,6 @@ register struct attack *mattk;
armpro = magic_negation(&g.youmonst); armpro = magic_negation(&g.youmonst);
uncancelled = !mtmp->mcan && (rn2(10) >= 3 * armpro); uncancelled = !mtmp->mcan && (rn2(10) >= 3 * armpro);
permdmg = 0;
/* Now, adjust damages via resistances or specific attacks */ /* Now, adjust damages via resistances or specific attacks */
switch (mattk->adtyp) { switch (mattk->adtyp) {
case AD_PHYS: case AD_PHYS:
@@ -1423,39 +1423,9 @@ register struct attack *mattk;
return mhm.hitflags; return mhm.hitflags;
break; break;
case AD_DETH: case AD_DETH:
pline("%s reaches out with its deadly touch.", Monnam(mtmp)); mhitm_ad_deth(mtmp, mattk, &g.youmonst, &mhm);
if (is_undead(g.youmonst.data)) { if (mhm.done)
/* Still does normal damage */ return mhm.hitflags;
pline("Was that the touch of death?");
break;
}
switch (rn2(20)) {
case 19:
case 18:
case 17:
if (!Antimagic) {
g.killer.format = KILLED_BY_AN;
Strcpy(g.killer.name, "touch of death");
done(DIED);
mhm.damage = 0;
break;
}
/*FALLTHRU*/
default: /* case 16: ... case 5: */
You_feel("your life force draining away...");
permdmg = 1; /* actual damage done below */
break;
case 4:
case 3:
case 2:
case 1:
case 0:
if (Antimagic)
shieldeff(u.ux, u.uy);
pline("Lucky for you, it didn't work!");
mhm.damage = 0;
break;
}
break; break;
case AD_PEST: case AD_PEST:
mhitm_ad_pest(mtmp, mattk, &g.youmonst, &mhm); mhitm_ad_pest(mtmp, mattk, &g.youmonst, &mhm);
@@ -1509,7 +1479,7 @@ register struct attack *mattk;
|| is_vampshifter(mtmp)))) || is_vampshifter(mtmp))))
mhm.damage = (mhm.damage + 1) / 2; mhm.damage = (mhm.damage + 1) / 2;
if (permdmg) { /* Death's life force drain */ if (mhm.permdmg) { /* Death's life force drain */
int lowerlimit, *hpmax_p; int lowerlimit, *hpmax_p;
/* /*
* Apply some of the damage to permanent hit points: * Apply some of the damage to permanent hit points:
@@ -1520,13 +1490,13 @@ register struct attack *mattk;
* otherwise 0..50% * otherwise 0..50%
* Never reduces hpmax below 1 hit point per level. * Never reduces hpmax below 1 hit point per level.
*/ */
permdmg = rn2(mhm.damage / 2 + 1); mhm.permdmg = rn2(mhm.damage / 2 + 1);
if (Upolyd || u.uhpmax > 25 * u.ulevel) if (Upolyd || u.uhpmax > 25 * u.ulevel)
permdmg = mhm.damage; mhm.permdmg = mhm.damage;
else if (u.uhpmax > 10 * u.ulevel) else if (u.uhpmax > 10 * u.ulevel)
permdmg += mhm.damage / 2; mhm.permdmg += mhm.damage / 2;
else if (u.uhpmax > 5 * u.ulevel) else if (u.uhpmax > 5 * u.ulevel)
permdmg += mhm.damage / 4; mhm.permdmg += mhm.damage / 4;
if (Upolyd) { if (Upolyd) {
hpmax_p = &u.mhmax; hpmax_p = &u.mhmax;
@@ -1536,8 +1506,8 @@ register struct attack *mattk;
hpmax_p = &u.uhpmax; hpmax_p = &u.uhpmax;
lowerlimit = u.ulevel; lowerlimit = u.ulevel;
} }
if (*hpmax_p - permdmg > lowerlimit) if (*hpmax_p - mhm.permdmg > lowerlimit)
*hpmax_p -= permdmg; *hpmax_p -= mhm.permdmg;
else if (*hpmax_p > lowerlimit) else if (*hpmax_p > lowerlimit)
*hpmax_p = lowerlimit; *hpmax_p = lowerlimit;
/* else unlikely... /* else unlikely...
+54
View File
@@ -3264,6 +3264,59 @@ struct mhitm_data *mhm;
} }
} }
void
mhitm_ad_deth(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 */
mhm->damage = 0;
} else if (mdef == &g.youmonst) {
/* mhitu */
pline("%s reaches out with its deadly touch.", Monnam(magr));
if (is_undead(pd)) {
/* Still does normal damage */
pline("Was that the touch of death?");
return;
}
switch (rn2(20)) {
case 19:
case 18:
case 17:
if (!Antimagic) {
g.killer.format = KILLED_BY_AN;
Strcpy(g.killer.name, "touch of death");
done(DIED);
mhm->damage = 0;
return;
}
/*FALLTHRU*/
default: /* case 16: ... case 5: */
You_feel("your life force draining away...");
mhm->permdmg = 1; /* actual damage done below */
return;
case 4:
case 3:
case 2:
case 1:
case 0:
if (Antimagic)
shieldeff(u.ux, u.uy);
pline("Lucky for you, it didn't work!");
mhm->damage = 0;
return;
}
} else {
/* mhitm */
mhm->damage = 0;
}
}
/* Template for monster hits monster for AD_FOO. /* Template for monster hits monster for AD_FOO.
- replace "break" with return - replace "break" with return
@@ -3312,6 +3365,7 @@ int specialdmg; /* blessed and/or silver bonus against various things */
struct mhitm_data mhm; struct mhitm_data mhm;
mhm.damage = d((int) mattk->damn, (int) mattk->damd); mhm.damage = d((int) mattk->damn, (int) mattk->damd);
mhm.hitflags = MM_MISS; mhm.hitflags = MM_MISS;
mhm.permdmg = 0;
armpro = magic_negation(mdef); armpro = magic_negation(mdef);
/* since hero can't be cancelled, only defender's armor applies */ /* since hero can't be cancelled, only defender's armor applies */