the #fire command -- throw from the quiver or use wielded polearm */
| 466 | |
| 467 | /* the #fire command -- throw from the quiver or use wielded polearm */ |
| 468 | int |
| 469 | dofire(void) |
| 470 | { |
| 471 | int shotlimit; |
| 472 | struct obj *obj; |
| 473 | /* AutoReturn() verifies Valkyrie if weapon is Mjollnir, but it relies |
| 474 | on its caller to make sure hero is strong enough to throw that */ |
| 475 | boolean uwep_Throw_and_Return = (uwep && AutoReturn(uwep, uwep->owornmask) |
| 476 | && (uwep->oartifact != ART_MJOLLNIR |
| 477 | || ACURR(A_STR) >= STR19(25))), |
| 478 | skip_fireassist = FALSE; |
| 479 | int altres, res = ECMD_OK; |
| 480 | |
| 481 | /* |
| 482 | * Same as dothrow(), except we use quivered missile instead |
| 483 | * of asking what to throw/shoot. [Note: with the advent of |
| 484 | * fireassist that is no longer accurate...] |
| 485 | * |
| 486 | * If hero is wielding a thrown-and-return weapon and quiver |
| 487 | * is empty or contains ammo, use the wielded weapon (won't |
| 488 | * have any ammo's launcher wielded due to the weapon). |
| 489 | * If quiver is empty, use autoquiver to fill it when the |
| 490 | * corresponding option is on. |
| 491 | * If option is off or autoquiver doesn't select anything, |
| 492 | * we ask what to throw. |
| 493 | * Then we put the chosen item into the quiver slot unless |
| 494 | * it is already in another slot. [Matters most if it is a |
| 495 | * stack but also matters for single item if this throw gets |
| 496 | * aborted (ESC at the direction prompt).] |
| 497 | */ |
| 498 | if (!ok_to_throw(&shotlimit)) |
| 499 | return ECMD_OK; |
| 500 | |
| 501 | obj = uquiver; |
| 502 | /* if wielding a throw-and-return weapon, throw it if quiver is empty |
| 503 | or has ammo rather than missiles [since the throw/return weapon is |
| 504 | wielded, the ammo's launcher isn't; the ammo-only policy avoids |
| 505 | throwing Mjollnir if quiver contains daggers] */ |
| 506 | if (uwep_Throw_and_Return && (!obj || is_ammo(obj))) { |
| 507 | obj = uwep; |
| 508 | skip_fireassist = TRUE; |
| 509 | |
| 510 | } else if (!obj) { |
| 511 | if (!flags.autoquiver) { |
| 512 | /* if we're wielding a polearm, apply it */ |
| 513 | if (uwep && is_pole(uwep)) { |
| 514 | return use_pole(uwep, TRUE); |
| 515 | /* if we're wielding a bullwhip, apply it */ |
| 516 | } else if (uwep && uwep->otyp == BULLWHIP) { |
| 517 | return use_whip(uwep); |
| 518 | } else if (iflags.fireassist |
| 519 | && uswapwep && is_pole(uswapwep) |
| 520 | && !(uswapwep->cursed && uswapwep->bknown)) { |
| 521 | /* we have a known not-cursed polearm as swap weapon. |
| 522 | swap to it and retry */ |
| 523 | cmdq_add_ec(CQ_CANNED, doswapweapon); |
| 524 | cmdq_add_ec(CQ_CANNED, dofire); |
| 525 | return ECMD_OK; /* haven't taken any time yet */ |
nothing calls this directly
no test coverage detected