From 6d374f9306213c65441e8b5f8598f1294d4d720d Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 11 May 2025 20:28:20 +0300 Subject: [PATCH] No knockback with flimsy or non-blunt weapon Weapons that can do knockback are lucern hammer, bec de corbin, dwarvish mattock, (silver) mace, morning star, war hammer, club, quarterstaff, aklys, flail, pick-axe, and grappling hook. --- include/obj.h | 3 +++ src/uhitm.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/obj.h b/include/obj.h index 3b1524b17..782f545bf 100644 --- a/include/obj.h +++ b/include/obj.h @@ -246,6 +246,9 @@ struct obj { ((o)->oclass == TOOL_CLASS && objects[(o)->otyp].oc_skill != P_NONE) /* towel is not a weptool: spe isn't an enchantment, cursed towel doesn't weld to hand, and twoweapon won't work with one */ +#define is_blunt_weapon(o) \ + (((o)->oclass == WEAPON_CLASS || is_weptool(o)) \ + && ((objects[(o)->otyp].oc_dir & WHACK) != 0)) #define is_wet_towel(o) ((o)->otyp == TOWEL && (o)->spe > 0) #define bimanual(otmp) \ ((otmp->oclass == WEAPON_CLASS || otmp->oclass == TOOL_CLASS) \ diff --git a/src/uhitm.c b/src/uhitm.c index ced52abc5..d03a267dc 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -5189,6 +5189,8 @@ mhitm_knockback( boolean u_agr = (magr == &gy.youmonst); boolean u_def = (mdef == &gy.youmonst); boolean was_u = FALSE, dismount = FALSE; + struct obj *wep = weapon_used ? (u_agr ? uwep : MON_WEP(magr)) + : (struct obj *)0; /* 1/6 chance of attack knocking back a monster */ if (rn2(6)) @@ -5236,12 +5238,16 @@ mhitm_knockback( if (!(magr->data->msize > (mdef->data->msize + 1))) return FALSE; + /* no knockback with a flimsy or non-blunt weapon */ + if (wep && (is_flimsy(wep) || !is_blunt_weapon(wep))) + return FALSE; + /* only certain attacks qualify for knockback */ if (!((mattk->adtyp == AD_PHYS) && (mattk->aatyp == AT_CLAW || mattk->aatyp == AT_KICK || mattk->aatyp == AT_BUTT - || (mattk->aatyp == AT_WEAP && !weapon_used)))) + || mattk->aatyp == AT_WEAP))) return FALSE; /* needs a solid physical hit */