MCPcopy Create free account
hub / github.com/demoth/jake2 / PM_AddCurrents

Method PM_AddCurrents

qcommon/src/main/java/jake2/qcommon/PMove.java:375–449  ·  view source on GitHub ↗

PM_AddCurrents.

(float[] wishvel)

Source from the content-addressed store, hash-verified

373 * PM_AddCurrents.
374 */
375 public static void PM_AddCurrents(float[] wishvel) {
376 float[] v = { 0, 0, 0 };
377 float s;
378
379 // account for ladders
380 if (pml.ladder && Math.abs(pml.velocity[2]) <= 200) {
381 if ((pm.viewangles[Defines.PITCH] <= -15)
382 && (pm.cmd.forwardmove > 0))
383 wishvel[2] = 200;
384 else if ((pm.viewangles[Defines.PITCH] >= 15)
385 && (pm.cmd.forwardmove > 0))
386 wishvel[2] = -200;
387 else if (pm.cmd.upmove > 0)
388 wishvel[2] = 200;
389 else if (pm.cmd.upmove < 0)
390 wishvel[2] = -200;
391 else
392 wishvel[2] = 0;
393
394 // limit horizontal speed when on a ladder
395 if (wishvel[0] < -25)
396 wishvel[0] = -25;
397 else if (wishvel[0] > 25)
398 wishvel[0] = 25;
399
400 if (wishvel[1] < -25)
401 wishvel[1] = -25;
402 else if (wishvel[1] > 25)
403 wishvel[1] = 25;
404 }
405
406 // add water currents
407 if ((pm.watertype & Defines.MASK_CURRENT) != 0) {
408 Math3D.VectorClear(v);
409
410 if ((pm.watertype & Defines.CONTENTS_CURRENT_0) != 0)
411 v[0] += 1;
412 if ((pm.watertype & Defines.CONTENTS_CURRENT_90) != 0)
413 v[1] += 1;
414 if ((pm.watertype & Defines.CONTENTS_CURRENT_180) != 0)
415 v[0] -= 1;
416 if ((pm.watertype & Defines.CONTENTS_CURRENT_270) != 0)
417 v[1] -= 1;
418 if ((pm.watertype & Defines.CONTENTS_CURRENT_UP) != 0)
419 v[2] += 1;
420 if ((pm.watertype & Defines.CONTENTS_CURRENT_DOWN) != 0)
421 v[2] -= 1;
422
423 s = pm_waterspeed;
424 if ((pm.waterlevel == 1) && (pm.groundentity != null))
425 s /= 2;
426
427 Math3D.VectorMA(wishvel, s, v, wishvel);
428 }
429
430 // add conveyor belt velocities
431 if (pm.groundentity != null) {
432 Math3D.VectorClear(v);

Callers 2

PM_WaterMoveMethod · 0.95
PM_AirMoveMethod · 0.95

Calls 2

VectorClearMethod · 0.95
VectorMAMethod · 0.95

Tested by

no test coverage detected