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

Function use_saddle

src/steed.c:35–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35int
36use_saddle(struct obj *otmp)
37{
38 struct monst *mtmp;
39 struct permonst *ptr;
40 int chance;
41
42 if (!u_handsy())
43 return ECMD_OK;
44
45 /* Select an animal */
46 if (u.uswallow || Underwater || !getdir((char *) 0)) {
47 pline1(Never_mind);
48 return ECMD_CANCEL;
49 }
50 if (!u.dx && !u.dy) {
51 pline("Saddle yourself? Very funny...");
52 return ECMD_OK;
53 }
54 if (!isok(u.ux + u.dx, u.uy + u.dy)
55 || !(mtmp = m_at(u.ux + u.dx, u.uy + u.dy)) || !canspotmon(mtmp)) {
56 pline("I see nobody there.");
57 return ECMD_TIME;
58 }
59
60 /* Is this a valid monster? */
61 if ((mtmp->misc_worn_check & W_SADDLE) != 0L
62 || which_armor(mtmp, W_SADDLE)) {
63 pline("%s doesn't need another one.", Monnam(mtmp));
64 return ECMD_TIME;
65 }
66 ptr = mtmp->data;
67 if (touch_petrifies(ptr) && !uarmg && !Stone_resistance) {
68 char kbuf[BUFSZ];
69
70 You("touch %s.", mon_nam(mtmp));
71 if (!(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) {
72 Sprintf(kbuf, "attempting to saddle %s",
73 an(pmname(mtmp->data, Mgender(mtmp))));
74 instapetrify(kbuf);
75 }
76 }
77 if (ptr == &mons[PM_AMOROUS_DEMON]) {
78 pline("Shame on you!");
79 exercise(A_WIS, FALSE);
80 return ECMD_TIME;
81 }
82 if (mtmp->isminion || mtmp->isshk || mtmp->ispriest || mtmp->isgd
83 || mtmp->iswiz) {
84 pline("I think %s would mind.", mon_nam(mtmp));
85 return ECMD_TIME;
86 }
87 if (!can_saddle(mtmp)) {
88 You_cant("saddle such a creature.");
89 return ECMD_TIME;
90 }
91
92 /* Calculate your chance */

Callers 1

doapplyFunction · 0.85

Calls 15

u_handsyFunction · 0.85
getdirFunction · 0.85
isokFunction · 0.85
which_armorFunction · 0.85
MonnamFunction · 0.85
YouFunction · 0.85
mon_namFunction · 0.85
poly_when_stonedFunction · 0.85
polymonFunction · 0.85
anFunction · 0.85
pmnameFunction · 0.85
MgenderFunction · 0.85

Tested by

no test coverage detected