the #wield command - wield a weapon */
| 352 | |
| 353 | /* the #wield command - wield a weapon */ |
| 354 | int |
| 355 | dowield(void) |
| 356 | { |
| 357 | char qbuf[QBUFSZ]; |
| 358 | struct obj *wep, *oldwep; |
| 359 | int result; |
| 360 | |
| 361 | /* May we attempt this? */ |
| 362 | gm.multi = 0; |
| 363 | if (cantwield(gy.youmonst.data)) { |
| 364 | pline("Don't be ridiculous!"); |
| 365 | return ECMD_FAIL; |
| 366 | } |
| 367 | /* Keep going even if inventory is completely empty, since wielding '-' |
| 368 | to wield nothing can be construed as a positive act even when done |
| 369 | so redundantly. */ |
| 370 | |
| 371 | /* Prompt for a new weapon */ |
| 372 | clear_splitobjs(); |
| 373 | if (!(wep = getobj("wield", wield_ok, GETOBJ_PROMPT | GETOBJ_ALLOWCNT))) { |
| 374 | /* Cancelled */ |
| 375 | return ECMD_CANCEL; |
| 376 | } else if (wep == uwep) { |
| 377 | already_wielded: |
| 378 | You("are already wielding that!"); |
| 379 | if (is_weptool(wep) || is_wet_towel(wep)) |
| 380 | gu.unweapon = FALSE; /* [see setuwep()] */ |
| 381 | return ECMD_FAIL; |
| 382 | } else if (welded(uwep)) { |
| 383 | weldmsg(uwep); |
| 384 | /* previously interrupted armor removal mustn't be resumed */ |
| 385 | reset_remarm(); |
| 386 | /* if player chose a partial stack but can't wield it, undo split */ |
| 387 | if (wep->o_id && wep->o_id == svc.context.objsplit.child_oid) |
| 388 | unsplitobj(wep); |
| 389 | return ECMD_FAIL; |
| 390 | } else if (wep->o_id && wep->o_id == svc.context.objsplit.child_oid) { |
| 391 | /* if wep is the result of supplying a count to getobj() |
| 392 | we don't want to split something already wielded; for |
| 393 | any other item, we need to give it its own inventory slot */ |
| 394 | if (uwep && uwep->o_id == svc.context.objsplit.parent_oid) { |
| 395 | unsplitobj(wep); |
| 396 | /* wep was merged back to uwep, already_wielded uses wep */ |
| 397 | wep = uwep; |
| 398 | goto already_wielded; |
| 399 | } |
| 400 | finish_splitting(wep); |
| 401 | goto wielding; |
| 402 | } |
| 403 | |
| 404 | /* Handle no object, or object in other slot */ |
| 405 | if (wep == &hands_obj) { |
| 406 | wep = (struct obj *) 0; |
| 407 | } else if (wep == uswapwep) { |
| 408 | return doswapweapon(); |
| 409 | } else if (wep == uquiver) { |
| 410 | /* offer to split stack if multiple are quivered */ |
| 411 | if (uquiver->quan > 1L && inv_cnt(FALSE) < invlet_basic |
nothing calls this directly
no test coverage detected