MCPcopy Create free account
hub / github.com/NetHack/NetHack / trapeffect_anti_magic

Function trapeffect_anti_magic

src/trap.c:2322–2450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2320}
2321
2322staticfn int
2323trapeffect_anti_magic(
2324 struct monst *mtmp, /* monster, possibly youmonst */
2325 struct trap *trap, /* trap->ttyp == ANTI_MAGIC */
2326 unsigned int trflags UNUSED)
2327{
2328 if (wearing_iron_shoes(mtmp)) {
2329 struct obj *shoes = which_armor(mtmp, W_ARMF);
2330 /* iron shoes protect against antimagic traps only if
2331 positively enchanted; the trap drains the enchantment
2332 rather than the wearer */
2333 if (shoes->spe > 0) {
2334 /* no message if a monster does this, it isn't visible enough */
2335 if (mtmp == &gy.youmonst) {
2336 seetrap(trap);
2337 pline("A lethargic aura surrounds %s.", yname(shoes));
2338 costly_alteration(shoes, COST_DECHNT);
2339 }
2340 shoes->spe -= 1;
2341 update_inventory();
2342 return Trap_Effect_Finished;
2343 }
2344 }
2345
2346 if (mtmp == &gy.youmonst) {
2347 int drain, halfd;
2348 boolean exclaim_it = FALSE;
2349
2350 seetrap(trap);
2351 if (Antimagic) {
2352 struct obj *otmp;
2353 int dmgval2 = rnd(4), hp = Upolyd ? u.mh : u.uhp;
2354
2355 /* Half_XXX_damage has opposite its usual effect (approx)
2356 but isn't cumulative if hero has more than one */
2357 if (Half_physical_damage || Half_spell_damage)
2358 dmgval2 += rnd(4);
2359 /* give Magicbane wielder dose of own medicine */
2360 if (u_wield_art(ART_MAGICBANE))
2361 dmgval2 += rnd(4);
2362 /* having an artifact--other than own quest one--which
2363 confers magic resistance simply by being carried
2364 also increases the effect */
2365 for (otmp = gi.invent; otmp; otmp = otmp->nobj)
2366 if (otmp->oartifact && !is_quest_artifact(otmp)
2367 && defends_when_carried(AD_MAGM, otmp))
2368 break;
2369 if (otmp)
2370 dmgval2 += rnd(4);
2371 if (Passes_walls)
2372 dmgval2 = (dmgval2 + 3) / 4;
2373
2374 You_feel((dmgval2 >= hp) ? "unbearably torpid!"
2375 : (dmgval2 >= hp / 4) ? "very lethargic."
2376 : "sluggish.");
2377 /* opposite of magical explosion */
2378 losehp(dmgval2, "anti-magic implosion", KILLED_BY_AN);
2379 }

Callers 1

trapeffect_selectorFunction · 0.85

Calls 15

wearing_iron_shoesFunction · 0.85
which_armorFunction · 0.85
seetrapFunction · 0.85
ynameFunction · 0.85
costly_alterationFunction · 0.85
update_inventoryFunction · 0.85
rndFunction · 0.85
is_quest_artifactFunction · 0.85
defends_when_carriedFunction · 0.85
You_feelFunction · 0.85
losehpFunction · 0.85
dFunction · 0.85

Tested by

no test coverage detected