boss getting close
This commit is contained in:
parent
f914443d86
commit
aee3a7f22c
19 changed files with 422 additions and 119 deletions
|
|
@ -18,7 +18,8 @@ public class CombatManager
|
|||
// Orbit: cycle W→D→S→A to dodge in a small circle
|
||||
private static readonly int[] OrbitKeys =
|
||||
[InputSender.VK.W, InputSender.VK.D, InputSender.VK.S, InputSender.VK.A];
|
||||
private const int OrbitStepMs = 400; // time per direction
|
||||
private const int OrbitStepMinMs = 60; // short tap per direction → ~10px radius
|
||||
private const int OrbitStepMaxMs = 120;
|
||||
|
||||
private readonly IGameController _game;
|
||||
private readonly HudReader _hudReader;
|
||||
|
|
@ -29,6 +30,12 @@ public class CombatManager
|
|||
private readonly Stopwatch _orbitSw = Stopwatch.StartNew();
|
||||
private int _orbitIndex = -1;
|
||||
private long _lastOrbitMs;
|
||||
private int _nextOrbitMs = OrbitStepMinMs;
|
||||
|
||||
// Smoothed mouse position — lerps toward target to avoid jitter
|
||||
private double _smoothX = 1280;
|
||||
private double _smoothY = 720;
|
||||
private const double SmoothFactor = 0.25; // 0=no movement, 1=instant snap
|
||||
|
||||
public bool IsHolding => _holding;
|
||||
|
||||
|
|
@ -47,6 +54,13 @@ public class CombatManager
|
|||
await _flasks.Tick();
|
||||
await UpdateOrbit();
|
||||
|
||||
// Lerp smoothed position toward target
|
||||
_smoothX += (x - _smoothX) * SmoothFactor;
|
||||
_smoothY += (y - _smoothY) * SmoothFactor;
|
||||
|
||||
var mouseX = (int)_smoothX + Rng.Next(-jitter, jitter + 1);
|
||||
var mouseY = (int)_smoothY + Rng.Next(-jitter, jitter + 1);
|
||||
|
||||
var mana = _hudReader.Current.ManaPct;
|
||||
|
||||
if (!_holding)
|
||||
|
|
@ -56,9 +70,7 @@ public class CombatManager
|
|||
else
|
||||
_manaStableCount = 0;
|
||||
|
||||
var targetX = x + Rng.Next(-jitter, jitter + 1);
|
||||
var targetY = y + Rng.Next(-jitter, jitter + 1);
|
||||
await _game.MoveMouseFast(targetX, targetY);
|
||||
await _game.MoveMouseFast(mouseX, mouseY);
|
||||
|
||||
_game.LeftMouseDown();
|
||||
await Helpers.Sleep(Rng.Next(20, 35));
|
||||
|
|
@ -79,9 +91,7 @@ public class CombatManager
|
|||
}
|
||||
else
|
||||
{
|
||||
var targetX = x + Rng.Next(-jitter, jitter + 1);
|
||||
var targetY = y + Rng.Next(-jitter, jitter + 1);
|
||||
await _game.MoveMouseFast(targetX, targetY);
|
||||
await _game.MoveMouseFast(mouseX, mouseY);
|
||||
|
||||
if (mana < 0.30f)
|
||||
{
|
||||
|
|
@ -102,15 +112,17 @@ public class CombatManager
|
|||
private async Task UpdateOrbit()
|
||||
{
|
||||
var now = _orbitSw.ElapsedMilliseconds;
|
||||
if (now - _lastOrbitMs < OrbitStepMs) return;
|
||||
if (now - _lastOrbitMs < _nextOrbitMs) return;
|
||||
_lastOrbitMs = now;
|
||||
_nextOrbitMs = Rng.Next(OrbitStepMinMs, OrbitStepMaxMs + 1);
|
||||
|
||||
// Release previous direction
|
||||
if (_orbitIndex >= 0)
|
||||
await _game.KeyUp(OrbitKeys[_orbitIndex]);
|
||||
|
||||
// Advance to next direction
|
||||
_orbitIndex = (_orbitIndex + 1) % OrbitKeys.Length;
|
||||
// Occasionally skip a direction to make movement less predictable
|
||||
var skip = Rng.Next(0, 5) == 0 ? 2 : 1;
|
||||
_orbitIndex = (_orbitIndex + skip) % OrbitKeys.Length;
|
||||
await _game.KeyDown(OrbitKeys[_orbitIndex]);
|
||||
}
|
||||
|
||||
|
|
@ -135,6 +147,8 @@ public class CombatManager
|
|||
}
|
||||
_holding = false;
|
||||
_manaStableCount = 0;
|
||||
_smoothX = 1280;
|
||||
_smoothY = 720;
|
||||
await ReleaseOrbit();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue