Skip to content

Commit

Permalink
Improve fru scripts (#251)
Browse files Browse the repository at this point in the history
* [improve] more fast display

* [add] disable when low hp

* [add] tank mitigation
  • Loading branch information
Garume authored Jan 16, 2025
1 parent afe75b0 commit a7ac0f4
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 217 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.Types;
using ECommons;
using ECommons.Configuration;
Expand All @@ -20,12 +21,15 @@ public class P4_AutoTargetSwitcher : SplatoonScript
private readonly List<float> _percentages = [];
private readonly Random _random = new();
private readonly List<IBattleChara> _targets = [];

private int _akhMornCount;
private IBattleChara? _currentTarget;

private Timings _currentTiming = Timings.Start;
private float _lastMinPercentage;
private int _mornAfahCount;
public override HashSet<uint>? ValidTerritories => [1238];
public override Metadata? Metadata => new(4, "Garume");
public override Metadata? Metadata => new(5, "Garume");

private Config C => Controller.GetConfig<Config>();

Expand Down Expand Up @@ -70,6 +74,9 @@ public override void OnSettingsDraw()
ImGui.SliderFloat("Acceptable Percentage", ref C.AcceptablePercentage, 0f, 100f);
ImGui.SliderInt("Interval", ref C.Interval, 100, 1000);

ImGui.Checkbox("Should Disable When Low Hp", ref C.ShouldDisableWhenLowHp);
if (C.ShouldDisableWhenLowHp) ImGui.SliderFloat("Low Hp Percentage", ref C.LowHpPercentage, 0f, 100f);

ImGui.Checkbox("Timing Mode", ref C.TimingMode);
if (C.TimingMode)
{
Expand Down Expand Up @@ -133,12 +140,8 @@ public override void OnActionEffectEvent(ActionEffectSet set)
_mornAfahCount++;
_currentTiming = _mornAfahCount == 1 ? Timings.FirstMornAfahEnd : Timings.SecondMornAfahEnd;
break;

}
}

private int _akhMornCount = 0;
private int _mornAfahCount = 0;

public override void OnStartingCast(uint source, uint castId)
{
Expand All @@ -152,7 +155,7 @@ public override void OnStartingCast(uint source, uint castId)
public override void OnUpdate()
{
if (!IsActive) return;
if(Svc.Condition[Dalamud.Game.ClientState.Conditions.ConditionFlag.DutyRecorderPlayback]) return;
if (Svc.Condition[ConditionFlag.DutyRecorderPlayback]) return;
if (EzThrottler.Throttle("AutoTargetSwitcher", C.Interval))
{
var darkGirl = DarkGirl;
Expand All @@ -164,6 +167,14 @@ public override void OnUpdate()
return;
}

if (C.ShouldDisableWhenLowHp && darkGirl != null && lightGirl != null)
if ((float)darkGirl.CurrentHp / darkGirl.MaxHp * 100f < C.LowHpPercentage ||
(float)lightGirl.CurrentHp / lightGirl.MaxHp * 100f < C.LowHpPercentage)
{
Alert("Disabling due to low hp");
return;
}

if (darkGirl == null && lightGirl != null)
{
Svc.Targets.SetTarget(lightGirl);
Expand Down Expand Up @@ -236,14 +247,11 @@ private enum Timings
FirstAkhMorn,
FirstMornAfahEnd,
SecondAkhMorn,
SecondMornAfahEnd
SecondMornAfahEnd
}

private class Config : IEzConfig
{
public float AcceptablePercentage = 3f;
public bool DebugMode;

public readonly List<Timings> DisableTimings =
[
];
Expand All @@ -252,7 +260,12 @@ private class Config : IEzConfig
[
];

public float AcceptablePercentage = 3f;
public bool DebugMode;

public int Interval = 300;
public bool TimingMode = false;
public float LowHpPercentage = 1f;
public bool ShouldDisableWhenLowHp;
public bool TimingMode;
}
}
Loading

0 comments on commit a7ac0f4

Please sign in to comment.