| 166 | } |
| 167 | |
| 168 | staticfn int |
| 169 | ready_weapon(struct obj *wep) |
| 170 | { |
| 171 | /* Separated function so swapping works easily */ |
| 172 | int res = ECMD_OK; |
| 173 | boolean was_twoweap = u.twoweap, had_wep = (uwep != 0); |
| 174 | |
| 175 | if (!wep) { |
| 176 | /* No weapon */ |
| 177 | if (uwep) { |
| 178 | You("are %s.", empty_handed()); |
| 179 | setuwep((struct obj *) 0); |
| 180 | res = ECMD_TIME; |
| 181 | } else |
| 182 | You("are already %s.", empty_handed()); |
| 183 | } else if (wep->otyp == CORPSE && cant_wield_corpse(wep)) { |
| 184 | /* hero must have been life-saved to get here; use a turn */ |
| 185 | res = ECMD_TIME; /* corpse won't be wielded */ |
| 186 | } else if (uarms && bimanual(wep)) { |
| 187 | You("cannot wield a two-handed %s while wearing a shield.", |
| 188 | is_sword(wep) ? "sword" : wep->otyp == BATTLE_AXE ? "axe" |
| 189 | : "weapon"); |
| 190 | res = ECMD_FAIL; |
| 191 | } else if (!retouch_object(&wep, FALSE)) { |
| 192 | res = ECMD_TIME; /* takes a turn even though it doesn't get wielded */ |
| 193 | } else { |
| 194 | /* Weapon WILL be wielded after this point */ |
| 195 | res = ECMD_TIME; |
| 196 | if (will_weld(wep)) { |
| 197 | const char *tmp = xname(wep), *thestr = "The "; |
| 198 | |
| 199 | if (strncmp(tmp, thestr, 4) && !strncmp(The(tmp), thestr, 4)) |
| 200 | tmp = thestr; |
| 201 | else |
| 202 | tmp = ""; |
| 203 | pline("%s%s %s to your %s%s!", tmp, aobjnam(wep, "weld"), |
| 204 | (wep->quan == 1L) ? "itself" : "themselves", /* a3 */ |
| 205 | bimanual(wep) ? "" : |
| 206 | (URIGHTY ? "dominant right " : "dominant left "), |
| 207 | bimanual(wep) ? (const char *) makeplural(body_part(HAND)) |
| 208 | : body_part(HAND)); |
| 209 | set_bknown(wep, 1); |
| 210 | } else { |
| 211 | /* The message must be printed before setuwep (since |
| 212 | * you might die and be revived from changing weapons), |
| 213 | * and the message must be before the death message and |
| 214 | * Lifesaved rewielding. Yet we want the message to |
| 215 | * say "weapon in hand", thus this kludge. |
| 216 | * [That comment is obsolete. It dates from the days (3.0) |
| 217 | * when unwielding Firebrand could cause hero to be burned |
| 218 | * to death in Hell due to loss of fire resistance. |
| 219 | * "Lifesaved re-wielding or re-wearing" is ancient history.] |
| 220 | */ |
| 221 | long dummy = wep->owornmask; |
| 222 | |
| 223 | wep->owornmask |= W_WEP; |
| 224 | if (wep->otyp == AKLYS && (wep->owornmask & W_WEP) != 0) |
| 225 | You("secure the tether."); |
no test coverage detected