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

Function zap_hit

src/zap.c:4704–4720  ·  view source on GitHub ↗

will zap/spell/breath attack score a hit against armor class `ac'? */

Source from the content-addressed store, hash-verified

4702
4703/* will zap/spell/breath attack score a hit against armor class `ac'? */
4704staticfn int
4705zap_hit(
4706 int ac,
4707 int type) /* either hero cast spell type or 0 */
4708{
4709 int chance = rn2(20);
4710 int spell_bonus = type ? spell_hit_bonus(type) : 0;
4711
4712 /* small chance for naked target to avoid being hit */
4713 if (!chance)
4714 return rnd(10) < ac + spell_bonus;
4715
4716 /* very high armor protection does not achieve invulnerability */
4717 ac = AC_VALUE(ac);
4718
4719 return (3 - chance < ac + spell_bonus);
4720}
4721
4722staticfn void
4723disintegrate_mon(

Callers 1

dobuzzFunction · 0.85

Calls 3

rn2Function · 0.85
spell_hit_bonusFunction · 0.85
rndFunction · 0.85

Tested by

no test coverage detected