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

Function hmon_hitmon_barehands

src/uhitm.c:837–882  ·  view source on GitHub ↗

hero hits monster bare handed */

Source from the content-addressed store, hash-verified

835
836/* hero hits monster bare handed */
837staticfn void
838hmon_hitmon_barehands(struct _hitmon_data *hmd, struct monst *mon)
839{
840 long spcdmgflg, silverhit = 0L; /* worn masks */
841
842 if (hmd->mdat == &mons[PM_SHADE]) {
843 hmd->dmg = 0;
844 } else {
845 /* note: 1..2 or 1..4 can be substantially increased by
846 strength bonus or skill bonus, usually both... */
847 hmd->dmg = rnd(!martial_bonus() ? 2 : 4);
848 hmd->use_weapon_skill = TRUE;
849 hmd->train_weapon_skill = (hmd->dmg > 1);
850 }
851
852 /* Blessed gloves give bonuses when fighting 'bare-handed'. So do
853 silver rings. Note: rings are worn under gloves, so you don't
854 get both bonuses, and two silver rings don't give double bonus.
855 When making only one hit, both rings are checked (backwards
856 compatibility => playability), but when making two hits, only the
857 ring on the hand making the attack is checked. */
858 spcdmgflg = uarmg ? W_ARMG
859 : (((hmd->twohits == 0 || hmd->twohits == 1) ? W_RINGR : 0L)
860 | ((hmd->twohits == 0 || hmd->twohits == 2) ? W_RINGL : 0L));
861 hmd->dmg += special_dmgval(&gy.youmonst, mon, spcdmgflg, &silverhit);
862
863 /* copy silverhit info back into struct _hitmon_data *hmd */
864 switch (hmd->twohits) {
865 case 0: /* only one hit being attempted; a silver ring on either hand
866 * applies but having silver rings on both is same as just one */
867 hmd->barehand_silver_rings = (silverhit & (W_RINGR | W_RINGL)) ? 1 : 0;
868 break;
869 case 1: /* first of two or more hit attempts; right ring applies */
870 hmd->barehand_silver_rings = (silverhit & W_RINGR) ? 1 : 0;
871 break;
872 case 2: /* second of two or more hit attempts; left ring applies */
873 hmd->barehand_silver_rings = (silverhit & W_RINGL) ? 1 : 0;
874 break;
875 default: /* third or later of more than two hit attempts (poly'd hero);
876 * rings were applied on first and second hits */
877 hmd->barehand_silver_rings = 0;
878 break;
879 }
880 if (hmd->barehand_silver_rings > 0)
881 hmd->silvermsg = TRUE;
882}
883
884staticfn void
885hmon_hitmon_weapon_ranged(

Callers 1

hmon_hitmon_do_hitFunction · 0.85

Calls 2

rndFunction · 0.85
special_dmgvalFunction · 0.85

Tested by

no test coverage detected