Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
movetypes.qh
Go to the documentation of this file.
1#pragma once
2
3#ifdef SVQC
4// undefined on client, engine cvar
6
7bool use_engine_physics; // debug option for testing legacy engine code
8#endif
9
10// water levels
11const int WATERLEVEL_NONE = 0;
12const int WATERLEVEL_WETFEET = 1;
13const int WATERLEVEL_SWIMMING = 2;
15
16#define IS_ONGROUND(s) boolean((s).flags & FL_ONGROUND)
17#define SET_ONGROUND(s) ((s).flags |= FL_ONGROUND)
18#define UNSET_ONGROUND(s) ((s).flags &= ~FL_ONGROUND)
19#define IS_ONSLICK(s) boolean((s).flags & FL_ONSLICK)
20#define SET_ONSLICK(s) ((s).flags |= FL_ONSLICK)
21#define UNSET_ONSLICK(s) ((s).flags &= ~FL_ONSLICK)
22
23#define GAMEPLAYFIX_DOWNTRACEONGROUND(s) STAT(GAMEPLAYFIX_DOWNTRACEONGROUND)
24#define GAMEPLAYFIX_EASIERWATERJUMP(s) STAT(GAMEPLAYFIX_EASIERWATERJUMP)
25#define GAMEPLAYFIX_STEPDOWN_MAXSPEED(s) STAT(GAMEPLAYFIX_STEPDOWN_MAXSPEED)
26#define GAMEPLAYFIX_STEPMULTIPLETIMES(s) STAT(GAMEPLAYFIX_STEPMULTIPLETIMES)
27#define GAMEPLAYFIX_UNSTICKPLAYERS(s) STAT(GAMEPLAYFIX_UNSTICKPLAYERS)
28#define GAMEPLAYFIX_WATERTRANSITION(s) STAT(GAMEPLAYFIX_WATERTRANSITION)
29#define GAMEPLAYFIX_SLIDEMOVEPROJECTILES(s) STAT(GAMEPLAYFIX_SLIDEMOVEPROJECTILES)
30#define GAMEPLAYFIX_GRENADEBOUNCESLOPES(s) STAT(GAMEPLAYFIX_GRENADEBOUNCESLOPES)
31#define GAMEPLAYFIX_NOAIRBORNCORPSE(s) STAT(GAMEPLAYFIX_NOAIRBORNCORPSE)
32#define NOAIRBORNCORPSE_ALLOWSUSPENDED(s) STAT(NOAIRBORNCORPSE_ALLOWSUSPENDED)
33#define UPWARD_VELOCITY_CLEARS_ONGROUND(s) STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND)
34#define GAMEPLAYFIX_DELAYPROJECTILES(s) STAT(GAMEPLAYFIX_DELAYPROJECTILES)
35
36
37#define PHYS_NOSTEP(s) STAT(NOSTEP)
38#define PHYS_JUMPSTEP(s) STAT(MOVEVARS_JUMPSTEP)
39#define PHYS_WALLFRICTION(s) STAT(MOVEVARS_WALLFRICTION)
40
41#define PHYS_WALLCLIP(s) STAT(MOVEVARS_WALLCLIP)
42
43#ifdef CSQC
46
47 #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE (boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE))
48 #define GAMEPLAYFIX_NOGRAVITYONGROUND (boolean(moveflags & MOVEFLAG_NOGRAVITYONGROUND))
49 #define GAMEPLAYFIX_Q2AIRACCELERATE (boolean(moveflags & MOVEFLAG_Q2AIRACCELERATE))
50 #define GAMEPLAYFIX_STEPDOWN(s) STAT(GAMEPLAYFIX_STEPDOWN, s)
51
52 #define PHYS_STEPHEIGHT(s) STAT(MOVEVARS_STEPHEIGHT, s)
53
54 #define PHYS_GRAVITY(s) ((s).move_movetype == MOVETYPE_WALK ? STAT(MOVEVARS_GRAVITY) : STAT(MOVEVARS_WORLDGRAVITY))
55 // FIXME: 0 doesn't mean zero gravity
56 #define PHYS_ENTGRAVITY(s) STAT(MOVEVARS_ENTGRAVITY, s)
57
58 #define TICRATE ticrate
59
60#elif defined(SVQC)
61
62 #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate
63 #define GAMEPLAYFIX_NOGRAVITYONGROUND autocvar_sv_gameplayfix_nogravityonground
64 #define GAMEPLAYFIX_Q2AIRACCELERATE autocvar_sv_gameplayfix_q2airaccelerate
65 #define GAMEPLAYFIX_STEPDOWN(s) ((s).move_movetype == MOVETYPE_WALK ? STAT(GAMEPLAYFIX_STEPDOWN, s) : autocvar_sv_gameplayfix_stepdown)
66
67 #define PHYS_STEPHEIGHT(s) ((s).move_movetype == MOVETYPE_WALK ? STAT(MOVEVARS_STEPHEIGHT, s) : autocvar_sv_stepheight)
68
69 #define PHYS_GRAVITY(s) ((s).move_movetype == MOVETYPE_WALK ? STAT(MOVEVARS_GRAVITY, s) : autocvar_sv_gravity)
70 #define PHYS_ENTGRAVITY(s) ((s).gravity)
71
72 #define TICRATE sys_frametime
73
74#endif
75
76void set_movetype(entity this, int mt);
77
78.float pm_time;
79
81.float move_time;
82//.vector move_origin;
83//.vector move_angles;
84//.vector move_velocity;
85//.vector move_avelocity;
86//.int move_flags;
87//.int move_watertype;
88//.int move_waterlevel;
89.void(float, float)contentstransition;
90//.float move_bounce_factor;
91//.float move_bounce_stopspeed;
92.float move_nomonsters; // -1 for MOVE_NORMAL, otherwise a MOVE_ constant
93
94.entity aiment;
95.vector punchangle;
96
97.entity groundentity; // FIXME add move_groundnetworkentity?
100
101// unsticking
102const int UNSTICK_FINE = 0;
103const int UNSTICK_FIXED = 1;
104const int UNSTICK_STUCK = 2;
105
106// set by _Movetype_FlyMove
108
110void _Movetype_WallFriction(entity this, vector stepnormal);
111int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepnormal, float stepheight);
116void _Movetype_LinkEdict(entity this, float touch_triggers);
117vector _Movetype_ClipVelocity(vector vel, vector norm, float f);
119bool _Movetype_PushEntity(entity this, vector push, bool dolink);
120
121void Movetype_Physics_NoMatchTicrate(entity this, float movedt, bool isclient);
122void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy);
123void Movetype_Physics_MatchServer(entity this, bool sloppy);
125void _Movetype_LinkEdict(entity this, float touch_triggers);
127
129
130const int MAX_CLIP_PLANES = 5;
131
132#ifdef CSQC
133const int MOVETYPE_NONE = 0;
135const int MOVETYPE_ANGLECLIP = 2;
136const int MOVETYPE_WALK = 3;
137const int MOVETYPE_STEP = 4;
138const int MOVETYPE_FLY = 5;
139const int MOVETYPE_TOSS = 6;
140const int MOVETYPE_PUSH = 7;
141const int MOVETYPE_NOCLIP = 8;
143const int MOVETYPE_BOUNCE = 10;
144const int MOVETYPE_BOUNCEMISSILE = 11; // Like bounce but doesn't lose speed on bouncing
145const int MOVETYPE_FOLLOW = 12;
146const int MOVETYPE_PHYSICS = 32;
148
149#elif defined(SVQC)
150const int MOVETYPE_ANGLENOCLIP = 1;
151const int MOVETYPE_ANGLECLIP = 2;
152#endif
153
154const int MOVETYPE_QCPLAYER = 150; // QC-driven player physics, no think functions!
155const int MOVETYPE_QCENTITY = 151; // QC-driven entity physics, some think functions!
156
157const int MOVETYPE_FAKEPUSH = 13;
158
159const int MOVEFLAG_VALID = BIT(23);
163
164#ifdef CSQC
165#define moveflags STAT(MOVEFLAGS)
166#endif
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector punchangle
void _Movetype_LinkEdict(entity this, float touch_triggers)
void _Movetype_CheckStuck(entity this)
Definition movetypes.qc:620
const int MOVETYPE_STEP
Definition movetypes.qh:137
const int MOVETYPE_WALK
Definition movetypes.qh:136
void Movetype_Physics_MatchServer(entity this, bool sloppy)
Definition movetypes.qc:817
const int MOVETYPE_NONE
Definition movetypes.qh:133
int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepnormal, float stepheight)
Definition movetypes.qc:120
const int WATERLEVEL_SWIMMING
Definition movetypes.qh:13
const int WATERLEVEL_WETFEET
Definition movetypes.qh:12
void _Movetype_PushEntityTrace(entity this, vector push)
Definition movetypes.qc:650
const int MOVETYPE_QCPLAYER
Definition movetypes.qh:154
const int WATERLEVEL_SUBMERGED
Definition movetypes.qh:14
void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy)
Definition movetypes.qc:835
const int MOVEFLAG_NOGRAVITYONGROUND
Definition movetypes.qh:161
const int MOVETYPE_FOLLOW
Definition movetypes.qh:145
const int UNSTICK_FINE
Definition movetypes.qh:102
const int MAX_CLIP_PLANES
Definition movetypes.qh:130
const int MOVETYPE_FAKEPUSH
Definition movetypes.qh:157
const int WATERLEVEL_NONE
Definition movetypes.qh:11
const int MOVEFLAG_Q2AIRACCELERATE
Definition movetypes.qh:160
float pm_time
Definition movetypes.qh:78
const int MOVETYPE_PUSH
Definition movetypes.qh:140
const int MOVETYPE_FLYMISSILE
Definition movetypes.qh:142
entity groundentity
Definition movetypes.qh:97
float _Movetype_CheckWater(entity ent)
Definition movetypes.qc:334
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
vector _Movetype_ClipVelocity(vector vel, vector norm, float f)
Definition movetypes.qc:639
const int MOVETYPE_FLY_WORLDONLY
Definition movetypes.qh:147
const int MOVETYPE_ANGLENOCLIP
Definition movetypes.qh:134
float bouncefactor
Definition movetypes.qh:45
const int MOVETYPE_ANGLECLIP
Definition movetypes.qh:135
float move_nomonsters
Definition movetypes.qh:92
bool _Movetype_PushEntity(entity this, vector push, bool dolink)
Definition movetypes.qc:668
int _Movetype_UnstickEntity(entity this)
Definition movetypes.qc:593
entity aiment
Definition movetypes.qh:94
void Movetype_Physics_NoMatchTicrate(entity this, float movedt, bool isclient)
Definition movetypes.qc:779
void _Movetype_LinkEdict_TouchAreaGrid(entity this)
Definition movetypes.qc:449
const int UNSTICK_STUCK
Definition movetypes.qh:104
const int MOVETYPE_BOUNCEMISSILE
Definition movetypes.qh:144
void _Movetype_CheckWaterTransition(entity ent)
Definition movetypes.qc:368
float move_time
Definition movetypes.qh:81
vector move_stepnormal
Definition movetypes.qh:107
float move_movetype
Definition movetypes.qh:80
void Movetype_Physics_NoMatchServer(entity this)
Definition movetypes.qc:805
const int MOVETYPE_PHYSICS
Definition movetypes.qh:146
const int MOVETYPE_NOCLIP
Definition movetypes.qh:141
const int MOVEFLAG_VALID
Definition movetypes.qh:159
const int MOVETYPE_QCENTITY
Definition movetypes.qh:155
float move_suspendedinair
Definition movetypes.qh:98
void _Movetype_WallFriction(entity this, vector stepnormal)
Definition movetypes.qc:102
const int MOVETYPE_FLY
Definition movetypes.qh:138
const int UNSTICK_FIXED
Definition movetypes.qh:103
float move_didgravity
Definition movetypes.qh:99
bool _Movetype_NudgeOutOfSolid_PivotIsKnownGood(entity this, vector pivot)
Definition movetypes.qc:19
const int MOVETYPE_TOSS
Definition movetypes.qh:139
bool use_engine_physics
Definition movetypes.qh:7
const int MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE
Definition movetypes.qh:162
bool autocvar_physics_ode
Definition movetypes.qh:5
float bouncestop
Definition movetypes.qh:44
const int MOVETYPE_BOUNCE
Definition movetypes.qh:143
vector
Definition self.qh:96