NetHack Community Patches (or Variation) Included
-------------------------------------------------
+Malcolm Ryan's improved tin opener
Code Cleanup and Reorganization
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));
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;
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.
*/
&& (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--;