Improve the tin opener

This commit is contained in:
Pasi Kallinen
2015-12-19 14:44:39 +02:00
parent a5c63af579
commit 43bf9c978d
5 changed files with 33 additions and 12 deletions

View File

@@ -76,6 +76,7 @@ Platform- and/or Interface-Specific New Features
NetHack Community Patches (or Variation) Included
-------------------------------------------------
Malcolm Ryan's improved tin opener
Code Cleanup and Reorganization

View File

@@ -604,6 +604,7 @@ E void NDECL(init_uhunger);
E int NDECL(Hear_again);
E void NDECL(reset_eat);
E int NDECL(doeat);
E int FDECL(use_tin_opener, (struct obj *));
E void NDECL(gethungry);
E void FDECL(morehungry, (int));
E void FDECL(lesshungry, (int));

View File

@@ -3494,18 +3494,8 @@ doapply()
res = dowrite(obj);
break;
case TIN_OPENER:
if (!carrying(TIN)) {
You("have no tin to open.");
goto xit;
}
You("cannot open a tin without eating or discarding its contents.");
if (flags.verbose)
pline("In order to eat, use the 'e' command.");
if (obj != uwep)
pline(
"Opening the tin will be much easier if you wield the tin opener.");
goto xit;
res = use_tin_opener(obj);
break;
case FIGURINE:
use_figurine(&obj);
break;

View File

@@ -2579,6 +2579,34 @@ doeat()
return 1;
}
int
use_tin_opener(obj)
register struct obj *obj;
{
register struct obj *otmp;
int res = 0;
if (!carrying(TIN)) {
You("have no tin to open.");
return 0;
}
if (obj != uwep) {
if (obj->cursed && obj->bknown) {
char qbuf[QBUFSZ];
(void) safe_qbuf(qbuf, "Really wield ", "?", obj, doname, ansimpleoname, "that");
if (ynq(qbuf) != 'y') return 0;
}
if (!wield_tool(obj, "use")) return 0;
else res = 1;
}
otmp = getobj((const char *)comestibles, "open");
if (!otmp) return 0;
start_tin(otmp);
return(1);
}
/* Take a single bite from a piece of food, checking for choking and
* modifying usedtime. Returns 1 if they choked and survived, 0 otherwise.
*/

View File

@@ -1099,6 +1099,7 @@ register const char *let, *word;
&& (otmp->otyp != HORN_OF_PLENTY || !otmp->dknown
|| !objects[HORN_OF_PLENTY].oc_name_known))
|| (!strcmp(word, "charge") && !is_chargeable(otmp))
|| (!strcmp(word, "open") && otyp != TIN)
|| (!strcmp(word, "call") && !objtyp_is_callable(otyp))
) {
foo--;