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

Function wand_explode

src/read.c:2413–2457  ·  view source on GitHub ↗

overcharging any wand or zapping/engraving cursed wand */

Source from the content-addressed store, hash-verified

2411
2412/* overcharging any wand or zapping/engraving cursed wand */
2413void
2414wand_explode(struct obj *obj, int chg /* recharging */)
2415{
2416 const char *expl = !chg ? "suddenly" : "vibrates violently and";
2417 int dmg, n, k;
2418
2419 /* number of damage dice */
2420 if (!chg)
2421 chg = 2; /* zap/engrave adjustment */
2422 n = obj->spe + chg;
2423 if (n < 2)
2424 n = 2; /* arbitrary minimum */
2425 /* size of damage dice */
2426 switch (obj->otyp) {
2427 case WAN_WISHING:
2428 k = 12;
2429 break;
2430 case WAN_CANCELLATION:
2431 case WAN_DEATH:
2432 case WAN_POLYMORPH:
2433 case WAN_UNDEAD_TURNING:
2434 k = 10;
2435 break;
2436 case WAN_COLD:
2437 case WAN_FIRE:
2438 case WAN_LIGHTNING:
2439 case WAN_MAGIC_MISSILE:
2440 k = 8;
2441 break;
2442 case WAN_NOTHING:
2443 k = 4;
2444 break;
2445 default:
2446 k = 6;
2447 break;
2448 }
2449 /* inflict damage and destroy the wand */
2450 dmg = d(n, k);
2451 obj->in_use = TRUE; /* in case losehp() is fatal (or --More--^C) */
2452 pline("%s %s explodes!", Yname2(obj), expl);
2453 losehp(Maybe_Half_Phys(dmg), "exploding wand", KILLED_BY_AN);
2454 useup(obj);
2455 /* obscure side-effect */
2456 exercise(A_STR, FALSE);
2457}
2458
2459/* used to collect gremlins being hit by light so that they can be processed
2460 after vision for the entire lit area has been brought up to date */

Callers 2

doengrave_sfx_itemFunction · 0.85
rechargeFunction · 0.85

Calls 6

dFunction · 0.85
Yname2Function · 0.85
losehpFunction · 0.85
useupFunction · 0.85
exerciseFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected