Make god-mode lag boundaries configurable.

This commit is contained in:
asofold 2013-02-04 23:48:37 +01:00
parent f126a13be5
commit fcd18ead24
4 changed files with 16 additions and 2 deletions

View File

@ -77,6 +77,8 @@ public class FightConfig extends ACheckConfig {
public final ActionList directionActions;
public final boolean godModeCheck;
public final long godModeLagMinAge;
public final long godModeLagMaxAge;
public final ActionList godModeActions;
public final boolean knockbackCheck;
@ -131,6 +133,8 @@ public class FightConfig extends ACheckConfig {
directionActions = data.getOptimizedActionList(ConfPaths.FIGHT_DIRECTION_ACTIONS, Permissions.FIGHT_DIRECTION);
godModeCheck = data.getBoolean(ConfPaths.FIGHT_GODMODE_CHECK);
godModeLagMinAge = data.getLong(ConfPaths.FIGHT_GODMODE_LAGMINAGE);
godModeLagMaxAge = data.getLong(ConfPaths.FIGHT_GODMODE_LAGMAXAGE);
godModeActions = data.getOptimizedActionList(ConfPaths.FIGHT_GODMODE_ACTIONS, Permissions.FIGHT_GODMODE);
knockbackCheck = data.getBoolean(ConfPaths.FIGHT_KNOCKBACK_CHECK);

View File

@ -120,6 +120,8 @@ public class GodMode extends Check {
legit = set = resetAcc = true;
}
// TODO: Might account for ndt/2 on regain health (!).
// Invulnerable or inconsistent.
// TODO: might check as well if NCP has taken over invulnerable ticks of this player.
if (invulnerabilityTicks > 0 && noDamageTicks != invulnerabilityTicks || tick < data.lastDamageTick){
@ -187,14 +189,18 @@ public class GodMode extends Check {
if (dht <= 20) return false;
}
final FightConfig cc = FightConfig.getConfig(player);
// Check for client side lag.
final long now = System.currentTimeMillis();
final long maxAge = 5000; // Allows 5 seconds lag max. TODO: Balance, test.
final long maxAge = cc.godModeLagMaxAge;
long keepAlive = mcAccess.getKeepAliveTime(player);
if (keepAlive > now || keepAlive == Long.MIN_VALUE){
keepAlive = CheckUtils.guessKeepAliveTime(player, now, maxAge);
}
if (keepAlive != Double.MIN_VALUE && now - keepAlive > 1000 && now - keepAlive < maxAge){
// TODO: else: still check the other time stamp ?
if (keepAlive != Double.MIN_VALUE && now - keepAlive > cc.godModeLagMinAge && now - keepAlive < maxAge){
// Assume lag.
return false;
}

View File

@ -369,6 +369,8 @@ public abstract class ConfPaths {
private static final String FIGHT_GODMODE = FIGHT + "godmode.";
public static final String FIGHT_GODMODE_CHECK = FIGHT_GODMODE + "active";
public static final String FIGHT_GODMODE_LAGMINAGE = FIGHT_GODMODE + "minage";
public static final String FIGHT_GODMODE_LAGMAXAGE = FIGHT_GODMODE + "maxage";
public static final String FIGHT_GODMODE_ACTIONS = FIGHT_GODMODE + "actions";
private static final String FIGHT_KNOCKBACK = FIGHT + "knockback.";

View File

@ -293,6 +293,8 @@ public class DefaultConfig extends ConfigFile {
"cancel vl>5 log:fdirection:3:5:f cancel vl>20 log:fdirection:0:5:if cancel vl>50 log:fdirection:0:5:cif cancel");
set(ConfPaths.FIGHT_GODMODE_CHECK, true);
set(ConfPaths.FIGHT_GODMODE_LAGMINAGE, 1100); // TODO: ndt/2 => 500-600.
set(ConfPaths.FIGHT_GODMODE_LAGMAXAGE, 5000);
set(ConfPaths.FIGHT_GODMODE_ACTIONS, "log:godmode:2:5:if cancel vl>60 log:godmode:2:5:icf cancel"); // cmd:kickgod");
set(ConfPaths.FIGHT_KNOCKBACK_CHECK, true);