]> granicus.if.org Git - nethack/commitdiff
Half_physical_damage 05
authornethack.allison <nethack.allison>
Tue, 21 Oct 2003 23:45:11 +0000 (23:45 +0000)
committernethack.allison <nethack.allison>
Tue, 21 Oct 2003 23:45:11 +0000 (23:45 +0000)
- [fixed in trunk] Jumping/Newton's-Thirding into something solid
- [fixed in trunk] Being hit by Mjollnir on the return
- [fixed in trunk] Contaminated or boiling water from a sink
- [fixed in trunk] Falling on a sink while levitating
- [fixed in trunk, fire only] Any passive attack
- [fixed in trunk] Zapping yourself with a wand, horn or spell
- [fixed in trunk] Burning (un)holy water
- [fixed in trunk] Thrown potion (bottle)
- [fixed in trunk] Bumping head on ceiling by cursed levitation
- [fixed in trunk] Exploding rings and wands (under all circumstances)
- [fixed in trunk] Stinking cloud damage
- [fixed in trunk] Sitting in a spiked pit, in lava
- [fixed in trunk] Exploding spellbooks
- [fixed in trunk] Falling off or failing to mount a steed
- [fixed in trunk] Falling into a (spiked) pit
- [fixed in trunk] Land mine explosion
- [fixed in trunk] Fire traps

13 files changed:
src/apply.c
src/do.c
src/dothrow.c
src/hack.c
src/music.c
src/potion.c
src/region.c
src/sit.c
src/spell.c
src/steed.c
src/trap.c
src/uhitm.c
src/zap.c

index 392982a62ea8499c9cf533afab073a0cec949df6..204241e5c922d9136ccd7fc602b53103244ee3da 100644 (file)
@@ -1310,7 +1310,8 @@ int magic; /* 0=Physical, otherwise skill level */
                case TT_BEARTRAP: {
                    register long side = rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
                    You("rip yourself free of the bear trap!  Ouch!");
-                   losehp(rnd(10), "jumping out of a bear trap", KILLED_BY);
+                   losehp(Maybe_Half_Phys(rnd(10)),
+                               "jumping out of a bear trap", KILLED_BY);
                    set_wounded_legs(side, rn1(1000,500));
                    break;
                  }
index e5bae275ee76ff3a5226f8aac16eeacf106c6729..46e4e9027eb99d1e6e971d3ddebc029e4a9fcf19 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -97,10 +97,12 @@ boolean pushing;
                    vision_full_recalc = 1;
                    You("find yourself on dry land again!");
                } else if (lava && distu(rx,ry) <= 2) {
+                   int dmg;
                    You("are hit by molten lava%c",
                        Fire_resistance ? '.' : '!');
                        burn_away_slime();
-                   losehp(d((Fire_resistance ? 1 : 3), 6),
+                   dmg = d((Fire_resistance ? 1 : 3), 6);
+                   losehp(Maybe_Half_Phys(dmg),
                           "molten lava", KILLED_BY);
                } else if (!fills_up && flags.verbose &&
                           (pushing ? !Blind : cansee(rx,ry)))
@@ -1158,7 +1160,8 @@ boolean at_stairs, falling, portal;
                        dismount_steed(DISMOUNT_FELL);
                    else
 #endif
-                       losehp(rnd(3), "falling downstairs", KILLED_BY);
+                       losehp(Maybe_Half_Phys(rnd(3)),
+                               "falling downstairs", KILLED_BY);
                    selftouch("Falling, you");
                } else if (u.dz && at_ladder)
                    You("climb down the ladder.");
index 2faab1426f41085699257a0c6a3fa5cba0031a71..59378e5e0eff1ef80d9aa26a9c5c95bc5ffa55e5 100644 (file)
@@ -453,6 +453,7 @@ hurtle_step(arg, x, y)
     struct monst *mon;
     boolean may_pass = TRUE;
     struct trap *ttmp;
