From: nethack.allison Date: Tue, 21 Oct 2003 16:47:59 +0000 (+0000) Subject: Half_physical_damage 2 X-Git-Tag: MOVE2GIT~1664 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47e1a6873a98d313b248e05b49f38e6b82d70751;p=nethack Half_physical_damage 2 Another batch of missing Half_physical_damage checks from the list provided by : - Scrolls of fire (!confused) - Broken wands - Splattered burning oil from thrown potion - Dipping a lit lamp into a potion of oil - Scrolls of fire (confused, didn't bother with non-confused) - Being caught in a fireball Adds a macro Maybe_Half_Phys to assist. --- diff --git a/include/hack.h b/include/hack.h index 38742adf6..cd9fac8e5 100644 --- a/include/hack.h +++ b/include/hack.h @@ -146,6 +146,13 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ /* 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 */ diff --git a/src/apply.c b/src/apply.c index 7233d8ae4..f7a818ed7 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* 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. */ @@ -2611,6 +2611,7 @@ do_break_wand(obj) 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?", @@ -2736,7 +2737,7 @@ do_break_wand(obj) 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) { diff --git a/src/dothrow.c b/src/dothrow.c index f34526b1c..2faab1426 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -1,4 +1,4 @@ -/* 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. */ @@ -798,7 +798,7 @@ boolean hitsroof; 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)) { diff --git a/src/explode.c b/src/explode.c index 3f80576a3..e7d687954 100644 --- a/src/explode.c +++ b/src/explode.c @@ -1,4 +1,4 @@ -/* 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. */ @@ -18,6 +18,13 @@ static int expl[3][3] = { * 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) @@ -39,6 +46,7 @@ int 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) { @@ -64,6 +72,7 @@ int expltype; olet == SCROLL_CLASS ? "tower of flame" : "fireball"; adtyp = AD_FIRE; + physical_dmg = TRUE; break; case 2: str = "ball of cold"; adtyp = AD_COLD; @@ -94,7 +103,7 @@ int expltype; 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: @@ -119,6 +128,7 @@ int expltype; break; case AD_ACID: explmask[i][j] = !!Acid_resistance; + physical_dmg = TRUE; break; default: impossible("explosion type %d?", adtyp); @@ -313,8 +323,8 @@ int expltype; 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); diff --git a/src/potion.c b/src/potion.c index a29a77e05..e6ee6eb99 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1,4 +1,4 @@ -/* 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. */ @@ -876,7 +876,7 @@ peffects(otmp) 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)