MCPcopy Index your code
hub / github.com/NetHack/NetHack / use_bell

Function use_bell

src/apply.c:1201–1316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1199}
1200
1201staticfn void
1202use_bell(struct obj **optr)
1203{
1204 struct obj *obj = *optr;
1205 struct monst *mtmp;
1206 boolean wakem = FALSE, learno = FALSE,
1207 ordinary = (obj->otyp != BELL_OF_OPENING || !obj->spe),
1208 invoking = (obj->otyp == BELL_OF_OPENING
1209 && invocation_pos(u.ux, u.uy)
1210 && !On_stairs(u.ux, u.uy));
1211
1212 Hero_playnotes(obj_to_instr(obj), "C", 100);
1213 You("ring %s.", the(xname(obj)));
1214
1215 if (Underwater || (u.uswallow && ordinary)) {
1216 pline("But the sound is muffled.");
1217
1218 } else if (invoking && ordinary) {
1219 /* needs to be recharged... */
1220 pline("But it makes no sound.");
1221 learno = TRUE; /* help player figure out why */
1222
1223 } else if (ordinary) {
1224 if (obj->cursed && !rn2(4)
1225 /* note: once any of them are gone, we stop all of them */
1226 && !(svm.mvitals[PM_WOOD_NYMPH].mvflags & G_GONE)
1227 && !(svm.mvitals[PM_WATER_NYMPH].mvflags & G_GONE)
1228 && !(svm.mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE)
1229 && (mtmp = makemon(mkclass(S_NYMPH, 0), u.ux, u.uy,
1230 NO_MINVENT | MM_NOMSG)) != 0) {
1231 You("summon %s!", a_monnam(mtmp));
1232 if (!obj_resists(obj, 93, 100)) {
1233 pline("%s shattered!", Tobjnam(obj, "have"));
1234 useup(obj);
1235 *optr = 0;
1236 } else
1237 switch (rn2(3)) {
1238 default:
1239 break;
1240 case 1:
1241 mon_adjust_speed(mtmp, 2, (struct obj *) 0);
1242 break;
1243 case 2: /* no explanation; it just happens... */
1244 gn.nomovemsg = "";
1245 gm.multi_reason = NULL;
1246 nomul(-rnd(2));
1247 break;
1248 }
1249 }
1250 wakem = TRUE;
1251
1252 } else {
1253 /* charged Bell of Opening */
1254 consume_obj_charge(obj, TRUE);
1255
1256 if (u.uswallow) {
1257 if (!obj->cursed)
1258 (void) openit();

Callers 1

doapplyFunction · 0.85

Calls 15

invocation_posFunction · 0.85
On_stairsFunction · 0.85
obj_to_instrFunction · 0.85
YouFunction · 0.85
theFunction · 0.85
xnameFunction · 0.85
rn2Function · 0.85
makemonFunction · 0.85
mkclassFunction · 0.85
a_monnamFunction · 0.85
obj_resistsFunction · 0.85
TobjnamFunction · 0.85

Tested by

no test coverage detected