/* special mhpmax value when loading bones monster to flag as extinct or genocided */
#define DEFUNCT_MONSTER (-100)
+/* macro form of adjustments of physical damage based on Half_physical_damage.
+ * Can be used on-the-fly with the 1st parameter to losehp() if you don't
+ * need to retain the dmg value beyond that call scope.
+ * Take care to ensure it doesn't get used more than once in other instances.
+ */
+#define Maybe_Half_Phys(dmg) ((Half_physical_damage) ? (((dmg) + 1) / 2) : (dmg))
+
/* flags for special ggetobj status returns */
#define ALL_FINISHED 0x01 /* called routine already finished the job */
-/* SCCS Id: @(#)apply.c 3.4 2003/05/25 */
+/* SCCS Id: @(#)apply.c 3.4 2003/10/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
boolean fillmsg = FALSE;
int expltype = EXPL_MAGICAL;
char confirm[QBUFSZ], the_wand[BUFSZ], buf[BUFSZ];
+ boolean physical_dmg = FALSE;
Strcpy(the_wand, yname(obj));
Sprintf(confirm, "Are you really sure you want to break %s?",
damage = zapyourself(obj, FALSE);
if (damage) {
Sprintf(buf, "killed %sself by breaking a wand", uhim());
- losehp(damage, buf, NO_KILLER_PREFIX);
+ losehp(Maybe_Half_Phys(damage), buf, NO_KILLER_PREFIX);
}
if (context.botl) bot(); /* blindness */
} else if ((mon = m_at(x, y)) != 0) {
-/* SCCS Id: @(#)dothrow.c 3.4 2003/01/24 */
+/* SCCS Id: @(#)dothrow.c 3.4 2003/10/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
if (dmg > 1 && less_damage) dmg = 1;
if (dmg > 0) dmg += u.udaminc;
if (dmg < 0) dmg = 0; /* beware negative rings of increase damage */
- if (Half_physical_damage) dmg = (dmg + 1) / 2;
+ dmg = Maybe_Half_Phys(dmg);
if (uarmh) {
if (less_damage && dmg < (Upolyd ? u.mh : u.uhp)) {
-/* SCCS Id: @(#)explode.c 3.4 2002/11/10 */
+/* SCCS Id: @(#)explode.c 3.4 2003/10/21 */
/* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
* they don't supply enough information--was it a player or a monster that
* did it, and with a wand, spell, or breath weapon? Object types share both
* these disadvantages....
+ *
+ * Important note about Half_physical_damage:
+ * Unlike losehp() , explode() makes the Half_physical_damage adjustments
+ * itself, so the caller should never have done that ahead of time.
+ * It has to be done this way because the damage value is applied to
+ * things beside the player. Care is taken within explode() to ensure
+ * that Half_physical_damage only affects the damage applied to the hero.
*/
void
explode(x, y, type, dam, olet, expltype)
/* 0=normal explosion, 1=do shieldeff, 2=do nothing */
boolean shopdamage = FALSE;
boolean generic = FALSE;
+ boolean physical_dmg = FALSE;
if (olet == WAND_CLASS) /* retributive strike */
switch (Role_switch) {
olet == SCROLL_CLASS ? "tower of flame" :
"fireball";
adtyp = AD_FIRE;
+ physical_dmg = TRUE;
break;
case 2: str = "ball of cold";
adtyp = AD_COLD;
if (i+x-1 == u.ux && j+y-1 == u.uy) {
switch(adtyp) {
- case AD_PHYS:
+ case AD_PHYS:
explmask[i][j] = 0;
break;
case AD_MAGM:
break;
case AD_ACID:
explmask[i][j] = !!Acid_resistance;
+ physical_dmg = TRUE;
break;
default:
impossible("explosion type %d?", adtyp);
if (Invulnerable) {
damu = 0;
You("are unharmed!");
- } else if (Half_physical_damage && adtyp == AD_PHYS)
- damu = (damu+1) / 2;
+ } else if (adtyp == AD_PHYS || physical_dmg)
+ damu = Maybe_Half_Phys(damu);
if (adtyp == AD_FIRE) (void) burnarmor(&youmonst);
destroy_item(SCROLL_CLASS, (int) adtyp);
destroy_item(SPBOOK_CLASS, (int) adtyp);
-/* SCCS Id: @(#)potion.c 3.4 2002/10/02 */
+/* SCCS Id: @(#)potion.c 3.4 2003/10/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
good_for_you = TRUE;
} else {
You("burn your %s.", body_part(FACE));
- losehp(d(Fire_resistance ? 1 : 3, 4),
+ losehp(Maybe_Half_Phys(d(Fire_resistance ? 1 : 3, 4)),
"burning potion of oil", KILLED_BY_AN);
}
} else if(otmp->cursed)