Skip to content

Commit 6ab108b

Browse files
author
Alex Smith
committed
ID charge count when the player would know it (including on light sources)
Ignore-this: e300df317d157c5fe9aa78316b55a8d8 darcs-hash:20110103140727-b78f9-a5660d84cc92d4807d23514c72f2001bd7634bd9
1 parent 6cdb009 commit 6ab108b

File tree

6 files changed

+75
-25
lines changed

6 files changed

+75
-25
lines changed

doc/fixes36.0

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ changed to 10 to prevent this leaking information that isn't readily
298298
available in vanilla NetHack. (Credits: this feature was inspired by
299299
Vulture's, although AceHack uses different code.)
300300

301+
Formally identifying light sources, or seeing them flicker, now makes
302+
their remaining burn time visible (much like charges on formally
303+
identified wands). Likewise, attempting to zap an empty wand marks it
304+
as empty, and scrolls of charging also identify the number of charges
305+
in the thing they charge (as a side-effect).
306+
301307
Platform- and/or Interface-Specific New Features
302308
------------------------------------------------
303309

src/objects.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ OBJECT(OBJ("Amulet of Yendor", /* note: description == name */
581581
BITS(kn,mrg,chg,0,mgc,chg,0,0,0,0,0,P_NONE,mat), \
582582
0, TOOL_CLASS, prob, 0, \
583583
wt, cost, 0, 0, 0, 0, wt, color, mc )
584+
#define LIGHTSOURCE(name,desc,kn,mrg,mgc,chg,prob,wt,cost,mat,color,mc) \
585+
OBJECT( OBJ(name,desc), \
586+
BITS(kn,mrg,1,0,mgc,chg,0,0,0,0,0,P_NONE,mat), \
587+
0, TOOL_CLASS, prob, 0, \
588+
wt, cost, 0, 0, 0, 0, wt, color, mc )
584589
#define CONTAINER(name,desc,kn,mgc,chg,prob,wt,cost,mat,color) \
585590
OBJECT( OBJ(name,desc), \
586591
BITS(kn,0,chg,1,mgc,chg,0,0,0,0,0,P_NONE,mat), \
@@ -614,16 +619,16 @@ TOOL("lock pick", (char *)0, 1, 0, 0, 0, 75, 4, 20, IRON, HI_METAL,
614619
MCLASS_INANIMATE),
615620
#endif
616621
/* light sources */
617-
TOOL("tallow candle", "candle", 0, 1, 0, 0, 20, 2, 10, WAX, CLR_WHITE,
618-
MCLASS_DIVINATION),
619-
TOOL("wax candle", "candle", 0, 1, 0, 0, 5, 2, 20, WAX, CLR_WHITE,
620-
MCLASS_DIVINATION),
621-
TOOL("brass lantern", (char *)0,1, 0, 0, 0, 30, 30, 12, COPPER, CLR_YELLOW,
622-
MCLASS_DIVINATION),
623-
TOOL("oil lamp", "lamp", 0, 0, 0, 0, 45, 20, 10, COPPER, CLR_YELLOW,
624-
MCLASS_DIVINATION),
622+
LIGHTSOURCE("tallow candle", "candle", 0, 1, 0, 0, 20, 2, 10, WAX, CLR_WHITE,
623+
MCLASS_DIVINATION),
624+
LIGHTSOURCE("wax candle", "candle", 0, 1, 0, 0, 5, 2, 20, WAX, CLR_WHITE,
625+
MCLASS_DIVINATION),
626+
LIGHTSOURCE("brass lantern", (char *)0,1, 0, 0, 0, 30, 30, 12, COPPER, CLR_YELLOW,
627+
MCLASS_DIVINATION),
628+
LIGHTSOURCE("oil lamp", "lamp", 0, 0, 0, 0, 45, 20, 10, COPPER, CLR_YELLOW,
629+
MCLASS_DIVINATION),
625630
TOOL("magic lamp", "lamp", 0, 0, 1, 0, 15, 20, 50, COPPER, CLR_YELLOW,
626-
MCLASS_DIVINATION),
631+
MCLASS_DIVINATION), /* TOOL not LIGHTSOURCE as it never runs out */
627632
/* other tools */
628633
#ifdef TOURIST
629634
TOOL("expensive camera", (char *)0,

src/objnam.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,17 +777,29 @@ boolean with_weight;
777777
Sprintf(eos(bp), " (%s candle%s%s)",
778778
tmpbuf, plur(obj->spe),
779779
!obj->lamplit ? " attached" : ", lit");
780-
break;
781780
} else if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP ||
782781
obj->otyp == BRASS_LANTERN || Is_candle(obj)) {
783782
if (Is_candle(obj) &&
784783
obj->age < 20L * (long)objects[obj->otyp].oc_cost)
785784
Strcat(prefix, "partly used ");
786785
if(obj->lamplit)
787786
Strcat(bp, " (lit)");
788-
break;
789787
}
790-
if(objects[obj->otyp].oc_charged)
788+
if (ignitable(obj) && obj->known &&
789+
obj->otyp != MAGIC_LAMP && !artifact_light(obj)) {
790+
/* We need to stop and restart the timer to
791+
get the exact number of turns remaining. */
792+
boolean waslit = obj->lamplit;
793+
/* without turning off the light source itself... */
794+
obj->lamplit = 0;
795+
if (waslit)
796+
stop_timer(BURN_OBJECT, (genericptr_t) obj);
797+
Sprintf(eos(bp), " (%d:%ld)", (int)obj->recharged,
798+
obj->age); /* not spe! */
799+
if (waslit) begin_burn(obj, TRUE);
800+
break;
801+
}
802+
if (objects[obj->otyp].oc_charged)
791803
goto charges;
792804
break;
793805
case WAND_CLASS:

src/read.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SCCS Id: @(#)read.c 3.4 2003/10/22 */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3-
/* Modified 8 Aug 2010 by Alex Smith */
3+
/* Modified 3 Jan 2011 by Alex Smith */
44
/* NetHack may be freely redistributed. See license for details. */
55

66
#include "hack.h"
@@ -201,8 +201,13 @@ struct obj *obj;
201201
(obj->known || objects[obj->otyp].oc_uname));
202202
if (is_weptool(obj)) /* specific check before general tools */
203203
return FALSE;
204+
/* magic lamps aren't actually chargeable, /but/ must be shown
205+
in the list to avoid accidentally IDing them */
204206
if (obj->oclass == TOOL_CLASS)
205-
return (boolean)(objects[obj->otyp].oc_charged);
207+
return (boolean)(objects[obj->otyp].oc_charged ||
208+
obj->otyp == BRASS_LANTERN ||
209+
obj->otyp == OIL_LAMP ||
210+
obj->otyp == MAGIC_LAMP);
206211
return FALSE; /* why are weapons/armor considered charged anyway? */
207212
}
208213

