Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_dodging.qc File Reference
Include dependency graph for sv_dodging.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PHYS_DODGING   g_dodging
#define PHYS_DODGING_AIR   autocvar_sv_dodging_air_dodging
#define PHYS_DODGING_AIR_MAXSPEED   autocvar_sv_dodging_air_maxspeed
#define PHYS_DODGING_CLIENTSELECT   autocvar_sv_dodging_clientselect
#define PHYS_DODGING_DELAY   autocvar_sv_dodging_delay
#define PHYS_DODGING_DISTANCE_THRESHOLD   autocvar_sv_dodging_wall_distance_threshold
#define PHYS_DODGING_ENABLED(s)
#define PHYS_DODGING_FRAMETIME   (1 / (frametime <= 0 ? 60 : frametime))
#define PHYS_DODGING_FROZEN_DOUBLETAP   autocvar_sv_dodging_frozen_doubletap
#define PHYS_DODGING_HEIGHT_THRESHOLD   autocvar_sv_dodging_height_threshold
#define PHYS_DODGING_HORIZ_FORCE_FASTEST   autocvar_sv_dodging_horiz_force_fastest
#define PHYS_DODGING_HORIZ_FORCE_FROZEN   autocvar_sv_dodging_horiz_force_frozen
#define PHYS_DODGING_HORIZ_FORCE_SLOWEST   autocvar_sv_dodging_horiz_force_slowest
#define PHYS_DODGING_HORIZ_SPEED_MAX   autocvar_sv_dodging_horiz_speed_max
#define PHYS_DODGING_HORIZ_SPEED_MIN   autocvar_sv_dodging_horiz_speed_min
#define PHYS_DODGING_MAXSPEED   autocvar_sv_dodging_maxspeed
#define PHYS_DODGING_PRESSED_KEYS(s)
#define PHYS_DODGING_RAMP_TIME   autocvar_sv_dodging_ramp_time
#define PHYS_DODGING_TIMEOUT(s)
#define PHYS_DODGING_UP_SPEED   autocvar_sv_dodging_up_speed
#define PHYS_DODGING_WALL   autocvar_sv_dodging_wall_dodging
#define X(COND, BTN, RESULT)
#define X(dir)

Functions

float determine_force (entity player)
void dodging_ResetPlayer (entity this)
bool is_close_to_ground (entity this, float threshold, vector up)
bool is_close_to_wall (entity this, float threshold, vector forward, vector right)
 MUTATOR_HOOKFUNCTION (dodging, GetPressedKeys)
 MUTATOR_HOOKFUNCTION (dodging, MakePlayerObserver)
 MUTATOR_HOOKFUNCTION (dodging, PlayerPhysics)
 MUTATOR_HOOKFUNCTION (dodging, PlayerSpawn)
void PM_dodging (entity this)
bool PM_dodging_checkpressedkeys (entity this)
void PM_dodging_GetPressedKeys (entity this)
 REPLICATE (cvar_cl_dodging, bool, "cl_dodging")
 REPLICATE (cvar_cl_dodging_timeout, float, "cl_dodging_timeout")

Variables

bool autocvar_cl_dodging
bool autocvar_sv_dodging_sound
float dodging_action
vector dodging_direction
float dodging_force_remaining
float dodging_force_total
float dodging_single_action
float last_BACKWARD_KEY_time
float last_dodging_time
float last_FORWARD_KEY_time
float last_LEFT_KEY_time
float last_RIGHT_KEY_time
int pressedkeys

Macro Definition Documentation

◆ PHYS_DODGING

#define PHYS_DODGING   g_dodging

Definition at line 5 of file sv_dodging.qc.

◆ PHYS_DODGING_AIR

#define PHYS_DODGING_AIR   autocvar_sv_dodging_air_dodging

Definition at line 18 of file sv_dodging.qc.

Referenced by PM_dodging(), and PM_dodging_checkpressedkeys().

◆ PHYS_DODGING_AIR_MAXSPEED

#define PHYS_DODGING_AIR_MAXSPEED   autocvar_sv_dodging_air_maxspeed

Definition at line 20 of file sv_dodging.qc.

Referenced by PM_dodging_checkpressedkeys().

◆ PHYS_DODGING_CLIENTSELECT

#define PHYS_DODGING_CLIENTSELECT   autocvar_sv_dodging_clientselect

Definition at line 21 of file sv_dodging.qc.

Referenced by PM_dodging().

◆ PHYS_DODGING_DELAY

#define PHYS_DODGING_DELAY   autocvar_sv_dodging_delay

Definition at line 6 of file sv_dodging.qc.

Referenced by PM_dodging_checkpressedkeys().

◆ PHYS_DODGING_DISTANCE_THRESHOLD

#define PHYS_DODGING_DISTANCE_THRESHOLD   autocvar_sv_dodging_wall_distance_threshold

Definition at line 7 of file sv_dodging.qc.

Referenced by PM_dodging_checkpressedkeys().

◆ PHYS_DODGING_ENABLED

#define PHYS_DODGING_ENABLED ( s)
Value:
bool autocvar_cl_dodging
Definition sv_dodging.qc:45

Definition at line 49 of file sv_dodging.qc.

Referenced by PM_dodging().

◆ PHYS_DODGING_FRAMETIME

#define PHYS_DODGING_FRAMETIME   (1 / (frametime <= 0 ? 60 : frametime))

Definition at line 46 of file sv_dodging.qc.

Referenced by PM_dodging().

◆ PHYS_DODGING_FROZEN_DOUBLETAP

#define PHYS_DODGING_FROZEN_DOUBLETAP   autocvar_sv_dodging_frozen_doubletap

Definition at line 8 of file sv_dodging.qc.

Referenced by PM_dodging_checkpressedkeys().

◆ PHYS_DODGING_HEIGHT_THRESHOLD

#define PHYS_DODGING_HEIGHT_THRESHOLD   autocvar_sv_dodging_height_threshold

Definition at line 9 of file sv_dodging.qc.

Referenced by PM_dodging_checkpressedkeys().

◆ PHYS_DODGING_HORIZ_FORCE_FASTEST

#define PHYS_DODGING_HORIZ_FORCE_FASTEST   autocvar_sv_dodging_horiz_force_fastest

Definition at line 13 of file sv_dodging.qc.

Referenced by determine_force().

◆ PHYS_DODGING_HORIZ_FORCE_FROZEN

#define PHYS_DODGING_HORIZ_FORCE_FROZEN   autocvar_sv_dodging_horiz_force_frozen

Definition at line 14 of file sv_dodging.qc.

Referenced by determine_force().

◆ PHYS_DODGING_HORIZ_FORCE_SLOWEST

#define PHYS_DODGING_HORIZ_FORCE_SLOWEST   autocvar_sv_dodging_horiz_force_slowest

Definition at line 12 of file sv_dodging.qc.

Referenced by determine_force().

◆ PHYS_DODGING_HORIZ_SPEED_MAX

#define PHYS_DODGING_HORIZ_SPEED_MAX   autocvar_sv_dodging_horiz_speed_max

Definition at line 11 of file sv_dodging.qc.

Referenced by determine_force().

◆ PHYS_DODGING_HORIZ_SPEED_MIN

#define PHYS_DODGING_HORIZ_SPEED_MIN   autocvar_sv_dodging_horiz_speed_min

Definition at line 10 of file sv_dodging.qc.

Referenced by determine_force().

◆ PHYS_DODGING_MAXSPEED

#define PHYS_DODGING_MAXSPEED   autocvar_sv_dodging_maxspeed

Definition at line 19 of file sv_dodging.qc.

Referenced by PM_dodging_checkpressedkeys().

◆ PHYS_DODGING_PRESSED_KEYS

