boiling oil (trunk only)

A suggestion from the newsgroup:  when potions are hit by fire and
get the "boil and explode" result, potions of oil should burn instead of
boil.  Even though oil can be heated to boiling, nethack's potions of oil
are noticeably flammable [just (a)pply one...] so having them burn makes
sense.  It's just a message change; no actual explosion has been added.

     destroy_strings[] was implemented as an {N} x {3} array that used
manually computed indices into one-dimension.  This changes it into a two-
dimensional array instead.  However, it's still being indexed by a bunch
of magic numbers.
This commit is contained in:
nethack.rankin
2006-12-17 04:43:55 +00:00
parent 2af813f9da
commit cc19fff23d
2 changed files with 46 additions and 35 deletions

View File

@@ -1,10 +1,10 @@
/* SCCS Id: @(#)trap.c 3.5 2006/11/22 */ /* SCCS Id: @(#)trap.c 3.5 2006/12/16 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
#include "hack.h" #include "hack.h"
extern const char * const destroy_strings[]; /* from zap.c */ extern const char * const destroy_strings[][3]; /* from zap.c */
STATIC_DCL void FDECL(dofiretrap, (struct obj *)); STATIC_DCL void FDECL(dofiretrap, (struct obj *));
STATIC_DCL void NDECL(domagictrap); STATIC_DCL void NDECL(domagictrap);
@@ -3010,17 +3010,17 @@ xchar x, y;
if (in_sight) pline("Smoke rises from %s.", the(xname(obj))); if (in_sight) pline("Smoke rises from %s.", the(xname(obj)));
continue; continue;
} }
dindx = (obj->oclass == SCROLL_CLASS) ? 2 : 3; dindx = (obj->oclass == SCROLL_CLASS) ? 3 : 4;
if (in_sight) if (in_sight)
pline("%s %s.", Yname2(obj), (obj->quan > 1L) ? pline("%s %s.", Yname2(obj),
destroy_strings[dindx*3 + 1] : destroy_strings[dindx*3]); destroy_strings[dindx][(obj->quan > 1L)]);
delobj(obj); delobj(obj);
retval++; retval++;
} else if (obj->oclass == POTION_CLASS) { } else if (obj->oclass == POTION_CLASS) {
dindx = 1; dindx = (obj->otyp != POT_OIL) ? 1 : 2;
if (in_sight) if (in_sight)
pline("%s %s.", Yname2(obj), (obj->quan > 1L) ? pline("%s %s.", Yname2(obj),
destroy_strings[dindx*3 + 1] : destroy_strings[dindx*3]); destroy_strings[dindx][(obj->quan > 1L)]);
delobj(obj); delobj(obj);
retval++; retval++;
} else if (is_flammable(obj) && obj->oeroded < MAX_ERODE && } else if (is_flammable(obj) && obj->oeroded < MAX_ERODE &&

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)zap.c 3.5 2006/11/27 */ /* SCCS Id: @(#)zap.c 3.5 2006/12/16 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -4132,13 +4132,26 @@ register struct obj *obj;
return TRUE; return TRUE;
} }
const char * const destroy_strings[] = { /* also used in trap.c */ /*
"freezes and shatters", "freeze and shatter", "shattered potion", * destroy_strings[dindx][0:singular,1:plural,2:killer_reason]
"boils and explodes", "boil and explode", "boiling potion", * [0] freezing potion
"catches fire and burns", "catch fire and burn", "burning scroll", * [1] boiling potion other than oil
"catches fire and burns", "catch fire and burn", "burning book", * [2] boiling potion of oil
"turns to dust and vanishes", "turn to dust and vanish", "", * [3] burning scroll
"breaks apart and explodes", "break apart and explode", "exploding wand" * [4] burning spellbook
* [5] shocked ring
* [6] shocked wand
* (books, rings, and wands don't stack so don't need plural form;
* crumbling ring doesn't do damage so doesn't need killer reason)
*/
const char * const destroy_strings[][3] = { /* also used in trap.c */
{ "freezes and shatters", "freeze and shatter", "shattered potion" },
{ "boils and explodes", "boil and explode", "boiling potion" },
{ "ignites and explodes", "ignite and explode", "exploding potion" },
{ "catches fire and burns", "catch fire and burn", "burning scroll" },
{ "catches fire and burns", "", "burning book" },
{ "turns to dust and vanishes", "", "" },
{ "breaks apart and explodes", "", "exploding wand" },
}; };
void void
@@ -4159,10 +4172,10 @@ register int osym, dmgtyp;
if(obj->oartifact) continue; /* don't destroy artifacts */ if(obj->oartifact) continue; /* don't destroy artifacts */
if(obj->in_use && obj->quan == 1L) continue; /* not available */ if(obj->in_use && obj->quan == 1L) continue; /* not available */
xresist = skip = 0; xresist = skip = 0;
#ifdef GCC_WARN /* lint suppression */
dmg = dindx = 0; dmg = dindx = 0;
quan = 0L; quan = 0L;
#endif
switch(dmgtyp) { switch(dmgtyp) {
case AD_COLD: case AD_COLD:
if(osym == POTION_CLASS && obj->otyp != POT_OIL) { if(osym == POTION_CLASS && obj->otyp != POT_OIL) {
@@ -4185,15 +4198,15 @@ register int osym, dmgtyp;
quan = obj->quan; quan = obj->quan;
switch(osym) { switch(osym) {
case POTION_CLASS: case POTION_CLASS:
dindx = 1; dindx = (obj->otyp != POT_OIL) ? 1 : 2;
dmg = rnd(6); dmg = rnd(6);
break; break;
case SCROLL_CLASS: case SCROLL_CLASS:
dindx = 2; dindx = 3;
dmg = 1; dmg = 1;
break; break;
case SPBOOK_CLASS: case SPBOOK_CLASS:
dindx = 3; dindx = 4;
dmg = 1; dmg = 1;
break; break;
default: default:
@@ -4208,7 +4221,7 @@ register int osym, dmgtyp;
case RING_CLASS: case RING_CLASS:
if(obj->otyp == RIN_SHOCK_RESISTANCE) if(obj->otyp == RIN_SHOCK_RESISTANCE)
{ skip++; break; } { skip++; break; }
dindx = 4; dindx = 5;
dmg = 0; dmg = 0;
break; break;
case WAND_CLASS: case WAND_CLASS:
@@ -4216,7 +4229,7 @@ register int osym, dmgtyp;
#if 0 #if 0
if (obj == current_wand) { skip++; break; } if (obj == current_wand) { skip++; break; }
#endif #endif
dindx = 5; dindx = 6;
dmg = rnd(10); dmg = rnd(10);
break; break;
default: default:
@@ -4234,11 +4247,10 @@ register int osym, dmgtyp;
if(!rn2(3)) cnt++; if(!rn2(3)) cnt++;
if(!cnt) continue; if(!cnt) continue;
if(cnt == quan) mult = "Your"; mult = (cnt == quan) ? "Your" :
else mult = (cnt == 1L) ? "One of your" : "Some of your"; (cnt == 1L) ? "One of your" : "Some of your";
pline("%s %s %s!", mult, xname(obj), pline("%s %s %s!", mult, xname(obj),
(cnt > 1L) ? destroy_strings[dindx*3 + 1] destroy_strings[dindx][(cnt > 1L)]);
: destroy_strings[dindx*3]);
if(osym == POTION_CLASS && dmgtyp != AD_COLD) { if(osym == POTION_CLASS && dmgtyp != AD_COLD) {
if (!breathless(youmonst.data) || haseyes(youmonst.data)) if (!breathless(youmonst.data) || haseyes(youmonst.data))
potionbreathe(obj); potionbreathe(obj);
@@ -4255,7 +4267,7 @@ register int osym, dmgtyp;
if(dmg) { if(dmg) {
if(xresist) You("aren't hurt!"); if(xresist) You("aren't hurt!");
else { else {
const char *how = destroy_strings[dindx * 3 + 2]; const char *how = destroy_strings[dindx][2];
boolean one = (cnt == 1L); boolean one = (cnt == 1L);
if (physical_damage) dmg = Maybe_Half_Phys(dmg); if (physical_damage) dmg = Maybe_Half_Phys(dmg);
@@ -4314,15 +4326,15 @@ int osym, dmgtyp;
quan = obj->quan; quan = obj->quan;
switch(osym) { switch(osym) {
case POTION_CLASS: case POTION_CLASS:
dindx = 1; dindx = (obj->otyp != POT_OIL) ? 1 : 2;
tmp++; tmp++;
break; break;
case SCROLL_CLASS: case SCROLL_CLASS:
dindx = 2; dindx = 3;
tmp++; tmp++;
break; break;
case SPBOOK_CLASS: case SPBOOK_CLASS:
dindx = 3; dindx = 4;
tmp++; tmp++;
break; break;
default: default:
@@ -4336,11 +4348,11 @@ int osym, dmgtyp;
case RING_CLASS: case RING_CLASS:
if(obj->otyp == RIN_SHOCK_RESISTANCE) if(obj->otyp == RIN_SHOCK_RESISTANCE)
{ skip++; break; } { skip++; break; }
dindx = 4; dindx = 5;
break; break;
case WAND_CLASS: case WAND_CLASS:
if(obj->otyp == WAN_LIGHTNING) { skip++; break; } if(obj->otyp == WAN_LIGHTNING) { skip++; break; }
dindx = 5; dindx = 6;
tmp++; tmp++;
break; break;
default: default:
@@ -4358,8 +4370,7 @@ int osym, dmgtyp;
if(!cnt) continue; if(!cnt) continue;
if (vis) pline("%s %s!", yname(obj), if (vis) pline("%s %s!", yname(obj),
(cnt > 1L) ? destroy_strings[dindx*3 + 1] destroy_strings[dindx][(cnt > 1L)]);
: destroy_strings[dindx*3]);
for(i = 0; i < cnt; i++) m_useup(mtmp, obj); for(i = 0; i < cnt; i++) m_useup(mtmp, obj);
} }
} }