#define PHYS_DODGING_RAMP_TIME STAT(DODGING_RAMP_TIME, this)
#define PHYS_DODGING_UP_SPEED STAT(DODGING_UP_SPEED, this)
#define PHYS_DODGING_WALL STAT(DODGING_WALL, this)
+#define PHYS_DODGING_AIR STAT(DODGING_AIR, this)
#define PHYS_DODGING_PRESSED_KEYS(s) (s).pressedkeys
#ifdef CSQC
#elif defined(SVQC)
#define PHYS_DODGING_FRAMETIME sys_frametime
#define PHYS_DODGING_TIMEOUT(s) s.cvar_cl_dodging_timeout
-
-
#endif
#ifdef SVQC
// the jump part of the dodge cannot be ramped
.float dodging_single_action;
-#include "../../../animdecide.qh"
-#include "../../../physics/player.qh"
+#include <common/animdecide.qh>
+#include <common/physics/player.qh>
.float cvar_cl_dodging_timeout = _STAT(DODGING_TIMEOUT);
{
if (PHYS_DODGING_WALL == 0) { return false; }
- #define X(OFFSET) \
- tracebox(this.origin, this.mins, this.maxs, this.origin + OFFSET, true, this); \
- if (trace_fraction < 1 && vlen (this.origin - trace_endpos) < threshold) \
+#define X(OFFSET) \
+ tracebox(this.origin, this.mins, this.maxs, this.origin + OFFSET, true, this); \
+ if(trace_fraction < 1 && vdist(this.origin - trace_endpos, <, threshold)) \
return true;
X(1000*v_right);
X(-1000*v_right);
X(1000*v_forward);
X(-1000*v_forward);
- #undef X
+#undef X
return false;
}
makevectors(this.angles);
+ if(!PHYS_DODGING_AIR)
if (check_close_to_ground(this, PHYS_DODGING_HEIGHT_THRESHOLD) != 1
&& check_close_to_wall(this, PHYS_DODGING_DISTANCE_THRESHOLD) != 1)
return true;
/* 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)) \
+ if ((time - this.last_##BTN##_KEY_time) < PHYS_DODGING_TIMEOUT(this) || frozen_no_doubletap) \
dodge_detected = true; \
this.last_##BTN##_KEY_time = time; \
}
if (!PHYS_DODGING)
return;
- if (PHYS_DEAD(this))
+ if (IS_DEAD(this))
return;
// when swimming, no dodging allowed..
}
// make sure v_up, v_right and v_forward are sane
- makevectors(this.angles);
+ if(PHYS_DODGING_AIR)
+ makevectors(this.v_angle);
+ else
+ makevectors(this.angles);
// if we have e.g. 0.5 sec ramptime and a frametime of 0.25, then the ramp code
// will be called ramp_time/frametime times = 2 times. so, we need to
#ifdef SVQC
if (autocvar_sv_dodging_sound)
- PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ PlayerSound(this, playersound_jump, CH_PLAYER, VOL_BASE, VOICETYPE_PLAYERSOUND);
animdecide_setaction(this, ANIMACTION_JUMP, true);
#endif
MUTATOR_HOOKFUNCTION(dodging, PlayerPhysics)
{
+ entity player = M_ARGV(0, entity);
+
// print("dodging_PlayerPhysics\n");
- PM_dodging_GetPressedKeys(self);
- PM_dodging(self);
- return false;
+ PM_dodging_GetPressedKeys(player);
+ PM_dodging(player);
}
#ifdef SVQC
-MUTATOR_HOOKFUNCTION(dodging, GetCvars)
-{
- GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_dodging_timeout, "cl_dodging_timeout");
- return false;
-}
+REPLICATE(cvar_cl_dodging_timeout, float, "cl_dodging_timeout");
MUTATOR_HOOKFUNCTION(dodging, GetPressedKeys)
{
- PM_dodging_checkpressedkeys(self);
- return false;
+ entity player = M_ARGV(0, entity);
+
+ PM_dodging_checkpressedkeys(player);
}
#endif