MCPcopy Create free account
hub / github.com/NetHack/NetHack / can_twoweapon

Function can_twoweapon

src/wield.c:760–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758}
759
760int
761can_twoweapon(void)
762{
763 struct obj *otmp;
764
765 if (!could_twoweap(gy.youmonst.data)) {
766 if (Upolyd)
767 You_cant("use two weapons in your current form.");
768 else
769 pline("%s aren't able to use two weapons at once.",
770 makeplural((flags.female && gu.urole.name.f)
771 ? gu.urole.name.f : gu.urole.name.m));
772 } else if (!uwep || !uswapwep) {
773 const char *hand_s = body_part(HAND);
774
775 if (!uwep && !uswapwep)
776 hand_s = makeplural(hand_s);
777 /* "your hands are empty" or "your {left|right} hand is empty" */
778 Your("%s%s %s empty.", uwep ? "left " : uswapwep ? "right " : "",
779 hand_s, vtense(hand_s, "are"));
780 } else if (!TWOWEAPOK(uwep) || !TWOWEAPOK(uswapwep)) {
781 otmp = !TWOWEAPOK(uwep) ? uwep : uswapwep;
782 pline("%s %s suitable %s weapon%s.", Yname2(otmp),
783 is_plural(otmp) ? "aren't" : "isn't a",
784 (otmp == uwep) ? "primary" : "secondary",
785 plur(otmp->quan));
786 } else if (bimanual(uwep) || bimanual(uswapwep)) {
787 otmp = bimanual(uwep) ? uwep : uswapwep;
788 pline("%s isn't one-handed.", Yname2(otmp));
789 } else if (uarms) {
790 You_cant("use two weapons while wearing a shield.");
791 } else if (uswapwep->oartifact) {
792 pline("%s being held second to another weapon!",
793 Yobjnam2(uswapwep, "resist"));
794 } else if (uswapwep->otyp == CORPSE && cant_wield_corpse(uswapwep)) {
795 /* [Note: !TWOWEAPOK() check prevents ever getting here...] */
796 ; /* must be life-saved to reach here; return FALSE */
797 } else if (Glib || uswapwep->cursed) {
798 if (!Glib)
799 set_bknown(uswapwep, 1);
800 drop_uswapwep();
801 } else
802 return TRUE;
803 return FALSE;
804}
805
806/* uswapwep has become cursed while in two-weapon combat mode or hero is
807 attempting to dual-wield when it is already cursed or hands are slippery */

Callers 3

doswapweaponFunction · 0.85
dotwoweaponFunction · 0.85
do_attackFunction · 0.85

Calls 11

You_cantFunction · 0.85
makepluralFunction · 0.85
body_partFunction · 0.85
YourFunction · 0.85
vtenseFunction · 0.85
Yname2Function · 0.85
Yobjnam2Function · 0.85
cant_wield_corpseFunction · 0.85
set_bknownFunction · 0.85
drop_uswapwepFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected