/* Wear the best object of each type that the monster has. During creation, * the monster can put everything on at once; otherwise, wearing takes time. * This doesn't affect monster searching for objects--a monster may very well * search for objects it would not want to wear, because we don't want to * check which_armor() each round. * * We'll let monsters put on shirts and/or suits under worn cloaks, but * not shirts under worn suits. This is somewhat arbitrary, but it's * too tedious to have them remove and later replace outer garments, * and preventing suits under cloaks makes it a little bit too easy for * players to influence what gets worn. Putting on a shirt underneath * already worn body armor is too obviously buggy... */ void m_dowear(struct monst *mon, boolean creation) { #define RACE_EXCEPTION TRUE /* Note the restrictions here are the same as in dowear in do_wear.c * except for the additional restriction on intelligence. (Players * are always intelligent, even if polymorphed). */ if (verysmall(mon->data) || nohands(mon->data) || is_animal(mon->data)) return; /* give mummies a chance to wear their wrappings * and let skeletons wear their initial armor */ if (mindless(mon->data) && (!creation || (mon->data->mlet != S_MUMMY && mon->data != &mons[PM_SKELETON]))) return; m_dowear_type(mon, W_AMUL, creation, FALSE); /* can't put on shirt if already wearing suit */ if (!cantweararm(mon->data) || (mon->misc_worn_check & W_ARM)) m_dowear_type(mon, W_ARMU, creation, FALSE); /* treating small as a special case allows hobbits, gnomes, and kobolds to wear cloaks */ if (!cantweararm(mon->data) || mon->data->msize == MZ_SMALL) m_dowear_type(mon, W_ARMC, creation, FALSE); m_dowear_type(mon, W_ARMH, creation, FALSE); if (!MON_WEP(mon) || !bimanual(MON_WEP(mon))) m_dowear_type(mon, W_ARMS, creation, FALSE); m_dowear_type(mon, W_ARMG, creation, FALSE); if (!slithy(mon->data) && mon->data->mlet != S_CENTAUR) m_dowear_type(mon, W_ARMF, creation, FALSE); if (!cantweararm(mon->data)) m_dowear_type(mon, W_ARM, creation, FALSE); else m_dowear_type(mon, W_ARM, creation, RACE_EXCEPTION); }
void curse(register struct obj *otmp) { #ifdef GOLDOBJ if (otmp->oclass == COIN_CLASS) return; #endif otmp->blessed = 0; otmp->cursed = 1; /* welded two-handed weapon interferes with some armor removal */ if (otmp == uwep && bimanual(uwep)) reset_remarm(); /* rules at top of wield.c state that twoweapon cannot be done with cursed alternate weapon */ if (otmp == uswapwep && u.twoweap) drop_uswapwep(); /* some cursed items need immediate updating */ if (carried(otmp) && confers_luck(otmp)) set_moreluck(); else if (otmp->otyp == BAG_OF_HOLDING) otmp->owt = weight(otmp); else if (otmp->otyp == FIGURINE) { if (otmp->corpsenm != NON_PM && !dead_species(otmp->corpsenm,TRUE) && (carried(otmp) || mcarried(otmp))) attach_fig_transform_timeout(otmp); } return; }
/* * 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 can_twoweapon(void) { struct obj *otmp; #define NOT_WEAPON(obj) (!is_weptool(obj) && obj->oclass != WEAPON_CLASS) if (!could_twoweap(youmonst.data)) { if (Upolyd) pline("You can't use two weapons in your current form."); else pline("%s aren't able to use two weapons at once.", makeplural((flags.female && urole.name.f) ? urole.name.f : urole.name.m)); } else if (!uwep || !uswapwep) pline("Your %s%s%s empty.", uwep ? "left " : uswapwep ? "right " : "", body_part(HAND), (!uwep && !uswapwep) ? "s are" : " is"); else if (NOT_WEAPON(uwep) || NOT_WEAPON(uswapwep)) { otmp = NOT_WEAPON(uwep) ? uwep : uswapwep; pline("%s %s.", Yname2(otmp), is_plural(otmp) ? "aren't weapons" : "isn't a weapon"); } else if (bimanual(uwep) || bimanual(uswapwep)) { otmp = bimanual(uwep) ? uwep : uswapwep; pline("%s isn't one-handed.", Yname2(otmp)); } else if (uarms) pline("You can't use two weapons while wearing a shield."); else if (uswapwep->oartifact) pline("%s %s being held second to another weapon!", Yname2(uswapwep), otense(uswapwep, "resist")); else if (!uarmg && !Stone_resistance && (uswapwep->otyp == CORPSE && touch_petrifies(&mons[uswapwep->corpsenm]))) { char kbuf[BUFSZ]; pline("You wield the %s corpse with your bare %s.", mons[uswapwep->corpsenm].mname, body_part(HAND)); sprintf(kbuf, "%s corpse", an(mons[uswapwep->corpsenm].mname)); instapetrify(kbuf); } else if (Glib || uswapwep->cursed) { if (!Glib) uswapwep->bknown = TRUE; drop_uswapwep(); } else return TRUE; return FALSE; }
void weldmsg(struct obj *obj) { long savewornmask; savewornmask = obj->owornmask; pline("Your %s %s welded to your %s!", xname(obj), otense(obj, "are"), bimanual(obj) ? (const char *)makeplural(body_part(HAND)) : body_part(HAND)); obj->owornmask = savewornmask; }
/* * See if this armor is better than what we're wearing. */ static boolean is_better_armor(struct monst *mtmp, struct obj *otmp) { struct obj *obj; struct obj *best = (struct obj *)0; if (otmp->oclass != ARMOR_CLASS) return FALSE; if (mtmp->data == &mons[PM_KI_RIN] || mtmp->data == &mons[PM_COUATL]) return FALSE; if (cantweararm(mtmp->data) && !(is_cloak(otmp) && mtmp->data->msize == MZ_SMALL)) return FALSE; if (is_shirt(otmp) && (mtmp->misc_worn_check & W_ARM)) return FALSE; if (is_shield(otmp) && (mtmp == &youmonst) ? (uwep && bimanual(uwep)) : (MON_WEP(mtmp) && bimanual(MON_WEP(mtmp)))) return FALSE; if (is_gloves(otmp) && nohands(mtmp->data)) return FALSE; if (is_boots(otmp) && (slithy(mtmp->data) || mtmp->data->mlet == S_CENTAUR)) return FALSE; if (is_helmet(otmp) && !is_flimsy(otmp) && num_horns(mtmp->data) > 0) return FALSE; obj = (mtmp == &youmonst) ? invent : mtmp->minvent; for (; obj; obj = obj->nobj) { if (is_cloak(otmp) && !is_cloak(obj)) continue; if (is_suit(otmp) && !is_suit(obj)) continue; if (is_shirt(otmp) && !is_shirt(obj)) continue; if (is_boots(otmp) && !is_boots(obj)) continue; if (is_shield(otmp) && !is_shield(obj)) continue; if (is_helmet(otmp) && !is_helmet(obj)) continue; if (is_gloves(otmp) && !is_gloves(obj)) continue; if (!obj->owornmask) continue; if (best && (ARM_BONUS(obj) + extra_pref(mtmp, obj) >= ARM_BONUS(best) + extra_pref(mtmp, best))) best = obj; } return ((best == (struct obj *)0) || (ARM_BONUS(otmp) + extra_pref(mtmp, otmp) > ARM_BONUS(best) + extra_pref(mtmp, best))); }
/* (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; }
static int ready_weapon(struct obj *wep) { /* Separated function so swapping works easily */ int res = 0; if (!wep) { /* No weapon */ if (uwep) { pline("You are empty %s.", body_part(HANDED)); setuwep(NULL); res++; } else pline("You are already empty %s.", body_part(HANDED)); } else if (!uarmg && !Stone_resistance && wep->otyp == CORPSE && touch_petrifies(&mons[wep->corpsenm])) { /* Prevent wielding cockatrice when not wearing gloves --KAA */ char kbuf[BUFSZ]; pline("You wield the %s corpse in your bare %s.", mons[wep->corpsenm].mname, makeplural(body_part(HAND))); sprintf(kbuf, "%s corpse", an(mons[wep->corpsenm].mname)); instapetrify(kbuf); } else if (uarms && bimanual(wep)) pline("You cannot wield a two-handed %s while wearing a shield.", is_sword(wep) ? "sword" : wep->otyp == BATTLE_AXE ? "axe" : "weapon"); else if (wep->oartifact && !touch_artifact(wep, &youmonst)) { res++; /* takes a turn even though it doesn't get wielded */ } else { /* Weapon WILL be wielded after this point */ res++; if (will_weld(wep)) { const char *tmp = xname(wep), *thestr = "The "; if (strncmp(tmp, thestr, 4) && !strncmp(The(tmp),thestr,4)) tmp = thestr; else tmp = ""; pline("%s%s %s to your %s!", tmp, aobjnam(wep, "weld"), (wep->quan == 1L) ? "itself" : "themselves", /* a3 */ bimanual(wep) ? (const char *)makeplural(body_part(HAND)) : body_part(HAND)); wep->bknown = TRUE; } else { /* The message must be printed before setuwep (since * you might die and be revived from changing weapons), * and the message must be before the death message and * Lifesaved rewielding. Yet we want the message to * say "weapon in hand", thus this kludge. */ long dummy = wep->owornmask; wep->owornmask |= W_WEP; prinv(NULL, wep, 0L); wep->owornmask = dummy; } setuwep(wep); /* KMH -- Talking artifacts are finally implemented */ arti_speak(wep); if (artifact_light(wep) && !wep->lamplit) { begin_burn(wep, FALSE); if (!Blind) pline("%s to glow brilliantly!", Tobjnam(wep, "begin")); } if (wep->unpaid) { struct monst *this_shkp; if ((this_shkp = shop_keeper(level, inside_shop(level, u.ux, u.uy))) != NULL) { pline("%s says \"You be careful with my %s!\"", shkname(this_shkp), xname(wep)); } } } return res; }