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 doswapweapon(void) { struct obj *oldwep, *oldswap; int result = 0; /* May we attempt this? */ multi = 0; if (cantwield(youmonst.data)) { pline("Don't be ridiculous!"); return 0; } if (welded(uwep)) { weldmsg(uwep); return 0; } /* Unwield your current secondary weapon */ oldwep = uwep; oldswap = uswapwep; setuswapwep(NULL); /* Set your new primary weapon */ result = ready_weapon(oldswap); /* Set your new secondary weapon */ if (uwep == oldwep) /* Wield failed for some reason */ setuswapwep(oldswap); else { setuswapwep(oldwep); if (uswapwep) prinv(NULL, uswapwep, 0L); else pline("You have no secondary weapon readied."); } if (u.twoweap && !can_twoweapon()) untwoweapon(); return result; }
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; }
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; }