quantum mechanic hits

Noticed while trying to find the reason for the wildmiss impossible(),
you could be teleported and then drop dead at the destination.  A QM's
AD_TLPT hit also does 1d4 physical damage which gets applied after the
teleport.  Getting "You die." seemed pretty strange, particularly after
picking the destination with telport control.  This makes sure that the
damage will never be fatal when teleport is attempted.
This commit is contained in:
PatR
2019-04-19 17:32:36 -07:00
parent edd412e56c
commit ab4625a6bf
4 changed files with 54 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.305 $ $NHDT-Date: 1555627306 2019/04/18 22:41:46 $
$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.306 $ $NHDT-Date: 1555720351 2019/04/20 00:32:31 $
This fixes36.2 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.1 in April 2018. Please note, however,
@@ -411,6 +411,9 @@ if a migrating long worm couldn't be placed, or some other monster was given
a "trying to place monster at <0,0>" warning would occur
if hero throws a pick-axe into a shop and shopkeeper catches it, shk will say
"get out of my way, scum" even if there's no monster at pick-axe spot
a quantum mechanic hit that teleported the target could also kill it at the
destination; make sure that the small amount of physical damage isn't
fatal unless the teleport is negated by cancellation (magic or armor)
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mhitm.c $NHDT-Date: 1547118629 2019/01/10 11:10:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.112 $ */
/* NetHack 3.6 mhitm.c $NHDT-Date: 1555720096 2019/04/20 00:28:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.113 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1101,6 +1101,7 @@ register struct attack *mattk;
if (!cancelled && tmp < mdef->mhp && !tele_restrict(mdef)) {
char mdef_Monnam[BUFSZ];
boolean wasseen = canspotmon(mdef);
/* save the name before monster teleports, otherwise
we'll get "it" in the suddenly disappears message */
if (vis && wasseen)
@@ -1109,6 +1110,11 @@ register struct attack *mattk;
(void) rloc(mdef, TRUE);
if (vis && wasseen && !canspotmon(mdef) && mdef != u.usteed)
pline("%s suddenly disappears!", mdef_Monnam);
if (tmp >= mdef->mhp) { /* see hitmu(mhitu.c) */
if (mdef->mhp == 1)
++mdef->mhp;
tmp = mdef->mhp - 1;
}
}
break;
case AD_SLEE:
@@ -1356,7 +1362,8 @@ register struct attack *mattk;
break; /* physical damage only */
if (!rn2(4) && !slimeproof(pd)) {
if (!munslime(mdef, FALSE) && !DEADMONSTER(mdef)) {
if (newcham(mdef, &mons[PM_GREEN_SLIME], FALSE, vis && canseemon(mdef)))
if (newcham(mdef, &mons[PM_GREEN_SLIME], FALSE,
(boolean) (vis && canseemon(mdef))))
pd = mdef->data;
mdef->mstrategy &= ~STRAT_WAITFORU;
res = MM_HIT;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mhitu.c $NHDT-Date: 1547118629 2019/01/10 11:10:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.161 $ */
/* NetHack 3.6 mhitu.c $NHDT-Date: 1555720104 2019/04/20 00:28:24 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.162 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -925,7 +925,7 @@ register struct attack *mattk;
{
struct permonst *mdat = mtmp->data;
int uncancelled, ptmp;
int dmg, armpro, permdmg;
int dmg, armpro, permdmg, tmphp;
char buf[BUFSZ];
struct permonst *olduasmon = youmonst.data;
int res;
@@ -1400,8 +1400,39 @@ register struct attack *mattk;
hitmsg(mtmp, mattk);
if (uncancelled) {
if (flags.verbose)
Your("position suddenly seems very uncertain!");
Your("position suddenly seems %suncertain!",
(Teleport_control && !Stunned && !unconscious()) ? ""
: "very ");
tele();
/* 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 ? (dmg - 1) / 2 : dmg)
>= (tmphp = (Upolyd ? u.mh : u.uhp))) {
dmg = tmphp - 1;
if (Half_physical_damage)
dmg *= 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 (dmg < 1) { /* implies (tmphp <= 1) */
dmg = 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] */
}
}
}
break;
case AD_RUST:

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 uhitm.c $NHDT-Date: 1553644725 2019/03/26 23:58:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.206 $ */
/* NetHack 3.6 uhitm.c $NHDT-Date: 1555720104 2019/04/20 00:28:24 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.207 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1742,7 +1742,7 @@ int specialdmg; /* blessed and/or silver bonus against various things */
case AD_TLPT:
if (tmp <= 0)
tmp = 1;
if (!negated && tmp < mdef->mhp) {
if (!negated) {
char nambuf[BUFSZ];
boolean u_saw_mon = (canseemon(mdef)
|| (u.uswallow && u.ustuck == mdef));
@@ -1752,6 +1752,11 @@ int specialdmg; /* blessed and/or silver bonus against various things */
if (u_teleport_mon(mdef, FALSE) && u_saw_mon
&& !(canseemon(mdef) || (u.uswallow && u.ustuck == mdef)))
pline("%s suddenly disappears!", nambuf);
if (tmp >= mdef->mhp) { /* see hitmu(mhitu.c) */
if (mdef->mhp == 1)
++mdef->mhp;
tmp = mdef->mhp - 1;
}
}
break;
case AD_BLND: