Add setting for overriding attack speed for autoattack (#1512)

* Add setting for overriding attack speed for autoattack

* Change cooldown value type to float

* Fix minor grammar issue
This commit is contained in:
ReinforceZwei 2021-03-28 19:26:38 +08:00 committed by GitHub
parent 70d3b6175b
commit 53e2413204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 7 deletions

View file

@ -173,6 +173,8 @@ namespace MinecraftClient
public static bool AutoAttack_Enabled = false;
public static string AutoAttack_Mode = "single";
public static string AutoAttack_Priority = "distance";
public static bool AutoAttack_OverrideAttackSpeed = false;
public static double AutoAttack_CooldownSeconds = 1;
//Auto Fishing
public static bool AutoFishing_Enabled = false;
@ -577,6 +579,17 @@ namespace MinecraftClient
case "enabled": AutoAttack_Enabled = str2bool(argValue); break;
case "mode": AutoAttack_Mode = argValue.ToLower(); break;
case "priority": AutoAttack_Priority = argValue.ToLower(); break;
case "cooldownseconds":
if (argValue.ToLower() == "auto")
{
AutoAttack_OverrideAttackSpeed = false;
}
else
{
AutoAttack_OverrideAttackSpeed = true;
AutoAttack_CooldownSeconds = str2float(argValue);
}
break;
}
break;
@ -726,6 +739,23 @@ namespace MinecraftClient
}
}
/// <summary>
/// Convert the specified string to a float number, defaulting to zero if invalid argument
/// </summary>
/// <param name="str">String to parse as a float number</param>
/// <returns>Float number</returns>
public static float str2float(string str)
{
float f;
if (float.TryParse(str.Trim(), out f))
return f;
else
{
ConsoleIO.WriteLogLine(Translations.Get("error.setting.str2int", str));
return 0;
}
}
/// <summary>
/// Convert the specified string to a boolean value, defaulting to false if invalid argument
/// </summary>