@@ -221,6 +226,10 @@ int curse_bless;
221226
is_cursed = curse_bless < 0;
222227
is_blessed = curse_bless > 0;
223228

229+
/* Scrolls of charging now ID charge count, as well as doing
230+
the charging, unless cursed. */
231+
if (!is_cursed) obj->known = 1;
232+
224233
if (obj->oclass == WAND_CLASS) {
225234
/* undo any prior cancellation, even when is_cursed */
226235
if (obj->spe == -1) obj->spe = 0;
@@ -298,11 +307,10 @@ int curse_bless;
298307
} else if (obj->oclass == TOOL_CLASS) {
299308
int rechrg = (int)obj->recharged;
300309

301-
if (objects[obj->otyp].oc_charged) {
302-
/* tools don't have a limit, but the counter used does */
303-
if (rechrg < 7) /* recharge_limit */
304-
obj->recharged++;
305-
}
310+
/* tools don't have a limit, but the counter used does */
311+
if (rechrg < 7) /* recharge_limit */
312+
obj->recharged++;
313+
306314
switch(obj->otyp) {
307315
case BELL_OF_OPENING:
308316
if (is_cursed) stripspe(obj);

src/timeout.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SCCS Id: @(#)timeout.c 3.4 2002/12/17 */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3-
/* Modified 8 Aug 2010 by Alex Smith */
3+
/* Modified 3 Jan 2011 by Alex Smith */
44
/* NetHack may be freely redistributed. See license for details. */
55

66
#include "hack.h"
@@ -712,7 +712,10 @@ const char *tailer;
712712
case OBJ_FLOOR:
713713
You("see %s flicker%s.", an(xname(obj)), tailer);
714714
break;
715+
default:
716+
return;
715717
}
718+
obj->known = 1; /* ID charge count */
716719
}
717720

718721
/* Print a dimming message for brass lanterns. */
@@ -734,7 +737,10 @@ struct obj *obj;
734737
pline("%s lantern is getting dim.",
735738
s_suffix(Monnam(obj->ocarry)));
736739
break;
740+
default:
741+
return;
737742
}
743+
obj->known = 1; /* ID charge count */
738744
}
739745

