static void drop_weapon(int alone) { struct obj *otmp; struct obj *otmp2; if ((otmp = uwep) != 0) { /* !alone check below is currently superfluous but in the * future it might not be so if there are monsters which cannot * wear gloves but can wield weapons */ if (!alone || cantwield(youmonst.data)) { struct obj *wep = uwep; if (alone) pline("You find you must drop your weapon%s!", u.twoweap ? "s" : ""); otmp2 = u.twoweap ? uswapwep : 0; uwepgone(); if (!wep->cursed || wep->otyp != LOADSTONE) dropx(otmp); if (otmp2 != 0) { uswapwepgone(); if (!otmp2->cursed || otmp2->otyp != LOADSTONE) dropx(otmp2); } untwoweapon(); } else if (!could_twoweap(youmonst.data)) { untwoweapon(); } } }
struct obj *oname(struct obj *obj, const char *name) { int lth; char buf[PL_PSIZ]; lth = *name ? (int)(strlen(name) + 1) : 0; if (lth > PL_PSIZ) { lth = PL_PSIZ; name = strncpy(buf, name, PL_PSIZ - 1); buf[PL_PSIZ - 1] = '\0'; } /* If named artifact exists in the game, do not create another. * Also trying to create an artifact shouldn't de-artifact * it (e.g. Excalibur from prayer). In this case the object * will retain its current name. */ if (obj->oartifact || (lth && exist_artifact(obj->otyp, name))) return obj; if (lth == obj->onamelth) { /* no need to replace entire object */ if (lth) strcpy(ONAME(obj), name); } else { obj = realloc_obj(obj, obj->oxlth, obj->oextra, lth, name); } if (lth) artifact_exists(obj, name, TRUE); if (obj->oartifact) { /* can't dual-wield with artifact as secondary weapon */ if (obj == uswapwep) untwoweapon(); /* activate warning if you've just named your weapon "Sting" */ if (obj == uwep) set_artifact_intrinsic(obj, TRUE, W_WEP); } if (carried(obj)) update_inventory(); return obj; }
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; }
struct obj * oname(struct obj *obj, const char *name) { int lth; lth = *name ? (int)(strlen(name) + 1) : 0; /* If named artifact exists in the game, do not create another. Also trying to create an artifact shouldn't de-artifact it (e.g. Excalibur from prayer). In this case the object will retain its current name. */ if (obj->oartifact || (lth && exist_artifact(obj->otyp, name))) return obj; christen_obj(obj, name); if (lth) artifact_exists(obj, name, TRUE); if (obj->oartifact) { /* can't dual-wield with artifact as secondary weapon */ if (obj == uswapwep) untwoweapon(); } if (carried(obj)) update_inventory(); return obj; }
/* make a (new) human out of the player */ static void polyman(const char *fmt, const char *arg) { boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow, was_mimicking = (youmonst.m_ap_type == M_AP_OBJECT); boolean could_pass_walls = Passes_walls; boolean was_blind = !!Blind; if (Upolyd) { u.acurr = u.macurr; /* restore old attribs */ u.amax = u.mamax; u.umonnum = u.umonster; flags.female = u.mfemale; } set_uasmon(); u.mh = u.mhmax = 0; u.mtimedone = 0; skinback(FALSE); u.uundetected = 0; if (sticky) uunstick(); find_ac(); if (was_mimicking) { if (multi < 0) unmul(""); youmonst.m_ap_type = M_AP_NOTHING; } newsym(u.ux,u.uy); pline(fmt, arg); /* check whether player foolishly genocided self while poly'd */ if ((mvitals[urole.malenum].mvflags & G_GENOD) || (urole.femalenum != NON_PM && (mvitals[urole.femalenum].mvflags & G_GENOD)) || (mvitals[urace.malenum].mvflags & G_GENOD) || (urace.femalenum != NON_PM && (mvitals[urace.femalenum].mvflags & G_GENOD))) { /* intervening activity might have clobbered genocide info */ killer = delayed_killer; if (!killer || !strstri(killer, "genocid")) { killer_format = KILLED_BY; killer = "self-genocide"; } done(GENOCIDED); } if (u.twoweap && !could_twoweap(youmonst.data)) untwoweapon(); if (u.utraptype == TT_PIT) { if (could_pass_walls) { /* player forms cannot pass walls */ u.utrap = rn1(6,2); } } if (was_blind && !Blind) { /* reverting from eyeless */ Blinded = 1L; make_blinded(0L, TRUE); /* remove blindness */ } if (!Levitation && !u.ustuck && (is_pool(level, u.ux,u.uy) || is_lava(level, u.ux,u.uy))) spoteffects(TRUE); see_monsters(); }
/* (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; }