1 #include "../player.qh"
3 void _Movetype_Physics_Toss(entity this, float dt) // SV_Physics_Toss
5 if (this.move_flags & FL_ONGROUND)
7 if (this.move_velocity.z >= 1 / 32 && UPWARD_VELOCITY_CLEARS_ONGROUND(this))
9 this.move_flags &= ~FL_ONGROUND;
11 else if (!this.move_groundentity)
15 else if (this.move_suspendedinair && wasfreed(this.move_groundentity))
17 this.move_groundentity = world;
22 this.move_suspendedinair = false;
24 _Movetype_CheckVelocity(this);
26 if (this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
28 this.move_didgravity = 1;
29 this.move_velocity_z -= (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1)
31 * (this.gravity ? this.gravity : 1)
35 this.move_angles = this.move_angles + this.move_avelocity * dt;
38 for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; ++bump)
40 vector move = this.move_velocity * movetime;
41 _Movetype_PushEntity(this, move, true);
47 _Movetype_UnstickEntity(this);
48 _Movetype_PushEntity(this, move, false);
53 if (trace_fraction == 1)
56 movetime *= 1 - min(1, trace_fraction);
58 if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
60 this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 2.0);
61 this.move_flags &= ~FL_ONGROUND;
63 else if (this.move_movetype == MOVETYPE_BOUNCE)
65 float bouncefac = this.move_bounce_factor; if (!bouncefac) bouncefac = 0.5;
66 float bouncestop = this.move_bounce_stopspeed; if (!bouncestop) bouncestop = 60 / 800;
67 bouncestop *= (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
69 this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 1 + bouncefac);
71 float d = trace_plane_normal * this.move_velocity;
72 if (trace_plane_normal.z > 0.7 && d < bouncestop && d > -bouncestop)
74 this.move_flags |= FL_ONGROUND;
75 this.move_groundentity = trace_ent;
76 this.move_velocity = '0 0 0';
77 this.move_avelocity = '0 0 0';
81 this.move_flags &= ~FL_ONGROUND;
86 this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 1.0);
87 if (trace_plane_normal.z > 0.7)
89 this.move_flags |= FL_ONGROUND;
90 this.move_groundentity = trace_ent;
91 if (trace_ent.solid == SOLID_BSP)
92 this.move_suspendedinair = true;
93 this.move_velocity = '0 0 0';
94 this.move_avelocity = '0 0 0';
98 this.move_flags &= ~FL_ONGROUND;
102 // DP revision 8905 (just, WHY...)
103 if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
106 // DP revision 8918 (WHY...)
107 if (this.move_flags & FL_ONGROUND)
111 if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE && this.move_didgravity > 0 && !(this.move_flags & FL_ONGROUND))
112 this.move_velocity_z -= 0.5 * dt * (this.gravity ? this.gravity : 1) * PHYS_GRAVITY(this);
114 _Movetype_CheckWaterTransition(this);