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

Function doswapweapon

src/wield.c:460–501  ·  view source on GitHub ↗

the #swap command - swap wielded and secondary weapons */

Source from the content-addressed store, hash-verified

458
459/* the #swap command - swap wielded and secondary weapons */
460int
461doswapweapon(void)
462{
463 struct obj *oldwep, *oldswap;
464 int result = 0;
465
466 /* May we attempt this? */
467 gm.multi = 0;
468 if (cantwield(gy.youmonst.data)) {
469 pline("Don't be ridiculous!");
470 return ECMD_FAIL;
471 }
472 if (welded(uwep)) {
473 weldmsg(uwep);
474 return ECMD_FAIL;
475 }
476
477 /* Unwield your current secondary weapon */
478 oldwep = uwep;
479 oldswap = uswapwep;
480 setuswapwep((struct obj *) 0);
481
482 /* Set your new primary weapon */
483 result = ready_weapon(oldswap);
484
485 /* Set your new secondary weapon */
486 if (uwep == oldwep) {
487 /* Wield failed for some reason */
488 setuswapwep(oldswap);
489 } else {
490 setuswapwep(oldwep);
491 if (uswapwep)
492 prinv((char *) 0, uswapwep, 0L);
493 else
494 You("have no secondary weapon readied.");
495 }
496
497 if (u.twoweap && !can_twoweapon())
498 untwoweapon();
499
500 return result;
501}
502
503/* the #quiver command */
504int

Callers 2

dowieldFunction · 0.85
wield_toolFunction · 0.85

Calls 9

weldedFunction · 0.85
weldmsgFunction · 0.85
setuswapwepFunction · 0.85
ready_weaponFunction · 0.85
prinvFunction · 0.85
YouFunction · 0.85
can_twoweaponFunction · 0.85
untwoweaponFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected