MCPcopy Create free account
hub / github.com/JACoders/OpenJK / PredictedAngularDecrement

Function PredictedAngularDecrement

code/game/FighterNPC.cpp:248–284  ·  view source on GitHub ↗

method of decrementing the given angle based on the given taking variable frame times into account

Source from the content-addressed store, hash-verified

246
247//method of decrementing the given angle based on the given taking variable frame times into account
248static float PredictedAngularDecrement(float scale, float timeMod, float originalAngle)
249{
250 float fixedBaseDec = originalAngle*0.05f;
251 float r = 0.0f;
252
253 if (fixedBaseDec < 0.0f)
254 {
255 fixedBaseDec = -fixedBaseDec;
256 }
257
258 fixedBaseDec *= (1.0f+(1.0f-scale));
259
260 if (fixedBaseDec < 0.1f)
261 { //don't increment in incredibly small fractions, it would eat up unnecessary bandwidth.
262 fixedBaseDec = 0.1f;
263 }
264
265 fixedBaseDec *= (timeMod*0.1f);
266 if (originalAngle > 0.0f)
267 { //subtract
268 r = (originalAngle-fixedBaseDec);
269 if (r < 0.0f)
270 {
271 r = 0.0f;
272 }
273 }
274 else if (originalAngle < 0.0f)
275 { //add
276 r = (originalAngle+fixedBaseDec);
277 if (r > 0.0f)
278 {
279 r = 0.0f;
280 }
281 }
282
283 return r;
284}
285
286#ifdef QAGAME//only do this check on GAME side, because if it's CGAME, it's being predicted, and it's only predicted if the local client is the driver
287qboolean FighterIsInSpace( gentity_t *gParent )

Callers 2

ProcessMoveCommandsFunction · 0.70
FighterNPC.cppFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected