| 355 | VARP(maxrollremote, 0, ROLLMOVDEF + ROLLEFFDEF, ROLLMOVMAX + ROLLEFFMAX); |
| 356 | |
| 357 | void resizephysent(physent *pl, int moveres, int curtime, float min, float max) |
| 358 | { |
| 359 | if(pl->eyeheightvel==0.0f) return; |
| 360 | |
| 361 | const bool water = waterlevel > pl->o.z; |
| 362 | const float speed = curtime*pl->maxspeed/(water ? 2000.0f : 1000.0f); |
| 363 | float h = pl->eyeheightvel * speed / moveres; |
| 364 | |
| 365 | loopi(moveres) |
| 366 | { |
| 367 | pl->eyeheight += h; |
| 368 | pl->o.z += h; |
| 369 | if(collide(pl) && !(pl != player1 && player1->isspectating() && player1->spectatemode < SM_FLY)) |
| 370 | { |
| 371 | pl->eyeheight -= h; // collided, revert mini-step |
| 372 | pl->o.z -= h; |
| 373 | break; |
| 374 | } |
| 375 | if(pl->eyeheight<min) // clamp to min |
| 376 | { |
| 377 | pl->o.z += min - pl->eyeheight; |
| 378 | pl->eyeheight = min; |
| 379 | pl->eyeheightvel = 0.0f; |
| 380 | break; |
| 381 | } |
| 382 | if(pl->eyeheight>max) |
| 383 | { |
| 384 | pl->o.z -= pl->eyeheight - max; |
| 385 | pl->eyeheight = max; |
| 386 | pl->eyeheightvel = 0.0f; |
| 387 | break; |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | // main physics routine, moves a player/monster for a curtime step |
| 393 | // moveres indicated the physics precision (which is lower for monsters and multiplayer prediction) |