Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add feature for auto off when combat end.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jun 7, 2023
1 parent bd6516d commit 6d444b9
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 25 deletions.
26 changes: 26 additions & 0 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"9": 0.6,
"15": 0.6,
"20": 0.6,
"23": 0.6,
"24": 0.6,
"31": 0.6,
"37": 0.6,
"40": 0.6,
Expand Down Expand Up @@ -74,6 +79,8 @@
"2876": 0.6,
"2878": 0.6,
"2890": 0.6,
"3538": 0.6,
"3539": 0.6,
"3543": 0.6,
"3545": 0.6,
"3546": 0.6,
Expand Down Expand Up @@ -128,6 +135,8 @@
"4639": 0.6,
"4868": 2.1,
"6993": 2.1,
"7383": 0.6,
"7384": 0.1,
"7386": 0.6,
"7387": 0.6,
"7388": 0.6,
Expand Down Expand Up @@ -210,6 +219,16 @@
"12260": 0.1,
"14100": 2.1,
"14971": 1.1,
"15989": 0.6,
"15990": 0.6,
"15991": 0.6,
"15992": 0.6,
"15997": 0.6,
"15999": 0.6,
"16000": 0.6,
"16001": 0.6,
"16002": 0.6,
"16010": 0.6,
"16137": 0.6,
"16138": 0.6,
"16139": 0.6,
Expand All @@ -236,6 +255,8 @@
"16163": 0.6,
"16164": 0.6,
"16165": 0.6,
"16459": 0.6,
"16461": 0.6,
"16462": 0.6,
"16464": 0.6,
"16473": 0.6,
Expand Down Expand Up @@ -344,6 +365,11 @@
"25063": 2.1,
"25064": 2.1,
"25065": 2.1,
"25746": 0.6,
"25747": 0.6,
"25748": 0.6,
"25749": 0.6,
"25750": 0.6,
"25751": 0.6,
"25752": 0.6,
"25753": 1.15,
Expand Down
1 change: 1 addition & 0 deletions Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
2375,
2398,
3282,
3358,
3416,
3519,
3676,
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace RotationSolver.Basic.Actions;
public partial class BaseAction
{
public float Range => ActionManager.GetActionRange(ID);
public float EffectRange => _action?.EffectRange ?? 0;
public float EffectRange => (ActionID)ID == ActionID.LiturgyOfTheBell ? 20 : _action?.EffectRange ?? 0;
internal ActionID[] ComboIdsNot { private get; init; } = null;

internal ActionID[] ComboIds { private get; init; } = null;
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private bool FindTarget(bool mustUse, out BattleChara target)
private bool TargetArea(float range, bool mustUse, int aoeCount, PlayerCharacter player)
{
//Moving
if (EffectRange == 1 && range >= 15 && (ActionID)ID != ActionID.LiturgyOfTheBell)
if (EffectRange == 1 && range >= 15)
{
return TargetAreaMove(range, mustUse);
}
Expand Down Expand Up @@ -160,7 +160,7 @@ private bool TargetAreaFriend(float range, bool mustUse, PlayerCharacter player)
}
else
{
var effectRange = (ActionID)ID == ActionID.LiturgyOfTheBell ? 20 : EffectRange;
var effectRange = EffectRange;
var attackT = TargetFilter.FindAttackedTarget(DataCenter.PartyTanks.GetObjectInRadius(range + effectRange), mustUse);

if (attackT == null)
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class PluginConfiguration : IPluginConfiguration

public bool AutoOffBetweenArea = true;
public bool AutoOffCutScene = true;
public float AutoOffAfterCombat = 2.5f;
public bool AutoOffWhenDead = true;
public bool PreventActionsIfOutOfCombat = false;
public bool PreventActionsIfDutyRing = false;
Expand Down Expand Up @@ -138,8 +139,8 @@ public class PluginConfiguration : IPluginConfiguration
public float InterruptDelayMin = 0.5f;
public float InterruptDelayMax = 1;

public float NotInCombatDelayMin = 1f;
public float NotInCombatDelayMax = 2;
public float NotInCombatDelayMin = 3;
public float NotInCombatDelayMax = 4;

public float ClickingDelayMin = 0.1f;
public float ClickingDelayMax = 0.15f;
Expand Down
7 changes: 2 additions & 5 deletions RotationSolver.Basic/Rotations/Basic/DNC_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ public abstract class DNC_Base : CustomRotation
#endregion

#region Support
/// <summary>
/// Moving
/// </summary>
public static IBaseAction EnAvant { get; } = new BaseAction(ActionID.EnAvant, ActionOption.Heal | ActionOption.EndSpecial);
public static IBaseAction EnAvant { get; } = new BaseAction(ActionID.EnAvant, ActionOption.Friendly | ActionOption.EndSpecial);

public static IBaseAction ShieldSamba { get; } = new BaseAction(ActionID.ShieldSamba, ActionOption.Defense)
{
Expand Down Expand Up @@ -256,7 +253,7 @@ protected static bool ExecuteStepGCD(out IAction act)
[RotationDesc(ActionID.EnAvant)]
protected sealed override bool MoveForwardAbility(out IAction act)
{
if (EnAvant.CanUse(out act)) return true;
if (EnAvant.CanUse(out act, CanUseOption.MustUseEmpty)) return true;
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ private void UpdateActions(JobRole role)

if (movingTarget && act is IBaseAction a)
{
if(a.Target == null)
if(a.Target == null || a.Target == Player)
{
MoveTarget = a.Position;
MoveTarget = a.Position == a.Target.Position ? null : a.Position;
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ internal static void UpdateRotationState()
DoStateCommandType(StateCommandType.Auto);
}
}
//Cancel when after combat.
else if (Service.Config.AutoOffAfterCombat > 0)
{
var time = (float)(DateTime.Now - ActionUpdater._endCombatTime).TotalSeconds;
if(time > Service.Config.AutoOffAfterCombat && time < Service.Config.AutoOffAfterCombat + 1)
{
CancelState();
}
}
}
}
}
1 change: 1 addition & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"ConfigWindow_Param_SpecialDuration": "Set the duration of special windows set by commands",
"ConfigWindow_Param_AddDotGCDCount": "Set GCD advance of DOT refresh",
"ConfigWindow_Param_MaxPing": "Set the Max Ping that RS can get.",
"ConfigWindow_Param_AutoOffAfterCombat": "Auto turn off when combat is over more than near several seconds.",
"ConfigWindow_Param_AutoOffBetweenArea": "Auto turn off when player is between area.",
"ConfigWindow_Param_AutoOffCutScene": "Auto turn off during cut scene.",
"ConfigWindow_Param_AutoOffWhenDead": "Auto turn off when dead.",
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ internal partial class Strings
public string ConfigWindow_Param_SpecialDuration { get; set; } = "Set the duration of special windows set by commands";
public string ConfigWindow_Param_AddDotGCDCount { get; set; } = "Set GCD advance of DOT refresh";
public string ConfigWindow_Param_MaxPing { get; set; } = "Set the Max Ping that RS can get.";
public string ConfigWindow_Param_AutoOffAfterCombat { get; set; } = "Auto turn off when combat is over more than near several seconds.";
public string ConfigWindow_Param_AutoOffBetweenArea { get; set; } = "Auto turn off when player is between area.";

public string ConfigWindow_Param_AutoOffCutScene { get; set; } = "Auto turn off during cut scene.";
Expand Down
14 changes: 11 additions & 3 deletions RotationSolver/SpeechHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Plugin;
using Dalamud.Logging;
using Dalamud.Plugin;
using ECommons.DalamudServices;
using ECommons.Reflection;
using RotationSolver.Localization;
Expand Down Expand Up @@ -29,7 +30,14 @@ internal static void Speak(string text)
_manager ??= _textToTalk?.GetType().GetRuntimeFields().FirstOrDefault(m => m.Name == "backendManager").GetValue(_textToTalk);
_stop ??= _manager?.GetType().GetRuntimeMethods().FirstOrDefault(m => m.Name == "CancelAllSpeech");

_stop?.Invoke(_manager, Array.Empty<object>());
_say?.Invoke(_textToTalk, new object[] { null, text, 1 });
try
{
_stop?.Invoke(_manager, Array.Empty<object>());
_say?.Invoke(_textToTalk, new object[] { null, text, 1 });
}
catch (Exception ex)
{
PluginLog.Warning(ex, "something wrong with TTT");
}
}
}
16 changes: 9 additions & 7 deletions RotationSolver/UI/PainterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class TargetDrawing : Drawing3DPoly
public TargetDrawing()
{
var c = Service.Config.TargetColor;
var Tcolor = ImGui.GetColorU32(new Vector4(c.X, c.Y, c.Z, 1));
_target = new Drawing3DCircularSector(default, 0, Tcolor, 3)
var TColor = ImGui.GetColorU32(new Vector4(c.X, c.Y, c.Z, 1));
_target = new Drawing3DCircularSector(default, 0, TColor, 3)
{
IsFill = false,
};
Expand All @@ -103,8 +103,8 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter)
var ratio = (float)DrawingHelper.EaseFuncRemap(EaseFuncType.None, EaseFuncType.Cubic)(d);

