fall from 128: 400 = 160000 fall from 256: 580 = 336400 fall from 384: 720 = 518400 fall from 512: 800 = 640000 fall from 640: 960 = damage = deltavelocity deltavelocity 0.0001
(SubgameEntity ent, float time)
| 252 | * damage = deltavelocity*deltavelocity * 0.0001 |
| 253 | */ |
| 254 | private void SV_CalcViewOffset(SubgameEntity ent, float time) { |
| 255 | float angles[] = { 0, 0, 0 }; |
| 256 | float bob; |
| 257 | float ratio; |
| 258 | float delta; |
| 259 | float[] v = { 0, 0, 0 }; |
| 260 | |
| 261 | // base angles |
| 262 | gclient_t client = ent.getClient(); |
| 263 | angles = client.getPlayerState().kick_angles; |
| 264 | |
| 265 | // if dead, fix the angle and don't add any kick |
| 266 | if (ent.deadflag != 0) { |
| 267 | Math3D.VectorClear(angles); |
| 268 | |
| 269 | client.getPlayerState().viewangles[Defines.ROLL] = 40; |
| 270 | client.getPlayerState().viewangles[Defines.PITCH] = -15; |
| 271 | client.getPlayerState().viewangles[Defines.YAW] = client.killer_yaw; |
| 272 | } else { |
| 273 | |
| 274 | // add angles based on weapon kick |
| 275 | Math3D.VectorCopy(client.kick_angles, angles); |
| 276 | |
| 277 | // add angles based on damage kick |
| 278 | ratio = (client.v_dmg_time - time) |
| 279 | / Defines.DAMAGE_TIME; |
| 280 | if (ratio < 0) { |
| 281 | ratio = 0; |
| 282 | client.v_dmg_pitch = 0; |
| 283 | client.v_dmg_roll = 0; |
| 284 | } |
| 285 | angles[Defines.PITCH] += ratio * client.v_dmg_pitch; |
| 286 | angles[Defines.ROLL] += ratio * client.v_dmg_roll; |
| 287 | |
| 288 | // add pitch based on fall kick |
| 289 | ratio = (client.fall_time - time) |
| 290 | / Defines.FALL_TIME; |
| 291 | if (ratio < 0) |
| 292 | ratio = 0; |
| 293 | angles[Defines.PITCH] += ratio * client.fall_value; |
| 294 | |
| 295 | // add angles based on velocity |
| 296 | delta = Math3D.DotProduct(ent.velocity, forward); |
| 297 | angles[Defines.PITCH] += delta * run_pitch.value; |
| 298 | |
| 299 | delta = Math3D.DotProduct(ent.velocity, right); |
| 300 | angles[Defines.ROLL] += delta * run_roll.value; |
| 301 | |
| 302 | // add angles based on bob |
| 303 | delta = bobfracsin * bob_pitch.value * xyspeed; |
| 304 | if ((client.getPlayerState().pmove.pm_flags & Defines.PMF_DUCKED) != 0) |
| 305 | delta *= 6; // crouching |
| 306 | angles[Defines.PITCH] += delta; |
| 307 | delta = bobfracsin * bob_roll.value * xyspeed; |
| 308 | if ((client.getPlayerState().pmove.pm_flags & Defines.PMF_DUCKED) != 0) |
| 309 | delta *= 6; // crouching |
| 310 | if ((bobcycle & 1) != 0) |
| 311 | delta = -delta; |
no test coverage detected