Make sv_gameplayfix_delayprojectiles match the engine's behaviour of only running...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / movetypes / movetypes.qh
1 #pragma once
2
3 // water levels
4 const int WATERLEVEL_NONE = 0;
5 const int WATERLEVEL_WETFEET = 1;
6 const int WATERLEVEL_SWIMMING = 2;
7 const int WATERLEVEL_SUBMERGED = 3;
8
9 #define IS_ONGROUND(s)                      boolean((s).flags & FL_ONGROUND)
10 #define SET_ONGROUND(s)                     ((s).flags |= FL_ONGROUND)
11 #define UNSET_ONGROUND(s)                   ((s).flags &= ~FL_ONGROUND)
12 #define IS_ONSLICK(s)                                           boolean((s).flags & FL_ONSLICK)
13 #define SET_ONSLICK(s)                                          ((s).flags |= FL_ONSLICK)
14 #define UNSET_ONSLICK(s)                                        ((s).flags &= ~FL_ONSLICK)
15
16 #define GAMEPLAYFIX_DOWNTRACEONGROUND(s)    STAT(GAMEPLAYFIX_DOWNTRACEONGROUND)
17 #define GAMEPLAYFIX_EASIERWATERJUMP(s)      STAT(GAMEPLAYFIX_EASIERWATERJUMP)
18 #define GAMEPLAYFIX_STEPDOWN(s)             STAT(GAMEPLAYFIX_STEPDOWN)
19 #define GAMEPLAYFIX_STEPDOWN_MAXSPEED(s)    STAT(GAMEPLAYFIX_STEPDOWN_MAXSPEED)
20 #define GAMEPLAYFIX_STEPMULTIPLETIMES(s)    STAT(GAMEPLAYFIX_STEPMULTIPLETIMES)
21 #define GAMEPLAYFIX_UNSTICKPLAYERS(s)       STAT(GAMEPLAYFIX_UNSTICKPLAYERS)
22 #define GAMEPLAYFIX_WATERTRANSITION(s)          STAT(GAMEPLAYFIX_WATERTRANSITION)
23 #define GAMEPLAYFIX_SLIDEMOVEPROJECTILES(s) STAT(GAMEPLAYFIX_SLIDEMOVEPROJECTILES)
24 #define GAMEPLAYFIX_GRENADEBOUNCESLOPES(s)      STAT(GAMEPLAYFIX_GRENADEBOUNCESLOPES)
25 #define GAMEPLAYFIX_NOAIRBORNCORPSE(s)          STAT(GAMEPLAYFIX_NOAIRBORNCORPSE)
26 #define NOAIRBORNCORPSE_ALLOWSUSPENDED(s)       STAT(NOAIRBORNCORPSE_ALLOWSUSPENDED)
27 #define UPWARD_VELOCITY_CLEARS_ONGROUND(s)  STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND)
28 #define GAMEPLAYFIX_DELAYPROJECTILES(s)         STAT(GAMEPLAYFIX_DELAYPROJECTILES)
29
30
31 #define PHYS_STEPHEIGHT(s)                  STAT(MOVEVARS_STEPHEIGHT)
32 #define PHYS_NOSTEP(s)                      STAT(NOSTEP)
33 #define PHYS_JUMPSTEP(s)                    STAT(MOVEVARS_JUMPSTEP)
34 #define PHYS_WALLFRICTION(s)                STAT(MOVEVARS_WALLFRICTION)
35
36 #define PHYS_WALLCLIP(s)                                        STAT(MOVEVARS_WALLCLIP)
37
38 #ifdef CSQC
39 .float bouncestop;
40 .float bouncefactor;
41
42         #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  (boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE))
43         #define GAMEPLAYFIX_NOGRAVITYONGROUND           (boolean(moveflags & MOVEFLAG_NOGRAVITYONGROUND))
44         #define GAMEPLAYFIX_Q2AIRACCELERATE             (boolean(moveflags & MOVEFLAG_Q2AIRACCELERATE))
45
46         #define PHYS_GRAVITY(s)                     STAT(MOVEVARS_GRAVITY, s)
47         // FIXME: 0 doesn't mean zero gravity
48         #define PHYS_ENTGRAVITY(s)                  STAT(MOVEVARS_ENTGRAVITY, s)
49
50         #define TICRATE                             ticrate
51
52 #elif defined(SVQC)
53
54         #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  autocvar_sv_gameplayfix_gravityunaffectedbyticrate
55         #define GAMEPLAYFIX_NOGRAVITYONGROUND           autocvar_sv_gameplayfix_nogravityonground
56         #define GAMEPLAYFIX_Q2AIRACCELERATE             autocvar_sv_gameplayfix_q2airaccelerate
57
58         #define PHYS_GRAVITY(s)                     autocvar_sv_gravity
59         #define PHYS_ENTGRAVITY(s)                  ((s).gravity)
60
61         #define TICRATE sys_frametime
62
63 #endif
64
65 void set_movetype(entity this, int mt);
66
67 .float pm_time;
68
69 .float move_movetype;
70 .float move_time;
71 //.vector move_origin;
72 //.vector move_angles;
73 //.vector move_velocity;
74 //.vector move_avelocity;
75 //.int move_flags;
76 //.int move_watertype;
77 //.int move_waterlevel;
78 .void(float, float)contentstransition;
79 //.float move_bounce_factor;
80 //.float move_bounce_stopspeed;
81 .float move_nomonsters;  // -1 for MOVE_NORMAL, otherwise a MOVE_ constant
82
83 .entity aiment;
84 .vector punchangle;
85
86 .entity groundentity;  // FIXME add move_groundnetworkentity?
87 .float move_suspendedinair;
88 .float move_didgravity;
89
90 // unsticking
91 const int UNSTICK_FINE = 0;
92 const int UNSTICK_FIXED = 1;
93 const int UNSTICK_STUCK = 2;
94
95 // set by _Movetype_FlyMove
96 vector move_stepnormal;
97
98 bool _Movetype_NudgeOutOfSolid_PivotIsKnownGood(entity this, vector pivot);
99 void _Movetype_WallFriction(entity this, vector stepnormal);
100 int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepnormal, float stepheight);
101 void _Movetype_CheckVelocity(entity this);
102 void _Movetype_CheckWaterTransition(entity ent);
103 void _Movetype_CheckStuck(entity this);
104 float _Movetype_CheckWater(entity ent);
105 void _Movetype_LinkEdict_TouchAreaGrid(entity this);
106 void _Movetype_LinkEdict(entity this, float touch_triggers);
107 vector _Movetype_ClipVelocity(vector vel, vector norm, float f);
108 void _Movetype_PushEntityTrace(entity this, vector push);
109 bool _Movetype_PushEntity(entity this, vector push, float failonstartsolid, bool dolink);
110
111 void Movetype_Physics_NoMatchTicrate(entity this, float movedt, bool isclient);
112 void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy);
113 void Movetype_Physics_MatchServer(entity this, bool sloppy);
114 void Movetype_Physics_NoMatchServer(entity this);
115 void _Movetype_LinkEdict(entity this, float touch_triggers);
116 void _Movetype_LinkEdict_TouchAreaGrid(entity this);
117
118 int _Movetype_UnstickEntity(entity this);
119
120 const int MAX_CLIP_PLANES = 5;
121
122 #ifdef CSQC
123 const int MOVETYPE_NONE             = 0;
124 const int MOVETYPE_ANGLENOCLIP      = 1;
125 const int MOVETYPE_ANGLECLIP        = 2;
126 const int MOVETYPE_WALK             = 3;
127 const int MOVETYPE_STEP             = 4;
128 const int MOVETYPE_FLY              = 5;
129 const int MOVETYPE_TOSS             = 6;
130 const int MOVETYPE_PUSH             = 7;
131 const int MOVETYPE_NOCLIP           = 8;
132 const int MOVETYPE_FLYMISSILE       = 9;
133 const int MOVETYPE_BOUNCE           = 10;
134 const int MOVETYPE_BOUNCEMISSILE    = 11;  // Like bounce but doesn't lose speed on bouncing
135 const int MOVETYPE_FOLLOW           = 12;
136 const int MOVETYPE_PHYSICS          = 32;
137 const int MOVETYPE_FLY_WORLDONLY    = 33;
138
139 #elif defined(SVQC)
140 const int MOVETYPE_ANGLENOCLIP      = 1;
141 const int MOVETYPE_ANGLECLIP        = 2;
142 #endif
143
144 const int MOVETYPE_QCPLAYER = 150; // QC-driven player physics, no think functions!
145 const int MOVETYPE_QCENTITY = 151; // QC-driven entity physics, some think functions!
146
147 const int MOVETYPE_FAKEPUSH         = 13;
148
149 const int MOVEFLAG_VALID = BIT(23);
150 const int MOVEFLAG_Q2AIRACCELERATE = BIT(0);
151 const int MOVEFLAG_NOGRAVITYONGROUND = BIT(1);
152 const int MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE = BIT(2);
153
154 #ifdef CSQC
155 #define moveflags STAT(MOVEFLAGS)
156 #endif