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

Function dog_nutrition

src/dogmove.c:155–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155int
156dog_nutrition(struct monst *mtmp, struct obj *obj)
157{
158 int nutrit;
159
160 /*
161 * It is arbitrary that the pet takes the same length of time to eat
162 * as a human, but gets more nutritional value.
163 */
164 if (obj->oclass == FOOD_CLASS) {
165 if (obj->otyp == CORPSE) {
166 mtmp->meating = 3 + (mons[obj->corpsenm].cwt >> 6);
167 nutrit = mons[obj->corpsenm].cnutrit;
168 } else {
169 mtmp->meating = objects[obj->otyp].oc_delay;
170 nutrit = objects[obj->otyp].oc_nutrition;
171 }
172 switch (mtmp->data->msize) {
173 case MZ_TINY:
174 nutrit *= 8;
175 break;
176 case MZ_SMALL:
177 nutrit *= 6;
178 break;
179 default:
180 case MZ_MEDIUM:
181 nutrit *= 5;
182 break;
183 case MZ_LARGE:
184 nutrit *= 4;
185 break;
186 case MZ_HUGE:
187 nutrit *= 3;
188 break;
189 case MZ_GIGANTIC:
190 nutrit *= 2;
191 break;
192 }
193 if (obj->oeaten) {
194 mtmp->meating = eaten_stat(mtmp->meating, obj);
195 nutrit = eaten_stat(nutrit, obj);
196 }
197 } else if (obj->oclass == COIN_CLASS) {
198 mtmp->meating = (int) (obj->quan / 2000) + 1;
199 if (mtmp->meating < 0)
200 mtmp->meating = 1;
201 nutrit = (int) (obj->quan / 20);
202 if (nutrit < 0)
203 nutrit = 0;
204 } else {
205 /* Unusual pet such as gelatinous cube eating odd stuff.
206 * meating made consistent with wild monsters in mon.c.
207 * nutrit made consistent with polymorphed player nutrit in
208 * eat.c. (This also applies to pets eating gold.)
209 */
210 mtmp->meating = obj->owt / 20 + 1;
211 nutrit = 5 * objects[obj->otyp].oc_nutrition;
212 }

Callers 3

mhitm_ad_dgstFunction · 0.85
dog_eatFunction · 0.85
mon_consume_unstoneFunction · 0.85

Calls 1

eaten_statFunction · 0.85

Tested by

no test coverage detected