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