/* the sounds of distressed pets */ void whimper(struct monst *mtmp) { const char *whimper_verb = 0; if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound || !canhear()) return; /* presumably nearness checks have already been made */ if (Hallucination) whimper_verb = h_sounds[rn2(SIZE(h_sounds))]; else switch (mtmp->data->msound) { case MS_MEW: case MS_GROWL: whimper_verb = "whimper"; break; case MS_BARK: whimper_verb = "whine"; break; case MS_SQEEK: whimper_verb = "squeal"; break; } if (whimper_verb) { pline("%s %s.", Monnam(mtmp), vtense(NULL, whimper_verb)); action_interrupted(); wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 6); } }
/* the sounds of a seriously abused pet, including player attacking it */ void growl(struct monst *mtmp) { const char *growl_verb = 0; if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound) return; /* presumably nearness and soundok checks have already been made */ if (Hallucination) growl_verb = h_sounds[rn2(SIZE(h_sounds))]; else growl_verb = growl_sound(mtmp); if (growl_verb) { pline("%s %s!", Monnam(mtmp), vtense(NULL, growl_verb)); if (flags.run) nomul(0, NULL); wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 18); } }
/* the sounds of mistreated pets */ void yelp(struct monst *mtmp) { const char *yelp_verb = 0; if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound || !canhear()) return; /* presumably nearness checks have already been made */ if (Hallucination) yelp_verb = h_sounds[rn2(SIZE(h_sounds))]; else switch (mtmp->data->msound) { case MS_MEW: yelp_verb = "yowl"; break; case MS_BARK: case MS_GROWL: yelp_verb = "yelp"; break; case MS_ROAR: yelp_verb = "snarl"; break; case MS_SQEEK: yelp_verb = "squeal"; break; case MS_SQAWK: yelp_verb = "screak"; break; case MS_WAIL: yelp_verb = "wail"; break; } if (yelp_verb) { pline("%s %s!", Monnam(mtmp), vtense(NULL, yelp_verb)); action_interrupted(); wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 12); } }
static int domonnoise(struct monst *mtmp) { const char *pline_msg = 0, /* Monnam(mtmp) will be prepended */ *verbl_msg = 0; /* verbalize() */ const struct permonst *ptr = mtmp->data; /* presumably nearness checks have already been made */ if (!canhear()) return 0; if (is_silent(ptr)) return 0; /* Make sure its your role's quest quardian; adjust if not */ if (ptr->msound == MS_GUARDIAN && ptr != &pm_guardian) { int mndx = monsndx(ptr); ptr = &mons[genus(mndx, 1)]; } /* be sure to do this before talking; the monster might teleport away, in which case we want to check its pre-teleport position */ if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); switch (ptr->msound) { case MS_ORACLE: return doconsult(mtmp); case MS_PRIEST: priest_talk(mtmp); break; case MS_LEADER: case MS_NEMESIS: case MS_GUARDIAN: quest_chat(mtmp); break; case MS_SELL: /* pitch, pay, total */ shk_chat(mtmp); break; case MS_VAMPIRE: { /* vampire messages are varied by tameness, peacefulness, and time of night */ boolean isnight = night(); boolean kindred = (Upolyd && (u.umonnum == PM_VAMPIRE || u.umonnum == PM_VAMPIRE_LORD)); boolean nightchild = (Upolyd && (u.umonnum == PM_WOLF || u.umonnum == PM_WINTER_WOLF || u.umonnum == PM_WINTER_WOLF_CUB)); const char *racenoun = (u.ufemale && urace.individual.f) ? urace. individual.f : (urace.individual.m) ? urace.individual. m : urace.noun; if (mtmp->mtame) { if (kindred) verbl_msg = msgprintf("Good %s to you Master%s", isnight ? "evening" : "day", isnight ? "!" : ". Why do we not rest?"); else verbl_msg = msgcat( nightchild ? "Child of the night, " : "", midnight()? "I can stand this craving no longer!" : isnight ? "I beg you, help me satisfy this growing craving!" : "I find myself growing a little weary."); } else if (mtmp->mpeaceful) { if (kindred && isnight) verbl_msg = msgprintf("Good feeding %s!", u.ufemale ? "sister" : "brother"); else if (nightchild && isnight) verbl_msg = "How nice to hear you, child of the night!"; else verbl_msg = "I only drink... potions."; } else { int vampindex; static const char *const vampmsg[] = { /* These first two (0 and 1) are specially handled below */ "I vant to suck your %s!", "I vill come after %s without regret!", /* other famous vampire quotes can follow here if desired */ }; if (kindred) verbl_msg = "This is my hunting ground that you dare to prowl!"; else if (youmonst.data == &mons[PM_SILVER_DRAGON] || youmonst.data == &mons[PM_BABY_SILVER_DRAGON]) { /* Silver dragons are silver in color, not made of silver */ verbl_msg = msgprintf( "%s! Your silver sheen does not frighten me!", youmonst.data == &mons[PM_SILVER_DRAGON] ? "Fool" : "Young Fool"); } else { vampindex = rn2(SIZE(vampmsg)); if (vampindex == 0) { verbl_msg = msgprintf( vampmsg[vampindex], body_part(BLOOD)); } else if (vampindex == 1) { verbl_msg = msgprintf( vampmsg[vampindex], Upolyd ? an(mons[u.umonnum].mname) : an(racenoun)); } else verbl_msg = vampmsg[vampindex]; } } } break; case MS_WERE: if (flags.moonphase == FULL_MOON && (night() ^ !rn2(13))) { pline("%s throws back %s head and lets out a blood curdling %s!", Monnam(mtmp), mhis(mtmp), ptr == &mons[PM_HUMAN_WERERAT] ? "shriek" : "howl"); wake_nearto(mtmp->mx, mtmp->my, 11 * 11); } else pline_msg = "whispers inaudibly. All you can make out is \"moon\"."; break; case MS_BARK: if (flags.moonphase == FULL_MOON && night()) { pline_msg = "howls."; } else if (mtmp->mpeaceful) { if (mtmp->mtame && (mtmp->mconf || mtmp->mflee || mtmp->mtrapped || moves > EDOG(mtmp)->hungrytime || mtmp->mtame < 5)) pline_msg = "whines."; else if (mtmp->mtame && EDOG(mtmp)->hungrytime > moves + 1000) pline_msg = "yips."; else { if (mtmp->data == &mons[PM_FOX]) pline_msg = whatthefoxsays(); else if (mtmp->data != &mons[PM_DINGO]) /* dingos do not actually bark */ pline_msg = "barks."; } } else { if (mtmp->data == &mons[PM_FOX]) pline_msg = whatthefoxsays(); else pline_msg = "growls."; } break; case MS_MEW: if (mtmp->mtame) { if (mtmp->mconf || mtmp->mflee || mtmp->mtrapped || mtmp->mtame < 5) pline_msg = "yowls."; else if (moves > EDOG(mtmp)->hungrytime) pline_msg = "meows."; else if (EDOG(mtmp)->hungrytime > moves + 1000) pline_msg = "purrs."; else pline_msg = "mews."; break; } /* else FALLTHRU */ case MS_GROWL: pline_msg = mtmp->mpeaceful ? "snarls." : "growls!"; break; case MS_ROAR: pline_msg = mtmp->mpeaceful ? "snarls." : "roars!"; break; case MS_SQEEK: pline_msg = "squeaks."; break; case MS_SQAWK: if (ptr == &mons[PM_RAVEN] && !mtmp->mpeaceful) verbl_msg = "Nevermore!"; else pline_msg = "squawks."; break; case MS_HISS: if (!mtmp->mpeaceful) pline_msg = "hisses!"; else return 0; /* no sound */ break; case MS_BUZZ: pline_msg = mtmp->mpeaceful ? "drones." : "buzzes angrily."; break; case MS_GRUNT: pline_msg = "grunts."; break; case MS_NEIGH: if (mtmp->mtame < 5) pline_msg = "neighs."; else if (moves > EDOG(mtmp)->hungrytime) pline_msg = "whinnies."; else pline_msg = "whickers."; break; case MS_WAIL: pline_msg = "wails mournfully."; break; case MS_GURGLE: pline_msg = "gurgles."; break; case MS_BURBLE: pline_msg = "burbles."; break; case MS_SHRIEK: pline_msg = "shrieks."; aggravate(); break; case MS_IMITATE: pline_msg = "imitates you."; break; case MS_BONES: pline("%s rattles noisily.", Monnam(mtmp)); pline("You freeze for a moment."); helpless(2, hr_afraid, "scared by rattling", NULL); break; case MS_LAUGH: { static const char *const laugh_msg[4] = { "giggles.", "chuckles.", "snickers.", "laughs.", }; pline_msg = laugh_msg[rn2(4)]; } break; case MS_MUMBLE: pline_msg = "mumbles incomprehensibly."; break; case MS_WISHGIVER: if (mtmp->mtame) { verbl_msg = "Sorry, I'm all out of wishes."; } else if (mtmp->mpeaceful) { if (ptr == &mons[PM_WATER_DEMON]) pline_msg = "gurgles."; else verbl_msg = "I'm free!"; } else verbl_msg = "This will teach you not to disturb me!"; break; case MS_BOAST: /* giants */ if (!mtmp->mpeaceful) { switch (rn2(4)) { case 0: pline("%s boasts about %s gem collection.", Monnam(mtmp), mhis(mtmp)); break; case 1: pline_msg = "complains about a diet of mutton."; break; default: pline_msg = "shouts \"Fee Fie Foe Foo!\" and guffaws."; wake_nearto(mtmp->mx, mtmp->my, 7 * 7); break; } break; } /* else FALLTHRU */ case MS_HUMANOID: if (!mtmp->mpeaceful) { if (In_endgame(&u.uz) && is_mplayer(ptr)) { mplayer_talk(mtmp); break; } else return 0; /* no sound */ } /* Generic peaceful humanoid behaviour. */ if (mtmp->mflee) pline_msg = "wants nothing to do with you."; else if (mtmp->mhp < mtmp->mhpmax / 4) pline_msg = "moans."; else if (mtmp->mconf || mtmp->mstun) verbl_msg = !rn2(3) ? "Huh?" : rn2(2) ? "What?" : "Eh?"; else if (!mtmp->mcansee) verbl_msg = "I can't see!"; else if (mtmp->mtrapped) { struct trap *t = t_at(level, mtmp->mx, mtmp->my); if (t) t->tseen = 1; verbl_msg = "I'm trapped!"; } else if (mtmp->mhp < mtmp->mhpmax / 2) pline_msg = "asks for a potion of healing."; else if (mtmp->mtame && !mtmp->isminion && moves > EDOG(mtmp)->hungrytime) verbl_msg = "I'm hungry."; /* Specific monsters' interests */ else if (is_elf(ptr)) pline_msg = "curses orcs."; else if (is_dwarf(ptr)) pline_msg = "talks about mining."; else if (likes_magic(ptr)) pline_msg = "talks about spellcraft."; else if (ptr->mlet == S_CENTAUR) pline_msg = "discusses hunting."; else switch (monsndx(ptr)) { case PM_HOBBIT: pline_msg = (mtmp->mhpmax - mtmp->mhp >= 10) ? "complains about unpleasant dungeon conditions." : "asks you about the One Ring."; break; case PM_ARCHEOLOGIST: pline_msg = "describes a recent article in \"Spelunker Today\" " "magazine."; break; case PM_TOURIST: verbl_msg = "Aloha."; break; case PM_PRISONER: verbl_msg = "Thank you for freeing me!"; break; default: pline_msg = "discusses dungeon exploration."; break; } break; case MS_SEDUCE: if (ptr->mlet != S_NYMPH && flags.seduce_enabled && could_seduce(mtmp, &youmonst, NULL) == 1) { doseduce(mtmp); break; } switch ((poly_gender() != (int)mtmp->female) ? rn2(3) : 0) { case 2: verbl_msg = "Hello, sailor."; break; case 1: pline_msg = "comes on to you."; break; default: pline_msg = "cajoles you."; } break; case MS_ARREST: if (mtmp->mpeaceful) verbalize("Just the facts, %s.", u.ufemale ? "Ma'am" : "Sir"); else { static const char *const arrest_msg[3] = { "Anything you say can be used against you.", "You're under arrest!", "Stop in the name of the Law!", }; verbl_msg = arrest_msg[rn2(3)]; } break; case MS_BRIBE: if (mtmp->mpeaceful && !mtmp->mtame) { demon_talk(mtmp); break; } /* fall through */ case MS_CUSS: if (!mtmp->mpeaceful) cuss(mtmp); break; case MS_SPELL: /* deliberately vague, since it's not actually casting any spell */ pline_msg = "seems to mutter a cantrip."; break; case MS_NURSE: if (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))) verbl_msg = "Put that weapon away before you hurt someone!"; else if (uarmc || (uarm && !uskin()) || uarmh || uarms || uarmg || uarmf) verbl_msg = Role_if(PM_HEALER) ? "Doc, I can't help you unless you cooperate." : "Please undress so I can examine you."; else if (uarmu) verbl_msg = "Take off your shirt, please."; else verbl_msg = "Relax, this won't hurt a bit."; break; case MS_GUARD: if (money_cnt(invent)) verbl_msg = "Please drop that gold and follow me."; else verbl_msg = "Please follow me."; break; case MS_SOLDIER: { static const char *const soldier_foe_msg[3] = { "Resistance is useless!", "You're dog meat!", "Surrender!", }, *const soldier_pax_msg[3] = { "What lousy pay we're getting here!", "The food's not fit for Orcs!", "My feet hurt, I've been on them all day!", }; verbl_msg = mtmp->mpeaceful ? soldier_pax_msg[rn2(3)] : soldier_foe_msg[rn2(3)]; } break; case MS_RIDER: if (ptr == &mons[PM_DEATH] && !rn2(10)) pline_msg = "is busy reading a copy of Sandman #8."; else verbl_msg = "Who do you think you are, War?"; break; } if (pline_msg) pline("%s %s", Monnam(mtmp), pline_msg); else if (verbl_msg) verbalize("%s", verbl_msg); return 1; }
/* * Let's destroy the drawbridge located at x,y */ void destroy_drawbridge(int x, int y) { struct rm *loc1, *loc2; struct trap *t; int x2, y2; int db_u; boolean e_inview; struct entity *etmp1 = &(occupants[0]), *etmp2 = &(occupants[1]); loc1 = &level->locations[x][y]; if (!IS_DRAWBRIDGE(loc1->typ)) return; x2 = x; y2 = y; get_wall_for_db(&x2,&y2); loc2 = &level->locations[x2][y2]; db_u = (loc1->drawbridgemask & DB_UNDER); if (db_u == DB_MOAT || db_u == DB_LAVA || db_u == DB_BOG) { struct obj *otmp; int where = (db_u == DB_LAVA) ? 0 : (db_u == DB_MOAT) ? 1 : 2; static char *wstr[3] = { "lava", "moat", "swamp" }; if (loc1->typ == DRAWBRIDGE_UP) { if (cansee(x2,y2)) pline("The portcullis of the drawbridge falls into the %s!", wstr[where]); else if (flags.soundok) You_hear("a loud *SPLASH*!"); } else { if (cansee(x,y)) pline("The drawbridge collapses into the %s!", wstr[where]); else if (flags.soundok) You_hear("a loud *SPLASH*!"); } loc1->typ = (where == 0) ? LAVAPOOL : (where == 1) ? MOAT : BOG; loc1->drawbridgemask = 0; if ((otmp = sobj_at(BOULDER, level, x,y)) != 0) { obj_extract_self(otmp); flooreffects(otmp,x,y,"fall"); } } else { if (cansee(x,y)) pline("The drawbridge disintegrates!"); else You_hear("a loud *CRASH*!"); loc1->typ = ((loc1->drawbridgemask & DB_ICE) ? ICE : ROOM); loc1->icedpool = ((loc1->drawbridgemask & DB_ICE) ? ICED_MOAT : 0); } wake_nearto(x, y, 500); loc2->typ = DOOR; loc2->doormask = D_NODOOR; if ((t = t_at(level, x, y)) != 0) deltrap(level, t); if ((t = t_at(level, x2, y2)) != 0) deltrap(level, t); newsym(x,y); newsym(x2,y2); if (!does_block(level, x2, y2, NULL)) unblock_point(x2,y2); /* vision */ if (Is_stronghold(&u.uz)) u.uevent.uopened_dbridge = TRUE; set_entity(x2, y2, etmp2); /* currently only automissers can be here */ if (etmp2->edata) { e_inview = e_canseemon(level, etmp2); if (!automiss(etmp2)) { if (e_inview) pline("%s blown apart by flying debris.", E_phrase(etmp2, "are")); killer_format = KILLED_BY_AN; killer = "exploding drawbridge"; e_died(etmp2, e_inview? 3 : 2, CRUSHING); /*no corpse*/ } /* nothing which is vulnerable can survive this */ } set_entity(x, y, etmp1); if (etmp1->edata) { e_inview = e_canseemon(level, etmp1); if (!e_missed(etmp1, TRUE)) { if (e_inview) { if (!is_u(etmp1) && Hallucination) pline("%s into some heavy metal!", E_phrase(etmp1, "get")); else pline("%s hit by a huge chunk of metal!", E_phrase(etmp1, "are")); } else { if (flags.soundok && !is_u(etmp1) && !is_pool(level, x,y)) You_hear("a crushing sound."); } killer_format = KILLED_BY_AN; killer = "collapsing drawbridge"; e_died(etmp1, e_inview? 3 : 2, CRUSHING); /*no corpse*/ if (loc1->typ == MOAT) do_entity(etmp1); } } }
/* returns true if something happened */ boolean doorlock(struct obj * otmp, int x, int y) { struct rm *door = &level->locations[x][y]; boolean res = TRUE; int loudness = 0; int wandlevel = 0; if (otmp->oclass == WAND_CLASS) wandlevel = getwandlevel(&youmonst, otmp); /* Not completely right, but works since monsters wont use knock/wizlock */ const char *msg = NULL; const char *dustcloud = "A cloud of dust"; const char *quickly_dissipates = "quickly dissipates"; if (door->typ == SDOOR) { switch (otmp->otyp) { case WAN_OPENING: case SPE_KNOCK: case WAN_STRIKING: case SPE_FORCE_BOLT: door->typ = DOOR; door->doormask = D_CLOSED | (door->doormask & D_TRAPPED); newsym(x, y); if (cansee(x, y)) pline(msgc_youdiscover, "A door appears in the wall!"); if (otmp->otyp == WAN_OPENING || otmp->otyp == SPE_KNOCK) return TRUE; break; /* striking: continue door handling below */ case WAN_LOCKING: case SPE_WIZARD_LOCK: default: return FALSE; } } switch (otmp->otyp) { case WAN_LOCKING: case SPE_WIZARD_LOCK: if (Is_rogue_level(&u.uz)) { boolean vis = cansee(x, y); /* Can't have real locking in Rogue, so just hide doorway */ if (vis) pline(msgc_actionok, "%s springs up in the older, more primitive doorway.", dustcloud); else You_hear(msgc_actionok, "a swoosh."); if (obstructed(x, y, msgc_yafm)) { if (vis) pline(msgc_yafm, "The cloud %s.", quickly_dissipates); return FALSE; } block_point(x, y); door->typ = SDOOR; if (vis) pline(msgc_actionok, "The doorway vanishes!"); newsym(x, y); return TRUE; } if (obstructed(x, y, msgc_yafm)) return FALSE; /* Don't allow doors to close over traps. This is for pits */ /* & trap doors, but is it ever OK for anything else? */ if (t_at(level, x, y)) { /* maketrap() clears doormask, so it should be NODOOR */ pline(msgc_yafm, "%s springs up in the doorway, but %s.", dustcloud, quickly_dissipates); return FALSE; } if (wandlevel == P_MASTER) { pline(msgc_yafm, "%s springs up in the doorway and conceals it!", dustcloud); door->typ = SDOOR; newsym(x, y); return TRUE; } switch (door->doormask & ~D_TRAPPED) { case D_CLOSED: msg = "The door locks!"; break; case D_ISOPEN: msg = "The door swings shut, and locks!"; break; case D_BROKEN: msg = "The broken door reassembles and locks!"; break; case D_NODOOR: msg = "A cloud of dust springs up and assembles itself into a door!"; break; default: res = FALSE; break; } block_point(x, y); door->doormask = D_LOCKED | (door->doormask & D_TRAPPED); newsym(x, y); break; case WAN_OPENING: case SPE_KNOCK: if (door->doormask & D_LOCKED) { msg = "The door unlocks!"; door->doormask = D_CLOSED | (door->doormask & D_TRAPPED); } else res = FALSE; break; case WAN_STRIKING: case SPE_FORCE_BOLT: if (door->doormask & (D_LOCKED | D_CLOSED)) { if (door->doormask & D_TRAPPED) { if (MON_AT(level, x, y)) mb_trapped(m_at(level, x, y)); else { if (cansee(x, y)) pline(msgc_substitute, "KABOOM!! You see a door explode."); else You_hear(msgc_levelsound, "a distant explosion."); } door->doormask = D_NODOOR; unblock_point(x, y); newsym(x, y); loudness = 40; break; } door->doormask = D_BROKEN; if (cansee(x, y)) pline(msgc_actionok, "The door crashes open!"); else You_hear(msgc_levelsound, "a crashing sound."); unblock_point(x, y); newsym(x, y); /* force vision recalc before printing more messages */ if (turnstate.vision_full_recalc) vision_recalc(0); loudness = 20; } else res = FALSE; break; default: impossible("magic (%d) attempted on door.", otmp->otyp); break; } if (msg && cansee(x, y)) { pline(msgc_actionok, "%s", msg); /* we know whether it's locked now */ level->locations[x][y].mem_door_l = 1; map_background(x, y, TRUE); } if (loudness > 0) { /* door was destroyed */ wake_nearto(x, y, loudness); if (*in_rooms(level, x, y, SHOPBASE)) add_damage(x, y, 0L); } return res; }
/* * Let's destroy the drawbridge located at x,y */ void destroy_drawbridge(int x, int y) { struct rm *loc1, *loc2; struct trap *t; struct obj *chain; int x2, y2, i; boolean e_inview; struct entity *etmp1 = &(occupants[0]), *etmp2 = &(occupants[1]); loc1 = &level->locations[x][y]; if (!IS_DRAWBRIDGE(loc1->typ)) return; x2 = x; y2 = y; get_wall_for_db(&x2, &y2); loc2 = &level->locations[x2][y2]; if ((loc1->drawbridgemask & DB_UNDER) == DB_MOAT || (loc1->drawbridgemask & DB_UNDER) == DB_LAVA) { struct obj *otmp; boolean lava = (loc1->drawbridgemask & DB_UNDER) == DB_LAVA; if (loc1->typ == DRAWBRIDGE_UP) { if (cansee(x2, y2)) pline("The portcullis of the drawbridge falls into the %s!", lava ? "lava" : waterbody_name(x2, y2)); else You_hear("a loud *SPLASH*!"); } else { if (cansee(x, y)) pline("The drawbridge collapses into the %s!", lava ? "lava" : waterbody_name(x, y)); else You_hear("a loud *SPLASH*!"); } loc1->typ = lava ? LAVAPOOL : MOAT; loc1->drawbridgemask = 0; if ((otmp = sobj_at(BOULDER, level, x, y)) != 0) { obj_extract_self(otmp); flooreffects(otmp, x, y, "fall"); } } else { if (cansee(x, y)) pline("The drawbridge disintegrates!"); else You_hear("a loud *CRASH*!"); loc1->typ = ((loc1->drawbridgemask & DB_ICE) ? ICE : ROOM); loc1->icedpool = ((loc1->drawbridgemask & DB_ICE) ? ICED_MOAT : 0); } wake_nearto(x, y, 500); loc2->typ = DOOR; loc2->doormask = D_NODOOR; if ((t = t_at(level, x, y)) != 0) deltrap(level, t); if ((t = t_at(level, x2, y2)) != 0) deltrap(level, t); del_engr_at(level, x, y); del_engr_at(level, x2, y2); for (i = rn2(6); i > 0; --i) { /* scatter some debris */ /* doesn't matter if we happen to pick <x,y2> or <x2,y>; since drawbridges are never placed diagonally, those pairings will always match one of <x,y> or <x2,y2> */ chain = mksobj_at(IRON_CHAIN, level, rn2(2) ? x : x2, rn2(2) ? y : y2, TRUE, FALSE, rng_main); /* a force of 5 here would yield a radius of 2 for iron chain; anything less produces a radius of 1 */ (void) scatter(chain->ox, chain->oy, 1, MAY_HIT, chain); } newsym(x, y); newsym(x2, y2); if (!does_block(level, x2, y2)) unblock_point(x2, y2); /* vision */ if (Is_stronghold(&u.uz)) u.uevent.uopened_dbridge = TRUE; set_entity(x2, y2, etmp2); /* currently only automissers can be here */ if (etmp2->edata) { e_inview = e_canseemon(etmp2); if (!automiss(etmp2)) { if (e_inview) pline("%s blown apart by flying debris.", E_phrase(etmp2, "are")); e_died(etmp2, e_inview ? 3 : 2, CRUSHING, killer_msg(CRUSHING, "an exploding drawbridge")); } /* nothing which is vulnerable can survive this */ } set_entity(x, y, etmp1); if (etmp1->edata) { e_inview = e_canseemon(etmp1); if (!e_missed(etmp1, TRUE)) { if (e_inview) { if (!is_u(etmp1) && Hallucination) pline("%s into some heavy metal!", E_phrase(etmp1, "get")); else pline("%s hit by a huge chunk of metal!", E_phrase(etmp1, "are")); } else { if (!is_u(etmp1) && !is_pool(level, x, y)) You_hear("a crushing sound."); } e_died(etmp1, e_inview ? 3 : 2, CRUSHING, killer_msg(CRUSHING, "a collapsing drawbridge")); /* if (loc1->typ == MOAT) do_entity(etmp1); */ } if (is_u(etmp1)) spoteffects(FALSE); else if (!DEADMONSTER(etmp1->emon)) minliquid(etmp1->emon); } }
/* 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); }
/* * Let's destroy the drawbridge located at x,y */ void destroy_drawbridge(int x, int y) { struct rm *loc1, *loc2; struct trap *t; int x2, y2; boolean e_inview; struct entity *etmp1 = &(occupants[0]), *etmp2 = &(occupants[1]); loc1 = &level->locations[x][y]; if (!IS_DRAWBRIDGE(loc1->typ)) return; x2 = x; y2 = y; get_wall_for_db(&x2, &y2); loc2 = &level->locations[x2][y2]; if ((loc1->drawbridgemask & DB_UNDER) == DB_MOAT || (loc1->drawbridgemask & DB_UNDER) == DB_LAVA) { struct obj *otmp; boolean lava = (loc1->drawbridgemask & DB_UNDER) == DB_LAVA; if (loc1->typ == DRAWBRIDGE_UP) { if (cansee(x2, y2)) pline(msgc_consequence, "The portcullis of the drawbridge falls into the %s!", lava ? "lava" : waterbody_name(x2, y2)); else You_hear(msgc_levelsound, "a loud *SPLASH*!"); } else { if (cansee(x, y)) pline(msgc_consequence, "The drawbridge collapses into the %s!", lava ? "lava" : waterbody_name(x, y)); else You_hear(msgc_levelsound, "a loud *SPLASH*!"); } loc1->typ = lava ? LAVAPOOL : MOAT; loc1->drawbridgemask = 0; if ((otmp = sobj_at(BOULDER, level, x, y)) != 0) { obj_extract_self(otmp); flooreffects(otmp, x, y, "fall"); } } else { if (cansee(x, y)) pline(msgc_consequence, "The drawbridge disintegrates!"); else You_hear(msgc_levelsound, "a loud *CRASH*!"); loc1->typ = ((loc1->drawbridgemask & DB_ICE) ? ICE : ROOM); loc1->icedpool = ((loc1->drawbridgemask & DB_ICE) ? ICED_MOAT : 0); } wake_nearto(x, y, 500); loc2->typ = DOOR; loc2->doormask = D_NODOOR; if ((t = t_at(level, x, y)) != 0) deltrap(level, t); if ((t = t_at(level, x2, y2)) != 0) deltrap(level, t); newsym(x, y); newsym(x2, y2); if (!does_block(level, x2, y2)) unblock_point(x2, y2); /* vision */ if (Is_stronghold(&u.uz)) u.uevent.uopened_dbridge = TRUE; set_entity(x2, y2, etmp2); /* currently only automissers can be here */ if (etmp2->edata) { enum msg_channel hit_msgc; if (is_u(etmp2)) hit_msgc = msgc_fatal_predone; else if (etmp2->emon->mtame && canspotmon(etmp2->emon)) hit_msgc = msgc_petfatal; else hit_msgc = msgc_monneutral; e_inview = e_canseemon(etmp2); if (!automiss(etmp2)) { if (e_inview) pline(hit_msgc, "%s blown apart by flying debris.", E_phrase(etmp2, "are")); e_died(etmp2, e_inview ? 3 : 2, CRUSHING, killer_msg(CRUSHING, "an exploding drawbridge")); } /* nothing which is vulnerable can survive this */ } set_entity(x, y, etmp1); if (etmp1->edata) { enum msg_channel hit_msgc; if (is_u(etmp1)) hit_msgc = msgc_fatal_predone; else if (etmp1->emon->mtame && canspotmon(etmp1->emon)) hit_msgc = msgc_petfatal; else hit_msgc = msgc_monneutral; e_inview = e_canseemon(etmp1); if (!e_missed(etmp1, TRUE)) { if (e_inview) { if (!is_u(etmp1) && Hallucination) pline(hit_msgc, "%s into some heavy metal!", E_phrase(etmp1, "get")); else pline(hit_msgc, "%s hit by a huge chunk of metal!", E_phrase(etmp1, "are")); } else { if (!is_u(etmp1) && !is_pool(level, x, y)) You_hear(msgc_levelsound, "a crushing sound."); } e_died(etmp1, e_inview ? 3 : 2, CRUSHING, killer_msg(CRUSHING, "a collapsing drawbridge")); /* if (loc1->typ == MOAT) do_entity(etmp1); */ } if (is_u(etmp1)) spoteffects(FALSE); else if (!DEADMONSTER(etmp1->emon)) minliquid(etmp1->emon); } }