]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/physics/movetypes/movetypes.qh
4cd184e9ec6de1557665415ecef80d36b5ad5706
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics / movetypes / movetypes.qh
1 #pragma once
2
3 #define IS_ONGROUND(s)                      boolean((s).flags & FL_ONGROUND)
4 #define SET_ONGROUND(s)                     ((s).flags |= FL_ONGROUND)
5 #define UNSET_ONGROUND(s)                   ((s).flags &= ~FL_ONGROUND)
6 #define IS_ONSLICK(s)                                           boolean((s).flags & FL_ONSLICK)
7 #define SET_ONSLICK(s)                                          ((s).flags |= FL_ONSLICK)
8 #define UNSET_ONSLICK(s)                                        ((s).flags &= ~FL_ONSLICK)
9
10 #define GAMEPLAYFIX_DOWNTRACEONGROUND(s)    STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, NULL)
11 #define GAMEPLAYFIX_EASIERWATERJUMP(s)      STAT(GAMEPLAYFIX_EASIERWATERJUMP, NULL)
12 #define GAMEPLAYFIX_STEPDOWN(s)             STAT(GAMEPLAYFIX_STEPDOWN, NULL)
13 #define GAMEPLAYFIX_STEPMULTIPLETIMES(s)    STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, NULL)
14 #define GAMEPLAYFIX_UNSTICKPLAYERS(s)       STAT(GAMEPLAYFIX_UNSTICKPLAYERS, NULL)
15 #define GAMEPLAYFIX_WATERTRANSITION(s)          STAT(GAMEPLAYFIX_WATERTRANSITION, NULL)
16 #define UPWARD_VELOCITY_CLEARS_ONGROUND(s)  STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, NULL)
17
18 #define PHYS_STEPHEIGHT(s)                  STAT(MOVEVARS_STEPHEIGHT, NULL)
19 #define PHYS_NOSTEP(s)                      STAT(NOSTEP, NULL)
20 #define PHYS_JUMPSTEP(s)                    STAT(MOVEVARS_JUMPSTEP, NULL)
21 #define PHYS_WALLFRICTION(s)                STAT(MOVEVARS_WALLFRICTION, NULL)
22
23 #ifdef CSQC
24 .float bouncestop;
25 .float bouncefactor;
26
27         #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  (boolean(moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE))
28         #define GAMEPLAYFIX_NOGRAVITYONGROUND           (boolean(moveflags & MOVEFLAG_NOGRAVITYONGROUND))
29         #define GAMEPLAYFIX_Q2AIRACCELERATE             (boolean(moveflags & MOVEFLAG_Q2AIRACCELERATE))
30
31         #define PHYS_GRAVITY(s)                     STAT(MOVEVARS_GRAVITY, s)
32         // FIXME: 0 doesn't mean zero gravity
33         #define PHYS_ENTGRAVITY(s)                  STAT(MOVEVARS_ENTGRAVITY, s)
34
35         #define TICRATE                             ticrate
36
37 #elif defined(SVQC)
38
39         #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  autocvar_sv_gameplayfix_gravityunaffectedbyticrate
40         #define GAMEPLAYFIX_NOGRAVITYONGROUND           autocvar_sv_gameplayfix_nogravityonground
41         #define GAMEPLAYFIX_Q2AIRACCELERATE             autocvar_sv_gameplayfix_q2airaccelerate
42
43         #define PHYS_GRAVITY(s)                     autocvar_sv_gravity
44         #define PHYS_ENTGRAVITY(s)                  ((s).gravity)
45
46         #define TICRATE sys_frametime
47
48 #endif
49
50 void set_movetype(entity this, int mt);
51
52 .float move_movetype;
53 .float move_time;
54 //.vector move_origin;
55 //.vector move_angles;
56 //.vector move_velocity;
57 //.vector move_avelocity;
58 //.int move_flags;
59 //.int move_watertype;
60 //.int move_waterlevel;
61 .void(float, float)contentstransition;
62 //.float move_bounce_factor;
63 //.float move_bounce_stopspeed;
64 .float move_nomonsters;  // -1 for MOVE_NORMAL, otherwise a MOVE_ constant
65
66 .entity aiment;
67 .vector punchangle;
68
69 .entity groundentity;  // FIXME add move_groundnetworkentity?
70 .float move_suspendedinair;
71 .float move_didgravity;
72
73 void _Movetype_WallFriction(entity this, vector stepnormal);
74 int _Movetype_FlyMove(entity this, float dt, bool applygravity, vector stepnormal, float stepheight);
75 void _Movetype_CheckVelocity(entity this);
76 void _Movetype_CheckWaterTransition(entity ent);
77 float _Movetype_CheckWater(entity ent);
78 void _Movetype_LinkEdict_TouchAreaGrid(entity this);
79 void _Movetype_LinkEdict(entity this, float touch_triggers);
80 vector _Movetype_ClipVelocity(vector vel, vector norm, float f);
81 void _Movetype_PushEntityTrace(entity this, vector push);
82 float _Movetype_PushEntity(entity this, vector push, float failonstartsolid);
83
84 void Movetype_Physics_NoMatchTicrate(entity this, float movedt, bool isclient);
85 void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy);
86 void Movetype_Physics_MatchServer(entity this, bool sloppy);
87 void Movetype_Physics_NoMatchServer(entity this);
88 void _Movetype_LinkEdict(entity this, float touch_triggers);
89 void _Movetype_LinkEdict_TouchAreaGrid(entity this);
90
91 float _Movetype_UnstickEntity(entity this);
92
93 const int MAX_CLIP_PLANES = 5;
94
95 #ifdef CSQC
96 const int MOVETYPE_NONE             = 0;
97 const int MOVETYPE_ANGLENOCLIP      = 1;
98 const int MOVETYPE_ANGLECLIP        = 2;
99 const int MOVETYPE_WALK             = 3;
100 const int MOVETYPE_STEP             = 4;
101 const int MOVETYPE_FLY              = 5;
102 const int MOVETYPE_TOSS             = 6;
103 const int MOVETYPE_PUSH             = 7;
104 const int MOVETYPE_NOCLIP           = 8;
105 const int MOVETYPE_FLYMISSILE       = 9;
106 const int MOVETYPE_BOUNCE           = 10;
107 const int MOVETYPE_BOUNCEMISSILE    = 11;  // Like bounce but doesn't lose speed on bouncing
108 const int MOVETYPE_FOLLOW           = 12;
109 const int MOVETYPE_PHYSICS          = 32;
110 const int MOVETYPE_FLY_WORLDONLY    = 33;
111
112 const int FL_ITEM                   = 256;
113 const int FL_ONGROUND                           = 512;
114 #elif defined(SVQC)
115 const int MOVETYPE_ANGLENOCLIP      = 1;
116 const int MOVETYPE_ANGLECLIP        = 2;
117 #endif
118
119 const int FL_ONSLICK = BIT(20);
120
121 const int MOVETYPE_FAKEPUSH         = 13;
122
123 const int MOVEFLAG_VALID = BIT(23);
124 const int MOVEFLAG_Q2AIRACCELERATE = BIT(0);
125 const int MOVEFLAG_NOGRAVITYONGROUND = BIT(1);
126 const int MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE = BIT(2);
127
128 #ifdef CSQC
129 #define moveflags STAT(MOVEFLAGS)
130 #endif