Skip to content

Commit

Permalink
Removed dependency on SharpDX.
Browse files Browse the repository at this point in the history
Allow to use warcries without enemies.
  • Loading branch information
0xE0D59 committed Dec 23, 2022
1 parent a08325a commit fe5543b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 14 additions & 13 deletions BuffUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using WindowsInput;
using WindowsInput.Native;
using ExileCore;
using ExileCore.PoEMemory.Components;
using ExileCore.PoEMemory.MemoryObjects;
using ExileCore.Shared.Enums;
using SharpDX;

namespace BuffUtil
{
Expand Down Expand Up @@ -209,7 +209,7 @@ private void HandleBloodRage()
if (Settings.Debug)
LogMessage("Casting Blood Rage");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.BloodRageKey.Value);
lastBloodRageCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.2));
lastBloodRageCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.2);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -251,7 +251,7 @@ private void HandleSteelSkin()
if (Settings.Debug)
LogMessage("Casting Steel Skin");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.SteelSkinKey.Value);
lastSteelSkinCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.2));
lastSteelSkinCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.2);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -292,7 +292,7 @@ private void HandleImmortalCall()
if (Settings.Debug)
LogMessage("Casting Immortal Call");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.ImmortalCallKey.Value);
lastImmortalCallCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.2));
lastImmortalCallCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.2);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -333,7 +333,7 @@ private void HandleMoltenShell()
if (Settings.Debug)
LogMessage("Casting Molten Shell");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.MoltenShellKey.Value);
lastMoltenShellCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.2));
lastMoltenShellCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.2);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -385,7 +385,7 @@ private void HandlePhaseRun()
if (Settings.Debug)
LogMessage("Casting Phase Run");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.PhaseRunKey.Value);
lastPhaseRunCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.2));
lastPhaseRunCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.2);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -429,7 +429,7 @@ private void HandleWitheringStep()
if (Settings.Debug)
LogMessage("Casting Withering Step");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.WitheringStepKey.Value);
lastWitheringStepCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.2));
lastWitheringStepCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.2);
}
catch (Exception ex)
{
Expand All @@ -455,9 +455,10 @@ private void HandleWarcry()
if (rage < minRage || rage > maxRage)
return;

var useAlways = Settings.WarcryUseAlways.Value;
var requiredEnemies = Settings.WarcryNearbyEnemiesCount;
var useOnBosses = Settings.WarcryUseOnUniqueBoss.Value;
if (!(requiredEnemies > 0 && requiredEnemies <= GetNearbyMonsterCount() ||
if (!(useAlways || requiredEnemies > 0 && requiredEnemies <= GetNearbyMonsterCount() ||
useOnBosses && IsUniqueBossInRange()))
return;

Expand All @@ -472,7 +473,7 @@ private void HandleWarcry()
if (Settings.Debug)
LogMessage("Casting Warcry");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.WarcryKey.Value);
lastWarcryCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.1));
lastWarcryCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.1);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -514,7 +515,7 @@ private void HandleBerserk()
if (Settings.Debug)
LogMessage("Casting Berserk");
inputSimulator.Keyboard.KeyPress((VirtualKeyCode)Settings.BerserkKey.Value);
lastBerserkCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble(0, 0.1));
lastBerserkCast = currentTime + TimeSpan.FromSeconds(rand.NextDouble() * 0.1);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -669,7 +670,7 @@ private int GetNearbyMonsterCount()
if (nearbyMonsterCount.HasValue)
return nearbyMonsterCount.Value;

var playerPosition = GameController.Game.IngameState.Data.LocalPlayer.GetComponent<Render>().Pos;
var playerPosition = GameController.Game.IngameState.Data.LocalPlayer.GetComponent<Render>().PosNum;

List<Entity> localLoadedMonsters;
lock (loadedMonstersLock)
Expand All @@ -693,7 +694,7 @@ private bool IsUniqueBossInRange()
if (uniqueBossNearby.HasValue)
return uniqueBossNearby.Value;

var playerPosition = GameController.Game.IngameState.Data.LocalPlayer.GetComponent<Render>().Pos;
var playerPosition = GameController.Game.IngameState.Data.LocalPlayer.GetComponent<Render>().PosNum;

List<Entity> localLoadedMonsters;
lock (loadedMonstersLock)
Expand Down Expand Up @@ -727,7 +728,7 @@ private bool IsValidNearbyMonster(Entity monster, Vector3 playerPosition, int ma
!monster.IsValid)
return false;

var monsterPosition = monster.Pos;
var monsterPosition = monster.PosNum;

var xDiff = playerPosition.X - monsterPosition.X;
var yDiff = playerPosition.Y - monsterPosition.Y;
Expand Down
4 changes: 4 additions & 0 deletions BuffUtilSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public BuffUtilSettings()
WarCryMaxRage = new RangeNode<int>(24, 0, 100);
WarcryNearbyEnemiesCount = new RangeNode<int>(1, 0, 50);
WarcryUseOnUniqueBoss = new ToggleNode(true);
WarcryUseAlways = new ToggleNode(false);

BladeFlurry = new ToggleNode(false);
BladeFlurryMinCharges = new RangeNode<int>(6, 1, 6);
Expand Down Expand Up @@ -188,6 +189,9 @@ public BuffUtilSettings()
[Menu("Unique bosses", "Use Berserk on Unique Bosses", 85, 8)]
public ToggleNode WarcryUseOnUniqueBoss { get; set; }

[Menu("Use always when ready", "Use always when ready (and matches Rage conditions)", 86, 8)]
public ToggleNode WarcryUseAlways { get; set; }

#endregion

#region Blade Flurry
Expand Down

0 comments on commit fe5543b

Please sign in to comment.