/* 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); }
const char *surface(int x, int y) { struct rm *loc = &level->locations[x][y]; if ((x == u.ux) && (y == u.uy) && u.uswallow && is_animal(u.ustuck->data)) return "maw"; else if (IS_AIR(loc->typ) && Is_airlevel(&u.uz)) return "air"; else if (is_pool(level, x, y)) return (Underwater && !Is_waterlevel(&u.uz)) ? "bottom" : "water"; else if (is_ice(level, x, y)) return "ice"; else if (is_lava(level, x, y)) return "lava"; else if (loc->typ == DRAWBRIDGE_DOWN) return "bridge"; else if (IS_ALTAR(level->locations[x][y].typ)) return "altar"; else if (IS_GRAVE(level->locations[x][y].typ)) return "headstone"; else if (IS_FOUNTAIN(level->locations[x][y].typ)) return "fountain"; else if ((IS_ROOM(loc->typ) && !Is_earthlevel(&u.uz)) || IS_WALL(loc->typ) || IS_DOOR(loc->typ) || loc->typ == SDOOR) return "floor"; else return "ground"; }
/* release the objects the creature is carrying */ void relobj(struct monst *mtmp, int show, boolean is_pet) { /* If true, pet should keep wielded/worn items */ struct obj *otmp; int omx = mtmp->mx, omy = mtmp->my; struct obj *keepobj = 0; struct obj *wep = MON_WEP(mtmp), *hwep = attacktype(mtmp->data, AT_WEAP) ? select_hwep(mtmp) : (struct obj *)0, *proj = attacktype(mtmp->data, AT_WEAP) ? select_rwep(mtmp) : (struct obj *)0, *rwep; boolean item1 = FALSE, item2 = FALSE; rwep = attacktype(mtmp->data, AT_WEAP) ? propellor : &zeroobj; if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data)) item1 = item2 = TRUE; if (!tunnels(mtmp->data) || !needspick(mtmp->data)) item1 = TRUE; while ((otmp = mtmp->minvent) != 0) { obj_extract_self(otmp); /* special case: pick-axe and unicorn horn are non-worn */ /* items that we also want pets to keep 1 of */ /* (It is a coincidence that these can also be wielded.) */ if (otmp->owornmask || otmp == wep || otmp == hwep || otmp == rwep || otmp == proj || would_prefer_hwep(mtmp, otmp) || /* cursed item in hand? */ would_prefer_rwep(mtmp, otmp) || could_use_item(mtmp, otmp) || ((!rwep || rwep == &zeroobj) && (is_ammo(otmp) || is_launcher(otmp))) || (rwep && rwep != &zeroobj && ammo_and_launcher(otmp, rwep)) || ((!item1 && otmp->otyp == PICK_AXE) || (!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) { if (is_pet) { /* dont drop worn/wielded item */ if (otmp->otyp == PICK_AXE) item1 = TRUE; if (otmp->otyp == UNICORN_HORN && !otmp->cursed) item2 = TRUE; otmp->nobj = keepobj; keepobj = otmp; continue; } } if (otmp == wep) setmnotwielded(mtmp, otmp); mdrop_obj(mtmp, otmp, is_pet && flags.verbose); } /* put kept objects back */ while ((otmp = keepobj) != NULL) { keepobj = otmp->nobj; add_to_minv(mtmp, otmp); } if (show & cansee(omx, omy)) newsym(omx, omy); }
/* * See if a monst could use this item in an offensive or defensive capacity. */ boolean could_use_item(struct monst *mtmp, struct obj *otmp) { boolean can_use = /* make sure this is an intelligent monster */ (mtmp && !is_animal(mtmp->data) && !mindless(mtmp->data) && !nohands(mtmp->data) && otmp && /* food */ ((dogfood(mtmp, otmp) < APPORT) || /* better weapons */ (attacktype(mtmp->data, AT_WEAP) && (otmp->oclass == WEAPON_CLASS || is_weptool(otmp)) && (would_prefer_hwep(mtmp, otmp) || would_prefer_rwep(mtmp, otmp))) || /* better armor */ (otmp->oclass == ARMOR_CLASS && is_better_armor(mtmp, otmp)) || /* useful amulets */ otmp->otyp == AMULET_OF_LIFE_SAVING || otmp->otyp == AMULET_OF_REFLECTION || /* misc magic items that muse can use */ otmp->otyp == SCR_TELEPORTATION || otmp->otyp == SCR_EARTH || otmp->otyp == SCR_REMOVE_CURSE || otmp->otyp == WAN_DEATH || otmp->otyp == WAN_DIGGING || otmp->otyp == WAN_FIRE || otmp->otyp == WAN_COLD || otmp->otyp == WAN_LIGHTNING || otmp->otyp == WAN_MAGIC_MISSILE || otmp->otyp == WAN_STRIKING || otmp->otyp == WAN_TELEPORTATION || otmp->otyp == POT_HEALING || otmp->otyp == POT_EXTRA_HEALING || otmp->otyp == POT_FULL_HEALING || otmp->otyp == POT_PARALYSIS || otmp->otyp == POT_BLINDNESS || otmp->otyp == POT_CONFUSION || otmp->otyp == POT_ACID || otmp->otyp == FROST_HORN || otmp->otyp == FIRE_HORN || otmp->otyp == UNICORN_HORN)); if (can_use) { /* arbitrary - greedy monsters keep any item you can use */ if (likes_gold(mtmp->data)) return TRUE; if (otmp->oclass == ARMOR_CLASS) { return !is_better_armor(&youmonst, otmp); } else if (otmp->oclass == WAND_CLASS && otmp->spe <= 0) return FALSE; /* used charges or was cancelled? */ else { /* Check if you've got one. If you don't, don't hoard it. */ register struct obj *otmp2; for (otmp2 = invent; otmp2; otmp2 = otmp2->nobj) if (otmp->otyp == otmp2->otyp) return TRUE; } } return FALSE; }
/* release the objects the creature is carrying */ // bool is_pet /* If true, pet should keep wielded/worn items */ void relobj ( struct monst *mtmp, int show, bool is_pet) { struct obj *otmp; int omx = mtmp->mx, omy = mtmp->my; struct obj *keepobj = 0; struct obj *wep = MON_WEP(mtmp); bool item1 = false, item2 = false; if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data)) item1 = item2 = true; if (!tunnels(mtmp->data) || !needspick(mtmp->data)) item1 = true; while ((otmp = mtmp->minvent) != 0) { obj_extract_self(otmp); /* special case: pick-axe and unicorn horn are non-worn */ /* items that we also want pets to keep 1 of */ /* (It is a coincidence that these can also be wielded.) */ if (otmp->owornmask || otmp == wep || ((!item1 && otmp->otyp == PICK_AXE) || (!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) { if (is_pet) { /* dont drop worn/wielded item */ if (otmp->otyp == PICK_AXE) item1 = true; if (otmp->otyp == UNICORN_HORN && !otmp->cursed) item2 = true; otmp->nobj = keepobj; keepobj = otmp; continue; } } mdrop_obj(mtmp, otmp, is_pet && flags.verbose); } /* put kept objects back */ while ((otmp = keepobj) != (struct obj *)0) { keepobj = otmp->nobj; (void) add_to_minv(mtmp, otmp); } if (mtmp->mgold) { long g = mtmp->mgold; (void) mkgold(g, omx, omy); if (is_pet && cansee(omx, omy) && flags.verbose) { message_monster_int(MSG_M_DROPS_X_GOLD_PIECES, mtmp, g); } mtmp->mgold = 0L; } if (show & cansee(omx, omy)) newsym(omx, omy); }
/* release the objects the creature is carrying */ void relobj(struct monst *mtmp, int show, boolean is_pet) /* If true, pet should keep wielded/worn items */ { struct obj *otmp; int omx = mtmp->mx, omy = mtmp->my; struct obj *keepobj = 0; struct obj *wep = MON_WEP(mtmp); boolean item1 = FALSE, item2 = FALSE; if (!is_pet || mindless(mtmp->data) || is_animal(mtmp->data)) item1 = item2 = TRUE; if (!tunnels(mtmp->data) || !needspick(mtmp->data)) item1 = TRUE; while ((otmp = mtmp->minvent) != 0) { obj_extract_self(otmp); /* special case: pick-axe and unicorn horn are non-worn */ /* items that we also want pets to keep 1 of */ /* (It is a coincidence that these can also be wielded.) */ if (otmp->owornmask || otmp == wep || ((!item1 && otmp->otyp == PICK_AXE) || (!item2 && otmp->otyp == UNICORN_HORN && !otmp->cursed))) { if (is_pet) { /* dont drop worn/wielded item */ if (otmp->otyp == PICK_AXE) item1 = TRUE; if (otmp->otyp == UNICORN_HORN && !otmp->cursed) item2 = TRUE; otmp->nobj = keepobj; keepobj = otmp; continue; } } mdrop_obj(mtmp, otmp, is_pet && flags.verbose); } /* put kept objects back */ while ((otmp = keepobj) != NULL) { keepobj = otmp->nobj; add_to_minv(mtmp, otmp); } if (show & cansee(omx, omy)) newsym(omx, omy); }
static struct obj * DROPPABLES(struct monst *mon) { struct obj *obj; struct obj *wep = MON_WEP(mon), *hwep = attacktype(mon->data, AT_WEAP) ? select_hwep(mon) : (struct obj *)0, *proj = attacktype(mon->data, AT_WEAP) ? select_rwep(mon) : (struct obj *)0, *rwep; boolean item1 = FALSE, item2 = FALSE; rwep = attacktype(mon->data, AT_WEAP) ? propellor : &zeroobj; if (is_animal(mon->data) || mindless(mon->data)) item1 = item2 = TRUE; if (!tunnels(mon->data) || !needspick(mon->data)) item1 = TRUE; for (obj = mon->minvent; obj; obj = obj->nobj) { if (!item1 && is_pick(obj) && (obj->otyp != DWARVISH_MATTOCK || !which_armor(mon, W_ARMS))) { item1 = TRUE; continue; } if (!item2 && obj->otyp == UNICORN_HORN && !obj->cursed) { item2 = TRUE; continue; } if (!obj->owornmask && obj != wep && obj != rwep && obj != proj && obj != hwep && !would_prefer_hwep(mon, obj) /* cursed item in hand? */ && !would_prefer_rwep(mon, obj) && ((rwep != &zeroobj) || (!is_ammo(obj) && !is_launcher(obj))) && (rwep == &zeroobj || !ammo_and_launcher(obj, rwep)) && !could_use_item(mon, obj)) return obj; } return NULL; }
void dosounds(void) { struct mkroom *sroom; int hallu, vx, vy; struct monst *mtmp; if (!canhear() || Engulfed || Underwater) return; hallu = Hallucination ? 1 : 0; if (has_terrain(level, FOUNTAIN) && !rn2(400)) { static const char *const fountain_msg[4] = { "bubbling water.", "water falling on coins.", "the splashing of a naiad.", "a soda fountain!", }; You_hear("%s", fountain_msg[rn2(3) + hallu]); } if (has_terrain(level, SINK) && !rn2(300)) { static const char *const sink_msg[3] = { "a slow drip.", "a gurgling noise.", "dishes being washed!", }; You_hear("%s", sink_msg[rn2(2) + hallu]); } if (search_special(level, COURT) && !rn2(200)) { static const char *const throne_msg[4] = { "the tones of courtly conversation.", "a sceptre pounded in judgment.", "Someone shouts \"Off with %s head!\"", "Queen Beruthiel's cats!", }; for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((mtmp->msleeping || is_lord(mtmp->data) || is_prince(mtmp->data)) && !is_animal(mtmp->data) && mon_in_room(mtmp, COURT)) { /* finding one is enough, at least for now */ int which = rn2(3) + hallu; if (which != 2) You_hear("%s", throne_msg[which]); else pline(throne_msg[2], uhis()); return; } } } if (search_special(level, SWAMP) && !rn2(200)) { static const char *const swamp_msg[3] = { "You hear mosquitoes!", "You smell marsh gas!", /* so it's a smell... */ "You hear Donald Duck!", }; pline("%s", swamp_msg[rn2(2) + hallu]); return; } if ((sroom = search_special(level, VAULT)) && !rn2(200)) { if (gd_sound()) switch (rn2(2) + hallu) { case 1:{ boolean gold_in_vault = FALSE; for (vx = sroom->lx; vx <= sroom->hx; vx++) for (vy = sroom->ly; vy <= sroom->hy; vy++) if (gold_at(level, vx, vy)) gold_in_vault = TRUE; if (vault_occupied(u.urooms) != (ROOM_INDEX(sroom) + ROOMOFFSET)) { if (gold_in_vault) You_hear(!hallu ? "someone counting money." : "the quarterback calling the play."); else You_hear("someone searching."); break; } /* fall into... (yes, even for hallucination) */ } case 0: You_hear("the footsteps of a guard on patrol."); break; case 2: You_hear("Ebenezer Scrooge!"); break; } return; } if (search_special(level, BEEHIVE) && !rn2(200)) { for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((mtmp->data->mlet == S_ANT && is_flyer(mtmp->data)) && mon_in_room(mtmp, BEEHIVE)) { switch (rn2(2) + hallu) { case 0: You_hear("a low buzzing."); break; case 1: You_hear("an angry drone."); break; case 2: You_hear("bees in your %sbonnet!", uarmh ? "" : "(nonexistent) "); break; } return; } } } if (search_special(level, MORGUE) && !rn2(200)) { for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if (is_undead(mtmp->data) && mon_in_room(mtmp, MORGUE)) { switch (rn2(2) + hallu) { case 1: if (!strcmp(body_part(HAIR), "hair")) { pline("The %s on the back of your %s stands up.", body_part(HAIR), body_part(NECK)); break; } /* fall through */ case 2: if (!strcmp(body_part(HAIR), "hair")) { pline("The %s on your %s seems to stand up.", body_part(HAIR), body_part(HEAD)); break; } /* fall through */ case 0: pline("You suddenly realize it is unnaturally quiet."); break; } return; } } } if (search_special(level, BARRACKS) && !rn2(200)) { static const char *const barracks_msg[4] = { "blades being honed.", "loud snoring.", "dice being thrown.", "General MacArthur!", }; int count = 0; for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if (is_mercenary(mtmp->data) && mon_in_room(mtmp, BARRACKS) && /* sleeping implies not-yet-disturbed (usually) */ (mtmp->msleeping || ++count > 5)) { You_hear("%s", barracks_msg[rn2(3) + hallu]); return; } } } if (search_special(level, ZOO) && !rn2(200)) { static const char *const zoo_msg[3] = { "a sound reminiscent of an elephant stepping on a peanut.", "a sound reminiscent of a seal barking.", "Doctor Dolittle!", }; for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((mtmp->msleeping || is_animal(mtmp->data)) && mon_in_room(mtmp, ZOO)) { You_hear("%s", zoo_msg[rn2(2) + hallu]); return; } } } if ((sroom = search_special(level, ANY_SHOP)) && !rn2(200)) { if (tended_shop(sroom) && !strchr(u.ushops, ROOM_INDEX(sroom) + ROOMOFFSET)) { static const char *const shop_msg[3] = { "someone cursing shoplifters.", "the chime of a cash register.", "Neiman and Marcus arguing!", }; You_hear("%s", shop_msg[rn2(2) + hallu]); } return; } if (search_special(level, DELPHI) && !rn2(400)) { /* make sure the Oracle is still here */ for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) if (!DEADMONSTER(mtmp) && mtmp->data == &mons[PM_POTTER]) break; /* and don't produce silly effects when he's clearly visible */ if (mtmp && (hallu || !canseemon(mtmp))) { static const char *const ora_msg[5] = { "political commentary.", "convulsive ravings about WLAN controllers.", "an Adirondack woodsman.", "someone ask you for your punchcards.", /* if(hallucinating) */ "loud praise for Netgear devices." /* if(hallucinating) */ }; You_hear("%s", ora_msg[rn2(3) + hallu * 2]); } return; } }
int dospinweb(void) { struct trap *ttmp = t_at(level, u.ux, u.uy); if (Levitation || Is_airlevel(&u.uz) || Underwater || Is_waterlevel(&u.uz)) { pline("You must be on the ground to spin a web."); return 0; } if (u.uswallow) { pline("You release web fluid inside %s.", mon_nam(u.ustuck)); if (is_animal(u.ustuck->data)) { expels(u.ustuck, u.ustuck->data, TRUE); return 0; } if (is_whirly(u.ustuck->data)) { int i; for (i = 0; i < NATTK; i++) if (u.ustuck->data->mattk[i].aatyp == AT_ENGL) break; if (i == NATTK) impossible("Swallower has no engulfing attack?"); else { char sweep[30]; sweep[0] = '\0'; switch(u.ustuck->data->mattk[i].adtyp) { case AD_FIRE: strcpy(sweep, "ignites and "); break; case AD_ELEC: strcpy(sweep, "fries and "); break; case AD_COLD: strcpy(sweep, "freezes, shatters and "); break; } pline("The web %sis swept away!", sweep); } return 0; } /* default: a nasty jelly-like creature */ pline("The web dissolves into %s.", mon_nam(u.ustuck)); return 0; } if (u.utrap) { pline("You cannot spin webs while stuck in a trap."); return 0; } exercise(A_DEX, TRUE); if (ttmp) switch (ttmp->ttyp) { case PIT: case SPIKED_PIT: pline("You spin a web, covering up the pit."); deltrap(ttmp); bury_objs(u.ux, u.uy); newsym(u.ux, u.uy); return 1; case SQKY_BOARD: pline("The squeaky board is muffled."); deltrap(ttmp); newsym(u.ux, u.uy); return 1; case TELEP_TRAP: case LEVEL_TELEP: case MAGIC_PORTAL: case VIBRATING_SQUARE: pline("Your webbing vanishes!"); return 0; case WEB: pline("You make the web thicker."); return 1; case HOLE: case TRAPDOOR: pline("You web over the %s.", (ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole"); deltrap(ttmp); newsym(u.ux, u.uy); return 1; case ROLLING_BOULDER_TRAP: pline("You spin a web, jamming the trigger."); deltrap(ttmp); newsym(u.ux, u.uy); return 1; case ARROW_TRAP: case DART_TRAP: case BEAR_TRAP: case ROCKTRAP: case FIRE_TRAP: case LANDMINE: case SLP_GAS_TRAP: case RUST_TRAP: case MAGIC_TRAP: case ANTI_MAGIC: case POLY_TRAP: pline("You have triggered a trap!"); dotrap(ttmp, 0); return 1; default: impossible("Webbing over trap type %d?", ttmp->ttyp); return 0; } else if (On_stairs(u.ux, u.uy)) { /* cop out: don't let them hide the stairs */ pline("Your web fails to impede access to the %s.", (level->locations[u.ux][u.uy].typ == STAIRS) ? "stairs" : "ladder"); return 1; } ttmp = maketrap(level, u.ux, u.uy, WEB); if (ttmp) { ttmp->tseen = 1; ttmp->madeby_u = 1; } newsym(u.ux, u.uy); return 1; }
void dosounds(void) { struct mkroom *sroom; int hallu, vx, vy; struct monst *mtmp; if (!flags.soundok || u.uswallow || Underwater) return; if (level->sounds && !rn2(level->sounds->freq)) { int idx = rn2(level->sounds->n_sounds); char *buf; struct lvl_sound_bite *snd = &level->sounds->sounds[idx]; buf = string_subst(snd->msg); switch (snd->flags) { default: case LVLSND_HEARD: You_hear(buf); break; case LVLSND_PLINED: pline(buf); break; case LVLSND_VERBAL: verbalize(buf); break; case LVLSND_FELT: pline("You feel %s", buf); break; } } hallu = Hallucination ? 1 : 0; if (level->flags.nfountains && !rn2(400)) { static const char * const fountain_msg[4] = { "bubbling water.", "water falling on coins.", "the splashing of a naiad.", "a soda fountain!", }; You_hear(fountain_msg[rn2(3)+hallu]); } if (level->flags.nsinks && !rn2(300)) { static const char * const sink_msg[3] = { "a slow drip.", "a gurgling noise.", "dishes being washed!", }; You_hear(sink_msg[rn2(2)+hallu]); } if (level->flags.has_court && !rn2(200)) { static const char * const throne_msg[4] = { "the tones of courtly conversation.", "a sceptre pounded in judgment.", "Someone shouts \"Off with %s head!\"", "Queen Beruthiel's cats!", }; for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((mtmp->msleeping || is_lord(mtmp->data) || is_prince(mtmp->data)) && !is_animal(mtmp->data) && mon_in_room(mtmp, COURT)) { /* finding one is enough, at least for now */ int which = rn2(3)+hallu; if (which != 2) You_hear(throne_msg[which]); else pline(throne_msg[2], uhis()); return; } } } if (level->flags.has_garden && !rn2(200)) { static const char * const garden_msg[4] = { "crickets chirping.", "birds singing.", "grass growing!", "wind in the willows!", }; You_hear(garden_msg[rn2(2) + 2 * hallu]); return; } if (level->flags.has_swamp && !rn2(200)) { static const char * const swamp_msg[3] = { "You hear mosquitoes!", "You smell marsh gas!", /* so it's a smell...*/ "You hear Donald Duck!", }; pline(swamp_msg[rn2(2)+hallu]); return; } if (level->flags.has_vault && !rn2(200)) { if (!(sroom = search_special(level, VAULT))) { /* strange ... */ level->flags.has_vault = 0; return; } if (gd_sound()) switch (rn2(2)+hallu) { case 1: { boolean gold_in_vault = FALSE; for (vx = sroom->lx;vx <= sroom->hx; vx++) for (vy = sroom->ly; vy <= sroom->hy; vy++) if (gold_at(level, vx, vy)) gold_in_vault = TRUE; if (vault_occupied(u.urooms) != (ROOM_INDEX(sroom) + ROOMOFFSET)) { if (gold_in_vault) You_hear(!hallu ? "someone counting money." : "the quarterback calling the play."); else You_hear("someone searching."); break; } /* fall into... (yes, even for hallucination) */ } case 0: You_hear("the footsteps of a guard on patrol."); break; case 2: You_hear("Ebenezer Scrooge!"); break; } return; } if (level->flags.has_beehive && !rn2(200)) { for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((mtmp->data->mlet == S_ANT && is_flyer(mtmp->data)) && mon_in_room(mtmp, BEEHIVE)) { switch (rn2(2)+hallu) { case 0: You_hear("a low buzzing."); break; case 1: You_hear("an angry drone."); break; case 2: You_hear("bees in your %sbonnet!", uarmh ? "" : "(nonexistent) "); break; } return; } } } if (level->flags.has_lemurepit && !rn2(20)) { for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if (mtmp->data == &mons[PM_LEMURE] && mon_in_room(mtmp, LEMUREPIT)) { if (hallu) { switch (rn2(3)) { case 0: You_hear("screams of lust!"); break; case 1: You_hear("the crack of your mistress's whip!"); break; case 2: You_hear("a weeping willow!"); break; } } else { switch (rn2(6)) { case 0: You_hear("the crack of a barbed whip!"); break; case 1: You_hear("the screams of tortured souls!"); break; case 2: You_hear("a wail of eternal anguish!"); break; case 3: You_hear("diabolical laughter!"); break; case 4: You_hear("cries of repentance!"); break; case 5: You_hear("futile pleas for mercy!"); break; } } return; } } } if (level->flags.has_morgue && !rn2(200)) { for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if (is_undead(mtmp->data) && mon_in_room(mtmp, MORGUE)) { switch (rn2(2)+hallu) { case 1: if (!strcmp(body_part(HAIR), "hair")) { pline("The %s on the back of your %s stands up.", body_part(HAIR), body_part(NECK)); break; } /* fall through */ case 2: if (!strcmp(body_part(HAIR), "hair")) { pline("The %s on your %s seems to stand up.", body_part(HAIR), body_part(HEAD)); break; } /* fall through */ case 0: pline("You suddenly realize it is unnaturally quiet."); break; } return; } } } if (level->flags.has_barracks && !rn2(200)) { static const char * const barracks_msg[4] = { "blades being honed.", "loud snoring.", "dice being thrown.", "General MacArthur!", }; int count = 0; for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if (is_mercenary(mtmp->data) && mon_in_room(mtmp, BARRACKS) && /* sleeping implies not-yet-disturbed (usually) */ (mtmp->msleeping || ++count > 5)) { You_hear(barracks_msg[rn2(3)+hallu]); return; } } } if (level->flags.has_zoo && !rn2(200)) { static const char * const zoo_msg[3] = { "a sound reminiscent of an elephant stepping on a peanut.", "a sound reminiscent of a seal barking.", "Doctor Dolittle!", }; for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((mtmp->msleeping || is_animal(mtmp->data)) && mon_in_room(mtmp, ZOO)) { You_hear(zoo_msg[rn2(2)+hallu]); return; } } } if (level->flags.has_shop && !rn2(200)) { if (!(sroom = search_special(level, ANY_SHOP))) { /* strange... */ level->flags.has_shop = 0; return; } if (tended_shop(sroom) && !strchr(u.ushops, ROOM_INDEX(sroom) + ROOMOFFSET)) { static const char * const shop_msg[3] = { "someone cursing shoplifters.", "the chime of a cash register.", "Neiman and Marcus arguing!", }; You_hear(shop_msg[rn2(2)+hallu]); } return; } if (Is_oracle_level(&u.uz) && !rn2(400)) { /* make sure the Oracle is still here */ for (mtmp = level->monlist; mtmp; mtmp = mtmp->nmon) if (!DEADMONSTER(mtmp) && mtmp->data == &mons[PM_ORACLE]) break; /* and don't produce silly effects when she's clearly visible */ if (mtmp && (hallu || !canseemon(level, mtmp))) { static const char * const ora_msg[5] = { "a strange wind.", /* Jupiter at Dodona */ "convulsive ravings.", /* Apollo at Delphi */ "snoring snakes.", /* AEsculapius at Epidaurus */ "someone say \"No more woodchucks!\"", "a loud ZOT!" /* both rec.humor.oracle */ }; You_hear(ora_msg[rn2(3)+hallu*2]); } return; } if (!Is_blackmarket(&u.uz) && at_dgn_entrance(&u.uz, "One-eyed Sam's Market") && !rn2(200)) { static const char *blkmar_msg[3] = { "You hear someone complaining about the prices.", "Somebody whispers: \"Food rations? Only 900 zorkmids.\"", "You feel like searching for more gold.", }; pline(blkmar_msg[rn2(2)+hallu]); } }
/* return 1 if action took 1 (or more) moves, 0 if error or aborted */ int doengrave(struct obj *otmp) { boolean dengr = FALSE; /* TRUE if we wipe out the current engraving */ boolean doblind = FALSE;/* TRUE if engraving blinds the player */ boolean doknown = FALSE;/* TRUE if we identify the stylus */ boolean eow = FALSE; /* TRUE if we are overwriting oep */ boolean jello = FALSE; /* TRUE if we are engraving in slime */ boolean ptext = TRUE; /* TRUE if we must prompt for engrave text */ boolean teleengr =FALSE;/* TRUE if we move the old engraving */ boolean zapwand = FALSE;/* TRUE if we remove a wand charge */ xchar type = DUST; /* Type of engraving made */ char buf[BUFSZ]; /* Buffer for final/poly engraving text */ char ebuf[BUFSZ]; /* Buffer for initial engraving text */ char qbuf[QBUFSZ]; /* Buffer for query text */ char post_engr_text[BUFSZ]; /* Text displayed after engraving prompt */ const char *everb; /* Present tense of engraving type */ const char *eloc; /* Where the engraving is (ie dust/floor/...) */ char *sp; /* Place holder for space count of engr text */ int len; /* # of nonspace chars of new engraving text */ int maxelen; /* Max allowable length of engraving text */ struct engr *oep = engr_at(level, u.ux,u.uy); /* The current engraving */ char *writer; multi = 0; /* moves consumed */ nomovemsg = NULL; /* occupation end message */ buf[0] = (char)0; ebuf[0] = (char)0; post_engr_text[0] = (char)0; maxelen = BUFSZ - 1; if (is_demon(youmonst.data) || youmonst.data->mlet == S_VAMPIRE) type = ENGR_BLOOD; /* Can the adventurer engrave at all? */ if (u.uswallow) { if (is_animal(u.ustuck->data)) { pline("What would you write? \"Jonah was here\"?"); return 0; } else if (is_whirly(u.ustuck->data)) { pline("You can't reach the %s.", surface(u.ux,u.uy)); return 0; } else jello = TRUE; } else if (is_lava(level, u.ux, u.uy)) { pline("You can't write on the lava!"); return 0; } else if (Underwater) { pline("You can't write underwater!"); return 0; } else if (is_pool(level, u.ux,u.uy) || IS_FOUNTAIN(level->locations[u.ux][u.uy].typ)) { pline("You can't write on the water!"); return 0; } if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)/* in bubble */) { pline("You can't write in thin air!"); return 0; } if (cantwield(youmonst.data)) { pline("You can't even hold anything!"); return 0; } if (check_capacity(NULL)) return 0; /* One may write with finger, or weapon, or wand, or..., or... * Edited by GAN 10/20/86 so as not to change weapon wielded. */ if (otmp && !validate_object(otmp, styluses, "write with")) return 0; else if (!otmp) otmp = getobj(styluses, "write with"); if (!otmp) return 0; /* otmp == zeroobj if fingers */ if (otmp == &zeroobj) writer = makeplural(body_part(FINGER)); else writer = xname(otmp); /* There's no reason you should be able to write with a wand * while both your hands are tied up. */ if (!freehand() && otmp != uwep && !otmp->owornmask) { pline("You have no free %s to write with!", body_part(HAND)); return 0; } if (jello) { pline("You tickle %s with your %s.", mon_nam(u.ustuck), writer); pline("Your message dissolves..."); return 0; } if (otmp->oclass != WAND_CLASS && !can_reach_floor()) { pline("You can't reach the %s!", surface(u.ux,u.uy)); return 0; } if (IS_ALTAR(level->locations[u.ux][u.uy].typ)) { pline("You make a motion towards the altar with your %s.", writer); altar_wrath(u.ux, u.uy); return 0; } if (IS_GRAVE(level->locations[u.ux][u.uy].typ)) { if (otmp == &zeroobj) { /* using only finger */ pline("You would only make a small smudge on the %s.", surface(u.ux, u.uy)); return 0; } else if (!level->locations[u.ux][u.uy].disturbed) { pline("You disturb the undead!"); level->locations[u.ux][u.uy].disturbed = 1; makemon(&mons[PM_GHOUL], level, u.ux, u.uy, NO_MM_FLAGS); exercise(A_WIS, FALSE); return 1; } } /* SPFX for items */ switch (otmp->oclass) { default: case AMULET_CLASS: case CHAIN_CLASS: case POTION_CLASS: case COIN_CLASS: break; case RING_CLASS: /* "diamond" rings and others should work */ case GEM_CLASS: /* diamonds & other hard gems should work */ if (objects[otmp->otyp].oc_tough) { type = ENGRAVE; break; } break; case ARMOR_CLASS: if (is_boots(otmp)) { type = DUST; break; } /* fall through */ /* Objects too large to engrave with */ case BALL_CLASS: case ROCK_CLASS: pline("You can't engrave with such a large object!"); ptext = FALSE; break; /* Objects too silly to engrave with */ case FOOD_CLASS: case SCROLL_CLASS: case SPBOOK_CLASS: pline("Your %s would get %s.", xname(otmp), is_ice(level, u.ux, u.uy) ? "all frosty" : "too dirty"); ptext = FALSE; break; case RANDOM_CLASS: /* This should mean fingers */ break; /* The charge is removed from the wand before prompting for * the engraving text, because all kinds of setup decisions * and pre-engraving messages are based upon knowing what type * of engraving the wand is going to do. Also, the player * will have potentially seen "You wrest .." message, and * therefore will know they are using a charge. */ case WAND_CLASS: if (zappable(otmp)) { check_unpaid(otmp); zapwand = TRUE; if (Levitation) ptext = FALSE; switch (otmp->otyp) { /* DUST wands */ default: break; /* NODIR wands */ case WAN_LIGHT: case WAN_SECRET_DOOR_DETECTION: case WAN_CREATE_MONSTER: case WAN_WISHING: case WAN_ENLIGHTENMENT: zapnodir(otmp); break; /* IMMEDIATE wands */ /* If wand is "IMMEDIATE", remember to affect the * previous engraving even if turning to dust. */ case WAN_STRIKING: strcpy(post_engr_text, "The wand unsuccessfully fights your attempt to write!" ); break; case WAN_SLOW_MONSTER: if (!Blind) { sprintf(post_engr_text, "The bugs on the %s slow down!", surface(u.ux, u.uy)); } break; case WAN_SPEED_MONSTER: if (!Blind) { sprintf(post_engr_text, "The bugs on the %s speed up!", surface(u.ux, u.uy)); } break; case WAN_POLYMORPH: if (oep) { if (!Blind) { type = (xchar)0; /* random */ random_engraving(buf); } dengr = TRUE; } break; case WAN_NOTHING: case WAN_UNDEAD_TURNING: case WAN_OPENING: case WAN_LOCKING: case WAN_PROBING: break; /* RAY wands */ case WAN_MAGIC_MISSILE: ptext = TRUE; if (!Blind) { sprintf(post_engr_text, "The %s is riddled by bullet holes!", surface(u.ux, u.uy)); } break; /* can't tell sleep from death - Eric Backus */ case WAN_SLEEP: case WAN_DEATH: if (!Blind) { sprintf(post_engr_text, "The bugs on the %s stop moving!", surface(u.ux, u.uy)); } break; case WAN_COLD: if (!Blind) strcpy(post_engr_text, "A few ice cubes drop from the wand."); if (!oep || (oep->engr_type != BURN)) break; case WAN_CANCELLATION: case WAN_MAKE_INVISIBLE: if (oep && oep->engr_type != HEADSTONE) { if (!Blind) pline("The engraving on the %s vanishes!", surface(u.ux,u.uy)); dengr = TRUE; } break; case WAN_TELEPORTATION: if (oep && oep->engr_type != HEADSTONE) { if (!Blind) pline("The engraving on the %s vanishes!", surface(u.ux,u.uy)); teleengr = TRUE; } break; /* type = ENGRAVE wands */ case WAN_DIGGING: ptext = TRUE; type = ENGRAVE; if (!objects[otmp->otyp].oc_name_known) { if (flags.verbose) pline("This %s is a wand of digging!", xname(otmp)); doknown = TRUE; } if (!Blind) strcpy(post_engr_text, IS_GRAVE(level->locations[u.ux][u.uy].typ) ? "Chips fly out from the headstone." : is_ice(level, u.ux, u.uy) ? "Ice chips fly up from the ice surface!" : "Gravel flies up from the floor."); else strcpy(post_engr_text, "You hear drilling!"); break; /* type = BURN wands */ case WAN_FIRE: ptext = TRUE; type = BURN; if (!objects[otmp->otyp].oc_name_known) { if (flags.verbose) pline("This %s is a wand of fire!", xname(otmp)); doknown = TRUE; } strcpy(post_engr_text, Blind ? "You feel the wand heat up." : "Flames fly from the wand."); break; case WAN_LIGHTNING: ptext = TRUE; type = BURN; if (!objects[otmp->otyp].oc_name_known) { if (flags.verbose) pline("This %s is a wand of lightning!", xname(otmp)); doknown = TRUE; } if (!Blind) { strcpy(post_engr_text, "Lightning arcs from the wand."); doblind = TRUE; } else strcpy(post_engr_text, "You hear crackling!"); break; /* type = MARK wands */ /* type = ENGR_BLOOD wands */ } } else /* end if zappable */ if (!can_reach_floor()) { pline("You can't reach the %s!", surface(u.ux,u.uy)); /* If it's a wrestable wand, the player wasted a turn trying. */ if (wrestable(otmp)) return 1; else return 0; } break; case WEAPON_CLASS: if (is_blade(otmp)) { if ((int)otmp->spe > -3) type = ENGRAVE; else pline("Your %s too dull for engraving.", aobjnam(otmp,"are")); } break; case TOOL_CLASS: if (otmp == ublindf) { pline( "That is a bit difficult to engrave with, don't you think?"); return 0; } switch (otmp->otyp) { case MAGIC_MARKER: if (otmp->spe <= 0) pline("Your marker has dried out."); else type = MARK; break; case TOWEL: /* Can't really engrave with a towel */ ptext = FALSE; if (oep) if ((oep->engr_type == DUST ) || (oep->engr_type == ENGR_BLOOD) || (oep->engr_type == MARK )) { if (!Blind) pline("You wipe out the message here."); else pline("Your %s %s %s.", xname(otmp), otense(otmp, "get"), is_ice(level, u.ux, u.uy) ? "frosty" : "dusty"); dengr = TRUE; } else pline("Your %s can't wipe out this engraving.", xname(otmp)); else pline("Your %s %s %s.", xname(otmp), otense(otmp, "get"), is_ice(level, u.ux, u.uy) ? "frosty" : "dusty"); break; default: break; } break; case VENOM_CLASS: if (wizard) { pline("Writing a poison pen letter??"); break; } case ILLOBJ_CLASS: impossible("You're engraving with an illegal object!"); break; } if (IS_GRAVE(level->locations[u.ux][u.uy].typ)) { if (type == ENGRAVE || type == 0) type = HEADSTONE; else { /* ensures the "cannot wipe out" case */ type = DUST; dengr = FALSE; teleengr = FALSE; buf[0] = (char)0; } } /* End of implement setup */ /* Identify stylus */ if (doknown) { makeknown(otmp->otyp); more_experienced(0,10); } if (teleengr) { rloc_engr(oep); oep = NULL; } if (dengr) { del_engr(oep, level); oep = NULL; } /* Something has changed the engraving here */ if (*buf) { make_engr_at(level, u.ux, u.uy, buf, moves, type); pline("The engraving now reads: \"%s\".", buf); ptext = FALSE; } if (zapwand && (otmp->spe < 0)) { pline("%s %sturns to dust.", The(xname(otmp)), Blind ? "" : "glows violently, then "); if (!IS_GRAVE(level->locations[u.ux][u.uy].typ)) pline("You are not going to get anywhere trying to write in the %s with your dust.", is_ice(level, u.ux, u.uy) ? "frost" : "dust"); useup(otmp); ptext = FALSE; } if (!ptext) { /* Early exit for some implements. */ if (otmp->oclass == WAND_CLASS && !can_reach_floor()) pline("You can't reach the %s!", surface(u.ux,u.uy)); return 1; } /* Special effects should have deleted the current engraving (if * possible) by now. */ if (oep) { char c = 'n'; /* Give player the choice to add to engraving. */ if (type == HEADSTONE) { /* no choice, only append */ c = 'y'; } else if ( (type == oep->engr_type) && (!Blind || (oep->engr_type == BURN) || (oep->engr_type == ENGRAVE)) ) { c = yn_function("Do you want to add to the current engraving?", ynqchars, 'y'); if (c == 'q') { pline("Never mind."); return 0; } } if (c == 'n' || Blind) { if ( (oep->engr_type == DUST) || (oep->engr_type == ENGR_BLOOD) || (oep->engr_type == MARK) ) { if (!Blind) { pline("You wipe out the message that was %s here.", ((oep->engr_type == DUST) ? "written in the dust" : ((oep->engr_type == ENGR_BLOOD) ? "scrawled in blood" : "written"))); del_engr(oep, level); oep = NULL; } else /* Don't delete engr until after we *know* we're engraving */ eow = TRUE; } else if ( (type == DUST) || (type == MARK) || (type == ENGR_BLOOD) ) { pline( "You cannot wipe out the message that is %s the %s here.", oep->engr_type == BURN ? (is_ice(level, u.ux, u.uy) ? "melted into" : "burned into") : "engraved in", surface(u.ux,u.uy)); return 1; } else if ( (type != oep->engr_type) || (c == 'n') ) { if (!Blind || can_reach_floor()) pline("You will overwrite the current message."); eow = TRUE; } } } eloc = surface(u.ux,u.uy); switch(type){ default: everb = (oep && !eow ? "add to the weird writing on" : "write strangely on"); break; case DUST: everb = (oep && !eow ? "add to the writing in" : "write in"); eloc = is_ice(level, u.ux, u.uy) ? "frost" : "dust"; break; case HEADSTONE: everb = (oep && !eow ? "add to the epitaph on" : "engrave on"); break; case ENGRAVE: everb = (oep && !eow ? "add to the engraving in" : "engrave in"); break; case BURN: everb = (oep && !eow ? ( is_ice(level, u.ux,u.uy) ? "add to the text melted into" : "add to the text burned into") : ( is_ice(level, u.ux,u.uy) ? "melt into" : "burn into")); break; case MARK: everb = (oep && !eow ? "add to the graffiti on" : "scribble on"); break; case ENGR_BLOOD: everb = (oep && !eow ? "add to the scrawl on" : "scrawl on"); break; } /* Tell adventurer what is going on */ if (otmp != &zeroobj) pline("You %s the %s with %s.", everb, eloc, doname(otmp)); else pline("You %s the %s with your %s.", everb, eloc, makeplural(body_part(FINGER))); /* Prompt for engraving! */ sprintf(qbuf,"What do you want to %s the %s here?", everb, eloc); getlin(qbuf, ebuf); /* Count the actual # of chars engraved not including spaces */ len = strlen(ebuf); for (sp = ebuf; *sp; sp++) if (isspace(*sp)) len -= 1; if (len == 0 || strchr(ebuf, '\033')) { if (zapwand) { if (!Blind) pline("%s, then %s.", Tobjnam(otmp, "glow"), otense(otmp, "fade")); return 1; } else { pline("Never mind."); if (otmp && otmp->oclass == WAND_CLASS && wrestable(otmp)) return 1; /* disallow zero turn wrest */ else return 0; } } /* A single `x' is the traditional signature of an illiterate person */ if (len != 1 || (!strchr(ebuf, 'x') && !strchr(ebuf, 'X'))) u.uconduct.literate++; /* Mix up engraving if surface or state of mind is unsound. Note: this won't add or remove any spaces. */ for (sp = ebuf; *sp; sp++) { if (isspace(*sp)) continue; if (((type == DUST || type == ENGR_BLOOD) && !rn2(25)) || (Blind && !rn2(11)) || (Confusion && !rn2(7)) || (Stunned && !rn2(4)) || (Hallucination && !rn2(2))) *sp = ' ' + rnd(96 - 2); /* ASCII '!' thru '~' (excludes ' ' and DEL) */ } /* Previous engraving is overwritten */ if (eow) { del_engr(oep, level); oep = NULL; } /* Figure out how long it took to engrave, and if player has * engraved too much. */ switch(type){ default: multi = -(len/10); if (multi) nomovemsg = "You finish your weird engraving."; break; case DUST: multi = -(len/10); if (multi) nomovemsg = "You finish writing in the dust."; break; case HEADSTONE: case ENGRAVE: multi = -(len/10); if ((otmp->oclass == WEAPON_CLASS) && ((otmp->otyp != ATHAME) || otmp->cursed)) { multi = -len; maxelen = ((otmp->spe + 3) * 2) + 1; /* -2 = 3, -1 = 5, 0 = 7, +1 = 9, +2 = 11 * Note: this does not allow a +0 anything (except * an athame) to engrave "Elbereth" all at once. * However, you could now engrave "Elb", then * "ere", then "th". */ pline("Your %s dull.", aobjnam(otmp, "get")); if (otmp->unpaid) { struct monst *shkp = shop_keeper(level, *u.ushops); if (shkp) { pline("You damage it, you pay for it!"); bill_dummy_object(otmp); } } if (len > maxelen) { multi = -maxelen; otmp->spe = -3; } else if (len > 1) otmp->spe -= len >> 1; else otmp->spe -= 1; /* Prevent infinite engraving */ } else
/* Returns 1 when something was stolen (or at least, when N should flee now) * Returns -1 if the monster died in the attempt * Avoid stealing the object stealoid */ int steal(struct monst *mtmp, char *objnambuf) { struct obj *otmp; int tmp, could_petrify, named = 0, armordelay; boolean monkey_business; /* true iff an animal is doing the thievery */ if (objnambuf) *objnambuf = '\0'; /* the following is true if successful on first of two attacks. */ if (!monnear(mtmp, u.ux, u.uy)) return 0; /* food being eaten might already be used up but will not have been removed from inventory yet; we don't want to steal that, so this will cause it to be removed now */ if (occupation) maybe_finished_meal(FALSE); if (!invent || (inv_cnt() == 1 && uskin)) { nothing_to_steal: /* Not even a thousand men in armor can strip a naked man. */ if (Blind) pline("Somebody tries to rob you, but finds nothing to steal."); else pline("%s tries to rob you, but there is nothing to steal!", Monnam(mtmp)); return 1; /* let her flee */ } monkey_business = is_animal(mtmp->data); if (monkey_business) { ; /* skip ring special cases */ } else if (Adornment & LEFT_RING) { otmp = uleft; goto gotobj; } else if (Adornment & RIGHT_RING) { otmp = uright; goto gotobj; } tmp = 0; for (otmp = invent; otmp; otmp = otmp->nobj) if ((!uarm || otmp != uarmc) && otmp != uskin #ifdef INVISIBLE_OBJECTS && (!otmp->oinvis || perceives(mtmp->data)) #endif ) tmp += ((otmp-> owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) ? 5 : 1); if (!tmp) goto nothing_to_steal; tmp = rn2(tmp); for (otmp = invent; otmp; otmp = otmp->nobj) if ((!uarm || otmp != uarmc) && otmp != uskin #ifdef INVISIBLE_OBJECTS && (!otmp->oinvis || perceives(mtmp->data)) #endif ) if ((tmp -= ((otmp-> owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) ? 5 : 1)) < 0) break; if (!otmp) { impossible("Steal fails!"); return 0; } /* can't steal gloves while wielding - so steal the wielded item. */ if (otmp == uarmg && uwep) otmp = uwep; /* can't steal armor while wearing cloak - so steal the cloak. */ else if (otmp == uarm && uarmc) otmp = uarmc; else if (otmp == uarmu && uarmc) otmp = uarmc; else if (otmp == uarmu && uarm) otmp = uarm; gotobj: if (otmp->o_id == stealoid) return 0; /* animals can't overcome curse stickiness nor unlock chains */ if (monkey_business) { boolean ostuck; /* is the player prevented from voluntarily giving up this item? (ignores loadstones; the !can_carry() check will catch those) */ if (otmp == uball) ostuck = TRUE; /* effectively worn; curse is implicit */ else if (otmp == uquiver || (otmp == uswapwep && !u.twoweap)) ostuck = FALSE; /* not really worn; curse doesn't matter */ else ostuck = (otmp->cursed && otmp->owornmask); if (ostuck || !can_carry(mtmp, otmp)) { static const char *const how[] = { "steal", "snatch", "grab", "take" }; cant_take: pline("%s tries to %s your %s but gives up.", Monnam(mtmp), how[rn2(SIZE(how))], (otmp->owornmask & W_ARMOR) ? equipname(otmp) : cxname(otmp)); /* the fewer items you have, the less likely the thief is going to stick around to try again (0) instead of running away (1) */ return !rn2(inv_cnt() / 5 + 2); } } if (otmp->otyp == LEASH && otmp->leashmon) { if (monkey_business && otmp->cursed) goto cant_take; o_unleash(otmp); } /* you're going to notice the theft... */ stop_occupation(); if ((otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) { switch (otmp->oclass) { case TOOL_CLASS: case AMULET_CLASS: case RING_CLASS: case FOOD_CLASS: /* meat ring */ remove_worn_item(otmp, TRUE); break; case ARMOR_CLASS: armordelay = objects[otmp->otyp].oc_delay; /* Stop putting on armor which has been stolen. */ if (donning(otmp)) { remove_worn_item(otmp, TRUE); break; } else if (monkey_business) { /* animals usually don't have enough patience to take off items which require extra time */ if (armordelay >= 1 && rn2(10)) goto cant_take; remove_worn_item(otmp, TRUE); break; } else { int curssv = otmp->cursed; int slowly; boolean seen = canspotmon(mtmp); otmp->cursed = 0; /* can't charm you without first waking you */ if (multi < 0 && is_fainted()) unmul(NULL); slowly = (armordelay >= 1 || multi < 0); if (multi < 0) { pline ("%s tries to %s you, but is dismayed by your lack of response.", !seen ? "She" : Monnam(mtmp), flags.female ? "charm" : "seduce"); return (0); } if (flags.female) pline("%s charms you. You gladly %s your %s.", !seen ? "She" : Monnam(mtmp), curssv ? "let her take" : slowly ? "start removing" : "hand over", equipname(otmp)); else pline("%s seduces you and %s off your %s.", !seen ? "She" : Adjmonnam(mtmp, "beautiful"), curssv ? "helps you to take" : slowly ? "you start taking" : "you take", equipname(otmp)); named++; /* the following is to set multi for later on */ nomul(-armordelay, "taking off clothes"); nomovemsg = "You finish disrobing."; remove_worn_item(otmp, TRUE); otmp->cursed = curssv; if (multi < 0) { /* multi = 0; nomovemsg = 0; afternmv = 0; */ stealoid = otmp->o_id; stealmid = mtmp->m_id; afternmv = stealarm; return 0; } } break; default: impossible("Tried to steal a strange worn thing. [%d]", otmp->oclass); } } else if (otmp->owornmask) remove_worn_item(otmp, TRUE); /* do this before removing it from inventory */ if (objnambuf) strcpy(objnambuf, yname(otmp)); /* set mavenge bit so knights won't suffer an alignment penalty during retaliation; */ mtmp->mavenge = 1; freeinv(otmp); pline("%s stole %s.", named ? "She" : Monnam(mtmp), doname(otmp)); could_petrify = (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])); mpickobj(mtmp, otmp); /* may free otmp */ if (could_petrify && !(mtmp->misc_worn_check & W_ARMG)) { minstapetrify(mtmp, TRUE); return -1; } return (multi < 0) ? 0 : 1; }
/* Note: I had to choose one of three possible kinds of "type" when writing * this function: a wand type (like in zap.c), an adtyp, or an object type. * Wand types get complex because they must be converted to adtyps for * determining such things as fire resistance. Adtyps get complex in that * they don't supply enough information--was it a player or a monster that * did it, and with a wand, spell, or breath weapon? Object types share both * these disadvantages.... * * The descr argument should be used to describe the explosion. It should be * a string suitable for use with an(). * raylevel is used for explosions caused by skilled wand usage (0=no wand) */ void explode(int x, int y, int type, /* the same as in zap.c */ int dam, char olet, int expltype, const char *descr, int raylevel) { int i, j, k, damu = dam; boolean visible, any_shield, resist_death; resist_death = FALSE; int uhurt = 0; /* 0=unhurt, 1=items damaged, 2=you and items damaged */ const char *str; const char *dispbuf = ""; /* lint suppression; I think the code's OK */ boolean expl_needs_the = TRUE; int idamres, idamnonres; struct monst *mtmp; uchar adtyp; int explmask[3][3]; /* 0=normal explosion, 1=do shieldeff, 2=do nothing */ boolean shopdamage = FALSE; #if 0 /* Damage reduction from wand explosions */ if (olet == WAND_CLASS) /* retributive strike */ switch (Role_switch) { case PM_PRIEST: case PM_MONK: case PM_WIZARD: damu /= 5; break; case PM_HEALER: case PM_KNIGHT: damu /= 2; break; default: break; } #endif if (olet == MON_EXPLODE) { str = descr; adtyp = AD_PHYS; if (Hallucination) { int name = rndmonidx(); dispbuf = msgcat(s_suffix(monnam_for_index(name)), " explosion"); expl_needs_the = !monnam_is_pname(name); } else { dispbuf = str; } } else { int whattype = abs(type) % 10; adtyp = whattype + 1; boolean done = FALSE, hallu = Hallucination; if (hallu) { do { whattype = rn2(8); } while (whattype == 3); } tryagain: switch (whattype) { case 0: str = "magical blast"; break; case 1: str = olet == BURNING_OIL ? "burning oil" : olet == SCROLL_CLASS ? "tower of flame" : "fireball"; break; case 2: str = "ball of cold"; break; case 3: str = "sleeping gas"; break; case 4: str = (olet == WAND_CLASS) ? "death field" : "disintegration field"; break; case 5: str = "ball of lightning"; break; case 6: str = "poison gas cloud"; break; case 7: str = "splash of acid"; break; default: impossible("explosion base type %d?", type); return; } if (!done) { dispbuf = str; done = TRUE; if (hallu) { whattype = adtyp - 1; goto tryagain; } } } any_shield = visible = FALSE; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { if (!isok(i + x - 1, j + y - 1)) { explmask[i][j] = 2; continue; } else explmask[i][j] = 0; if (i + x - 1 == u.ux && j + y - 1 == u.uy) { switch (adtyp) { case AD_PHYS: explmask[i][j] = 0; break; case AD_MAGM: explmask[i][j] = !!(raylevel >= P_EXPERT || Antimagic); break; case AD_FIRE: explmask[i][j] = !!Fire_resistance; break; case AD_COLD: explmask[i][j] = !!Cold_resistance; break; case AD_SLEE: explmask[i][j] = !!Sleep_resistance; break; case AD_DISN: if (raylevel == P_UNSKILLED && Drain_resistance) resist_death = TRUE; /* why MR doesn't resist general deathfields is beyond me, but... */ if (nonliving(youmonst.data) || is_demon(youmonst.data)) resist_death = TRUE; if (raylevel && Antimagic) resist_death = TRUE; if (raylevel >= P_EXPERT && !Drain_resistance) resist_death = FALSE; explmask[i][j] = (olet == WAND_CLASS) ? !!resist_death : !!Disint_resistance; break; case AD_ELEC: explmask[i][j] = !!Shock_resistance; break; case AD_DRST: explmask[i][j] = !!Poison_resistance; break; case AD_ACID: explmask[i][j] = !!Acid_resistance; break; default: impossible("explosion type %d?", adtyp); break; } } /* can be both you and mtmp if you're swallowed */ mtmp = m_at(level, i + x - 1, j + y - 1); if (!mtmp && i + x - 1 == u.ux && j + y - 1 == u.uy) mtmp = u.usteed; if (mtmp) { if (mtmp->mhp < 1) explmask[i][j] = 2; else switch (adtyp) { case AD_PHYS: break; case AD_MAGM: explmask[i][j] |= (raylevel >= 4 || resists_magm(mtmp)); break; case AD_FIRE: explmask[i][j] |= resists_fire(mtmp); break; case AD_COLD: explmask[i][j] |= resists_cold(mtmp); break; case AD_SLEE: explmask[i][j] |= resists_sleep(mtmp); case AD_DISN: if (raylevel == P_UNSKILLED && resists_drli(mtmp)) resist_death = TRUE; if (nonliving(mtmp->data) || is_demon(mtmp->data)) resist_death = TRUE; if (raylevel && resists_magm(mtmp)) resist_death = TRUE; if (raylevel >= P_EXPERT && !resists_drli(mtmp)) resist_death = FALSE; explmask[i][j] |= (olet == WAND_CLASS) ? resist_death : resists_disint(mtmp); break; case AD_ELEC: explmask[i][j] |= resists_elec(mtmp); break; case AD_DRST: explmask[i][j] |= resists_poison(mtmp); break; case AD_ACID: explmask[i][j] |= resists_acid(mtmp); break; default: impossible("explosion type %d?", adtyp); break; } } reveal_monster_at(i + x - 1, j + y - 1, TRUE); if (cansee(i + x - 1, j + y - 1)) visible = TRUE; if (explmask[i][j] == 1) any_shield = TRUE; } if (visible) { struct tmp_sym *tsym = tmpsym_init(DISP_BEAM, 0); /* Start the explosion */ for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { if (explmask[i][j] == 2) continue; tmpsym_change(tsym, dbuf_explosion(expltype, explosion[i][j])); tmpsym_at(tsym, i + x - 1, j + y - 1); } flush_screen(); /* will flush screen and output */ if (any_shield && flags.sparkle) { /* simulate shield effect */ for (k = 0; k < SHIELD_COUNT; k++) { for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { if (explmask[i][j] == 1) /* * Bypass tmpsym_at() and send the shield glyphs * directly to the buffered screen. tmpsym_at() * will clean up the location for us later. */ dbuf_set_effect(i + x - 1, j + y - 1, dbuf_effect(E_MISC, shield_static[k])); } flush_screen(); /* will flush screen and output */ win_delay_output(); } /* Cover last shield glyph with blast symbol. */ for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { if (explmask[i][j] == 1) dbuf_set_effect(i + x - 1, j + y - 1, dbuf_explosion(expltype, explosion[i][j])); } } else { /* delay a little bit. */ win_delay_output(); win_delay_output(); } tmpsym_end(tsym); /* clear the explosion */ } else { if (olet == MON_EXPLODE) { str = "explosion"; } You_hear("a blast."); } if (dam) for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) { if (explmask[i][j] == 2) continue; if (i + x - 1 == u.ux && j + y - 1 == u.uy) uhurt = (explmask[i][j] == 1) ? 1 : 2; idamres = idamnonres = 0; if (type >= 0) zap_over_floor((xchar) (i + x - 1), (xchar) (j + y - 1), type, &shopdamage); mtmp = m_at(level, i + x - 1, j + y - 1); if (!mtmp && i + x - 1 == u.ux && j + y - 1 == u.uy) mtmp = u.usteed; if (!mtmp) continue; if (Engulfed && mtmp == u.ustuck) { if (is_animal(u.ustuck->data)) pline("%s gets %s!", Monnam(u.ustuck), (adtyp == AD_FIRE) ? "heartburn" : (adtyp == AD_COLD) ? "chilly" : (adtyp == AD_DISN) ? ((olet == WAND_CLASS) ? "irradiated by pure energy" : "perforated") : (adtyp == AD_ELEC) ? "shocked" : (adtyp == AD_DRST) ? "poisoned" : (adtyp == AD_ACID) ? "an upset stomach" : "fried"); else pline("%s gets slightly %s!", Monnam(u.ustuck), (adtyp == AD_FIRE) ? "toasted" : (adtyp == AD_COLD) ? "chilly" : (adtyp == AD_DISN) ? ((olet == WAND_CLASS) ? "overwhelmed by pure energy" : "perforated") : (adtyp == AD_ELEC) ? "shocked" : (adtyp == AD_DRST) ? "intoxicated" : (adtyp == AD_ACID) ? "burned" : "fried"); } else if (cansee(i + x - 1, j + y - 1)) { if (mtmp->m_ap_type) seemimic(mtmp); pline("%s is caught in %s%s!", Monnam(mtmp), expl_needs_the ? "the " : "", dispbuf); } idamres += destroy_mitem(mtmp, SCROLL_CLASS, (int)adtyp); idamres += destroy_mitem(mtmp, SPBOOK_CLASS, (int)adtyp); idamnonres += destroy_mitem(mtmp, POTION_CLASS, (int)adtyp); idamnonres += destroy_mitem(mtmp, WAND_CLASS, (int)adtyp); idamnonres += destroy_mitem(mtmp, RING_CLASS, (int)adtyp); if (explmask[i][j] == 1) { golemeffects(mtmp, (int)adtyp, dam + idamres); mtmp->mhp -= idamnonres; } else { /* call resist with 0 and do damage manually so 1) we can get out the message before doing the damage, and 2) we can call mondied, not killed, if it's not your blast */ int mdam = dam; if (resist(mtmp, olet, 0, FALSE)) { if (cansee(i + x - 1, j + y - 1)) pline("%s resists %s%s!", Monnam(mtmp), expl_needs_the ? "the " : "", dispbuf); mdam = dam / 2; } if (mtmp == u.ustuck) mdam *= 2; if (resists_cold(mtmp) && adtyp == AD_FIRE) mdam *= 2; else if (resists_fire(mtmp) && adtyp == AD_COLD) mdam *= 2; if (adtyp == AD_MAGM && raylevel >= P_EXPERT && resists_magm(mtmp)) mdam = (mdam + 1) / 2; if (adtyp == AD_SLEE && raylevel) { sleep_monst(mtmp, mdam, WAND_CLASS); mdam = 0; } if (adtyp == AD_DISN && raylevel) { if (nonliving(mtmp->data) || is_demon(mtmp->data) || resists_magm(mtmp) || raylevel == P_UNSKILLED) { /* monster is deathresistant or raylevel==unskilled, since monster apparently failed to resist earlier, monster must be vulnerable to drli */ /* FIXME: make a generic losexp() for monsters */ mdam = dice(2, 6); if (cansee(i + x - 1, j + y - 1)) pline("%s suddenly seems weaker!", Monnam(mtmp)); mtmp->mhpmax -= mdam; if (mtmp->m_lev == 0) mdam = mtmp->mhp; else mtmp->m_lev--; } else mdam = mtmp->mhp; /* instadeath */ } mtmp->mhp -= mdam; mtmp->mhp -= (idamres + idamnonres); } if (mtmp->mhp <= 0) { /* KMH -- Don't blame the player for pets killing gas spores */ if (!flags.mon_moving) killed(mtmp); else monkilled(mtmp, "", (int)adtyp); } else if (!flags.mon_moving) setmangry(mtmp); } /* Do your injury last */ if (uhurt) { if ((type >= 0 || adtyp == AD_PHYS) && /* gas spores */ flags.verbose && olet != SCROLL_CLASS) pline("You are caught in %s%s!", expl_needs_the ? "the " : "", dispbuf); /* do property damage first, in case we end up leaving bones */ if (adtyp == AD_FIRE) burn_away_slime(); if (u.uinvulnerable) { damu = 0; pline("You are unharmed!"); } else if (Half_physical_damage && adtyp == AD_PHYS) damu = (damu + 1) / 2; else if (raylevel) { if (adtyp == AD_MAGM && Antimagic) damu = (damu + 1) / 2; if (adtyp == AD_SLEE) { helpless(damu, hr_asleep, "sleeping", NULL); damu = 0; } if (adtyp == AD_DISN) { if (nonliving(youmonst.data) || is_demon(youmonst.data) || Antimagic || raylevel == P_UNSKILLED) { losexp("drained by a death field",FALSE); damu = 0; } else { done(DIED, "killed by a death field"); damu = 0; /* lifesaved */ } } } if (adtyp == AD_FIRE) { burnarmor(&youmonst); set_candles_afire(); } destroy_item(SCROLL_CLASS, (int)adtyp); destroy_item(SPBOOK_CLASS, (int)adtyp); destroy_item(POTION_CLASS, (int)adtyp); destroy_item(RING_CLASS, (int)adtyp); destroy_item(WAND_CLASS, (int)adtyp); ugolemeffects((int)adtyp, damu); if (uhurt == 2) { if (Upolyd) u.mh -= damu; else u.uhp -= damu; } if (u.uhp <= 0 || (Upolyd && u.mh <= 0)) { int death = adtyp == AD_FIRE ? BURNING : DIED; const char *killer; if (olet == MON_EXPLODE) { killer = killer_msg(death, an(str)); } else if (type >= 0 && olet != SCROLL_CLASS) { /* check whether or not we were the source of the explosion */ if (!flags.mon_moving) killer = msgprintf("caught %sself in %s own %s", uhim(), uhis(), str); else killer = msgprintf("killed by a %s", str); } else if (!strcmp(str, "burning oil")) { /* This manual check hack really sucks */ killer = killer_msg(death, str); } else { killer = killer_msg(death, an(str)); } /* Known BUG: BURNING suppresses corpse in bones data, but done does not handle killer reason correctly */ if (Upolyd) { rehumanize(death, killer); } else { done(death, killer); } } exercise(A_STR, FALSE); } if (shopdamage) { pay_for_damage(adtyp == AD_FIRE ? "burn away" : adtyp == AD_COLD ? "shatter" : adtyp == AD_DISN ? "disintegrate" : "destroy", FALSE); } /* explosions are noisy */ i = dam * dam; if (i < 50) i = 50; /* in case random damage is very small */ wake_nearto(x, y, i); }
void mstatusline(struct monst *mtmp) { aligntyp alignment; const char *info, *monnambuf; if (mtmp->ispriest || (mtmp->isminion && roamer_type(mtmp->data))) alignment = CONST_EPRI(mtmp)->shralign; else if (mtmp->isminion) alignment = EMIN(mtmp)->min_align; else { alignment = mtmp->data->maligntyp; alignment = (alignment > 0) ? A_LAWFUL : (alignment == A_NONE) ? A_NONE : (alignment < 0) ? A_CHAOTIC : A_NEUTRAL; } info = ""; if (mtmp->mtame) { info = msgcat(info, ", tame"); if (wizard) { info = msgprintf("%s (%d", info, mtmp->mtame); if (!mtmp->isminion) info = msgprintf("%s; hungry %u; apport %d", info, EDOG(mtmp)->hungrytime, EDOG(mtmp)->apport); info = msgcat(info, ")"); } } else if (mtmp->mpeaceful) info = msgcat(info, ", peaceful"); if (mtmp->meating) info = msgcat(info, ", eating"); if (mtmp->mcan) info = msgcat(info, ", cancelled"); if (mtmp->mconf) info = msgcat(info, ", confused"); if (mtmp->mblinded || !mtmp->mcansee) info = msgcat(info, ", blind"); if (mtmp->mstun) info = msgcat(info, ", stunned"); if (mtmp->msleeping) info = msgcat(info, ", asleep"); else if (mtmp->mfrozen || !mtmp->mcanmove) info = msgcat(info, ", can't move"); /* [arbitrary reason why it isn't moving] */ else if (mtmp->mstrategy & STRAT_WAITMASK) info = msgcat(info, ", meditating"); else if (mtmp->mflee) info = msgcat(info, ", scared"); if (mtmp->mtrapped) info = msgcat(info, ", trapped"); if (mtmp->mspeed) info = msgcat(info, mtmp->mspeed == MFAST ? ", fast" : mtmp->mspeed == MSLOW ? ", slow" : ", ???? speed"); if (mtmp->mundetected) info = msgcat(info, ", concealed"); if (mtmp->minvis) info = msgcat(info, ", invisible"); if (mtmp == u.ustuck) info = msgcat(info, (sticks(youmonst.data)) ? ", held by you" : Engulfed ? (is_animal(u.ustuck->data) ? ", swallowed you" : ", engulfed you") : ", holding you"); if (mtmp == u.usteed) info = msgcat(info, ", carrying you"); /* avoid "Status of the invisible newt ..., invisible" */ /* and unlike a normal mon_nam, use "saddled" even if it has a name */ monnambuf = x_monnam(mtmp, ARTICLE_THE, NULL, (SUPPRESS_IT | SUPPRESS_INVISIBLE), FALSE); pline("Status of %s (%s): Level %d HP %d(%d) Def %d%s.", monnambuf, align_str(alignment), mtmp->m_lev, mtmp->mhp, mtmp->mhpmax, 10 - find_mac(mtmp), info); }
/* Returns 1 when something was stolen (or at least, when N should flee now) * Returns -1 if the monster died in the attempt * Avoid stealing the object stealoid */ int steal(struct monst *mtmp, const char **objnambuf) { struct obj *otmp; int tmp, could_petrify, named = 0, armordelay, slowly = 0; boolean monkey_business; /* true iff an animal is doing the thievery */ if (objnambuf) *objnambuf = ""; /* the following is true if successful on first of two attacks. */ if (!monnear(mtmp, u.ux, u.uy)) return 0; if (!invent || (inv_cnt(FALSE) == 1 && uskin())) { nothing_to_steal: /* Not even a thousand men in armor can strip a naked man. */ if (Blind) pline("Somebody tries to rob you, but finds nothing to steal."); else pline("%s tries to rob you, but there is nothing to steal!", Monnam(mtmp)); return 1; /* let her flee */ } monkey_business = is_animal(mtmp->data); if (monkey_business) { ; /* skip ring special cases */ } else if (Adornment & W_MASK(os_ringl)) { otmp = uleft; goto gotobj; } else if (Adornment & W_MASK(os_ringr)) { otmp = uright; goto gotobj; } tmp = 0; for (otmp = invent; otmp; otmp = otmp->nobj) if ((!uarm || otmp != uarmc) && otmp != uskin() #ifdef INVISIBLE_OBJECTS && (!otmp->oinvis || perceives(mtmp->data)) #endif ) tmp += ((otmp->owornmask & W_WORN) ? 5 : 1); if (!tmp) goto nothing_to_steal; tmp = rn2(tmp); for (otmp = invent; otmp; otmp = otmp->nobj) if ((!uarm || otmp != uarmc) && otmp != uskin() #ifdef INVISIBLE_OBJECTS && (!otmp->oinvis || perceives(mtmp->data)) #endif ) if ((tmp -= ((otmp->owornmask & W_WORN) ? 5 : 1)) < 0) break; if (!otmp) { impossible("Steal fails!"); return 0; } /* can't steal gloves while wielding - so steal the wielded item. */ if (otmp == uarmg && uwep) otmp = uwep; /* can't steal armor while wearing cloak - so steal the cloak. */ else if (otmp == uarm && uarmc) otmp = uarmc; else if (otmp == uarmu && uarmc) otmp = uarmc; else if (otmp == uarmu && uarm && !uskin()) otmp = uarm; gotobj: /* animals can't overcome curse stickiness nor unlock chains */ if (monkey_business) { boolean ostuck; /* is the player prevented from voluntarily giving up this item? (ignores loadstones; the !can_carry() check will catch those) */ if (otmp == uball) ostuck = TRUE; /* effectively worn; curse is implicit */ else if (otmp == uquiver || (otmp == uswapwep && !u.twoweap)) ostuck = FALSE; /* not really worn; curse doesn't matter */ else ostuck = (otmp->cursed && otmp->owornmask); if (ostuck || !can_carry(mtmp, otmp)) { static const char *const how[] = { "steal", "snatch", "grab", "take" }; cant_take: pline("%s tries to %s your %s but gives up.", Monnam(mtmp), how[rn2(SIZE(how))], (otmp->owornmask & W_ARMOR) ? equipname(otmp) : cxname(otmp)); /* the fewer items you have, the less likely the thief is going to stick around to try again (0) instead of running away (1) */ return !rn2(inv_cnt(FALSE) / 5 + 2); } } if (otmp->otyp == LEASH && otmp->leashmon) { if (monkey_business && otmp->cursed) goto cant_take; o_unleash(otmp); } /* you're going to notice the theft... */ action_interrupted(); if (otmp->owornmask & W_WORN) { switch (otmp->oclass) { case TOOL_CLASS: case AMULET_CLASS: case RING_CLASS: case FOOD_CLASS: /* meat ring */ remove_worn_item(otmp, TRUE); break; case ARMOR_CLASS: armordelay = objects[otmp->otyp].oc_delay; if (monkey_business) { /* animals usually don't have enough patience to take off items which require extra time */ if (armordelay >= 1 && rn2(10)) goto cant_take; remove_worn_item(otmp, TRUE); break; } else { int curssv = otmp->cursed; boolean seen = canspotmon(mtmp); otmp->cursed = 0; /* can't charm you without first waking you */ cancel_helplessness(hm_fainted, "Someone revives you."); slowly = (armordelay >= 1 || u_helpless(hm_all)); if (u_helpless(hm_all)) { pline("%s tries to %s you, but is dismayed by your lack of " "response.", !seen ? "She" : Monnam(mtmp), u.ufemale ? "charm" : "seduce"); return (0); } if (u.ufemale) pline("%s charms you. You gladly %s your %s.", !seen ? "She" : Monnam(mtmp), curssv ? "let her take" : slowly ? "start removing" : "hand over", equipname(otmp)); else pline("%s seduces you and %s off your %s.", !seen ? "She" : Adjmonnam(mtmp, "beautiful"), curssv ? "helps you to take" : slowly ? "you start taking" : "you take", equipname(otmp)); named++; if (armordelay) helpless(armordelay, hr_busy, "taking off clothes", "You finish disrobing."); remove_worn_item(otmp, TRUE); otmp->cursed = curssv; /* Note: it used to be that the nymph would wait for you to disrobe, then take the item, but that lead to huge complications in the code (and a rather unfun situation where the nymph could chain armor theft), and some resulting bugs. Instead, we just go down the normal codepath; you lose the item, and you're left helpless for the length of time it should have taken to remove. The nymph will stay around (due to the slowly || u_helpless(hm_all) check at the end of the function). */ } break; default: impossible("Tried to steal a strange worn thing. [%d]", otmp->oclass); } } else if (otmp->owornmask) remove_worn_item(otmp, TRUE); /* do this before removing it from inventory */ if (objnambuf) *objnambuf = yname(otmp); /* set mavenge bit so knights won't suffer an alignment penalty during retaliation; */ mtmp->mavenge = 1; freeinv(otmp); pline("%s stole %s.", named ? "She" : Monnam(mtmp), doname(otmp)); could_petrify = (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])); mpickobj(mtmp, otmp); /* may free otmp */ if (could_petrify && !(mtmp->misc_worn_check & W_MASK(os_armg))) { minstapetrify(mtmp, TRUE); return -1; } return (slowly || u_helpless(hm_all)) ? 0 : 1; }