CS(player).movement_y = -M_SQRT1_2 * wishspeed;
}
}
- calculate_strafe_efficiency(player, CS(player).movement);
+ player.strafe_efficiency_average += calculate_strafe_efficiency(player, CS(player).movement);
}
MUTATOR_HOOKFUNCTION(cts, reset_map_global)
FOREACH_CLIENT(true, {
it.strafe_efficiency_best = -2;
- PlayerScore_Set(it, SP_CTS_STRAFE, it.strafe_efficiency_best * 10000);
+ PlayerScore_Set(it, SP_CTS_STRAFE, -20000);
if(it.race_place)
{
player.strafe_efficiency_average = player.strafe_efficiency_tics = 0;
player.strafe_efficiency_best = -2;
- PlayerScore_Set(player, SP_CTS_STRAFE, player.strafe_efficiency_best * 10000);
+ PlayerScore_Set(player, SP_CTS_STRAFE, -20000);
}
}
.float race_checkpoint;
-.float strafe_efficiency_average;
-.float strafe_efficiency_tics;
-.float strafe_efficiency_best;
-
-void calculate_strafe_efficiency(entity strafeplayer, vector movement)
+float calculate_strafe_efficiency(entity strafeplayer, vector movement)
{
- float efficiency = 0;
-
if(strafeplayer)
{
// physics
int direction;
int keys_fwd;
float wishangle = 0;
- float moveangle;
bool fwd = true;
- float bestangle;
// determine whether the player is pressing forwards or backwards keys
if(movement.x > 0)
wishangle = -wishangle;
}
- moveangle = angle + wishangle;
-
- // best angle to strafe at
- bestangle = (speed > maxspeed ? acos(maxspeed / speed) : 0) * RAD2DEG;
-
if(speed > 0 && !swimming && strafeplayer.race_checkpoint > 0) // only calculate a new average if all conditions are met
{
+ float efficiency = 0;
+ float moveangle = angle + wishangle;
+ float bestangle = (speed > maxspeed ? acos(maxspeed / speed) : 0) * RAD2DEG; // best angle to strafe at
+
++strafeplayer.strafe_efficiency_tics;
if(fabs(vlen(vec2(movement))) > 0)
{
}
else
{
- if((moveangle) >= bestangle)
+ if(moveangle >= bestangle)
{
efficiency = 1 - (moveangle - bestangle) / (90 - bestangle);
}
- else if((moveangle) <= -bestangle)
+ else if(moveangle <= -bestangle)
{
efficiency = 1 - (moveangle + bestangle) / (-90 + bestangle);
}
}
}
+ return efficiency;
}
-
- strafeplayer.strafe_efficiency_average += efficiency;
}
+ return 0;
}
#pragma once
-void calculate_strafe_efficiency(entity, vector);
+.float strafe_efficiency_average;
+.float strafe_efficiency_tics;
+.float strafe_efficiency_best;
+
+float calculate_strafe_efficiency(entity, vector);