guts of #quiver command; also used by #fire when refilling empty quiver */
| 509 | |
| 510 | /* guts of #quiver command; also used by #fire when refilling empty quiver */ |
| 511 | int |
| 512 | doquiver_core(const char *verb) /* "ready" or "fire" */ |
| 513 | { |
| 514 | char qbuf[QBUFSZ]; |
| 515 | struct obj *newquiver; |
| 516 | int res; |
| 517 | boolean was_uwep = FALSE, was_twoweap = u.twoweap; |
| 518 | |
| 519 | /* Since the quiver isn't in your hands, don't check cantwield(), |
| 520 | will_weld(), touch_petrifies(), etc. */ |
| 521 | gm.multi = 0; |
| 522 | if (!gi.invent) { |
| 523 | /* could accept '-' to empty quiver, but there's no point since |
| 524 | inventory is empty so uquiver is already Null */ |
| 525 | You("have nothing to ready for firing."); |
| 526 | return ECMD_OK; |
| 527 | } |
| 528 | |
| 529 | /* forget last splitobj() before calling getobj() with GETOBJ_ALLOWCNT */ |
| 530 | clear_splitobjs(); |
| 531 | /* Prompt for a new quiver: "What do you want to {ready|fire}?" */ |
| 532 | newquiver = getobj(verb, ready_ok, GETOBJ_PROMPT | GETOBJ_ALLOWCNT); |
| 533 | |
| 534 | if (!newquiver) { |
| 535 | /* Cancelled */ |
| 536 | return ECMD_CANCEL; |
| 537 | } else if (newquiver == &hands_obj) { /* no object */ |
| 538 | /* Explicitly nothing */ |
| 539 | if (uquiver) { |
| 540 | You("now have no ammunition readied."); |
| 541 | /* skip 'quivering: prinv()' */ |
| 542 | setuqwep((struct obj *) 0); |
| 543 | } else { |
| 544 | You("already have no ammunition readied!"); |
| 545 | } |
| 546 | return ECMD_OK; |
| 547 | } else if (newquiver->o_id == svc.context.objsplit.child_oid) { |
| 548 | /* if newquiver is the result of supplying a count to getobj() |
| 549 | we don't want to split something already in the quiver; |
| 550 | for any other item, we need to give it its own inventory slot */ |
| 551 | if (uquiver && uquiver->o_id == svc.context.objsplit.parent_oid) { |
| 552 | unsplitobj(newquiver); |
| 553 | goto already_quivered; |
| 554 | } else if (newquiver->oclass == COIN_CLASS) { |
| 555 | /* don't allow splitting a stack of coins into quiver */ |
| 556 | You("can't ready only part of your gold."); |
| 557 | unsplitobj(newquiver); |
| 558 | return ECMD_OK; |
| 559 | } |
| 560 | finish_splitting(newquiver); |
| 561 | } else if (newquiver == uquiver) { |
| 562 | already_quivered: |
| 563 | pline("That ammunition is already readied!"); |
| 564 | return ECMD_OK; |
| 565 | } else if (newquiver->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) { |
| 566 | You("cannot %s that!", verb); |
| 567 | return ECMD_OK; |
| 568 | } else if (newquiver == uwep) { |
no test coverage detected