Adjust critical, remove remainders of old god-mode check.

Critical:
* Add tags.
* Add extra flag (redundant to MediumLiftOff, just indicating what the
real lift off was, might need redesign, since m-lo is modified
sometimes.)
This commit is contained in:
asofold 2013-04-22 01:14:05 +02:00
parent 6b4421dc81
commit f4b88b3309
7 changed files with 38 additions and 69 deletions

View File

@ -1,11 +1,16 @@
package fr.neatmonster.nocheatplus.checks.fight;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import fr.neatmonster.nocheatplus.actions.ParameterName;
import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
@ -73,23 +78,33 @@ public class Critical extends Check {
if (dataM.sfLowJump || player.getFallDistance() < cc.criticalFallDistance && !BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround)){
final MovingConfig ccM = MovingConfig.getConfig(player);
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance())
/ cc.criticalFallDistance;
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY()))
/ cc.criticalVelocity;
final double delta = deltaFallDistance > 0D ? deltaFallDistance
: 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance()) / cc.criticalFallDistance;
final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY())) / cc.criticalVelocity;
double delta = deltaFallDistance > 0D ? deltaFallDistance : 0D + deltaVelocity > 0D ? deltaVelocity : 0D;
final List<String> tags = new ArrayList<String>();
// Player failed the check, but this is influenced by lag so don't do it if there was lag.
if (TickTask.getLag(1000) < 1.5){
// TODO: 1.5 is a fantasy value.
// Increment the violation level.
data.criticalVL += delta;
}
else{
tags.add("lag");
delta = 0;
}
// Execute whatever actions are associated with this check and the violation level and find out if we
// should cancel the event.
cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions);
final ViolationData vd = new ViolationData(this, player, data.criticalVL, delta, cc.criticalActions);
if (vd.needsParameters()){
if (dataM.sfLowJump){
tags.add("sf_lowjump");
}
vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
}
cancel = executeActions(vd);
}
}
}

View File