var c = Service.Config.TargetColor;
var Tcolor = ImGui.GetColorU32(new Vector4(c.X, c.Y, c.Z, 1));
_target.Color = Tcolor;
var TColor = ImGui.GetColorU32(new Vector4(c.X, c.Y, c.Z, 1));
_target.Color = TColor;

List<IDrawing3D> subItems = new List<IDrawing3D>() { _target };
_target.Center = act.Target.Position;
Expand All @@ -113,14 +113,14 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter)
if (DataCenter.HostileTargets.Contains(act.Target) || act.Target == Player.Object && !act.IsFriendly)
{
c = Service.Config.SubTargetColor;
var Scolor = ImGui.GetColorU32(new Vector4(c.X, c.Y, c.Z, 1));
var SColor = ImGui.GetColorU32(new Vector4(c.X, c.Y, c.Z, 1));

foreach (var t in DataCenter.HostileTargets)
{
if (t == act.Target) continue;
if (act.CanGetTarget(act.Target, t))
{
subItems.Add(new Drawing3DCircularSector(t.Position, targetRadius * ratio, Scolor, 3)
subItems.Add(new Drawing3DCircularSector(t.Position, targetRadius * ratio, SColor, 3)
{
IsFill = false,
});
Expand Down Expand Up @@ -230,7 +230,9 @@ public static void Init()
_painter.AddDrawings(_positional, annulus, movingTarget, new TargetDrawing(), new TargetText());

#if DEBUG
_painter.AddDrawings(new Drawing3DCircularSectorO(Player.Object, 3, ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 0.5f, 0.4f, 0.15f)), 5));
//_painter.AddDrawings(new Drawing3DCircularSectorO(Player.Object, 3, ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 0.5f, 0.4f, 0.15f)), 5),
// new Drawing3DAnnulus(Player.Object.Position, 10, 10 + Service.Config.MeleeRangeOffset,
// ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 0.8f, 0.75f, 0.15f)), 2));
//var color = ImGui.ColorConvertFloat4ToU32(new Vector4(1f, 0.5f, 0.4f, 0.15f));

//var p = new Drawing3DCircularSector(Player.Object.Position, 5, color, 5);
Expand Down
7 changes: 5 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ private void DrawParamBasic()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoOffWhenDead,
ref Service.Config.AutoOffWhenDead, Service.Default.AutoOffWhenDead);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_AutoOffAfterCombat,
ref Service.Config.AutoOffAfterCombat, Service.Default.AutoOffAfterCombat, min: 0, max: 10);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_StartOnCountdown,
ref Service.Config.StartOnCountdown, Service.Default.StartOnCountdown);

