From: nethack.allison Date: Tue, 21 Oct 2003 23:45:11 +0000 (+0000) Subject: Half_physical_damage 05 X-Git-Tag: MOVE2GIT~1660 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cdf982e47834b2fbd98cbba003a4f358b13230b9;p=nethack Half_physical_damage 05 - [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 --- diff --git a/src/apply.c b/src/apply.c index 392982a62..204241e5c 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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; } diff --git a/src/do.c b/src/do.c index e5bae275e..46e4e9027 100644 --- 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."); diff --git a/src/dothrow.c b/src/dothrow.c index 2faab1426..59378e5e0 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -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)) { diff --git a/src/hack.c b/src/hack.c index 4c850e5ca..b4520e06b 100644 --- a/src/hack.c +++ b/src/hack.c @@ -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; diff --git a/src/music.c b/src/music.c index d9a559560..b661816ec 100644 --- a/src/music.c +++ b/src/music.c @@ -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 { diff --git a/src/potion.c b/src/potion.c index e6ee6eb99..7d1d0c96e 100644 --- a/src/potion.c +++ b/src/potion.c @@ -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!"); diff --git a/src/region.c b/src/region.c index 7dffd275b..ddbbcf48d 100644 --- a/src/region.c +++ b/src/region.c @@ -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!"); diff --git a/src/sit.c b/src/sit.c index 40f9d57b8..69c4f90f1 100644 --- 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."); diff --git a/src/spell.c b/src/spell.c index 104b0a000..59cbd5de8 100644 --- a/src/spell.c +++ b/src/spell.c @@ -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); diff --git a/src/steed.c b/src/steed.c index 79cfe56c6..a9aa36a44 100644 --- a/src/steed.c +++ b/src/steed.c @@ -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; diff --git a/src/trap.c b/src/trap.c index 2481e5837..276242521 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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)) { diff --git a/src/uhitm.c b/src/uhitm.c index 8c27ef922..a9d431f3f 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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: diff --git a/src/zap.c b/src/zap.c index 189f2f45c..db8e8385e 100644 --- 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);