Skip to content

Commit 8250116

Browse files
committed
feat: health check for spells
1 parent 38bb739 commit 8250116

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Added
1010

11-
- `MinHealthPercent` to spell/skill metadata
12-
- `MaxHealthPercent` to spell/skill metadata (Crasher/Animal Feast/Execute)
11+
- `MinHealthPercent` to ability metadata
12+
- `MaxHealthPercent` to ability metadata (Crasher/Animal Feast/Execute)
13+
- Visual indicator on spell queue when waiting on HP thresholds
1314
- `OpensDialog` to spell metadata (was only skills before)
14-
- HP threshold in spell/skill tooltips
15+
- HP threshold in ability tooltips
1516
- More tooltips in metadata editors
1617

1718
### Changed
1819

19-
- Use new metadata properties for HP based conditions
20+
- Use new metadata properties for HP based conditions on abilities
2021
- Redesign some metadata editors for skill/spells
2122
- Increase dialog size for skill/spell metadata editors
2223
- Tooltip design
2324

2425
### Removed
2526

26-
- Removed hard-coded names for HP-based skills
27+
- Removed hard-coded names for HP-based skills (now is customizable)
2728

2829
### Fixed
2930

SleepHunter/Macro/PlayerMacroState.cs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,11 @@ private bool DoSkillMacro(out bool didAssail)
553553
}
554554

555555
// Min health percentage (ex: > 90%), skip if cannot use YET
556-
if (skill.MinHealthPercent.HasValue && skill.MinHealthPercent >= client.Stats.HealthPercent)
556+
if (skill.MinHealthPercent.HasValue && skill.MinHealthPercent.Value >= client.Stats.HealthPercent)
557557
continue;
558558

559559
// Max health percentage (ex < 2%), skip if cannot use YET
560-
if (skill.MaxHealthPercent.HasValue && client.Stats.HealthPercent > skill.MaxHealthPercent)
560+
if (skill.MaxHealthPercent.HasValue && client.Stats.HealthPercent > skill.MaxHealthPercent.Value)
561561
continue;
562562

563563
if (client.SwitchToPanelAndWait(skill.Panel, TimeSpan.FromSeconds(1), out var didRequireSwitch, useShiftKey))
@@ -924,32 +924,28 @@ private SpellQueueItem GetNextSpell()
924924
private SpellQueueItem GetNextSpell_NoRotation(bool skipOnCooldown = true)
925925
{
926926
if (skipOnCooldown)
927-
return spellQueue.FirstOrDefault(spell => !spell.IsOnCooldown);
927+
return spellQueue.FirstOrDefault(spell => !spell.IsWaitingOnHealth && !spell.IsOnCooldown);
928928
else
929-
return spellQueue.FirstOrDefault();
929+
return spellQueue.FirstOrDefault(spell => !spell.IsWaitingOnHealth);
930930
}
931931

932932
private SpellQueueItem GetNextSpell_SingularOrder(bool skipOnCooldown = true)
933933
{
934934
if (skipOnCooldown)
935-
return spellQueue.FirstOrDefault(spell => !spell.IsOnCooldown && !spell.IsDone);
935+
return spellQueue.FirstOrDefault(spell => !spell.IsWaitingOnHealth && !spell.IsOnCooldown && !spell.IsDone);
936936
else
937-
return spellQueue.FirstOrDefault(spell => !spell.IsDone);
937+
return spellQueue.FirstOrDefault(spell => !spell.IsWaitingOnHealth && !spell.IsDone);
938938
}
939939

940940
private SpellQueueItem GetNextSpell_RoundRobin(bool skipOnCooldown = true)
941941
{
942-
// All spells are done, nothing to cast
943-
if (spellQueue.All(spell => spell.IsDone))
944-
return null;
945-
946-
// All spells are on cooldown, and skipping so nothing to do
947-
if (spellQueue.All(spell => spell.IsOnCooldown) && skipOnCooldown)
942+
// All spells are unavailable, nothing to do
943+
if (spellQueue.All(spell => spell.IsWaitingOnHealth || spell.IsOnCooldown || spell.IsDone))
948944
return null;
949945

950946
var currentSpell = spellQueue.ElementAt(spellQueueIndex);
951947

952-
while (currentSpell.IsDone || (skipOnCooldown && currentSpell.IsOnCooldown))
948+
while (currentSpell.IsWaitingOnHealth || currentSpell.IsDone || (skipOnCooldown && currentSpell.IsOnCooldown))
953949
currentSpell = AdvanceToNextSpell();
954950

955951
// Round robin rotation for next time

SleepHunter/Views/MainWindow.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,17 @@ private void HandleClientUpdateTick(object sender, EventArgs e)
499499
queuedSpell.MaximumLevel = spell.MaximumLevel;
500500
queuedSpell.CurrentLevel = spell.CurrentLevel;
501501
queuedSpell.IsOnCooldown = spell.IsOnCooldown;
502+
503+
var isWaitingOnHealth = false;
504+
505+
// Min health percentage (ex: > 90%), cannot use yet
506+
if (spell.MinHealthPercent.HasValue && spell.MinHealthPercent.Value >= player.Stats.HealthPercent)
507+
isWaitingOnHealth = true;
508+
// Max health percentage (ex: < 2%), cannot use yet
509+
else if (spell.MaxHealthPercent.HasValue && player.Stats.HealthPercent > spell.MaxHealthPercent.Value)
510+
isWaitingOnHealth = true;
511+
512+
queuedSpell.IsWaitingOnHealth = isWaitingOnHealth;
502513
}
503514
}
504515

0 commit comments

Comments
 (0)