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

Function weapon_status

src/botl.c:480–555  ·  view source on GitHub ↗

weapon description for status lines; started as a terser version of what ^X shows but has diverged to some extent */

Source from the content-addressed store, hash-verified

478/* weapon description for status lines; started as a terser version of
479 what ^X shows but has diverged to some extent */
480char *
481weapon_status(char *outbuf)
482{
483 const char *res = 0;
484
485 *outbuf = '\0'; /* lint suppression */
486 if (!uwep) {
487 /* no weapon; gloves imply hands; humanoid also implies hands;
488 otherwise make no assumptions */
489 res = uarmg ? "Empty-hnd" /* empty handed means "gloves only" */
490 : humanoid(gy.youmonst.data) ? "Bare-hnds" /* bare hands */
491 : "No-weapon";
492 } else if (u.twoweap) {
493 /* two-weaponing implies hands and a weapon or wep-tool
494 (not other odd stuff) in each hand */
495 res = "Dual-weps";
496 /* note: dual wielding two lances doesn't produce double joust */
497 if (u.usteed && (weapon_type(uwep) == P_LANCE
498 || weapon_type(uswapwep) == P_LANCE))
499 res = "Dual+joust"; /* lance behaves specially when mounted */
500 } else {
501 /* report most weapons by their skill class (so a katana will be
502 described as a long sword, for instance; mattock and hook are
503 exceptions), or wielded non-weapon item by its object class */
504 char *p;
505 int skill = weapon_type(uwep);
506
507 if (u.usteed && skill == P_LANCE) {
508 /* lance behaves specially when hero is mounted */
509 res = "joust";
510 } else if (uwep->otyp == AKLYS) {
511 /* aklys behaves specially when thrown while wielded, so
512 give it a distinct name instead of skill name of "club";
513 [maybe FIXME?] for the time being
514 use real name even if 'obj' is undiscovered "thonged club" */
515 res = "aklys";
516 } else if (is_sword(uwep)) {
517 /* simplify short short/broad sword/long sword/two-handed sword
518 (similar to messages when dropped due to slippery fingers) */
519 res = "sword";
520 } else {
521 /* shorten several */
522 switch (skill) {
523 case P_QUARTERSTAFF:
524 res = "staff";
525 break;
526 case P_MORNING_STAR:
527 res = "mrng-star"; /* still pretty long */
528 break;
529 case P_POLEARMS:
530 res = "pole";
531 break;
532 case P_UNICORN_HORN:
533 res = "unihorn";
534 break;
535 default:
536 res = weapon_descr(uwep);
537 /* [should this be moved into weapon_descr()?] */

Callers 1

botl.cFile · 0.85

Calls 6

weapon_typeFunction · 0.85
weapon_descrFunction · 0.85
eosFunction · 0.85
highcFunction · 0.85
strNsubstFunction · 0.85
strncmpiFunction · 0.70

Tested by

no test coverage detected