MCPcopy Create free account
hub / github.com/NetHack/NetHack / start_tin

Function start_tin

src/eat.c:1722–1797  ·  view source on GitHub ↗

called when starting to open a tin */

Source from the content-addressed store, hash-verified

1720
1721/* called when starting to open a tin */
1722staticfn void
1723start_tin(struct obj *otmp)
1724{
1725 const char *mesg = 0;
1726 int tmp;
1727
1728 if (metallivorous(gy.youmonst.data)) {
1729 mesg = "You bite right into the metal tin...";
1730 tmp = 0;
1731 } else if (cantwield(gy.youmonst.data)) { /* nohands || verysmall */
1732 You("cannot handle the tin properly to open it.");
1733 return;
1734 } else if (otmp->blessed) {
1735 /* 50/50 chance for immediate access vs 1 turn delay (unless
1736 wielding blessed tin opener which always yields immediate
1737 access); 1 turn delay case is non-deterministic: getting
1738 interrupted and retrying might yield another 1 turn delay
1739 or might open immediately on 2nd (or 3rd, 4th, ...) try */
1740 tmp = (uwep && uwep->blessed && uwep->otyp == TIN_OPENER) ? 0
1741 : rn2(2);
1742 if (!tmp)
1743 mesg = "The tin opens like magic!";
1744 else
1745 pline_The("tin seems easy to open.");
1746 } else if (uwep) {
1747 switch (uwep->otyp) {
1748 case TIN_OPENER:
1749 mesg = "You easily open the tin."; /* iff tmp==0 */
1750 tmp = rn2(uwep->cursed ? 3 : !uwep->blessed ? 2 : 1);
1751 break;
1752 case DAGGER:
1753 case SILVER_DAGGER:
1754 case ELVEN_DAGGER:
1755 case ORCISH_DAGGER:
1756 case ATHAME:
1757 case KNIFE:
1758 case STILETTO:
1759 case CRYSKNIFE:
1760 tmp = 3;
1761 break;
1762 case PICK_AXE:
1763 case AXE:
1764 tmp = 6;
1765 break;
1766 default:
1767 goto no_opener;
1768 }
1769 pline("Using %s you try to open the tin.", yobjnam(uwep, (char *) 0));
1770 } else {
1771 no_opener:
1772 pline("It is not so easy to open this tin.");
1773 if (Glib) {
1774 pline_The("tin slips from your %s.", fingers_or_gloves(FALSE));
1775 if (otmp->quan > 1L) {
1776 otmp = splitobj(otmp, 1L);
1777 }
1778 if (carried(otmp))
1779 dropx(otmp);

Callers 2

doeatFunction · 0.85
use_tin_openerFunction · 0.85

Calls 11

YouFunction · 0.85
rn2Function · 0.85
pline_TheFunction · 0.85
yobjnamFunction · 0.85
fingers_or_glovesFunction · 0.85
splitobjFunction · 0.85
dropxFunction · 0.85
stackobjFunction · 0.85
consume_tinFunction · 0.85
set_occupationFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected