]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/physics.qh
Client side multijump (broken due to physics issues)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / physics.qh
1 // Client/server mappings
2
3 #ifdef CSQC
4
5         float pm_multijump;
6
7         #define PHYS_INPUT_ANGLES(s)                            input_angles
8 // TODO
9         #define PHYS_WORLD_ANGLES(s)                            input_angles
10
11         #define PHYS_INPUT_TIMELENGTH                           input_timelength
12
13         #define PHYS_INPUT_MOVEVALUES(s)                        input_movevalues
14
15         #define PHYS_INPUT_BUTTON_MASK(s)               (input_buttons | 128 * (input_movevalues_x < 0) | 256 * (input_movevalues_x > 0) | 512 * (input_movevalues_y < 0) | 1024 * (input_movevalues_y > 0))
16         #define PHYS_INPUT_BUTTON_ATCK(s)                       (input_buttons & 1)
17         #define PHYS_INPUT_BUTTON_JUMP(s)                       (input_buttons & 2)
18         #define PHYS_INPUT_BUTTON_ATCK2(s)                      (input_buttons & 4)
19         #define PHYS_INPUT_BUTTON_ZOOM(s)                       (input_buttons & 8)
20         #define PHYS_INPUT_BUTTON_CROUCH(s)                     (input_buttons & 16)
21         #define PHYS_INPUT_BUTTON_HOOK(s)                       (input_buttons & 32)
22         #define PHYS_INPUT_BUTTON_USE(s)                        (input_buttons & 64)
23         #define PHYS_INPUT_BUTTON_BACKWARD(s)           (input_buttons & 128)
24         #define PHYS_INPUT_BUTTON_FORWARD(s)            (input_buttons & 256)
25         #define PHYS_INPUT_BUTTON_LEFT(s)                       (input_buttons & 512)
26         #define PHYS_INPUT_BUTTON_RIGHT(s)                      (input_buttons & 1024)
27
28         #define PHYS_DEAD(s)                                            s.csqcmodel_isdead
29
30         #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE
31         #define GAMEPLAYFIX_NOGRAVITYONGROUND                   cvar("sv_gameplayfix_nogravityonground")
32         #define GAMEPLAYFIX_Q2AIRACCELERATE                             cvar("sv_gameplayfix_q2airaccelerate")
33
34         #define IS_DUCKED(s)                                            (s.pmove_flags & PMF_DUCKED)
35         #define SET_DUCKED(s)                                           s.pmove_flags |= PMF_DUCKED
36         #define UNSET_DUCKED(s)                                         s.pmove_flags &= ~PMF_DUCKED
37
38         #define IS_JUMP_HELD(s)                                         (s.pmove_flags & PMF_JUMP_HELD)
39         #define SET_JUMP_HELD(s)                                        s.pmove_flags |= PMF_JUMP_HELD
40         #define UNSET_JUMP_HELD(s)                                      s.pmove_flags &= ~PMF_JUMP_HELD
41
42         #define IS_ONGROUND(s)                                          (s.pmove_flags & PMF_ONGROUND)
43         #define SET_ONGROUND(s)                                         s.pmove_flags |= PMF_ONGROUND
44         #define UNSET_ONGROUND(s)                                       s.pmove_flags &= ~PMF_ONGROUND
45
46         #define ITEMS(s)                                                        getstati(STAT_ITEMS, 0, 24)
47
48         #define PHYS_AMMO_FUEL(s)                                       getstati(STAT_FUEL)
49
50         #define PHYS_FROZEN(s)                                          getstati(STAT_FROZEN)
51
52         #define PHYS_ACCELERATE                                         getstatf(STAT_MOVEVARS_ACCELERATE)
53         #define PHYS_AIRACCEL_QW(s)                                     getstatf(STAT_MOVEVARS_AIRACCEL_QW)
54         #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s)       getstatf(STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR)
55         #define PHYS_AIRACCEL_SIDEWAYS_FRICTION         getstatf(STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION)
56         #define PHYS_AIRACCELERATE                                      getstatf(STAT_MOVEVARS_AIRACCELERATE)
57         #define PHYS_AIRCONTROL                                         getstatf(STAT_MOVEVARS_AIRCONTROL)
58         #define PHYS_AIRCONTROL_PENALTY                         getstatf(STAT_MOVEVARS_AIRCONTROL_PENALTY)
59         #define PHYS_AIRCONTROL_POWER                           getstatf(STAT_MOVEVARS_AIRCONTROL_POWER)
60         #define PHYS_AIRSPEEDLIMIT_NONQW(s)                     getstatf(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW)
61         #define PHYS_AIRSTOPACCELERATE                          getstatf(STAT_MOVEVARS_AIRSTOPACCELERATE)
62         #define PHYS_AIRSTRAFEACCEL_QW(s)                       getstatf(STAT_MOVEVARS_AIRSTRAFEACCEL_QW)
63         #define PHYS_AIRSTRAFEACCELERATE                        getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE)
64         #define PHYS_ENTGRAVITY(s)                                      getstatf(STAT_MOVEVARS_ENTGRAVITY)
65         #define PHYS_FRICTION                                           getstatf(STAT_MOVEVARS_FRICTION)
66         #define PHYS_GRAVITY                                            getstatf(STAT_MOVEVARS_GRAVITY)
67         #define PHYS_HIGHSPEED                                          getstatf(STAT_MOVEVARS_HIGHSPEED)
68         #define PHYS_JUMPVELOCITY                                       getstatf(STAT_MOVEVARS_JUMPVELOCITY)
69         #define PHYS_MAXAIRSPEED                                        getstatf(STAT_MOVEVARS_MAXAIRSPEED)
70         #define PHYS_MAXAIRSTRAFESPEED                          getstatf(STAT_MOVEVARS_MAXAIRSTRAFESPEED)
71         #define PHYS_MAXSPEED(s)                                        getstatf(STAT_MOVEVARS_MAXSPEED)
72         #define PHYS_STEPHEIGHT                                         getstatf(STAT_MOVEVARS_STEPHEIGHT)
73         #define PHYS_STOPSPEED                                          getstatf(STAT_MOVEVARS_STOPSPEED)
74         #define PHYS_WARSOWBUNNY_ACCEL                          getstatf(STAT_MOVEVARS_WARSOWBUNNY_ACCEL)
75         #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO        getstatf(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO)
76         #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL        getstatf(STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL)
77         #define PHYS_WARSOWBUNNY_TOPSPEED                       getstatf(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED)
78         #define PHYS_WARSOWBUNNY_TURNACCEL                      getstatf(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL)
79
80         #define PHYS_JETPACK_ACCEL_UP                           getstatf(STAT_JETPACK_ACCEL_UP)
81         #define PHYS_JETPACK_ACCEL_SIDE                         getstatf(STAT_JETPACK_ACCEL_SIDE)
82         #define PHYS_JETPACK_ANTIGRAVITY                        getstatf(STAT_JETPACK_ANTIGRAVITY)
83         #define PHYS_JETPACK_FUEL                                       getstatf(STAT_JETPACK_FUEL)
84         #define PHYS_JETPACK_MAXSPEED_UP                        getstatf(STAT_JETPACK_MAXSPEED_UP)
85         #define PHYS_JETPACK_MAXSPEED_SIDE                      getstatf(STAT_JETPACK_MAXSPEED_SIDE)
86
87         #define PHYS_DODGING_FROZEN                                     getstati(STAT_DODGING_FROZEN)
88
89 #elif defined(SVQC)
90
91         #define PHYS_INPUT_ANGLES(s)                            s.v_angle
92         #define PHYS_WORLD_ANGLES(s)                            s.angles
93
94         #define PHYS_INPUT_TIMELENGTH                           frametime
95
96         #define PHYS_INPUT_MOVEVALUES(s)                        s.movement
97         // TODO: cache
98         #define PHYS_INPUT_BUTTON_MASK(s)               (s.BUTTON_ATCK | 2 * s.BUTTON_JUMP | 4 * s.BUTTON_ATCK2 | 8 * s.BUTTON_ZOOM | 16 * s.BUTTON_CROUCH | 32 * s.BUTTON_HOOK | 64 * s.BUTTON_USE | 128 * (s.movement_x < 0) | 256 * (s.movement_x > 0) | 512 * (s.movement_y < 0) | 1024 * (s.movement_y > 0))
99         #define PHYS_INPUT_BUTTON_ATCK(s)                       s.BUTTON_ATCK
100         #define PHYS_INPUT_BUTTON_JUMP(s)                       s.BUTTON_JUMP
101         #define PHYS_INPUT_BUTTON_ATCK2(s)                      s.BUTTON_ATCK2
102         #define PHYS_INPUT_BUTTON_ZOOM(s)                       s.BUTTON_ZOOM
103         #define PHYS_INPUT_BUTTON_CROUCH(s)                     s.BUTTON_CROUCH
104         #define PHYS_INPUT_BUTTON_HOOK(s)                       s.BUTTON_HOOK
105         #define PHYS_INPUT_BUTTON_USE(s)                        s.BUTTON_USE
106         #define PHYS_INPUT_BUTTON_BACKWARD(s)           (s.movement_x < 0)
107         #define PHYS_INPUT_BUTTON_FORWARD(s)            (s.movement_x > 0)
108         #define PHYS_INPUT_BUTTON_LEFT(s)                       (s.movement_y < 0)
109         #define PHYS_INPUT_BUTTON_RIGHT(s)                      (s.movement_y > 0)
110
111         #define PHYS_DEAD(s)                                            s.deadflag != DEAD_NO
112
113         #define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE  autocvar_sv_gameplayfix_gravityunaffectedbyticrate
114         #define GAMEPLAYFIX_NOGRAVITYONGROUND                   cvar("sv_gameplayfix_nogravityonground")
115         #define GAMEPLAYFIX_Q2AIRACCELERATE                             autocvar_sv_gameplayfix_q2airaccelerate
116
117         #define IS_DUCKED(s)                                            s.crouch
118         #define SET_DUCKED(s)                                           s.crouch = TRUE
119         #define UNSET_DUCKED(s)                                         s.crouch = FALSE
120
121         #define IS_JUMP_HELD(s)                                         (s.flags & FL_JUMPRELEASED == 0)
122         #define SET_JUMP_HELD(s)                                        s.flags &= ~FL_JUMPRELEASED
123         #define UNSET_JUMP_HELD(s)                                      s.flags |= FL_JUMPRELEASED
124
125         #define IS_ONGROUND(s)                                          (s.flags & FL_ONGROUND)
126         #define SET_ONGROUND(s)                                         s.flags |= FL_ONGROUND
127         #define UNSET_ONGROUND(s)                                       s.flags &= ~FL_ONGROUND
128
129         #define ITEMS(s)                                                        s.items
130
131         #define PHYS_AMMO_FUEL(s)                                       s.ammo_fuel
132
133         #define PHYS_FROZEN(s)                                          s.frozen
134
135         #define PHYS_ACCELERATE                                         autocvar_sv_accelerate
136         #define PHYS_AIRACCEL_QW(s)                                     s.stat_sv_airaccel_qw
137         #define PHYS_AIRACCEL_QW_STRETCHFACTOR(s)       autocvar_sv_airaccel_qw_stretchfactor
138         #define PHYS_AIRACCEL_SIDEWAYS_FRICTION         autocvar_sv_airaccel_sideways_friction
139         #define PHYS_AIRACCELERATE                                      autocvar_sv_airaccelerate
140         #define PHYS_AIRCONTROL                                         autocvar_sv_aircontrol
141         #define PHYS_AIRCONTROL_PENALTY                         autocvar_sv_aircontrol_penalty
142         #define PHYS_AIRCONTROL_POWER                           autocvar_sv_aircontrol_power
143         #define PHYS_AIRSPEEDLIMIT_NONQW(s)                     s.stat_sv_airspeedlimit_nonqw
144         #define PHYS_AIRSTOPACCELERATE                          autocvar_sv_airstopaccelerate
145         #define PHYS_AIRSTRAFEACCEL_QW(s)                       s.stat_sv_airstrafeaccel_qw
146         #define PHYS_AIRSTRAFEACCELERATE                        autocvar_sv_airstrafeaccelerate
147         #define PHYS_ENTGRAVITY(s)                                      s.gravity
148         #define PHYS_FRICTION                                           autocvar_sv_friction
149         #define PHYS_GRAVITY                                            autocvar_sv_gravity
150         #define PHYS_HIGHSPEED                                          autocvar_g_movement_highspeed
151         #define PHYS_JUMPVELOCITY                                       autocvar_sv_jumpvelocity
152         #define PHYS_MAXAIRSPEED                                        autocvar_sv_maxairspeed
153         #define PHYS_MAXAIRSTRAFESPEED                          autocvar_sv_maxairstrafespeed
154         #define PHYS_MAXSPEED(s)                                        s.stat_sv_maxspeed
155         #define PHYS_STEPHEIGHT                                         autocvar_sv_stepheight
156         #define PHYS_STOPSPEED                                          autocvar_sv_stopspeed
157         #define PHYS_WARSOWBUNNY_ACCEL                          autocvar_sv_warsowbunny_accel
158         #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO        autocvar_sv_warsowbunny_backtosideratio
159         #define PHYS_WARSOWBUNNY_AIRFORWARDACCEL        autocvar_sv_warsowbunny_airforwardaccel
160         #define PHYS_WARSOWBUNNY_TOPSPEED                       autocvar_sv_warsowbunny_topspeed
161         #define PHYS_WARSOWBUNNY_TURNACCEL                      autocvar_sv_warsowbunny_turnaccel
162
163         #define PHYS_JETPACK_ACCEL_UP                           autocvar_g_jetpack_acceleration_up
164         #define PHYS_JETPACK_ACCEL_SIDE                         autocvar_g_jetpack_acceleration_side
165         #define PHYS_JETPACK_ANTIGRAVITY                        autocvar_g_jetpack_antigravity
166         #define PHYS_JETPACK_FUEL                                       autocvar_g_jetpack_fuel
167         #define PHYS_JETPACK_MAXSPEED_UP                        autocvar_g_jetpack_maxspeed_up
168         #define PHYS_JETPACK_MAXSPEED_SIDE                      autocvar_g_jetpack_maxspeed_side
169
170         #define PHYS_DODGING_FROZEN                                     autocvar_sv_dodging_frozen
171
172 #endif