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

Commit

Permalink
feat: add stop casting delay.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 1, 2023
1 parent d40f88e commit 6944b7b
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 35 deletions.
18 changes: 12 additions & 6 deletions RotationSolver/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,29 @@ public class PluginConfiguration : IPluginConfiguration
public float WeaponDelayMin = 0;
public float WeaponDelayMax = 0;

public float DeathDelayMin = 0;
public float DeathDelayMax = 0;
public float DeathDelayMin = 0.5f;
public float DeathDelayMax = 1;

public float WeakenDelayMin = 0;
public float WeakenDelayMax = 0;
public float WeakenDelayMin = 0.5f;
public float WeakenDelayMax = 1;

public float HostileDelayMin = 0;
public float HostileDelayMax = 0;

public float HealDelayMin = 0;
public float HealDelayMax = 0;
public float HealDelayMin = 0.5f;
public float HealDelayMax = 1;

public float StopCastingDelayMin = 0.5f;
public float StopCastingDelayMax = 1;

public float InterruptDelayMin = 0.5f;
public float InterruptDelayMax = 1;

public bool UseWorkTask = true;
public int WorkTaskDelay = 20;

public bool UseStopCasting = true;

public string PositionalErrorText = string.Empty;

public int MoveTargetAngle = 24;
Expand Down
6 changes: 5 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@
"Configwindow_Param_SpecialDuration": "Set the duration of special windows set by commands",
"Configwindow_Param_AddDotGCDCount": "Set GCD advance of DOT refresh",
"Configwindow_Param_AutoOffBetweenArea": "Turn off when player is between area.",
"Configwindow_Param_UseWorkTask": "Use work task for acceleration.",
"Configwindow_Param_Delay": "Delay",
"Configwindow_Param_WeaponDelay": "Set the range of random delay for GCD in second.",
"Configwindow_Param_DeathDelay": "Set the range of random delay for raising deaths in second.",
"Configwindow_Param_HostileDelay": "Set the range of random delay for finding hostile targets in second.",
"Configwindow_Param_InterruptDelay": "Set the range of random delay for interrupting hostile targets in second.",
"Configwindow_Param_WeakenDelay": "Set the range of random delay for esuna weakens in second.",
"Configwindow_Param_HealDelay": "Set the range of random delay for healing people in second.",
"Configwindow_Param_StopCastingDelay": "Set the range of random delay for stoping casting when target is dead in second.",
"Configwindow_Param_WorkTaskDelay": "Set the work task delay in millisecond. Smaller, more precise, more resource-intensive",
"Configwindow_Param_Display": "Display",
"Configwindow_Param_PoslockCasting": "Lock the movement when casting",
"Configwindow_Param_PoslockCasting": "Lock the movement when casting.",
"Configwindow_Param_UseStopCasting": "Use stopping casting when target is dead.",
"Configwindow_Param_PoslockModifier": "Set the modifier key to unlock the movement temporary",
"Configwindow_Param_PoslockDescription": "LT is for gamepad player",
"Configwindow_Param_CastingDisplay": "Enhance castbar with casting status",
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver/Localization/Strings_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ internal partial class Strings
public string Configwindow_Param_AddDotGCDCount { get; set; } = "Set GCD advance of DOT refresh";
public string Configwindow_Param_AutoOffBetweenArea { get; set; } = "Turn off when player is between area.";

public string Configwindow_Param_UseWorkTask { get; set; } = "Use work task for acceleration.";
public string Configwindow_Param_Delay { get; set; } = "Delay";

public string Configwindow_Param_WeaponDelay { get; set; } = "Set the range of random delay for GCD in second.";
Expand All @@ -114,10 +115,12 @@ internal partial class Strings

public string Configwindow_Param_HealDelay { get; set; } = "Set the range of random delay for healing people in second.";

public string Configwindow_Param_StopCastingDelay { get; set; } = "Set the range of random delay for stoping casting when target is dead in second.";
public string Configwindow_Param_WorkTaskDelay { get; set; } = "Set the work task delay in millisecond. Smaller, more precise, more resource-intensive";

public string Configwindow_Param_Display { get; set; } = "Display";
public string Configwindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting";
public string Configwindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting.";
public string Configwindow_Param_UseStopCasting { get; set; } = "Use stopping casting when target is dead.";
public string Configwindow_Param_PoslockModifier { get; set; } = "Set the modifier key to unlock the movement temporary";
public string Configwindow_Param_PoslockDescription { get; set; } = "LT is for gamepad player";
public string Configwindow_Param_CastingDisplay { get; set; } = "Enhance castbar with casting status";
Expand Down
43 changes: 20 additions & 23 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ private static void FrameworkUpdate(Framework framework)
// }
//#endif

