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

Function mhitm_ad_phys

src/uhitm.c:3980–4200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3978}
3979
3980void
3981mhitm_ad_phys(
3982 struct monst *magr, struct attack *mattk,
3983 struct monst *mdef, struct mhitm_data *mhm)
3984{
3985 struct permonst *pa = magr->data;
3986 struct permonst *pd = mdef->data;
3987
3988 if (magr == &gy.youmonst) {
3989 /* uhitm */
3990 if (pd == &mons[PM_SHADE]) {
3991 mhm->damage = 0;
3992 if (!mhm->specialdmg)
3993 impossible("bad shade attack function flow?");
3994 }
3995 mhm->damage += mhm->specialdmg;
3996
3997 if (mattk->aatyp == AT_WEAP) {
3998 /* hmonas() uses known_hitum() to deal physical damage,
3999 then also damageum() for non-AD_PHYS; don't inflict
4000 extra physical damage for unusual damage types */
4001 mhm->damage = 0;
4002 } else if (mattk->aatyp == AT_KICK
4003 || mattk->aatyp == AT_CLAW
4004 || mattk->aatyp == AT_TUCH
4005 || mattk->aatyp == AT_HUGS) {
4006 if (thick_skinned(pd))
4007 mhm->damage = (mattk->aatyp == AT_KICK) ? 0
4008 : (mhm->damage + 1) / 2;
4009 /* add ring(s) of increase damage */
4010 if (u.udaminc > 0) {
4011 /* applies even if damage was 0 */
4012 mhm->damage += u.udaminc;
4013 } else if (mhm->damage > 0) {
4014 /* ring(s) might be negative; avoid converting
4015 0 to non-0 or positive to non-positive */
4016 mhm->damage += u.udaminc;
4017 if (mhm->damage < 1)
4018 mhm->damage = 1;
4019 }
4020 }
4021 } else if (mdef == &gy.youmonst) {
4022 /* mhitu */
4023 if (mattk->aatyp == AT_HUGS && !sticks(pd)) {
4024 if (!u.ustuck && rn2(2)) {
4025 if (u_slip_free(magr, mattk)) {
4026 mhm->damage = 0;
4027 mhm->hitflags |= M_ATTK_MISS;
4028 } else {
4029 set_ustuck(magr);
4030 pline_mon(magr, "%s grabs you!", Monnam(magr));
4031 mhm->hitflags |= M_ATTK_HIT;
4032 }
4033 } else if (u.ustuck == magr) {
4034 exercise(A_STR, FALSE);
4035 You("are being %s.",
4036 (pa == &mons[PM_ROPE_GOLEM]) ? "choked" : "crushed");
4037 }

Callers 5

mhitm_ad_wereFunction · 0.85
mhitm_ad_healFunction · 0.85
mhitm_ad_stunFunction · 0.85
mhitm_ad_legsFunction · 0.85
mhitm_adtypingFunction · 0.85

Calls 15

sticksFunction · 0.85
rn2Function · 0.85
u_slip_freeFunction · 0.85
set_ustuckFunction · 0.85
pline_monFunction · 0.85
MonnamFunction · 0.85
exerciseFunction · 0.85
YouFunction · 0.85
permapoisonedFunction · 0.85
do_stone_uFunction · 0.85
dmgvalFunction · 0.85
which_armorFunction · 0.85

Tested by

no test coverage detected