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

Function zhitm

src/zap.c:4237–4398  ·  view source on GitHub ↗

used by buzz(); also used by munslime(muse.c); returns damage applied to mon; note: caller is responsible for killing mon if damage is fatal */

Source from the content-addressed store, hash-verified

4235/* used by buzz(); also used by munslime(muse.c); returns damage applied
4236 to mon; note: caller is responsible for killing mon if damage is fatal */
4237int
4238zhitm(
4239 struct monst *mon, /* monster being hit */
4240 int type, /* zap or breath type */
4241 int nd, /* number of hit dice to use */
4242 struct obj **ootmp) /* to return worn armor for caller to disintegrate */
4243{
4244 int tmp = 0, orig_dmg = 0; /* damage amount */
4245 int damgtype = zaptype(type) % 10;
4246 boolean sho_shieldeff = FALSE;
4247 boolean spellcaster = is_hero_spell(type); /* maybe get a bonus! */
4248
4249 *ootmp = (struct obj *) 0;
4250 switch (damgtype) {
4251 case ZT_MAGIC_MISSILE:
4252 if (resists_magm(mon) || defended(mon, AD_MAGM)) {
4253 sho_shieldeff = TRUE;
4254 break;
4255 }
4256 tmp = d(nd, 6);
4257 if (spellcaster)
4258 tmp = spell_damage_bonus(tmp);
4259 break;
4260 case ZT_FIRE:
4261 if (resists_fire(mon) || defended(mon, AD_FIRE)) {
4262 sho_shieldeff = TRUE;
4263 break;
4264 }
4265 tmp = d(nd, 6);
4266 if (spellcaster)
4267 tmp = spell_damage_bonus(tmp);
4268 orig_dmg = tmp; /* includes spell bonus but not monster vuln to fire */
4269 if (resists_cold(mon))
4270 tmp += 7;
4271 if (burnarmor(mon)) {
4272 if (!rn2(3)) {
4273 tmp += destroy_items(mon, AD_FIRE, orig_dmg);
4274 ignite_items(mon->minvent);
4275 }
4276 }
4277 break;
4278 case ZT_COLD:
4279 if (resists_cold(mon) || defended(mon, AD_COLD)) {
4280 sho_shieldeff = TRUE;
4281 break;
4282 }
4283 tmp = d(nd, 6);
4284 if (spellcaster)
4285 tmp = spell_damage_bonus(tmp);
4286 orig_dmg = tmp; /* includes spell bonus but not monster vuln to cold */
4287 if (resists_fire(mon))
4288 tmp += d(nd, 3);
4289 if (!rn2(3))
4290 tmp += destroy_items(mon, AD_COLD, orig_dmg);
4291 break;
4292 case ZT_SLEEP:
4293 /* resistance and shield effect and revealing concealed mimic are
4294 handled by sleep_monst() */

Callers 3

dobuzzFunction · 0.85
cast_chain_lightningFunction · 0.85
muse_unslimeFunction · 0.85

Calls 15

zaptypeFunction · 0.85
resists_magmFunction · 0.85
defendedFunction · 0.85
dFunction · 0.85
spell_damage_bonusFunction · 0.85
burnarmorFunction · 0.85
rn2Function · 0.85
destroy_itemsFunction · 0.85
ignite_itemsFunction · 0.85
sleep_monstFunction · 0.85
healmonFunction · 0.85
which_armorFunction · 0.85

Tested by

no test coverage detected