//PreviewUpdater.UpdateCastBarState();
PreviewUpdater.UpdatePreview();
//ActionUpdater.UpdateActionInfo();
//TargetUpdater.UpdateTarget();
//MovingUpdater.UpdateLocation();
if (Service.Configuration.UseWorkTask)
{
UpdateWork();
}

PreviewUpdater.UpdatePreview();
ActionUpdater.DoAction();

//TimeLineUpdater.UpdateTimelineAction();
//ActionUpdater.UpdateNextAction();
//RSCommands.UpdateRotationState();
MacroUpdater.UpdateMacro();
}

Expand All @@ -55,31 +51,32 @@ public static void Enable()
while (true)
{
if(_quit) return;
if (!Service.Conditions.Any() || Service.ClientState.LocalPlayer == null)
if (!Service.Configuration.UseWorkTask || !Service.Conditions.Any() || Service.ClientState.LocalPlayer == null)
{
Task.Delay(200);
continue;
}

PreviewUpdater.UpdateCastBarState();
//PreviewUpdater.UpdatePreview();
ActionUpdater.UpdateActionInfo();
TargetUpdater.UpdateTarget();
MovingUpdater.UpdateLocation();

//ActionUpdater.DoAction();

TimeLineUpdater.UpdateTimelineAction();
ActionUpdater.UpdateNextAction();
RSCommands.UpdateRotationState();
//MacroUpdater.UpdateMacro();

UpdateWork();
Task.Delay(Service.Configuration.WorkTaskDelay);
}
});
MovingUpdater.Enable();
}

private static void UpdateWork()
{
PreviewUpdater.UpdateCastBarState();
ActionUpdater.UpdateActionInfo();
TargetUpdater.UpdateTarget();
MovingUpdater.UpdateLocation();

TimeLineUpdater.UpdateTimelineAction();
ActionUpdater.UpdateNextAction();
RSCommands.UpdateRotationState();

}

public static void Dispose()
{
_quit = true;
Expand Down
7 changes: 5 additions & 2 deletions RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ private static void UpdateEntry()

static bool _canMove;
static bool _isTarDead;
static RandomDelay _tarDeadDelay = new RandomDelay(() =>
(Service.Configuration.StopCastingDelayMin, Service.Configuration.StopCastingDelayMax));
internal static void UpdateCastBarState()
{
_isTarDead = Service.ObjectTable.SearchById(Service.ClientState.LocalPlayer.CastTargetObjectId)
is BattleChara b && b.CurrentHp == 0;
var tardead = Service.Configuration.UseStopCasting ? Service.ObjectTable.SearchById(Service.ClientState.LocalPlayer.CastTargetObjectId)
is BattleChara b && b.CurrentHp == 0 : false;
_isTarDead = _tarDeadDelay.Delay(tardead);

bool canMove = !Service.Conditions[Dalamud.Game.ClientState.Conditions.ConditionFlag.OccupiedInEvent]
&& !Service.Conditions[Dalamud.Game.ClientState.Conditions.ConditionFlag.Casting];
Expand Down
20 changes: 18 additions & 2 deletions RotationSolver/Windows/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ private void DrawParamBasic()

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_AutoOffBetweenArea,
ref Service.Configuration.AutoOffBetweenArea);

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_UseWorkTask,
ref Service.Configuration.UseWorkTask);
}

private void DrawParamDelay()
Expand All @@ -93,8 +96,17 @@ private void DrawParamDelay()
DrawRangedFloat(LocalizationManager.RightLang.Configwindow_Param_HealDelay,
ref Service.Configuration.HealDelayMin, ref Service.Configuration.HealDelayMax);

DrawIntNumber(LocalizationManager.RightLang.Configwindow_Param_WorkTaskDelay,
ref Service.Configuration.WorkTaskDelay, min: 0, max: 200);
if (Service.Configuration.UseStopCasting)
{
DrawRangedFloat(LocalizationManager.RightLang.Configwindow_Param_StopCastingDelay,
ref Service.Configuration.StopCastingDelayMin, ref Service.Configuration.StopCastingDelayMax);
}

if (Service.Configuration.UseWorkTask)
{
DrawIntNumber(LocalizationManager.RightLang.Configwindow_Param_WorkTaskDelay,
ref Service.Configuration.WorkTaskDelay, min: 0, max: 200);
}
}

private void DrawParamDisplay()
Expand Down Expand Up @@ -164,6 +176,10 @@ private void DrawParamDisplay()
ConfigurationHelper.Keys,
LocalizationManager.RightLang.Configwindow_Param_PoslockDescription);
}

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_UseStopCasting,
ref Service.Configuration.UseStopCasting);

ImGui.Separator();

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_SayOutStateChanged,
Expand Down

0 comments on commit 6944b7b

Please sign in to comment.