#define PHYS_DODGING_PRESSED_KEYS ( s)
Value:
int pressedkeys

Definition at line 48 of file sv_dodging.qc.

◆ PHYS_DODGING_RAMP_TIME

#define PHYS_DODGING_RAMP_TIME   autocvar_sv_dodging_ramp_time

Definition at line 15 of file sv_dodging.qc.

Referenced by PM_dodging().

◆ PHYS_DODGING_TIMEOUT

#define PHYS_DODGING_TIMEOUT ( s)
Value:
STAT(DODGING_TIMEOUT)
#define STAT(...)
Definition stats.qh:82

Definition at line 47 of file sv_dodging.qc.

◆ PHYS_DODGING_UP_SPEED

#define PHYS_DODGING_UP_SPEED   autocvar_sv_dodging_up_speed

Definition at line 16 of file sv_dodging.qc.

Referenced by PM_dodging().

◆ PHYS_DODGING_WALL

#define PHYS_DODGING_WALL   autocvar_sv_dodging_wall_dodging

Definition at line 17 of file sv_dodging.qc.

Referenced by PM_dodging_checkpressedkeys().

◆ X [1/2]

#define X ( COND,
BTN,
RESULT )
Value:
if (mymovement_##COND) { \
/* is this a state change? */ \
if(!(PHYS_DODGING_PRESSED_KEYS(this) & KEY_##BTN) || frozen_no_doubletap) { \
tap_direction_##RESULT; \
if ((time - this.last_##BTN##_KEY_time) < PHYS_DODGING_TIMEOUT(this) || frozen_no_doubletap) { \
dodge_detected = true; \
} else if(PHYS_INPUT_BUTTON_DODGE(this)) { \
dodge_detected = true; \
} \
this.last_##BTN##_KEY_time = time; \
} \
}
#define PHYS_INPUT_BUTTON_DODGE(s)
Definition player.qh:163
float time
#define PHYS_DODGING_TIMEOUT(s)
Definition sv_dodging.qc:47
#define PHYS_DODGING_PRESSED_KEYS(s)
Definition sv_dodging.qc:48

Definition at line 116 of file sv_dodging.qc.

116#define X(dir) \
117 tracebox(this.origin, this.mins, this.maxs, this.origin + threshold * dir, true, this); \
118 if (trace_fraction < 1 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) \
119 return true;

◆ X [2/2]

#define X ( dir)
Value:
tracebox(this.origin, this.mins, this.maxs, this.origin + threshold * dir, true, this); \
return true;
float Q3SURFACEFLAG_SKY
vector mins
vector maxs
float trace_dphitq3surfaceflags
vector origin
float trace_fraction
int dir
Definition impulse.qc:89

Definition at line 116 of file sv_dodging.qc.

116#define X(dir) \
117 tracebox(this.origin, this.mins, this.maxs, this.origin + threshold * dir, true, this); \
118 if (trace_fraction < 1 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) \
119 return true;

Referenced by is_close_to_ground(), is_close_to_wall(), and PM_dodging_checkpressedkeys().

Function Documentation

◆ determine_force()

float determine_force ( entity player)

Definition at line 142 of file sv_dodging.qc.

142 {
144
145 float horiz_vel = vlen(vec2(player.velocity));
146 return map_bound_ranges(horiz_vel,
149}
#define PHYS_FROZEN(s)
Definition player.qh:118
ERASEABLE float map_bound_ranges(float value, float src_min, float src_max, float dest_min, float dest_max)
Same as map_ranges except that values outside the source range are clamped to min or max.
Definition math.qh:372
float vlen(vector v)
#define PHYS_DODGING_HORIZ_FORCE_SLOWEST
Definition sv_dodging.qc:12
#define PHYS_DODGING_HORIZ_FORCE_FROZEN
Definition sv_dodging.qc:14
#define PHYS_DODGING_HORIZ_SPEED_MAX
Definition sv_dodging.qc:11
#define PHYS_DODGING_HORIZ_SPEED_MIN
Definition sv_dodging.qc:10
#define PHYS_DODGING_HORIZ_FORCE_FASTEST
Definition sv_dodging.qc:13
#define vec2(...)
Definition vector.qh:90

References entity(), map_bound_ranges(), PHYS_DODGING_HORIZ_FORCE_FASTEST, PHYS_DODGING_HORIZ_FORCE_FROZEN, PHYS_DODGING_HORIZ_FORCE_SLOWEST, PHYS_DODGING_HORIZ_SPEED_MAX, PHYS_DODGING_HORIZ_SPEED_MIN, PHYS_FROZEN, vec2, and vlen().

Referenced by PM_dodging_checkpressedkeys().

◆ dodging_ResetPlayer()

void dodging_ResetPlayer ( entity this)

Definition at line 309 of file sv_dodging.qc.

310{
311 this.last_dodging_time = 0;
312
313 this.dodging_action = 0;
314 this.dodging_single_action = 0;
315
316 this.dodging_force_total = 0;
318
319 this.dodging_direction = '0 0 0';
320}
vector dodging_direction
float dodging_force_total
float last_dodging_time
float dodging_single_action
Definition sv_dodging.qc:92
float dodging_action
Definition sv_dodging.qc:89
float dodging_force_remaining

References dodging_action, dodging_direction, dodging_force_remaining, dodging_force_total, dodging_single_action, entity(), and last_dodging_time.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ is_close_to_ground()

bool is_close_to_ground ( entity this,
float threshold,
vector up )

Definition at line 132 of file sv_dodging.qc.

133{
134 if (IS_ONGROUND(this)) return true;
135 X(-up); // necessary for dodging down a slope using doubletap (using `+dodge` works anyway)
136
137 return false;
138}
#define IS_ONGROUND(s)
Definition movetypes.qh:16
#define X(dir)

References entity(), IS_ONGROUND, vector, and X.

Referenced by PM_dodging_checkpressedkeys().

◆ is_close_to_wall()

bool is_close_to_wall ( entity this,
float threshold,
vector forward,
vector right )

Definition at line 122 of file sv_dodging.qc.

123{
124 X(right);
125 X(-right);
126 X(forward);
127 X(-forward);
128
129 return false;
130}

References entity(), vector, and X.

Referenced by PM_dodging_checkpressedkeys().

◆ MUTATOR_HOOKFUNCTION() [1/4]

MUTATOR_HOOKFUNCTION ( dodging ,
GetPressedKeys  )

Definition at line 334 of file sv_dodging.qc.

335{
336 entity player = M_ARGV(0, entity);
337
339}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define M_ARGV(x, type)
Definition events.qh:17
bool PM_dodging_checkpressedkeys(entity this)

References entity(), GetPressedKeys(), M_ARGV, and PM_dodging_checkpressedkeys().

◆ MUTATOR_HOOKFUNCTION() [2/4]

MUTATOR_HOOKFUNCTION ( dodging ,
MakePlayerObserver  )

Definition at line 328 of file sv_dodging.qc.

329{
330 entity player = M_ARGV(0, entity);
331 dodging_ResetPlayer(player);
332}
void dodging_ResetPlayer(entity this)

References dodging_ResetPlayer(), entity(), and M_ARGV.

◆ MUTATOR_HOOKFUNCTION() [3/4]

MUTATOR_HOOKFUNCTION ( dodging ,
PlayerPhysics  )

Definition at line 297 of file sv_dodging.qc.

298{
299 entity player = M_ARGV(0, entity);
300
301#ifdef CSQC
303#endif
304 PM_dodging(player);
305}
void PM_dodging(entity this)
void PM_dodging_GetPressedKeys(entity this)

References entity(), M_ARGV, PM_dodging(), and PM_dodging_GetPressedKeys().

◆ MUTATOR_HOOKFUNCTION() [4/4]

MUTATOR_HOOKFUNCTION ( dodging ,
PlayerSpawn  )

Definition at line 322 of file sv_dodging.qc.

323{
324 entity player = M_ARGV(0, entity);
325 dodging_ResetPlayer(player);
326}

References dodging_ResetPlayer(), entity(), and M_ARGV.

◆ PM_dodging()

void PM_dodging ( entity this)

Definition at line 217 of file sv_dodging.qc.

218{
219 // can't use return value from PM_dodging_checkpressedkeys because they're called from different hooks
220 if (!this.dodging_action) return;
221
222 // when swimming or dead, no dodging allowed..
223 bool frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN(this));
224 if (this.waterlevel >= WATERLEVEL_SWIMMING || IS_DEAD(this) || (PHYS_DODGING_CLIENTSELECT && !PHYS_DODGING_ENABLED(this) && !frozen_dodging))
225 {
226 this.dodging_action = 0;
227 this.dodging_direction.x = 0;
228 this.dodging_direction.y = 0;
229 return;
230 }
231
232 vector forward, right, up;
234 MAKE_VECTORS(this.v_angle, forward, right, up);
235 else
236 MAKE_VECTORS(this.angles, forward, right, up);
237
238 // fraction of the force to apply each frame
239 // if we have e.g. 0.5 sec ramptime and a frametime of 0.25, then the ramp code
240 // will be called ramp_time/frametime times = 2 times. so, we need to
241 // add 0.5 * the total speed each frame until the dodge action is done..
242 float common_factor = PHYS_DODGING_FRAMETIME / PHYS_DODGING_RAMP_TIME;
243 // NOTE: depending on cl_netfps the client may (and probably will) send more input frames during each server frame
244 // but common_factor uses server frame rate so players with higher cl_netfps will ramp slightly faster
245
246 float velocity_increase = min(common_factor * this.dodging_force_total, this.dodging_force_remaining);
247 this.dodging_force_remaining -= velocity_increase;
248 this.velocity += this.dodging_direction.x * velocity_increase * forward
249 + this.dodging_direction.y * velocity_increase * right;
250
251 // the up part of the dodge is a single shot action
252 if (this.dodging_single_action == 1)
253 {
254 UNSET_ONGROUND(this);
255
256 this.velocity += PHYS_DODGING_UP_SPEED * up;
257
258#ifdef SVQC
260 PlayerSound(this, playersound_jump, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
261
263#endif
264
265 this.dodging_single_action = 0;
266 }
267
268 if(this.dodging_force_remaining <= 0)
269 {
270 // reset state so next dodge can be done correctly
271 this.dodging_action = 0;
272 this.dodging_direction.x = 0;
273 this.dodging_direction.y = 0;
274 }
275}
void animdecide_setaction(entity e, float action, float restart)
const int ANIMACTION_JUMP
#define IS_DEAD(s)
Definition player.qh:245
vector v_angle
Definition player.qh:237
float waterlevel
Definition player.qh:226
#define PHYS_DODGING_FROZEN(s)
Definition player.qh:112
vector velocity
#define MAKE_VECTORS(angles, forward, right, up)
Same as the makevectors builtin but uses the provided locals instead of the v_* globals.
ent angles
Definition ent_cs.qc:121
#define PlayerSound(this, def, chan, vol, voicetype)
const int VOICETYPE_PLAYERSOUND
float min(float f,...)
const int WATERLEVEL_SWIMMING
Definition movetypes.qh:13
#define UNSET_ONGROUND(s)
Definition movetypes.qh:18
vector
Definition self.qh:92
const float VOL_BASE
Definition sound.qh:36
const int CH_PLAYER
Definition sound.qh:20
#define PHYS_DODGING_ENABLED(s)
Definition sv_dodging.qc:49
#define PHYS_DODGING_AIR
Definition sv_dodging.qc:18
bool autocvar_sv_dodging_sound
Definition sv_dodging.qc:62
#define PHYS_DODGING_FRAMETIME
Definition sv_dodging.qc:46
#define PHYS_DODGING_CLIENTSELECT
Definition sv_dodging.qc:21
#define PHYS_DODGING_RAMP_TIME
Definition sv_dodging.qc:15
#define PHYS_DODGING_UP_SPEED
Definition sv_dodging.qc:16

References angles, ANIMACTION_JUMP, animdecide_setaction(), autocvar_sv_dodging_sound, CH_PLAYER, dodging_action, dodging_direction, dodging_force_remaining, dodging_force_total, dodging_single_action, entity(), IS_DEAD, MAKE_VECTORS, min(), PHYS_DODGING_AIR, PHYS_DODGING_CLIENTSELECT, PHYS_DODGING_ENABLED, PHYS_DODGING_FRAMETIME, PHYS_DODGING_FROZEN, PHYS_DODGING_RAMP_TIME, PHYS_DODGING_UP_SPEED, PHYS_FROZEN, PlayerSound, UNSET_ONGROUND, v_angle, vector, velocity, VOICETYPE_PLAYERSOUND, VOL_BASE, waterlevel, and WATERLEVEL_SWIMMING.

Referenced by MUTATOR_HOOKFUNCTION().

◆ PM_dodging_checkpressedkeys()

bool PM_dodging_checkpressedkeys ( entity this)

Definition at line 151 of file sv_dodging.qc.

152{
153 bool frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN(this));
154 bool frozen_no_doubletap = (frozen_dodging && !PHYS_DODGING_FROZEN_DOUBLETAP);
155
156 float tap_direction_x = 0;
157 float tap_direction_y = 0;
158 bool dodge_detected = false;
159 vector mymovement = PHYS_CS(this).movement;
160
161 #define X(COND,BTN,RESULT) \
162 if (mymovement_##COND) { \
163 /* is this a state change? */ \
164 if(!(PHYS_DODGING_PRESSED_KEYS(this) & KEY_##BTN) || frozen_no_doubletap) { \
165 tap_direction_##RESULT; \
166 if ((time - this.last_##BTN##_KEY_time) < PHYS_DODGING_TIMEOUT(this) || frozen_no_doubletap) { \
167 dodge_detected = true; \
168 } else if(PHYS_INPUT_BUTTON_DODGE(this)) { \
169 dodge_detected = true; \
170 } \
171 this.last_##BTN##_KEY_time = time; \
172 } \
173 }
174 X(x < 0, BACKWARD, x--);
175 X(x > 0, FORWARD, x++);
176 X(y < 0, LEFT, y--);
177 X(y > 0, RIGHT, y++);
178 #undef X
179
180 if (!dodge_detected) return false;
181
182 // this check has to be after checking keys:
183 // the first key press of the double tap is allowed to be before dodging delay,
184 // only the second has to be after, otherwise +dodge gives an advantage because typical repress time is 0.1 s
185 // or higher which means players using +dodge would be able to do it more often
187 return false;
188
189 vector forward, right, up;
190 MAKE_VECTORS(this.angles, forward, right, up);
191
193 bool can_wall_dodge = (PHYS_DODGING_WALL && is_close_to_wall(this, PHYS_DODGING_DISTANCE_THRESHOLD, forward, right));
194 bool can_air_dodge = (PHYS_DODGING_AIR && (PHYS_DODGING_AIR_MAXSPEED == 0 || vdist(this.velocity, <, PHYS_DODGING_AIR_MAXSPEED)));
195 if (!can_dodge && !can_wall_dodge && !can_air_dodge) return false;
196
197 this.last_dodging_time = time;
198
199 this.dodging_action = 1;
200 this.dodging_single_action = 1;
201
204
205 this.dodging_direction.x = tap_direction_x;
206 this.dodging_direction.y = tap_direction_y;
207
208 // normalize the dodging_direction vector.. (unlike UT99) XD
209 float length = sqrt(this.dodging_direction.x ** 2 + this.dodging_direction.y ** 2);
210
211 this.dodging_direction.x = this.dodging_direction.x / length;
212 this.dodging_direction.y = this.dodging_direction.y / length;
213
214 return true;
215}
#define PHYS_CS(s)
Definition player.qh:258
v y
Definition ent_cs.qc:121
float sqrt(float f)
#define PHYS_DODGING_AIR_MAXSPEED
Definition sv_dodging.qc:20
#define PHYS_DODGING_FROZEN_DOUBLETAP
Definition sv_dodging.qc:8
#define PHYS_DODGING_MAXSPEED
Definition sv_dodging.qc:19
#define PHYS_DODGING_WALL
Definition sv_dodging.qc:17
#define PHYS_DODGING_HEIGHT_THRESHOLD
Definition sv_dodging.qc:9
#define PHYS_DODGING_DELAY
Definition sv_dodging.qc:6
bool is_close_to_ground(entity this, float threshold, vector up)
#define PHYS_DODGING_DISTANCE_THRESHOLD
Definition sv_dodging.qc:7
bool is_close_to_wall(entity this, float threshold, vector forward, vector right)
float determine_force(entity player)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition vector.qh:8

References angles, determine_force(), dodging_action, dodging_direction, dodging_force_remaining, dodging_force_total, dodging_single_action, entity(), is_close_to_ground(), is_close_to_wall(), last_dodging_time, MAKE_VECTORS, PHYS_CS, PHYS_DODGING_AIR, PHYS_DODGING_AIR_MAXSPEED, PHYS_DODGING_DELAY, PHYS_DODGING_DISTANCE_THRESHOLD, PHYS_DODGING_FROZEN, PHYS_DODGING_FROZEN_DOUBLETAP, PHYS_DODGING_HEIGHT_THRESHOLD, PHYS_DODGING_MAXSPEED, PHYS_DODGING_WALL, PHYS_FROZEN, sqrt(), time, vdist, vector, velocity, X, and y.

Referenced by MUTATOR_HOOKFUNCTION(), and PM_dodging_GetPressedKeys().

◆ PM_dodging_GetPressedKeys()

void PM_dodging_GetPressedKeys ( entity this)

Definition at line 278 of file sv_dodging.qc.

279{
281
282 // NOTE: GetPressedKeys and PM_dodging_GetPressedKeys use similar code
283 int keys = this.pressedkeys;
284 keys = BITSET(keys, KEY_FORWARD, PHYS_CS(this).movement.x > 0);
285 keys = BITSET(keys, KEY_BACKWARD, PHYS_CS(this).movement.x < 0);
286 keys = BITSET(keys, KEY_RIGHT, PHYS_CS(this).movement.y > 0);
287 keys = BITSET(keys, KEY_LEFT, PHYS_CS(this).movement.y < 0);
288
289 keys = BITSET(keys, KEY_JUMP, PHYS_INPUT_BUTTON_JUMP(this));
290 keys = BITSET(keys, KEY_CROUCH, IS_DUCKED(this)); // workaround: player can't un-crouch until their path is clear, so we keep the button held here
291 keys = BITSET(keys, KEY_ATCK, PHYS_INPUT_BUTTON_ATCK(this));
292 keys = BITSET(keys, KEY_ATCK2, PHYS_INPUT_BUTTON_ATCK2(this));
293 this.pressedkeys = keys;
294}
#define BITSET(var, mask, flag)
Definition bits.qh:11
vector movement
Definition player.qh:229
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition player.qh:151
#define IS_DUCKED(s)
Definition player.qh:210
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition player.qh:150
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:152
const int KEY_JUMP
Definition constants.qh:39
const int KEY_ATCK2
Definition constants.qh:42
const int KEY_RIGHT
Definition constants.qh:38
const int KEY_BACKWARD
Definition constants.qh:36
const int KEY_FORWARD
Definition constants.qh:35
const int KEY_LEFT
Definition constants.qh:37
const int KEY_CROUCH
Definition constants.qh:40
const int KEY_ATCK
Definition constants.qh:41

References BITSET, entity(), IS_DUCKED, KEY_ATCK, KEY_ATCK2, KEY_BACKWARD, KEY_CROUCH, KEY_FORWARD, KEY_JUMP, KEY_LEFT, KEY_RIGHT, movement, PHYS_CS, PHYS_INPUT_BUTTON_ATCK, PHYS_INPUT_BUTTON_ATCK2, PHYS_INPUT_BUTTON_JUMP, PM_dodging_checkpressedkeys(), and pressedkeys.

Referenced by MUTATOR_HOOKFUNCTION().

◆ REPLICATE() [1/2]

REPLICATE ( cvar_cl_dodging ,
bool ,
"cl_dodging"  )

◆ REPLICATE() [2/2]

REPLICATE ( cvar_cl_dodging_timeout ,
float ,
"cl_dodging_timeout"  )

Variable Documentation

◆ autocvar_cl_dodging

bool autocvar_cl_dodging

Definition at line 45 of file sv_dodging.qc.

◆ autocvar_sv_dodging_sound

bool autocvar_sv_dodging_sound

Definition at line 62 of file sv_dodging.qc.

Referenced by PM_dodging().

◆ dodging_action

float dodging_action
Initial value:
{
{
g_dodging = cvar("g_dodging");
}
{
g_dodging = 0;
}
return false
#define MUTATOR_ONADD
Definition base.qh:309
#define MUTATOR_ONROLLBACK_OR_REMOVE
Definition base.qh:311
int g_dodging
cvar loopback
Definition stats.qh:251
float cvar(string name)

Definition at line 89 of file sv_dodging.qc.

Referenced by dodging_ResetPlayer(), PM_dodging(), and PM_dodging_checkpressedkeys().

◆ dodging_direction

vector dodging_direction

Definition at line 101 of file sv_dodging.qc.

Referenced by dodging_ResetPlayer(), PM_dodging(), and PM_dodging_checkpressedkeys().

◆ dodging_force_remaining

float dodging_force_remaining

Definition at line 110 of file sv_dodging.qc.

Referenced by dodging_ResetPlayer(), PM_dodging(), and PM_dodging_checkpressedkeys().

◆ dodging_force_total

float dodging_force_total

Definition at line 108 of file sv_dodging.qc.

Referenced by dodging_ResetPlayer(), PM_dodging(), and PM_dodging_checkpressedkeys().

◆ dodging_single_action

float dodging_single_action

Definition at line 92 of file sv_dodging.qc.

Referenced by dodging_ResetPlayer(), PM_dodging(), and PM_dodging_checkpressedkeys().

◆ last_BACKWARD_KEY_time

float last_BACKWARD_KEY_time

Definition at line 96 of file sv_dodging.qc.

◆ last_dodging_time

float last_dodging_time

Definition at line 105 of file sv_dodging.qc.

Referenced by dodging_ResetPlayer(), and PM_dodging_checkpressedkeys().

◆ last_FORWARD_KEY_time

float last_FORWARD_KEY_time

Definition at line 95 of file sv_dodging.qc.

◆ last_LEFT_KEY_time

float last_LEFT_KEY_time

Definition at line 97 of file sv_dodging.qc.

◆ last_RIGHT_KEY_time

float last_RIGHT_KEY_time

Definition at line 98 of file sv_dodging.qc.

◆ pressedkeys

int pressedkeys

Definition at line 113 of file sv_dodging.qc.

Referenced by HUD_PressedKeys(), multi_touch(), and PM_dodging_GetPressedKeys().