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

Function zapyourself

src/zap.c:2704–3013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2702}
2703
2704int
2705zapyourself(struct obj *obj, boolean ordinary)
2706{
2707 boolean learn_it = FALSE;
2708 int damage = 0;
2709 int orig_dmg = 0; /* for passing to destroy_items() */
2710
2711 switch (obj->otyp) {
2712 case WAN_STRIKING:
2713 case SPE_FORCE_BOLT:
2714 learn_it = TRUE;
2715 if (Antimagic) {
2716 shieldeff(u.ux, u.uy);
2717 pline("Boing!");
2718 monstseesu(M_SEEN_MAGR);
2719 } else {
2720 if (ordinary) {
2721 You("bash yourself!");
2722 damage = d(2, 12);
2723 } else
2724 damage = d(1 + obj->spe, 6);
2725 exercise(A_STR, FALSE);
2726 monstunseesu(M_SEEN_MAGR);
2727 }
2728 break;
2729
2730 case WAN_LIGHTNING:
2731 learn_it = TRUE;
2732 orig_dmg = d(12, 6);
2733 if (!Shock_resistance) {
2734 You("shock yourself!");
2735 damage = orig_dmg;
2736 exercise(A_CON, FALSE);
2737 monstunseesu(M_SEEN_ELEC);
2738 } else {
2739 shieldeff(u.ux, u.uy);
2740 You("zap yourself, but seem unharmed.");
2741 monstseesu(M_SEEN_ELEC);
2742 ugolemeffects(AD_ELEC, orig_dmg);
2743 }
2744 (void) destroy_items(&gy.youmonst, AD_ELEC, orig_dmg);
2745 (void) flashburn((long) rnd(100), TRUE);
2746 break;
2747
2748 case SPE_FIREBALL:
2749 You("explode a fireball on top of yourself!");
2750 explode(u.ux, u.uy, 11, d(6, 6), WAND_CLASS, EXPL_FIERY);
2751 break;
2752 case WAN_FIRE:
2753 case FIRE_HORN:
2754 learn_it = TRUE;
2755 orig_dmg = d(12, 6);
2756 if (Fire_resistance) {
2757 shieldeff(u.ux, u.uy);
2758 You_feel("rather warm.");
2759 monstseesu(M_SEEN_FIRE);
2760 ugolemeffects(AD_FIRE, orig_dmg);
2761 } else {

Callers 5

do_improvisationFunction · 0.85
dozapFunction · 0.85
spelleffectsFunction · 0.85
use_cameraFunction · 0.85
do_break_wandFunction · 0.85

Calls 15

shieldeffFunction · 0.85
monstseesuFunction · 0.85
YouFunction · 0.85
dFunction · 0.85
exerciseFunction · 0.85
monstunseesuFunction · 0.85
ugolemeffectsFunction · 0.85
destroy_itemsFunction · 0.85
flashburnFunction · 0.85
rndFunction · 0.85
explodeFunction · 0.85
You_feelFunction · 0.85

Tested by

no test coverage detected