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

Function adj_lev

src/makemon.c:2015–2046  ·  view source on GitHub ↗

adjust strength of monsters based on u.uz and u.ulevel */

Source from the content-addressed store, hash-verified

2013
2014/* adjust strength of monsters based on u.uz and u.ulevel */
2015int
2016adj_lev(struct permonst *ptr)
2017{
2018 int tmp, tmp2;
2019
2020 if (ptr == &mons[PM_WIZARD_OF_YENDOR]) {
2021 /* does not depend on other strengths, but does get stronger
2022 * every time he is killed
2023 */
2024 tmp = ptr->mlevel + svm.mvitals[PM_WIZARD_OF_YENDOR].died;
2025 if (tmp > 49)
2026 tmp = 49;
2027 return tmp;
2028 }
2029
2030 if ((tmp = ptr->mlevel) > 49)
2031 return 50; /* "special" demons/devils */
2032 tmp2 = (level_difficulty() - tmp);
2033 if (tmp2 < 0)
2034 tmp--; /* if mlevel > u.uz decrement tmp */
2035 else
2036 tmp += (tmp2 / 5); /* else increment 1 per five diff */
2037
2038 tmp2 = (u.ulevel - ptr->mlevel); /* adjust vs. the player */
2039 if (tmp2 > 0)
2040 tmp += (tmp2 / 4); /* level as well */
2041
2042 tmp2 = (3 * ((int) ptr->mlevel)) / 2; /* crude upper limit */
2043 if (tmp2 > 49)
2044 tmp2 = 49; /* hard upper limit */
2045 return ((tmp > tmp2) ? tmp2 : (tmp > 0 ? tmp : 0)); /* 0 lower limit */
2046}
2047
2048/* monster earned experience and will gain some hit points; it might also
2049 grow into a bigger monster (baby to adult, soldier to officer, etc) */

Callers 4

really_doneFunction · 0.85
abonFunction · 0.85
newmonhpFunction · 0.85
mkclass_alignedFunction · 0.85

Calls 1

level_difficultyFunction · 0.85

Tested by

no test coverage detected