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

Function abon

src/weapon.c:949–989  ·  view source on GitHub ↗

attack bonus for strength & dexterity */

Source from the content-addressed store, hash-verified

947
948/* attack bonus for strength & dexterity */
949int
950abon(void)
951{
952 int sbon;
953 int str = ACURR(A_STR), dex = ACURR(A_DEX);
954
955 if (Upolyd)
956 return (adj_lev(&mons[u.umonnum]) - 3);
957
958 /* this used to be '<= 18/50' for bonus of 1 but got changed to '< 18/50'
959 so that '18/50' gives a bonus of 2; gnome and orc player characters
960 have max Str of 18/50 and giving an extra bonus at that break point
961 provides an incentive for them to max out that characteristic */
962 if (str < 6)
963 sbon = -2;
964 else if (str < 8)
965 sbon = -1;
966 else if (str < 17)
967 sbon = 0;
968 else if (str < STR18(50))
969 sbon = 1; /* up to 18/49 */
970 else if (str < STR18(100))
971 sbon = 2;
972 else
973 sbon = 3;
974
975 /* Game tuning kludge: make it a bit easier for a low level character to
976 * hit */
977 sbon += (u.ulevel < 3) ? 1 : 0;
978
979 if (dex < 4)
980 return (sbon - 3);
981 else if (dex < 6)
982 return (sbon - 2);
983 else if (dex < 8)
984 return (sbon - 1);
985 else if (dex < 14)
986 return sbon;
987 else
988 return (sbon + dex - 14);
989}
990
991/* damage bonus for strength */
992int

Callers 2

find_roll_to_hitFunction · 0.85
digFunction · 0.85

Calls 1

adj_levFunction · 0.85

Tested by

no test coverage detected