+    int dmg = 0;
     
     if (!isok(x,y)) {
        You_feel("the spirits holding you back.");
@@ -474,23 +475,28 @@ hurtle_step(arg, x, y)
                s = "bumping into a wall";
            else
                s = "bumping into a door";
-           losehp(rnd(2+*range), s, KILLED_BY);
+           dmg = rnd(2+*range);
+           losehp(Maybe_Half_Phys(dmg), s, KILLED_BY);
            return FALSE;
        }
        if (levl[x][y].typ == IRONBARS) {
            You("crash into some iron bars.  Ouch!");
-           losehp(rnd(2+*range), "crashing into iron bars", KILLED_BY);
+           dmg = rnd(2+*range);
+           losehp(Maybe_Half_Phys(dmg), "crashing into iron bars", KILLED_BY);
            return FALSE;
        }
        if ((obj = sobj_at(BOULDER,x,y)) != 0) {
            You("bump into a %s.  Ouch!", xname(obj));
-           losehp(rnd(2+*range), "bumping into a boulder", KILLED_BY);
+           dmg = rnd(2+*range);
+           losehp(Maybe_Half_Phys(dmg), "bumping into a boulder", KILLED_BY);
            return FALSE;
        }
        if (!may_pass) {
            /* did we hit a no-dig non-wall position? */
            You("smack into something!");
-           losehp(rnd(2+*range), "touching the edge of the universe", KILLED_BY);
+           dmg = rnd(2+*range);
+           losehp(Maybe_Half_Phys(dmg), "touching the edge of the universe",
+                       KILLED_BY);
            return FALSE;
        }
        if ((u.ux - x) && (u.uy - y) &&
@@ -500,7 +506,9 @@ hurtle_step(arg, x, y)
            if (bigmonst(youmonst.data) || too_much) {
                You("%sget forcefully wedged into a crevice.",
                        too_much ? "and all your belongings " : "");
-               losehp(rnd(2+*range), "wedging into a narrow crevice", KILLED_BY);
+               dmg = rnd(2+*range);
+               losehp(Maybe_Half_Phys(dmg), "wedging into a narrow crevice",
+                       KILLED_BY);
                return FALSE;
            }
        }
@@ -1048,7 +1056,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
                                  body_part(ARM));
                            (void) artifact_hit((struct monst *)0,
                                                &youmonst, obj, &dmg, 0);
