Make fight.direction check violation level depend on how far off

players were with their hits vs. their line of sight.
This commit is contained in:
Evenprime 2011-10-15 15:48:58 +02:00
parent a0024d0737
commit 9bbdfc59da
2 changed files with 20 additions and 5 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 2.11
version: 2.11a
commands:
nocheat:

View File

@ -61,14 +61,29 @@ public class FightCheck {
final double y2 = y1 + 2 * h;
final double z2 = z1 + 2 * p;
if(factor * direction.getX() >= x1 && factor * direction.getY() >= y1 && factor * direction.getZ() >= z1 && factor * direction.getX() <= x2 && factor * direction.getY() <= y2 && factor * direction.getZ() <= z2) {
// Player did nothing wrong
final double xPrediction = factor * direction.getX();
final double yPrediction = factor * direction.getY();
final double zPrediction = factor * direction.getZ();
double off = 0.0D;
off += Math.max(x1 - xPrediction, 0.0D);
off += Math.max(y1 - yPrediction, 0.0D);
off += Math.max(z1 - zPrediction, 0.0D);
off += Math.max(xPrediction - x2, 0.0D);
off += Math.max(yPrediction - y2, 0.0D);
off += Math.max(zPrediction - z2, 0.0D);
if(off < 0.1D) {
// Player did probably nothing wrong
// reduce violation counter
data.violationLevel *= 0.95D;
data.violationLevel *= 0.80D;
} else {
// Player failed the check
// Increment violation counter
data.violationLevel += 1;
if(!plugin.skipCheck()) {
data.violationLevel += Math.sqrt(off);
}
// Prepare some event-specific values for logging and custom
// actions