740746
/*
@@ -836,10 +842,12 @@ long timeout;
836842
case OBJ_MINVENT:
837843
pline("%s %s seems about to go out.",
838844
whose, xname(obj));
845+
obj->known = 1;
839846
break;
840847
case OBJ_FLOOR:
841848
You("see %s about to go out.",
842849
an(xname(obj)));
850+
obj->known = 1;
843851
break;
844852
}
845853
}
@@ -858,13 +866,15 @@ long timeout;
858866
else
859867
pline("%s %s has gone out.",
860868
whose, xname(obj));
869+
obj->known = 1;
861870
break;
862871
case OBJ_FLOOR:
863872
if (obj->otyp == BRASS_LANTERN)
864873
You("see a lantern run out of power.");
865874
else
866875
You("see %s go out.",
867876
an(xname(obj)));
877+
obj->known = 1;
868878
break;
869879
}
870880
}
@@ -898,12 +908,14 @@ long timeout;
898908
whose,
899909
menorah ? "candelabrum's " : "",
900910
many ? "s are" : " is");
911+
obj->known = 1;
901912
break;
902913
case OBJ_FLOOR:
903914
You("see %scandle%s getting short.",
904915
menorah ? "a candelabrum's " :
905916
many ? "some " : "a ",
906917
many ? "s" : "");
918+
obj->known = 1;
907919
break;
908920
}
909921
break;
@@ -920,13 +932,15 @@ long timeout;
920932
many ? "s'" : "'s",
921933
many ? "s" : "",
922934
many ? "" : "s");
935+
obj->known = 1;
923936
break;
924937
case OBJ_FLOOR:
925938
You("see %scandle%s flame%s flicker low!",
926939
menorah ? "a candelabrum's " :
927940
many ? "some " : "a ",
928941
many ? "s'" : "'s",
929942
many ? "s" : "");
943+
obj->known = 1;
930944
break;
931945
}
932946
break;
@@ -941,7 +955,7 @@ long timeout;
941955
pline("%s candelabrum's flame%s.",
942956
whose,
943957
many ? "s die" : " dies");
944-
break;
958+
break;
945959
case OBJ_FLOOR:
946960
You("see a candelabrum's flame%s die.",
947961
many ? "s" : "");
@@ -1169,7 +1183,9 @@ cleanup_burn(arg, expire_time)
11691183
{
11701184
struct obj *obj = (struct obj *)arg;
11711185
if (!obj->lamplit) {
1172-
impossible("cleanup_burn: obj %s not lit", xname(obj));
1186+
/* This happens when updating charge count for inventory
1187+
purposes. We don't turn the light source off in that case. */
1188+
obj->age += expire_time - monstermoves;
11731189
return;
11741190
}
11751191

src/zap.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SCCS Id: @(#)zap.c 3.4 2003/08/24 */
22
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3-
/* Modified 23 Dec 2010 by Alex Smith */
3+
/* Modified 3 Jan 2011 by Alex Smith */
44
/* NetHack may be freely redistributed. See license for details. */
55

66
#include "hack.h"
@@ -1765,8 +1765,11 @@ int
17651765
zappable(wand)
17661766
register struct obj *wand;
17671767
{
1768-
if(wand->spe < 0 || (wand->spe == 0 && rn2(121)))
1768+
if(wand->spe < 0 || (wand->spe == 0 && rn2(121))) {
1769+
You("feel an absence of magical power.");
1770+
wand->known = 1; /* show it as :0 */
17691771
return 0;
1772+
}
17701773
if(wand->spe == 0)
17711774
You("wrest one last charge from the worn-out wand.");
17721775
wand->spe--;
@@ -1848,7 +1851,7 @@ dozap()
18481851
check_unpaid(obj);
18491852

18501853
/* zappable addition done by GAN 11/03/86 */
1851-
if(!zappable(obj)) pline("%s",nothing_happens);
1854+
if(!zappable(obj)) {} /* zappable now prints the message itself */
18521855
else if(obj->cursed && !rn2(100)) {
18531856
backfire(obj); /* the wand blows up in your face! */
18541857
exercise(A_STR, FALSE);

0 commit comments

Comments
 (0)