mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-10-06 10:27:26 +02:00
Add "strict" method to fight.direction.
Set as default, the "strict" option will also check the angle between the viewing direction and the direction towards the target. This might not stay the default method, but it does help against auras in close combat.
This commit is contained in:
parent
593ea71c9b
commit
61bc88b64f
@ -64,7 +64,15 @@ public class Direction extends Check {
|
|||||||
// the center of the target entity. If the line of sight is more too far off, "off" will be bigger than 0.
|
// the center of the target entity. If the line of sight is more too far off, "off" will be bigger than 0.
|
||||||
final Location loc = player.getLocation();
|
final Location loc = player.getLocation();
|
||||||
final Vector direction = player.getEyeLocation().getDirection();
|
final Vector direction = player.getEyeLocation().getDirection();
|
||||||
final double off = CheckUtils.directionCheck(loc, player.getEyeHeight(), direction, dLoc.getX(), dLoc.getY() + height / 2D, dLoc.getZ(), width, height, CheckUtils.DIRECTION_PRECISION);
|
|
||||||
|
final double off;
|
||||||
|
if (cc.directionStrict){
|
||||||
|
off = CheckUtils.combinedDirectionCheck(loc, player.getEyeHeight(), direction, dLoc.getX(), dLoc.getY() + height / 2D, dLoc.getZ(), width, height, CheckUtils.DIRECTION_PRECISION, 80.0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// Also take into account the angle.
|
||||||
|
off = CheckUtils.directionCheck(loc, player.getEyeHeight(), direction, dLoc.getX(), dLoc.getY() + height / 2D, dLoc.getZ(), width, height, CheckUtils.DIRECTION_PRECISION);
|
||||||
|
}
|
||||||
|
|
||||||
if (off > 0.1) {
|
if (off > 0.1) {
|
||||||
// Player failed the check. Let's try to guess how far he was from looking directly to the entity...
|
// Player failed the check. Let's try to guess how far he was from looking directly to the entity...
|
||||||
|
@ -73,6 +73,7 @@ public class FightConfig extends ACheckConfig {
|
|||||||
public final ActionList criticalActions;
|
public final ActionList criticalActions;
|
||||||
|
|
||||||
public final boolean directionCheck;
|
public final boolean directionCheck;
|
||||||
|
public final boolean directionStrict;
|
||||||
public final long directionPenalty;
|
public final long directionPenalty;
|
||||||
public final ActionList directionActions;
|
public final ActionList directionActions;
|
||||||
|
|
||||||
@ -134,6 +135,7 @@ public class FightConfig extends ACheckConfig {
|
|||||||
criticalActions = data.getOptimizedActionList(ConfPaths.FIGHT_CRITICAL_ACTIONS, Permissions.FIGHT_CRITICAL);
|
criticalActions = data.getOptimizedActionList(ConfPaths.FIGHT_CRITICAL_ACTIONS, Permissions.FIGHT_CRITICAL);
|
||||||
|
|
||||||
directionCheck = data.getBoolean(ConfPaths.FIGHT_DIRECTION_CHECK);
|
directionCheck = data.getBoolean(ConfPaths.FIGHT_DIRECTION_CHECK);
|
||||||
|
directionStrict = data.getBoolean(ConfPaths.FIGHT_DIRECTION_STRICT);
|
||||||
directionPenalty = data.getLong(ConfPaths.FIGHT_DIRECTION_PENALTY);
|
directionPenalty = data.getLong(ConfPaths.FIGHT_DIRECTION_PENALTY);
|
||||||
directionActions = data.getOptimizedActionList(ConfPaths.FIGHT_DIRECTION_ACTIONS, Permissions.FIGHT_DIRECTION);
|
directionActions = data.getOptimizedActionList(ConfPaths.FIGHT_DIRECTION_ACTIONS, Permissions.FIGHT_DIRECTION);
|
||||||
|
|
||||||
|
@ -390,6 +390,7 @@ public abstract class ConfPaths {
|
|||||||
|
|
||||||
private static final String FIGHT_DIRECTION = FIGHT + "direction.";
|
private static final String FIGHT_DIRECTION = FIGHT + "direction.";
|
||||||
public static final String FIGHT_DIRECTION_CHECK = FIGHT_DIRECTION + "active";
|
public static final String FIGHT_DIRECTION_CHECK = FIGHT_DIRECTION + "active";
|
||||||
|
public static final String FIGHT_DIRECTION_STRICT = FIGHT_DIRECTION + "strict";
|
||||||
public static final String FIGHT_DIRECTION_PENALTY = FIGHT_DIRECTION + "penalty";
|
public static final String FIGHT_DIRECTION_PENALTY = FIGHT_DIRECTION + "penalty";
|
||||||
public static final String FIGHT_DIRECTION_ACTIONS = FIGHT_DIRECTION + "actions";
|
public static final String FIGHT_DIRECTION_ACTIONS = FIGHT_DIRECTION + "actions";
|
||||||
|
|
||||||
|
@ -305,6 +305,7 @@ public class DefaultConfig extends ConfigFile {
|
|||||||
set(ConfPaths.FIGHT_CRITICAL_ACTIONS, "cancel vl>50 log:critical:0:5:cif cancel");
|
set(ConfPaths.FIGHT_CRITICAL_ACTIONS, "cancel vl>50 log:critical:0:5:cif cancel");
|
||||||
|
|
||||||
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
|
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
|
||||||
|
set(ConfPaths.FIGHT_DIRECTION_STRICT, true);
|
||||||
set(ConfPaths.FIGHT_DIRECTION_PENALTY, 500L);
|
set(ConfPaths.FIGHT_DIRECTION_PENALTY, 500L);
|
||||||
set(ConfPaths.FIGHT_DIRECTION_ACTIONS,
|
set(ConfPaths.FIGHT_DIRECTION_ACTIONS,
|
||||||
"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");
|
"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");
|
||||||
|
Loading…
Reference in New Issue
Block a user