weapon's skill category name for use as generalized description of weapon; mostly used to shorten "you drop your " messages when slippery fingers or polymorph causes hero to involuntarily drop wielded weapon(s) */
| 87 | mostly used to shorten "you drop your <weapon>" messages when slippery |
| 88 | fingers or polymorph causes hero to involuntarily drop wielded weapon(s) */ |
| 89 | const char * |
| 90 | weapon_descr(struct obj *obj) |
| 91 | { |
| 92 | int skill = weapon_type(obj); |
| 93 | const char *descr = P_NAME(skill); |
| 94 | |
| 95 | /* assorted special cases */ |
| 96 | switch (skill) { |
| 97 | case P_NONE: |
| 98 | /* not a weapon or weptool: use item class name; |
| 99 | override class name for things where it sounds strange and |
| 100 | for things that aren't unexpected to find being wielded: |
| 101 | corpses, tins, eggs, and globs avoid "food", |
| 102 | statues and boulders avoid "large rock", |
| 103 | and towels and tin openers avoid "tool" */ |
| 104 | descr = (obj->otyp == CORPSE || obj->otyp == TIN || obj->otyp == EGG |
| 105 | || obj->otyp == STATUE || obj->otyp == BOULDER |
| 106 | || obj->otyp == TOWEL || obj->otyp == TIN_OPENER) |
| 107 | ? OBJ_NAME(objects[obj->otyp]) |
| 108 | : obj->globby ? "glob" |
| 109 | : def_oc_syms[(int) obj->oclass].name; |
| 110 | break; |
| 111 | case P_SLING: |
| 112 | if (is_ammo(obj)) |
| 113 | descr = (obj->otyp == ROCK || is_graystone(obj)) |
| 114 | ? "stone" |
| 115 | /* avoid "rock"; what about known glass? */ |
| 116 | : (obj->oclass == GEM_CLASS) |
| 117 | ? "gem" |
| 118 | /* in case somebody adds odd sling ammo */ |
| 119 | : def_oc_syms[(int) obj->oclass].name; |
| 120 | break; |
| 121 | case P_BOW: |
| 122 | if (is_ammo(obj)) |
| 123 | descr = "arrow"; |
| 124 | break; |
| 125 | case P_CROSSBOW: |
| 126 | if (is_ammo(obj)) |
| 127 | descr = "bolt"; |
| 128 | break; |
| 129 | case P_FLAIL: |
| 130 | if (obj->otyp == GRAPPLING_HOOK) |
| 131 | descr = "hook"; |
| 132 | break; |
| 133 | case P_PICK_AXE: |
| 134 | /* even if "dwarvish mattock" hasn't been discovered yet */ |
| 135 | if (obj->otyp == DWARVISH_MATTOCK) |
| 136 | descr = "mattock"; |
| 137 | break; |
| 138 | default: |
| 139 | break; |
| 140 | } |
| 141 | return makesingular(descr); |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | * hitval returns an integer representing the "to hit" bonuses |
no test coverage detected