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

Function domagictrap

src/trap.c:4316–4451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4314}
4315
4316staticfn void
4317domagictrap(void)
4318{
4319 int fate = rnd(20);
4320
4321 /* What happened to the poor sucker? */
4322
4323 if (fate < 10) {
4324 /* Most of the time, it creates some monsters. */
4325 int cnt = rnd(4);
4326
4327 /* blindness effects */
4328 if (!resists_blnd(&gy.youmonst)) {
4329 You("are momentarily blinded by a flash of light!");
4330 make_blinded((long) rn1(5, 10), FALSE);
4331 if (!Blind)
4332 Your1(vision_clears);
4333 } else if (!Blind) {
4334 You_see("a flash of light!");
4335 }
4336
4337 /* deafness effects */
4338 if (!Deaf) {
4339 Soundeffect(se_deafening_roar_atmospheric, 100);
4340 You_hear("a deafening roar!");
4341 incr_itimeout(&HDeaf, rn1(20, 30));
4342 disp.botl = TRUE;
4343 } else {
4344 /* magic vibrations still hit you */
4345 You_feel("rankled.");
4346 incr_itimeout(&HDeaf, rn1(5, 15));
4347 disp.botl = TRUE;
4348 }
4349 while (cnt--)
4350 (void) makemon((struct permonst *) 0, u.ux, u.uy, NO_MM_FLAGS);
4351 /* roar: wake monsters in vicinity, after placing trap-created ones */
4352 wake_nearto(u.ux, u.uy, 7 * 7);
4353 /* [flash: should probably also hit nearby gremlins with light] */
4354 } else {
4355 switch (fate) {
4356 case 10:
4357 /* sometimes nothing happens */
4358 break;
4359 case 11: /* toggle intrinsic invisibility */
4360 Soundeffect(se_low_hum, 100);
4361 You_hear("a low hum.");
4362 if (!Invis) {
4363 if (!Blind)
4364 self_invis_message();
4365 } else if (!EInvis && !pm_invisible(gy.youmonst.data)) {
4366 if (!Blind) {
4367 if (!See_invisible)
4368 You("can see yourself again!");
4369 else
4370 You_cant("see through yourself anymore.");
4371 }
4372 } else {
4373 /* If we're invisible from another source */

Callers 1

trapeffect_magic_trapFunction · 0.85

Calls 15

rndFunction · 0.85
resists_blndFunction · 0.85
YouFunction · 0.85
make_blindedFunction · 0.85
You_seeFunction · 0.85
You_hearFunction · 0.85
incr_itimeoutFunction · 0.85
You_feelFunction · 0.85
makemonFunction · 0.85
wake_neartoFunction · 0.85
self_invis_messageFunction · 0.85
You_cantFunction · 0.85

Tested by

no test coverage detected