Expand Down Expand Up @@ -209,9 +212,9 @@ private void DrawParamDisplay()
PainterManager._painter.DrawingHeight = Service.Config.DrawingHeight;
});

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_SampleLength, ref Service.Config.SampleLength, Service.Default.SampleLength, 0.005f, 0.1f, 3, otherThing: () =>
DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_SampleLength, ref Service.Config.SampleLength, Service.Default.SampleLength, 0.005f, 0.05f, 3, otherThing: () =>
{
PainterManager._painter.SampleLength = Service.Config.SampleLength;
PainterManager._painter.SampleLength = Math.Max(0.05f, Service.Config.SampleLength);
});

ImGui.Separator();
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace RotationSolver.Updaters;
internal static class ActionUpdater
{
static DateTime _startCombatTime = DateTime.MinValue;
internal static DateTime _endCombatTime = DateTime.MinValue;

static RandomDelay _GCDDelay = new(() => (Service.Config.WeaponDelayMin, Service.Config.WeaponDelayMax));

Expand Down Expand Up @@ -111,6 +112,7 @@ private unsafe static void UpdateTimeInfo()
else if(last && !DataCenter.InCombat)
{
_startCombatTime = DateTime.MinValue;
_endCombatTime = DateTime.Now;
}
if (_startCombatTime == DateTime.MinValue)
{
Expand Down
2 changes: 1 addition & 1 deletion XIVPainter

0 comments on commit 6d444b9

Please sign in to comment.