AuotoAttack: add support for multiple interact modes (#2044)

* Adds support for multiple interact modes
* Entity interaction: Implement enum

Co-authored-by: ORelio <ORelio@users.noreply.github.com>
This commit is contained in:
Booquefius 2022-08-15 17:31:17 -04:00 committed by GitHub
parent fd7f79402f
commit 613f52d3ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 116 additions and 80 deletions

View file

@ -22,8 +22,9 @@ namespace MinecraftClient.ChatBots
private float health = 100;
private bool singleMode = true;
private bool priorityDistance = true;
private InteractType interactMode;
public AutoAttack(string mode, string priority, bool overrideAttackSpeed = false, double cooldownSeconds = 1)
public AutoAttack(string mode, string priority, bool overrideAttackSpeed = false, double cooldownSeconds = 1, InteractType interaction = InteractType.Attack)
{
if (mode == "single")
singleMode = true;
@ -37,6 +38,8 @@ namespace MinecraftClient.ChatBots
priorityDistance = false;
else LogToConsoleTranslated("bot.autoAttack.priority", priority);
interactMode = interaction;
if (overrideAttackSpeed)
{
if (cooldownSeconds <= 0)
@ -103,7 +106,7 @@ namespace MinecraftClient.ChatBots
// check entity distance and health again
if (shouldAttackEntity(entitiesToAttack[priorityEntity]))
{
InteractEntity(priorityEntity, 1); // hit the entity!
InteractEntity(priorityEntity, interactMode); // hit the entity!
SendAnimation(Inventory.Hand.MainHand); // Arm animation
}
}
@ -114,7 +117,7 @@ namespace MinecraftClient.ChatBots
// check that we are in range once again.
if (shouldAttackEntity(entity.Value))
{
InteractEntity(entity.Key, 1); // hit the entity!
InteractEntity(entity.Key, interactMode); // hit the entity!
}
}
SendAnimation(Inventory.Hand.MainHand); // Arm animation