Unify ad_tlpt

This commit is contained in:
Pasi Kallinen
2020-11-30 20:42:39 +02:00
parent bfe773812e
commit 607d1bcd96
4 changed files with 112 additions and 73 deletions

View File

@@ -1405,43 +1405,9 @@ register struct attack *mattk;
break;
case AD_TLPT:
hitmsg(mtmp, mattk);
if (uncancelled) {
if (flags.verbose)
Your("position suddenly seems %suncertain!",
(Teleport_control && !Stunned && !unconscious()) ? ""
: "very ");
tele();
/* As of 3.6.2: make sure damage isn't fatal; previously, it
was possible to be teleported and then drop dead at
the destination when QM's 1d4 damage gets applied below;
even though that wasn't "wrong", it seemed strange,
particularly if the teleportation had been controlled
[applying the damage first and not teleporting if fatal
is another alternative but it has its own complications] */
if ((Half_physical_damage ? (mhm.damage - 1) / 2 : mhm.damage)
>= (tmphp = (Upolyd ? u.mh : u.uhp))) {
mhm.damage = tmphp - 1;
if (Half_physical_damage)
mhm.damage *= 2; /* doesn't actually increase damage; we only
* get here if half the original damage would
* would have been fatal, so double reduced
* damage will be less than original damage */
if (mhm.damage < 1) { /* implies (tmphp <= 1) */
mhm.damage = 1;
/* this might increase current HP beyond maximum HP but
it will be immediately reduced below, so that should
be indistinguishable from zero damage; we don't drop
damage all the way to zero because that inhibits any
passive counterattack if poly'd hero has one */
if (Upolyd && u.mh == 1)
++u.mh;
else if (!Upolyd && u.uhp == 1)
++u.uhp;
/* [don't set context.botl here] */
}
}
}
mhitm_ad_tlpt(mtmp, mattk, &g.youmonst, &mhm);
if (mhm.done)
return mhm.hitflags;
break;
case AD_RUST:
mhitm_ad_rust(mtmp, mattk, &g.youmonst, &mhm);