Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve fru scripts #251

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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