Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
toss.qc File Reference
#include "toss.qh"
Include dependency graph for toss.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void _Movetype_Physics_Toss (entity this, float dt)

Function Documentation

◆ _Movetype_Physics_Toss()

void _Movetype_Physics_Toss ( entity this,
float dt )

Definition at line 3 of file toss.qc.

4{
5 if(IS_ONGROUND(this))
6 {
7 if(this.velocity.z >= (1 / 32) && UPWARD_VELOCITY_CLEARS_ONGROUND(this))
8 {
9 // don't stick to ground if onground and moving upward
10 UNSET_ONGROUND(this);
11 }
12 else if(!this.groundentity || !GAMEPLAYFIX_NOAIRBORNCORPSE(this))
13 {
14 return;
15 }
16 else if(this.move_suspendedinair && wasfreed(this.groundentity))
17 {
18 this.groundentity = NULL;
20 return;
21 }
22 else if(boxesoverlap(this.absmin, this.absmax, this.groundentity.absmin, this.groundentity.absmax))
23 {
24 // don't slide if still touching the groundentity
25 return;
26 }
27 }
28
29 this.move_suspendedinair = false;
30
32 {
33 this.move_didgravity = true;
34 this.velocity_z -= (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1)
35 * dt
36 * ((this.gravity) ? this.gravity : 1)
37 * PHYS_GRAVITY(this);
38 }
39
40 /*if (this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
41 {
42 this.move_didgravity = true;
43 this.velocity_z -= (((this.gravity) ? this.gravity : 1) * PHYS_GRAVITY(this) * dt);
44 }*/
45
46 this.angles = this.angles + this.avelocity * dt;
47
48 float movetime = dt;
49 for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; ++bump)
50 {
51 if(this.velocity == '0 0 0')
52 break;
53
54 vector move = this.velocity * movetime;
55 if(!_Movetype_PushEntity(this, move, true))
56 return; // teleported
57 if (wasfreed(this))
58 return;
59
60 // NOTE: this is bmodelstartsolid in the engine
61 if (trace_allsolid && trace_fraction == 0 && trace_ent.solid == SOLID_BSP)
62 {
63 // QC lacks pointers so we must save the old trace values
64 float oldtrace_fraction = trace_fraction;
65 vector oldtrace_plane_normal = trace_plane_normal;
66 entity oldtrace_ent = trace_ent;
68 trace_fraction = oldtrace_fraction;
69 trace_plane_normal = oldtrace_plane_normal;
70 trace_ent = oldtrace_ent;
71 if(!_Movetype_PushEntity(this, move, true))
72 return; // teleported
73 if (wasfreed(this))
74 return;
76 {
77 // immovably stuck, don't waste CPU trying to move again
78 this.velocity = '0 0 0';
79 SET_ONGROUND(this);
80 return;
81 }
82 }
83
84 if (trace_fraction == 1)
85 break;
86
87 movetime *= 1 - min(1, trace_fraction);
88
90 {
91 float bouncefac = (!this.bouncefactor) ? 1.0 : this.bouncefactor;
93 UNSET_ONGROUND(this);
95 movetime = 0;
96 }
97 else if (this.move_movetype == MOVETYPE_BOUNCE)
98 {
99 float bouncefac = (!this.bouncefactor) ? 0.5 : this.bouncefactor;
100 float bstop = (!this.bouncestop) ? (60 / 800) : this.bouncestop;
101 float grav = ((this.gravity) ? this.gravity : 1);
102
103 this.velocity = _Movetype_ClipVelocity(this.velocity, trace_plane_normal, 1 + bouncefac);
104
105 float d = trace_plane_normal * this.velocity;
107 d = this.velocity.z;
108 if (trace_plane_normal.z > 0.7 && d < PHYS_GRAVITY(this) * bstop * grav)
109 {
110 SET_ONGROUND(this);
111 this.groundentity = trace_ent;
112 this.velocity = '0 0 0';
113 this.avelocity = '0 0 0';
114 movetime = 0;
115 }
116 else
117 {
118 UNSET_ONGROUND(this);
120 movetime = 0;
121 }
122 }
123 else
124 {
125 this.velocity = _Movetype_ClipVelocity(this.velocity, trace_plane_normal, 1.0);
126 if (trace_plane_normal.z > 0.7)
127 {
128 SET_ONGROUND(this);
129 this.groundentity = trace_ent;
130 if (trace_ent.solid == SOLID_BSP)
131 this.move_suspendedinair = true;
132 this.velocity = '0 0 0';
133 this.avelocity = '0 0 0';
134 movetime = 0;
135 }
136 else
137 {
138 UNSET_ONGROUND(this);
140 movetime = 0;
141 }
142 }
143
144 // DP revision 8905 (just, WHY...)
145 //if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
146 //break;
147
148 // DP revision 8918 (WHY...)
149 //if (IS_ONGROUND(this))
150 //break;
151 }
152
154 this.velocity_z -= 0.5 * dt * ((this.gravity) ? this.gravity : 1) * PHYS_GRAVITY(this);
155
157}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float gravity
Definition items.qh:17
entity trace_ent
vector avelocity
vector velocity
vector absmax
float trace_fraction
vector absmin
float trace_allsolid
const float SOLID_BSP
vector trace_plane_normal
ent angles
Definition ent_cs.qc:121
float min(float f,...)
vector _Movetype_ClipVelocity(vector vel, vector norm, float f)
Definition movetypes.qc:639
bool _Movetype_PushEntity(entity this, vector push, bool dolink)
Definition movetypes.qc:668
int _Movetype_UnstickEntity(entity this)
Definition movetypes.qc:593
void _Movetype_CheckWaterTransition(entity ent)
Definition movetypes.qc:368
#define NOAIRBORNCORPSE_ALLOWSUSPENDED(s)
Definition movetypes.qh:33
#define PHYS_GRAVITY(s)
Definition movetypes.qh:53
entity groundentity
Definition movetypes.qh:93
#define SET_ONGROUND(s)
Definition movetypes.qh:17
float bouncefactor
Definition movetypes.qh:47
#define UPWARD_VELOCITY_CLEARS_ONGROUND(s)
Definition movetypes.qh:34
const int MOVETYPE_BOUNCEMISSILE
Definition movetypes.qh:140
float move_movetype
Definition movetypes.qh:76
#define UNSET_ONGROUND(s)
Definition movetypes.qh:18
#define GAMEPLAYFIX_NOAIRBORNCORPSE(s)
Definition movetypes.qh:32
float move_suspendedinair
Definition movetypes.qh:94
#define GAMEPLAYFIX_GRENADEBOUNCESLOPES(s)
Definition movetypes.qh:31
#define GAMEPLAYFIX_SLIDEMOVEPROJECTILES(s)
Definition movetypes.qh:30
float move_didgravity
Definition movetypes.qh:95
const int MOVETYPE_TOSS
Definition movetypes.qh:135
#define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE
Definition movetypes.qh:49
float bouncestop
Definition movetypes.qh:46
const int MOVETYPE_BOUNCE
Definition movetypes.qh:139
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define NULL
Definition post.qh:14
vector
Definition self.qh:92
entity this
Definition self.qh:72
ERASEABLE float boxesoverlap(vector m1, vector m2, vector m3, vector m4)
requires that m2>m1 in all coordinates, and that m4>m3
Definition vector.qh:73

References _Movetype_CheckWaterTransition(), _Movetype_ClipVelocity(), _Movetype_PushEntity(), _Movetype_UnstickEntity(), absmax, absmin, angles, avelocity, bouncefactor, bouncestop, boxesoverlap(), entity(), GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE, GAMEPLAYFIX_GRENADEBOUNCESLOPES, GAMEPLAYFIX_NOAIRBORNCORPSE, GAMEPLAYFIX_SLIDEMOVEPROJECTILES, gravity, groundentity, IS_ONGROUND, min(), move_didgravity, move_movetype, move_suspendedinair, MOVETYPE_BOUNCE, MOVETYPE_BOUNCEMISSILE, MOVETYPE_TOSS, NOAIRBORNCORPSE_ALLOWSUSPENDED, NULL, PHYS_GRAVITY, SET_ONGROUND, SOLID_BSP, trace_allsolid, trace_ent, trace_fraction, trace_plane_normal, UNSET_ONGROUND, UPWARD_VELOCITY_CLEARS_ONGROUND, vector, and velocity.

Referenced by _Movetype_Physics_ClientFrame(), and _Movetype_Physics_Frame().