void ballfall() { boolean gets_hit; gets_hit = (((uball->ox != u.ux) || (uball->oy != u.uy)) && ((uwep == uball)? FALSE : (boolean)rn2(5))); if (carried(uball)) { pline("Startled, you drop the iron ball."); if (uwep == uball) setuwep((struct obj *)0); if (uswapwep == uball) setuswapwep((struct obj *)0); if (uquiver == uball) setuqwep((struct obj *)0);; if (uwep != uball) freeinv(uball); } if(gets_hit){ int dmg = rn1(7,25); pline_The("iron ball falls on your %s.", body_part(HEAD)); if (uarmh) { if(is_metallic(uarmh)) { pline("Fortunately, you are wearing a hard helmet."); dmg = 3; } else if (flags.verbose) Your("%s does not protect you.", xname(uarmh)); } losehp(dmg, "crunched in the head by an iron ball", NO_KILLER_PREFIX); } }
/* Unwields all weapons silently. */ void unwield_weapons_silently(void) { setuwep(NULL); setuswapwep(NULL); setuqwep(NULL); u.twoweap = FALSE; }
int dowield(struct obj *wep) { struct obj *oldwep; int result; /* May we attempt this? */ multi = 0; if (cantwield(youmonst.data)) { pline("Don't be ridiculous!"); return 0; } /* Prompt for a new weapon */ if (wep && !validate_object(wep, wield_objs, "wield")) return 0; else if (!wep) wep = getobj(wield_objs, "wield"); if (!wep) /* Cancelled */ return 0; else if (wep == uwep) { pline("You are already wielding that!"); if (is_weptool(wep)) unweapon = FALSE; /* [see setuwep()] */ return 0; } else if (welded(uwep)) { weldmsg(uwep); /* previously interrupted armor removal mustn't be resumed */ reset_remarm(); return 0; } /* Handle no object, or object in other slot */ if (wep == &zeroobj) wep = NULL; else if (wep == uswapwep) return doswapweapon(); else if (wep == uquiver) setuqwep(NULL); else if (wep->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) { pline("You cannot wield that!"); return 0; } /* Set your new primary weapon */ oldwep = uwep; result = ready_weapon(wep); if (flags.pushweapon && oldwep && uwep != oldwep) setuswapwep(oldwep); untwoweapon(); return result; }
/* (moved from apply.c) */ boolean wield_tool(struct obj *obj, const char *verb) /* "rub",&c */ { const char *what; boolean more_than_1; if (obj == uwep) return TRUE; /* nothing to do if already wielding it */ if (!verb) verb = "wield"; what = xname(obj); more_than_1 = (obj->quan > 1L || strstri(what, "pair of ") != 0 || strstri(what, "s of ") != 0); if (obj->owornmask & (W_ARMOR|W_RING|W_AMUL|W_TOOL)) { char yourbuf[BUFSZ]; pline("You can't %s %s %s while wearing %s.", verb, shk_your(yourbuf, obj), what, more_than_1 ? "them" : "it"); return FALSE; } if (welded(uwep)) { if (flags.verbose) { const char *hand = body_part(HAND); if (bimanual(uwep)) hand = makeplural(hand); if (strstri(what, "pair of ") != 0) more_than_1 = FALSE; pline( "Since your weapon is welded to your %s, you cannot %s %s %s.", hand, verb, more_than_1 ? "those" : "that", xname(obj)); } else { pline("You can't do that."); } return FALSE; } if (cantwield(youmonst.data)) { pline("You can't hold %s strongly enough.", more_than_1 ? "them" : "it"); return FALSE; } /* check shield */ if (uarms && bimanual(obj)) { pline("You cannot %s a two-handed %s while wearing a shield.", verb, (obj->oclass == WEAPON_CLASS) ? "weapon" : "tool"); return FALSE; } if (uquiver == obj) setuqwep(NULL); if (uswapwep == obj) { doswapweapon(); /* doswapweapon might fail */ if (uswapwep == obj) return FALSE; } else { pline("You now wield %s.", doname(obj)); setuwep(obj); } if (uwep != obj) return FALSE; /* rewielded old object after dying */ /* applying weapon or tool that gets wielded ends two-weapon combat */ if (u.twoweap) untwoweapon(); if (obj->oclass != WEAPON_CLASS) unweapon = TRUE; return TRUE; }
int dowieldquiver(struct obj *newquiver) { const char *quivee_types = (uslinging() || (uswapwep && objects[uswapwep->otyp].oc_skill == P_SLING)) ? bullets : ready_objs; /* Since the quiver isn't in your hands, don't check cantwield(), */ /* will_weld(), touch_petrifies(), etc. */ multi = 0; if (newquiver && !validate_object(newquiver, quivee_types, "ready")) return 0; else if (!newquiver) /* Prompt for a new quiver */ newquiver = getobj(quivee_types, "ready"); if (!newquiver) /* Cancelled */ return 0; /* Handle no object, or object in other slot */ /* Any type is okay, since we give no intrinsics anyways */ if (newquiver == &zeroobj) { /* Explicitly nothing */ if (uquiver) { pline("You now have no ammunition readied."); setuqwep(newquiver = NULL); } else { pline("You already have no ammunition readied!"); return 0; } } else if (newquiver == uquiver) { pline("That ammunition is already readied!"); return 0; } else if (newquiver == uwep) { /* Prevent accidentally readying the main weapon */ pline("%s already being used as a weapon!", !is_plural(uwep) ? "That is" : "They are"); return 0; } else if (newquiver->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) { pline("You cannot ready that!"); return 0; } else { long dummy; /* Check if it's the secondary weapon */ if (newquiver == uswapwep) { setuswapwep(NULL); untwoweapon(); } /* Okay to put in quiver; print it */ dummy = newquiver->owornmask; newquiver->owornmask |= W_QUIVER; prinv(NULL, newquiver, 0L); newquiver->owornmask = dummy; } /* Finally, place it in the quiver */ setuqwep(newquiver); /* Take no time since this is a convenience slot */ return 0; }