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

Function pick_can_reach

src/dig.c:140–165  ·  view source on GitHub ↗

called when attempting to break a statue or boulder with a pick */

Source from the content-addressed store, hash-verified

138
139/* called when attempting to break a statue or boulder with a pick */
140staticfn boolean
141pick_can_reach(struct obj *pick, coordxy x, coordxy y)
142{
143 struct trap *t = t_at(x, y);
144 /* tseen: pit only affects item positioning when it is known */
145 boolean target_in_pit = t && is_pit(t->ttyp) && t->tseen;
146
147 /* if hero is in a pit, pick can only reach if the statue is too and
148 the two pits are conjoined or the statue isn't and pick is two-handed;
149 this applies to hero in pit trying to reach an adjcacent boulder too */
150 if (u.utrap && u.utraptype == TT_PIT) {
151 if (target_in_pit)
152 return conjoined_pits(t, t_at(u.ux, u.uy), FALSE);
153 return bimanual(pick);
154 }
155
156 /* when hero isn't in a pit, a mattock or flying hero w/ pick can reach
157 whether or not the statue is in a pit */
158 if (bimanual(pick) || Flying)
159 return TRUE;
160 /* one-handed pick-axe can reach if statue isn't in a pit */
161 if (!target_in_pit)
162 return TRUE;
163
164 return FALSE;
165}
166
167/* When digging into location <x,y>, what are you actually digging into? */
168int

Callers 1

dig_typFunction · 0.85

Calls 2

t_atFunction · 0.85
conjoined_pitsFunction · 0.85

Tested by

no test coverage detected