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

Function damageum

src/uhitm.c:4834–4884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4832}
4833
4834int
4835damageum(
4836 struct monst *mdef, /* target */
4837 struct attack *mattk, /* hero's attack */
4838 int specialdmg) /* blessed and/or silver bonus against various things */
4839{
4840 struct mhitm_data mhm;
4841
4842 mhm.damage = d((int) mattk->damn, (int) mattk->damd);
4843 mhm.hitflags = M_ATTK_MISS;
4844 mhm.permdmg = 0;
4845 mhm.specialdmg = specialdmg;
4846 mhm.done = FALSE;
4847
4848 if (is_demon(gy.youmonst.data) && !rn2(13) && !uwep
4849 && u.umonnum != PM_AMOROUS_DEMON && u.umonnum != PM_BALROG) {
4850 demonpet();
4851 return M_ATTK_MISS;
4852 }
4853
4854 mhitm_adtyping(&gy.youmonst, mattk, mdef, &mhm);
4855
4856 if (mhm.done)
4857 return mhm.hitflags;
4858
4859 mdef->mstrategy &= ~STRAT_WAITFORU; /* in case player is very fast */
4860 mdef->mhp -= mhm.damage;
4861 if (DEADMONSTER(mdef)) {
4862 /* troll killed by Trollsbane won't auto-revive; FIXME? same when
4863 Trollsbane is wielded as primary and two-weaponing kills with
4864 secondary, which matches monster vs monster behavior but is
4865 different from the non-poly'd hero vs monster behavior */
4866 if (mattk->aatyp == AT_WEAP || mattk->aatyp == AT_CLAW)
4867 gm.mkcorpstat_norevive = troll_baned(mdef, uwep) ? TRUE : FALSE;
4868 /* (DEADMONSTER(mdef) and !mhm.damage => already killed) */
4869 if (mdef->mtame && !cansee(mdef->mx, mdef->my)) {
4870 You_feel("embarrassed for a moment.");
4871 if (mhm.damage)
4872 xkilled(mdef, XKILL_NOMSG);
4873 } else if (!flags.verbose) {
4874 You("destroy it!");
4875 if (mhm.damage)
4876 xkilled(mdef, XKILL_NOMSG);
4877 } else if (mhm.damage) {
4878 killed(mdef); /* regular "you kill <mdef>" message */
4879 }
4880 gm.mkcorpstat_norevive = FALSE;
4881 return M_ATTK_DEF_DIED;
4882 }
4883 return M_ATTK_HIT;
4884}
4885
4886/* Hero, as a monster which is capable of an exploding attack mattk, is
4887 * exploding at a target monster mdef, or just exploding at nothing (e.g. with

Callers 2

hmonasFunction · 0.85
kick_monsterFunction · 0.85

Calls 8

dFunction · 0.85
rn2Function · 0.85
demonpetFunction · 0.85
mhitm_adtypingFunction · 0.85
You_feelFunction · 0.85
xkilledFunction · 0.85
YouFunction · 0.85
killedFunction · 0.85

Tested by

no test coverage detected