MCPcopy Index your code
hub / github.com/NetHack/NetHack / experience

Function experience

src/exper.c:84–166  ·  view source on GitHub ↗

return # of exp points for mtmp after nk killed */

Source from the content-addressed store, hash-verified

82
83/* return # of exp points for mtmp after nk killed */
84int
85experience(struct monst *mtmp, int nk)
86{
87 struct permonst *ptr = mtmp->data;
88 int i, tmp, tmp2;
89
90 tmp = 1 + mtmp->m_lev * mtmp->m_lev;
91
92 /* For higher ac values, give extra experience */
93 if ((i = find_mac(mtmp)) < 3)
94 tmp += (7 - i) * ((i < 0) ? 2 : 1);
95
96 /* For very fast monsters, give extra experience */
97 if (ptr->mmove > NORMAL_SPEED)
98 tmp += (ptr->mmove > (3 * NORMAL_SPEED / 2)) ? 5 : 3;
99
100 /* For each "special" attack type give extra experience */
101 for (i = 0; i < NATTK; i++) {
102 tmp2 = ptr->mattk[i].aatyp;
103 if (tmp2 > AT_BUTT) {
104 if (tmp2 == AT_WEAP)
105 tmp += 5;
106 else if (tmp2 == AT_MAGC)
107 tmp += 10;
108 else
109 tmp += 3;
110 }
111 }
112
113 /* For each "special" damage type give extra experience */
114 for (i = 0; i < NATTK; i++) {
115 tmp2 = ptr->mattk[i].adtyp;
116 if (tmp2 > AD_PHYS && tmp2 < AD_BLND)
117 tmp += 2 * mtmp->m_lev;
118 else if ((tmp2 == AD_DRLI) || (tmp2 == AD_STON) || (tmp2 == AD_SLIM))
119 tmp += 50;
120 else if (tmp2 != AD_PHYS)
121 tmp += mtmp->m_lev;
122 /* extra heavy damage bonus */
123 if ((int) (ptr->mattk[i].damd * ptr->mattk[i].damn) > 23)
124 tmp += mtmp->m_lev;
125 if (tmp2 == AD_WRAP && ptr->mlet == S_EEL && !Amphibious)
126 tmp += 1000;
127 }
128
129 /* For certain "extra nasty" monsters, give even more */
130 if (extra_nasty(ptr))
131 tmp += (7 * mtmp->m_lev);
132
133 /* For higher level monsters, an additional bonus is given */
134 if (mtmp->m_lev > 8)
135 tmp += 50;
136
137#ifdef MAIL_STRUCTURES
138 /* Mail daemons put up no fight. */
139 if (mtmp->data == &mons[PM_MAIL_DAEMON])
140 tmp = 1;
141#endif

Callers 3

domove_swap_with_petFunction · 0.85
xkilledFunction · 0.85
see_monster_closeupFunction · 0.85

Calls 1

find_macFunction · 0.85

Tested by

no test coverage detected