-                           losehp(dmg, xname(obj),
+                           losehp(Maybe_Half_Phys(dmg), xname(obj),
                                obj_is_pname(obj) ? KILLED_BY : KILLED_BY_AN);
                        }
                        if (ship_object(obj, u.ux, u.uy, FALSE)) {
index 4c850e5cabc36bf987820f1e2991e1eec59cafff..b4520e06ba50fca6db8c1f28f32b762defe2f777 100644 (file)
@@ -446,6 +446,7 @@ STATIC_OVL void
 dosinkfall()
 {
        register struct obj *obj;
+       int dmg;
 
        if (is_floater(youmonst.data) || (HLevitation & FROMOUTSIDE)) {
            You("wobble unsteadily for a moment.");
@@ -458,14 +459,15 @@ dosinkfall()
               are really still worn has no effect on bones data */
            ELevitation = HLevitation = 0L;
            You("crash to the floor!");
-           losehp(rn1(8, 25 - (int)ACURR(A_CON)),
+           dmg = rn1(8, 25 - (int)ACURR(A_CON));
+           losehp(Maybe_Half_Phys(dmg),
                   fell_on_sink, NO_KILLER_PREFIX);
            exercise(A_DEX, FALSE);
            selftouch("Falling, you");
            for (obj = level.objects[u.ux][u.uy]; obj; obj = obj->nexthere)
                if (obj->oclass == WEAPON_CLASS || is_weptool(obj)) {
                    You("fell on %s.", doname(obj));
-                   losehp(rnd(3), fell_on_sink, NO_KILLER_PREFIX);
+                   losehp(Maybe_Half_Phys(rnd(3)), fell_on_sink, NO_KILLER_PREFIX);
                    exercise(A_CON, FALSE);
                }
            ELevitation = save_ELev;
index d9a5595601a8d7a10847c867e574560cb5aa88de..b661816eca5c58abff8e2ff8e8b3aa3d22bfe421 100644 (file)
@@ -325,7 +325,8 @@ do_pit:                 chasm = maketrap(x,y,PIT);
                                    You("fall into a chasm!");
                                    u.utrap = rn1(6,2);
                                    u.utraptype = TT_PIT;
-                                   losehp(rnd(6),"fell into a chasm",
+                                   losehp(Maybe_Half_Phys(rnd(6)),
+                                       "fell into a chasm",
                                        NO_KILLER_PREFIX);
                                    selftouch("Falling, you");
                            }
@@ -354,6 +355,7 @@ do_improvisation(instr)
 struct obj *instr;
 {
        int damage, do_spec = !Confusion;
+       boolean physical_damage = FALSE;
 #if defined(MAC) || defined(AMIGA) || defined(VPIX_MUSIC) || defined (PCMUSIC)
        struct obj itmp;
 
@@ -397,8 +399,10 @@ struct obj *instr;
            if (do_spec) charm_snakes(u.ulevel * 3);
            exercise(A_DEX, TRUE);
            break;
-       case FROST_HORN:                /* Idem wand of cold */
        case FIRE_HORN:                 /* Idem wand of fire */
+           physical_damage = TRUE;
+           /* fall through */
+       case FROST_HORN:                /* Idem wand of cold */
            if (do_spec && instr->spe > 0) {
                consume_obj_charge(instr, TRUE);
 
@@ -409,6 +413,7 @@ struct obj *instr;
                    if ((damage = zapyourself(instr, TRUE)) != 0) {
                        char buf[BUFSZ];
                        Sprintf(buf, "using a magical horn on %sself", uhim());
+                       if (physical_damage) damage = Maybe_Half_Phys(damage);
                        losehp(damage, buf, KILLED_BY);
                    }
                } else {
index e6ee6eb991a0223070d19fa846add9284724e79d..7d1d0c96e059bffa5322f003eb361ad857a157c1 100644 (file)
@@ -474,7 +474,8 @@ peffects(otmp)
                                you_unwere(FALSE);
                            u.ulycn = NON_PM;   /* cure lycanthropy */
                        }
-                       losehp(d(2,6), "potion of holy water", KILLED_BY_AN);
+                       losehp(Maybe_Half_Phys(d(2,6)),
+                               "potion of holy water", KILLED_BY_AN);
                    } else if(otmp->cursed) {
                        You_feel("quite proud of yourself.");
                        healup(d(2,6),0,0,0);
@@ -493,7 +494,8 @@ peffects(otmp)
                    } else {
                        if(u.ualign.type == A_LAWFUL) {
                            pline("This burns like acid!");
-                           losehp(d(2,6), "potion of unholy water",
+                           losehp(Maybe_Half_Phys(d(2,6)),
+                               "potion of unholy water",
                                KILLED_BY_AN);
                        } else
                            You_feel("full of dread.");
@@ -835,10 +837,11 @@ peffects(otmp)
           && (u.ux != sstairs.sx || u.uy != sstairs.sy || !sstairs.up)
           && (!xupladder || u.ux != xupladder || u.uy != yupladder)
        ) {
+                                       int dmg = uarmh ? 1 : rnd(10);
                                        You("hit your %s on the %s.",
                                                body_part(HEAD),
                                                ceiling(u.ux,u.uy));
-                                       losehp(uarmh ? 1 : rnd(10),
+                                       losehp(Maybe_Half_Phys(dmg),
                                                "colliding with the ceiling",
                                                KILLED_BY);
                                } else (void) doup();
@@ -976,7 +979,7 @@ boolean your_fault;
                distance = 0;
                pline_The("%s crashes on your %s and breaks into shards.",
                        botlnam, body_part(HEAD));
-               losehp(rnd(2), "thrown potion", KILLED_BY_AN);
+               losehp(Maybe_Half_Phys(rnd(2)), "thrown potion", KILLED_BY_AN);
        } else {
                distance = distu(mon->mx,mon->my);
                if (!cansee(mon->mx,mon->my)) pline("Crash!");
index 7dffd275b0dba98885a8ff239c4ed91c5588ba09..ddbbcf48dbf7d2500557e8e7ead09df3670b24fe 100644 (file)
@@ -912,7 +912,7 @@ genericptr_t p2;
        if (!Poison_resistance) {
            pline("%s is burning your %s!", Something, makeplural(body_part(LUNG)));
            You("cough and spit blood!");
-           losehp(rnd(dam) + 5, "gas cloud", KILLED_BY_AN);
+           losehp(Maybe_Half_Phys(rnd(dam) + 5), "gas cloud", KILLED_BY_AN);
            return FALSE;
        } else {
            You("cough!");
index 40f9d57b8469f38e44b0074ae373f6929baa4fcc..69c4f90f172e36e9b3d5d92449ed472551f19bb7 100644 (file)
--- a/src/sit.c
+++ b/src/sit.c
@@ -79,7 +79,8 @@ dosit()
                } else if(u.utraptype == TT_PIT) {
                    if(trap->ttyp == SPIKED_PIT) {
                        You("sit down on a spike.  Ouch!");
-                       losehp(1, "sitting on an iron spike", KILLED_BY);
+                       losehp(Half_physical_damage ? rn2(2) : 1,
+                               "sitting on an iron spike", KILLED_BY);
                        exercise(A_STR, FALSE);
                    } else
                        You("sit down in the pit.");
index 104b0a000932290cc5bd5c7853b64d7fd83dcfd1..59cbd5de8b6fb8753530fbef0bb825f6edb8d805 100644 (file)
@@ -107,6 +107,7 @@ cursed_book(bp)
        struct obj *bp;
 {
        int lev = objects[bp->otyp].oc_level;
+       int dmg = 0;
 
        switch(rn2(lev)) {
        case 0:
@@ -161,7 +162,8 @@ cursed_book(bp)
                } else {
                    pline("As you read the book, it %s in your %s!",
                          explodes, body_part(FACE));
-                   losehp(2*rnd(10)+5, "exploding rune", KILLED_BY_AN);
+                   dmg = 2*rnd(10)+5;
+                   losehp(Maybe_Half_Phys(dmg), "exploding rune", KILLED_BY_AN);
                }
                return TRUE;
        default:
@@ -726,6 +728,7 @@ boolean atme;
        int energy, damage, chance, n, intell;
        int skill, role_skill;
        boolean confused = (Confusion != 0);
+       boolean physical_damage = FALSE;
        struct obj *pseudo;
        coord cc;
 
@@ -833,8 +836,10 @@ boolean atme;
         * effects, e.g. more damage, further distance, and so on, without
         * additional cost to the spellcaster.
         */
-       case SPE_CONE_OF_COLD:
        case SPE_FIREBALL:
+           physical_damage = TRUE;
+           /* fall through */
+       case SPE_CONE_OF_COLD:
            if (role_skill >= P_SKILLED) {
                if (throwspell()) {
                    cc.x=u.dx;cc.y=u.dy;
@@ -844,6 +849,8 @@ boolean atme;
                            if ((damage = zapyourself(pseudo, TRUE)) != 0) {
                                char buf[BUFSZ];
                                Sprintf(buf, "zapped %sself with a spell", uhim());
+                               if (physical_damage)
+                                       damage = Maybe_Half_Phys(damage);
                                losehp(damage, buf, NO_KILLER_PREFIX);
                            }
                        } else {
@@ -867,6 +874,8 @@ boolean atme;
 
        /* these spells are all duplicates of wand effects */
        case SPE_FORCE_BOLT:
+               physical_damage = TRUE;
+               /* fall through */
        case SPE_SLEEP:
        case SPE_MAGIC_MISSILE:
        case SPE_KNOCK:
@@ -894,6 +903,7 @@ boolean atme;
                            if ((damage = zapyourself(pseudo, TRUE)) != 0) {
                                char buf[BUFSZ];
                                Sprintf(buf, "zapped %sself with a spell", uhim());
+                               if (physical_damage) damage = Maybe_Half_Phys(damage);
                                losehp(damage, buf, NO_KILLER_PREFIX);
                            }
                        } else weffects(pseudo);
index 79cfe56c6dadb72eeb6799f2285eff29270d3b24..a9aa36a44509eb5dfdbc7240d8f76fa5c13baabb 100644 (file)
@@ -324,7 +324,7 @@ mount_steed(mtmp, force)
                    x_monnam(mtmp, ARTICLE_A, (char *)0,
                        SUPPRESS_IT|SUPPRESS_INVISIBLE|SUPPRESS_HALLUCINATION,
                             TRUE));
-           losehp(rn1(5,10), buf, NO_KILLER_PREFIX);
+           losehp(Maybe_Half_Phys(rn1(5,10)), buf, NO_KILLER_PREFIX);
            return (FALSE);
        }
 
@@ -483,7 +483,7 @@ dismount_steed(reason)
            case DISMOUNT_FELL:
                You("%s off of %s!", verb, mon_nam(mtmp));
                if (!have_spot) have_spot = landing_spot(&cc,reason,1);
-               losehp(rn1(10,10), "riding accident", KILLED_BY_AN);
+               losehp(Maybe_Half_Phys(rn1(10,10)), "riding accident", KILLED_BY_AN);
                set_wounded_legs(BOTH_SIDES, (int)HWounded_legs + rn1(5,5));
                repair_leg_damage = FALSE;
                break;
index 2481e5837fe1b3c2df18484a7b383fbb024dfc3f..2762425214584a009777000f5e7145b7b6d56adc 100644 (file)
@@ -2443,7 +2443,7 @@ struct obj *box;  /* null for floor trap */
        if (!num)
            You("are uninjured.");
        else
-           losehp(num, tower_of_flame, KILLED_BY_AN);
+           losehp(Maybe_Half_Phys(num), tower_of_flame, KILLED_BY_AN);
        burn_away_slime();
 
        if (burnarmor(&youmonst) || rn2(3)) {
index 8c27ef9226417f0b7bb493ceab1d070792908fa7..a9d431f3f1306b816bf9407f2a8e7c8174ee5897 100644 (file)
@@ -2324,7 +2324,7 @@ uchar aatyp;
                        break;
                    }
                    You("are suddenly very hot!");
-                   mdamageu(mon, tmp);
+                   mdamageu(mon, Maybe_Half_Phys(tmp));
                }
                break;
              case AD_ELEC:
index 189f2f45c1e9ee0dcd514e8601782ea5620887b3..db8e8385ed162affc8a6e6f90d98a974b5c659ef 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1789,9 +1789,11 @@ STATIC_OVL void
 backfire(otmp)
 struct obj *otmp;
 {
+       int dmg;
        otmp->in_use = TRUE;    /* in case losehp() is fatal */
        pline("%s suddenly explodes!", The(xname(otmp)));
-       losehp(d(otmp->spe+2,6), "exploding wand", KILLED_BY_AN);
+       dmg = d(otmp->spe+2,6);
+       losehp(Maybe_Half_Phys(dmg), "exploding wand", KILLED_BY_AN);
        useup(otmp);
 }
 
@@ -1823,7 +1825,7 @@ dozap()
            if ((damage = zapyourself(obj, TRUE)) != 0) {
                char buf[BUFSZ];
                Sprintf(buf, "zapped %sself with a wand", uhim());
-               losehp(damage, buf, NO_KILLER_PREFIX);
+               losehp(Maybe_Half_Phys(damage), buf, NO_KILLER_PREFIX);
            }
        } else {
 
@@ -2313,10 +2315,12 @@ struct obj *obj;        /* wand or spell */
            } else if (striking && u.dz < 0 && rn2(3) &&
                        !Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) &&
                        !Underwater && !Is_qstart(&u.uz)) {
+               int dmg;
                /* similar to zap_dig() */
                pline("A rock is dislodged from the %s and falls on your %s.",
                      ceiling(x, y), body_part(HEAD));
-               losehp(rnd((uarmh && is_metallic(uarmh)) ? 2 : 6),
+               dmg = rnd((uarmh && is_metallic(uarmh)) ? 2 : 6);
+               losehp(Maybe_Half_Phys(dmg),
                       "falling rock", KILLED_BY_AN);
                if ((otmp = mksobj_at(ROCK, x, y, FALSE, FALSE)) != 0) {
                    (void)xname(otmp);  /* set dknown, maybe bknown */
@@ -3835,9 +3839,11 @@ register int osym, dmgtyp;
        register long i, cnt, quan;
        register int dindx;
        const char *mult;
+       boolean physical_damage;
 
        for(obj = invent; obj; obj = obj2) {
            obj2 = obj->nobj;
+           physical_damage = FALSE;
            if(obj->oclass != osym) continue; /* test only objs of type osym */
            if(obj->oartifact) continue; /* don't destroy artifacts */
            if(obj->in_use && obj->quan == 1) continue; /* not available */
@@ -3856,6 +3862,7 @@ register int osym, dmgtyp;
                    break;
                case AD_FIRE:
                    xresist = (Fire_resistance && obj->oclass != POTION_CLASS);
+                   physical_damage = TRUE;
 
                    if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL)
                        skip++;
@@ -3941,6 +3948,7 @@ register int osym, dmgtyp;
                        const char *how = destroy_strings[dindx * 3 + 2];
                        boolean one = (cnt == 1L);
 
+                       if (physical_damage) dmg = Maybe_Half_Phys(dmg);
                        losehp(dmg, one ? how : (const char *)makeplural(how),
                               one ? KILLED_BY_AN : KILLED_BY);
                        exercise(A_STR, FALSE);