int dothrow() { register struct obj *obj; if(check_capacity(NULL)) return(0); obj = getobj(toss_objs, "throw"); /* it is also possible to throw food */ /* (or jewels, or iron balls... ) */ if(!obj || !getdir(NULL)) { /* ask "in what direction?" */ if (obj && obj->oclass == GOLD_CLASS) { u.ugold += obj->quan; flags.botl = 1; dealloc_obj(obj); } return(0); } if(obj->oclass == GOLD_CLASS) return(throw_gold(obj)); if(!canletgo(obj,"throw")) return(0); if (obj->oartifact == ART_MJOLLNIR && obj != uwep) { You("must be wielding %s in order to throw it.", xname(obj)); return(0); } if ((obj->oartifact == ART_MJOLLNIR && ACURR(A_STR) != 125) || (obj->otyp == BOULDER #ifdef POLYSELF && !throws_rocks(uasmon) #endif )) { pline("It's too heavy."); return(1); } if(!u.dx && !u.dy && !u.dz) { You("cannot throw an object at yourself."); return(0); } u_wipe_engr(2); if(obj == uwep) { if(welded(obj)) { weldmsg(obj, FALSE); return(1); } if(obj->quan > 1L) setuwep(splitobj(obj, 1L)); else { setuwep((struct obj *)0); if (uwep) return(1); /* unwielded, died, rewielded */ } } else if(obj->quan > 1L) (void) splitobj(obj, 1L); freeinv(obj); return(throwit(obj)); }
/* * freehand - returns true if player has a free hand */ int freehand(void) { return(!uwep || !welded(uwep) || (!bimanual(uwep) && (!uarms || !uarms->cursed))); /* if ((uwep && bimanual(uwep)) || (uwep && uarms)) return 0; else return 1;*/ }
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 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; }
/* (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; }