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

Function u_calc_moveamt

src/allmain.c:113–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113staticfn void
114u_calc_moveamt(int wtcap)
115{
116 int moveamt = 0;
117
118 /* calculate how much time passed. */
119 if (u.usteed && u.umoved) {
120 /* your speed doesn't augment steed's speed */
121 moveamt = mcalcmove(u.usteed, TRUE);
122 } else {
123 moveamt = gy.youmonst.data->mmove;
124
125 if (Very_fast) { /* speed boots, potion, or spell */
126 /* gain a free action on 2/3 of turns */
127 if (rn2(3) != 0)
128 moveamt += NORMAL_SPEED;
129 } else if (Fast) { /* intrinsic */
130 /* gain a free action on 1/3 of turns */
131 if (rn2(3) == 0)
132 moveamt += NORMAL_SPEED;
133 }
134 }
135
136 switch (wtcap) {
137 case UNENCUMBERED:
138 break;
139 case SLT_ENCUMBER:
140 moveamt -= (moveamt / 4);
141 break;
142 case MOD_ENCUMBER:
143 moveamt -= (moveamt / 2);
144 break;
145 case HVY_ENCUMBER:
146 moveamt -= ((moveamt * 3) / 4);
147 break;
148 case EXT_ENCUMBER:
149 moveamt -= ((moveamt * 7) / 8);
150 break;
151 default:
152 break;
153 }
154
155 u.umovement += moveamt;
156 if (u.umovement < 0)
157 u.umovement = 0;
158}
159
160/* small chance of generating a new random monster */
161staticfn void

Callers 1

allmain.cFile · 0.85

Calls 2

mcalcmoveFunction · 0.85
rn2Function · 0.85

Tested by

no test coverage detected