MCPcopy Index your code
hub / github.com/NetHack/NetHack / doapply

Function doapply

src/apply.c:4213–4425  ·  view source on GitHub ↗

the #apply command, 'a' */

Source from the content-addressed store, hash-verified

4211
4212/* the #apply command, 'a' */
4213int
4214doapply(void)
4215{
4216 struct obj *obj;
4217 int res = ECMD_TIME;
4218
4219 if (nohands(gy.youmonst.data)) {
4220 You("aren't able to use or apply tools in your current form.");
4221 return ECMD_OK;
4222 }
4223 if (check_capacity((char *) 0))
4224 return ECMD_OK;
4225
4226 obj = getobj("use or apply", apply_ok, GETOBJ_NOFLAGS);
4227 if (!obj)
4228 return ECMD_CANCEL;
4229
4230 if (!retouch_object(&obj, FALSE))
4231 return ECMD_TIME; /* evading your grasp costs a turn; just be
4232 grateful that you don't drop it as well */
4233
4234 if (obj->oclass == WAND_CLASS)
4235 return do_break_wand(obj);
4236
4237 if (obj->oclass == SPBOOK_CLASS)
4238 return flip_through_book(obj);
4239
4240 if (obj->oclass == COIN_CLASS)
4241 return flip_coin(obj);
4242
4243 switch (obj->otyp) {
4244 case BLINDFOLD:
4245 case LENSES:
4246 if (obj == ublindf) {
4247 if (!cursed(obj))
4248 Blindf_off(obj);
4249 } else if (!ublindf) {
4250 Blindf_on(obj);
4251 } else {
4252 You("are already %s.",
4253 (ublindf->otyp == TOWEL) ? "covered by a towel"
4254 : (ublindf->otyp == BLINDFOLD) ? "wearing a blindfold"
4255 : "wearing lenses");
4256 }
4257 break;
4258 case CREAM_PIE:
4259 res = use_cream_pie(obj);
4260 obj = (struct obj *) 0;
4261 break;
4262 case LUMP_OF_ROYAL_JELLY:
4263 res = use_royal_jelly(&obj);
4264 break;
4265 case BULLWHIP:
4266 res = use_whip(obj);
4267 break;
4268 case GRAPPLING_HOOK:
4269 res = use_grapple(obj);
4270 break;

Callers

nothing calls this directly

Calls 15

YouFunction · 0.85
check_capacityFunction · 0.85
getobjFunction · 0.85
retouch_objectFunction · 0.85
do_break_wandFunction · 0.85
flip_through_bookFunction · 0.85
flip_coinFunction · 0.85
cursedFunction · 0.85
Blindf_offFunction · 0.85
Blindf_onFunction · 0.85
use_cream_pieFunction · 0.85
use_royal_jellyFunction · 0.85

Tested by

no test coverage detected