@ -276,7 +276,6 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final FightData damagedData = damagedPlayer == null ? null : FightData.getData(damagedPlayer);
final boolean damagedIsDead = damaged.isDead();
if (damagedPlayer != null && !damagedIsDead) {
// if (godMode.isEnabled(player) && godMode.check(player)){
if (!damagedPlayer.isDead() && godMode.isEnabled(damagedPlayer) && godMode.check(damagedPlayer, event.getDamage(), damagedData)){
// It requested to "cancel" the players invulnerability, so set his noDamageTicks to 0.
damagedPlayer.setNoDamageTicks(0);

View File

@ -29,63 +29,6 @@ public class GodMode extends Check {
public GodMode() {
super(CheckType.FIGHT_GODMODE);
}
/**
* Checks a player.
*
* @param player
* the player
* @return true, if successful
*/
public boolean check(final Player player) {
final FightData data = FightData.getData(player);
boolean cancel = false;
// Check at most once a second.
if (data.godModeLastTime < System.currentTimeMillis() - 1000L) {
data.godModeLastTime = System.currentTimeMillis();
final int age = player.getTicksLived();
// How much older did he get?
final int ageDelta = Math.max(0, age - data.godModeLastAge);
if (player.getNoDamageTicks() > 0 && ageDelta < 15) {
// He is invulnerable and didn't age fast enough, that costs some points.
data.godModeBuffer -= 15 - ageDelta;
// Still points left?
if (data.godModeBuffer <= 0) {
// No, that means we can increase his violation level.
data.godModeVL -= data.godModeBuffer;
// Execute whatever actions are associated with this check and the violation level and find out if
// we should cancel the event.
cancel = executeActions(player, data.godModeVL, -data.godModeBuffer,
FightConfig.getConfig(player).godModeActions);
}
} else {
// Give some new points, once a second.
data.godModeBuffer += 15;
// Decrease the violation level.
data.godModeVL *= 0.95;
}
if (data.godModeBuffer < 0)
// Can't have less than 0!
data.godModeBuffer = 0;
else if (data.godModeBuffer > 30)
// And 30 is enough for simple lag situations.
data.godModeBuffer = 30;
// Start age counting from a new time.
data.godModeLastAge = age;
}
return cancel;
}
/**
* New style god mode check. Much more sensitive.

View File

@ -160,6 +160,7 @@ public class MovingData extends ACheckData {
/** Indicate low jumping descending phase (likely cheating). */
public boolean sfLowJump = false;
public boolean sfNoLowJump = false; // Hacks.
/**
* Last valid y distance covered by a move. Integer.MAX_VALUE indicates "not set".

View File

@ -1008,7 +1008,9 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final Vector velocity = event.getVelocity();
if (cc.debug) System.out.println(event.getPlayer().getName() + " new velocity: " + velocity);
if (cc.debug){
System.out.println(event.getPlayer().getName() + " new velocity: " + velocity);
}
double newVal = velocity.getY();
boolean used = false;
@ -1036,6 +1038,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Set dirty flag here.
if (used){
data.sfDirty = true;
data.sfNoLowJump = true;
}
// TODO: clear accounting here ?
@ -1070,6 +1073,8 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
Location newTo = null;
final MovingData data = MovingData.getData(player);
data.sfNoLowJump = true;
if (morePacketsVehicle.isEnabled(player)){
// If the player is handled by the more packets vehicle check, execute it.
newTo = morePacketsVehicle.check(player, from, to);

View File

@ -282,6 +282,7 @@ public class SurvivalFly extends Check {
// Calculate the vertical speed limit based on the current jump phase.
double vAllowedDistance = 0, vDistanceAboveLimit = 0;
if (from.isInWeb()){
data.sfNoLowJump = true;
// Very simple: force players to descend or stay.
vAllowedDistance = from.isOnGround() ? 0.1D : 0;
data.jumpAmplifier = 0; // TODO: later maybe fetch.
@ -301,6 +302,7 @@ public class SurvivalFly extends Check {
}
else if (data.verticalFreedom <= 0.001 && from.isOnClimbable()){
// Ladder types.
data.sfNoLowJump = true;
// TODO: bring in in-medium accounting.
// // TODO: make these extra checks to the jumpphase thing ?
// if (fromOnGround) vAllowedDistance = climbSpeed + 0.3;
@ -328,6 +330,7 @@ public class SurvivalFly extends Check {
}
else if (data.verticalFreedom <= 0.001 && from.isInLiquid() && (Math.abs(yDistance) > 0.2 || to.isInLiquid())){
// Swimming...
data.sfNoLowJump = true;
if (yDistance >= 0){
// This is more simple to test.
// TODO: Friction in water...
@ -378,6 +381,7 @@ public class SurvivalFly extends Check {
if (data.mediumLiftOff == MediumLiftOff.LIMIT_JUMP){
// TODO: In normal water this is 0. Could set higher for special cases only (needs efficient data + flags collection?).
maxJumpPhase = 3;
data.sfNoLowJump = true;
if (data.sfJumpPhase > 0) tags.add("limitjump");
}
else if (data.jumpAmplifier > 0){
@ -526,6 +530,7 @@ public class SurvivalFly extends Check {
data.sfJumpPhase = 0;
data.clearAccounting();
data.sfLowJump = false;
data.sfNoLowJump = false;
// TODO: Experimental: reset velocity.
if (data.verticalVelocityUsed > cc.velocityGraceTicks && toOnGround && yDistance < 0){
data.verticalVelocityCounter = 0;
@ -540,6 +545,7 @@ public class SurvivalFly extends Check {
data.sfJumpPhase = 1; // TODO: ?
data.clearAccounting();
data.sfLowJump = false;
// not resetting nolow...
}
// Check removal of active horizontal velocity.
@ -979,7 +985,7 @@ public class SurvivalFly extends Check {
// Decrease
tags.add("ychdec");
// Detect low jumping.
if (!data.sfDirty && data.mediumLiftOff == MediumLiftOff.GROUND){
if (!data.sfNoLowJump && !data.sfDirty && data.mediumLiftOff == MediumLiftOff.GROUND){
final double setBackYDistance = to.getY() - data.getSetBackY();
if (setBackYDistance > 0.0){
// Only count it if the player has actually been jumping (higher than setback).

View File

@ -470,7 +470,7 @@ public class DefaultConfig extends ConfigFile {
set(ConfPaths.STRINGS + ".color", start + "sent colored chat message" + end);
set(ConfPaths.STRINGS + ".commands", start + "issued too many commands" + end);
set(ConfPaths.STRINGS + ".combspeed", start + "performs different actions at very high speed" + end);
set(ConfPaths.STRINGS + ".critical", start + "tried to do a critical hit but wasn't technically jumping" + end);
set(ConfPaths.STRINGS + ".critical", start + "tried to do a critical hit but wasn't technically jumping [tags]" + end);
set(ConfPaths.STRINGS + ".drop", start + "tried to drop more items than allowed" + end);
set(ConfPaths.STRINGS + ".dropkick", "ncp delay ncp kick [player] Dropping items too fast.");
set(ConfPaths.STRINGS + ".fastbreak", start + "tried to break blocks ([blockid]) faster than possible" + end);