loot a container on the floor or loot saddle from mon. */
| 2175 | |
| 2176 | /* loot a container on the floor or loot saddle from mon. */ |
| 2177 | staticfn int |
| 2178 | doloot_core(void) |
| 2179 | { |
| 2180 | struct obj *cobj, *nobj; |
| 2181 | int c = -1; |
| 2182 | int timepassed = 0; |
| 2183 | coord cc; |
| 2184 | boolean underfoot = TRUE; |
| 2185 | const char *dont_find_anything = "don't find anything"; |
| 2186 | struct monst *mtmp; |
| 2187 | int prev_inquiry = 0; |
| 2188 | boolean prev_loot = FALSE; |
| 2189 | int num_conts = 0; |
| 2190 | int clr = NO_COLOR; |
| 2191 | |
| 2192 | ga.abort_looting = FALSE; |
| 2193 | |
| 2194 | if (check_capacity((char *) 0)) { |
| 2195 | /* "Can't do that while carrying so much stuff." */ |
| 2196 | return ECMD_OK; |
| 2197 | } |
| 2198 | if (nohands(gy.youmonst.data)) { |
| 2199 | You("have no hands!"); /* not `body_part(HAND)' */ |
| 2200 | return ECMD_OK; |
| 2201 | } |
| 2202 | if (Confusion) { |
| 2203 | if (rn2(6) && reverse_loot()) |
| 2204 | return ECMD_TIME; |
| 2205 | if (rn2(2)) { |
| 2206 | pline("Being confused, you find nothing to loot."); |
| 2207 | return ECMD_TIME; /* costs a turn */ |
| 2208 | } /* else fallthrough to normal looting */ |
| 2209 | } |
| 2210 | cc.x = u.ux; |
| 2211 | cc.y = u.uy; |
| 2212 | |
| 2213 | if (iflags.menu_requested) |
| 2214 | goto lootmon; |
| 2215 | |
| 2216 | lootcont: |
| 2217 | if ((num_conts = container_at(cc.x, cc.y, TRUE)) > 0) { |
| 2218 | boolean anyfound = FALSE; |
| 2219 | |
| 2220 | if (!able_to_loot(cc.x, cc.y, TRUE)) |
| 2221 | return ECMD_OK; |
| 2222 | |
| 2223 | if (Blind && !uarmg) { |
| 2224 | /* if blind and without gloves, attempting to #loot at the |
| 2225 | location of a cockatrice corpse is fatal before asking |
| 2226 | whether to manipulate any containers */ |
| 2227 | for (nobj = sobj_at(CORPSE, cc.x, cc.y); nobj; |
| 2228 | nobj = nxtobj(nobj, CORPSE, TRUE)) |
| 2229 | if (will_feel_cockatrice(nobj, FALSE)) { |
| 2230 | feel_cockatrice(nobj, FALSE); |
| 2231 | /* if life-saved (or poly'd into stone golem), |
| 2232 | terminate attempt to loot */ |
| 2233 | return ECMD_TIME; |
| 2234 | } |
no test coverage detected