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

Function weight_cap

src/hack.c:4294–4346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4292}
4293
4294int
4295weight_cap(void)
4296{
4297 long carrcap, save_ELev = ELevitation, save_BLev = BLevitation;
4298
4299 /* boots take multiple turns to wear but any properties they
4300 confer are enabled at the start rather than the end; that
4301 causes message sequencing issues for boots of levitation
4302 so defer their encumbrance benefit until they're fully worn */
4303 if (ga.afternmv == Boots_on && (ELevitation & W_ARMF) != 0L) {
4304 ELevitation &= ~W_ARMF;
4305 float_vs_flight(); /* in case Levitation is blocking Flying */
4306 }
4307 /* levitation is blocked by being trapped in the floor, but it still
4308 functions enough in that situation to enhance carrying capacity */
4309 BLevitation &= ~I_SPECIAL;
4310
4311 carrcap = (WT_WEIGHTCAP_STRCON * (ACURRSTR + ACURR(A_CON)))
4312 + WT_WEIGHTCAP_SPARE;
4313 if (Upolyd) {
4314 /* consistent with can_carry() in mon.c */
4315 if (gy.youmonst.data->mlet == S_NYMPH)
4316 carrcap = MAX_CARR_CAP;
4317 else if (!gy.youmonst.data->cwt)
4318 carrcap = (carrcap * (long) gy.youmonst.data->msize) / MZ_HUMAN;
4319 else if (!strongmonst(gy.youmonst.data)
4320 || (strongmonst(gy.youmonst.data)
4321 && (gy.youmonst.data->cwt > WT_HUMAN)))
4322 carrcap = (carrcap * (long) gy.youmonst.data->cwt / WT_HUMAN);
4323 }
4324
4325 if (Levitation || Is_airlevel(&u.uz) /* pugh@cornell */
4326 || (u.usteed && strongmonst(u.usteed->data))) {
4327 carrcap = MAX_CARR_CAP;
4328 } else {
4329 if (carrcap > MAX_CARR_CAP)
4330 carrcap = MAX_CARR_CAP;
4331 if (!Flying) {
4332 if (EWounded_legs & LEFT_SIDE)
4333 carrcap -= WT_WOUNDEDLEG_REDUCT;
4334 if (EWounded_legs & RIGHT_SIDE)
4335 carrcap -= WT_WOUNDEDLEG_REDUCT;
4336 }
4337 }
4338
4339 if (ELevitation != save_ELev || BLevitation != save_BLev) {
4340 ELevitation = save_ELev;
4341 BLevitation = save_BLev;
4342 float_vs_flight();
4343 }
4344
4345 return (int) max(carrcap, 1L); /* never return 0 */
4346}
4347
4348/* returns how far beyond the normal capacity the player is currently. */
4349/* inv_weight() is negative if the player is below normal capacity. */

Callers 7

litterFunction · 0.85
cant_squeeze_thruFunction · 0.85
inv_weightFunction · 0.85
hurtle_stepFunction · 0.85
try_disarmFunction · 0.85
kick_monsterFunction · 0.85
dokickFunction · 0.85

Calls 1

float_vs_flightFunction · 0.85

Tested by

no test coverage detected