.int pressedkeys;
#endif
-// returns 1 if the player is close to a wall
+// returns true if the player is close to a wall
bool check_close_to_wall(entity this, float threshold)
{
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 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) && vdist(this.origin - trace_endpos, <, threshold)) \
+#define X(dir) \
+ tracebox(this.origin, this.mins, this.maxs, this.origin + threshold * dir, true, this); \
+ if (trace_fraction < 1 && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)) \
return true;
- X(1000*v_right);
- X(-1000*v_right);
- X(1000*v_forward);
- X(-1000*v_forward);
+
+ X(v_right);
+ X(-v_right);
+ X(v_forward);
+ X(-v_forward);
#undef X
return false;
bool PM_dodging_checkpressedkeys(entity this)
{
- if(!PHYS_DODGING)
- return false;
-
- bool frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN(this));
- bool frozen_no_doubletap = (frozen_dodging && !PHYS_DODGING_FROZEN_NODOUBLETAP);
-
// first check if the last dodge is far enough back in time so we can dodge again
if ((time - this.last_dodging_time) < PHYS_DODGING_DELAY)
return false;
if(!wall_dodge && PHYS_DODGING_MAXSPEED && vdist(this.velocity, >, PHYS_DODGING_MAXSPEED))
return false;
+ bool frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN(this));
+ bool frozen_no_doubletap = (frozen_dodging && !PHYS_DODGING_FROZEN_NODOUBLETAP);
+
float tap_direction_x = 0;
float tap_direction_y = 0;
bool dodge_detected = false;
void PM_dodging(entity this)
{
- if (!PHYS_DODGING)
- return;
-
// when swimming or dead, no dodging allowed..
if (this.waterlevel >= WATERLEVEL_SWIMMING || IS_DEAD(this))
{
void PM_dodging_GetPressedKeys(entity this)
{
#ifdef CSQC
- if(!PHYS_DODGING) { return; }
-
PM_dodging_checkpressedkeys(this);
int keys = this.pressedkeys;
MUTATOR_HOOKFUNCTION(dodging, PlayerPhysics)
{
- entity player = M_ARGV(0, entity);
+ entity player = M_ARGV(0, entity);
// print("dodging_PlayerPhysics\n");
PM_dodging_GetPressedKeys(player);