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

Commit

Permalink
fix: posLock. add auto target.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 9, 2023
1 parent 9e210f6 commit 9b1a62e
Show file tree
Hide file tree
Showing 21 changed files with 205 additions and 104 deletions.
2 changes: 2 additions & 0 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"7381": 0.6,
"7383": 0.6,
"7384": 0.1,
"7385": 0.6,
"7386": 0.6,
"7387": 0.6,
"7388": 0.6,
Expand All @@ -181,6 +182,7 @@
"7412": 0.6,
"7413": 0.6,
"7414": 0.6,
"7418": 0.6,
"7421": 0.6,
"7426": 0.6,
"7427": 0.6,
Expand Down
4 changes: 4 additions & 0 deletions Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
1385,
1688,
2225,
2279,
2317,
2375,
2398,
Expand Down Expand Up @@ -35,9 +36,11 @@
5317,
5329,
5331,
5823,
5919,
5928,
5959,
6020,
6107,
6469,
6547,
Expand Down Expand Up @@ -237,6 +240,7 @@
32116,
32117,
32122,
32132,
32785,
32868,
32944,
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ public unsafe virtual bool CanUse(out IAction act, CanUseOption option = CanUseO
}
}

if (!option.HasFlag(CanUseOption.IgnoreCastCheck) && CastTime > 0 && DataCenter.IsMoving &&
!player.HasStatus(true, CustomRotation.Swiftcast.StatusProvide)) return false;
if (DataCenter.NoPoslock && DataCenter.IsMoving
&& !option.HasFlag(CanUseOption.IgnoreCastCheck) && CastTime > 0
&& !player.HasStatus(true, CustomRotation.Swiftcast.StatusProvide)) return false;

if (IsGeneralGCD && IsEot && IsFriendly && IActionHelper.IsLastGCD(true, this)
&& DataCenter.TimeSinceLastAction.TotalSeconds < 3) return false;
Expand Down
8 changes: 7 additions & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ public class PluginConfiguration : IPluginConfiguration
public bool ShowInfoOnToast = true;
public bool RaiseAll = false;
public bool CastingDisplay = true;
public bool PoslockCasting = false;
public bool PoslockCasting = true;
public int PoslockModifier = 0;
public bool PosPassageOfArms = false;
public bool PosTenChiJin = false;
public bool PosFlameThrower = false;
public bool PosImprovisation = false;

public bool RaisePlayerByCasting = true;
public bool RaiseBrinkOfDeath = true;
public int LessMPNoRaise = 0;
Expand Down Expand Up @@ -85,6 +90,7 @@ public class PluginConfiguration : IPluginConfiguration
public float KeyBoardNoiseTimeMax = 0.2f;
public bool MoveAreaActionFarthest = true;
public bool StartOnCountdown = true;
public bool StartOnAttackedBySomeone = false;
public bool NoNewHostiles = false;
public bool UseHealWhenNotAHealer = true;
public float HealthDifference = 0.25f;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Data/ActionID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public enum ActionID : uint
#region BlueMage
WaterCannon = 11385,

FlameThrower = 11402,
FlameThrower = 7418,

AquaBreath = 11390,

Expand Down
15 changes: 15 additions & 0 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ public static TextureWrap GetTexture(this IAction action, bool isAdjust = true)
return GetTexture(iconId);
}

public static TextureWrap GetTexture(this ActionID actionID, bool isAction = true)
{
var id = (uint)actionID;

if (!_actionIcons.TryGetValue(id, out var iconId))
{
iconId = isAction
? Service.GetSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(id).Icon
: Service.GetSheet<Lumina.Excel.GeneratedSheets.Item>().GetRow(id).Icon;

_actionIcons[id] = iconId;
}
return GetTexture(iconId);
}

private static readonly Dictionary<IconType, uint[]> _icons = new()
{
{ IconType.Gold, new uint[40]
Expand Down
4 changes: 4 additions & 0 deletions RotationSolver.Basic/Data/StatusID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,8 @@ public enum StatusID : ushort
LivingDead = WillDead,

Overheated = 2688,

Flamethrower = 1205,

PassageOfArms = 1175,
}
13 changes: 10 additions & 3 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Logging;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Fate;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using Lumina.Excel.GeneratedSheets;
using Action = Lumina.Excel.GeneratedSheets.Action;
using CharacterManager = FFXIVClientStructs.FFXIV.Client.Game.Character.CharacterManager;

namespace RotationSolver.Basic;

public static class DataCenter
internal static class DataCenter
{
internal static bool NoPoslock => Svc.Condition[ConditionFlag.OccupiedInEvent]
|| !Service.Config.PoslockCasting
//Key cancel.
|| Svc.KeyState[ConfigurationHelper.Keys[Service.Config.PoslockModifier]]
//Gamepad cancel.
|| Svc.GamepadState.Raw(Dalamud.Game.ClientState.GamePad.GamepadButtons.L2) >= 0.5f;

internal static DateTime EffectTime { private get; set; } = DateTime.Now;
internal static DateTime EffectEndTime { private get; set; } = DateTime.Now;

Expand Down
8 changes: 8 additions & 0 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ internal static void UpdateRotationState()
_lastCountdownTime = 0;
CancelState();
}
//Auto manual on being attacked by someone.
else if (Service.Config.StartOnAttackedBySomeone && DataCenter.AllHostileTargets.Any(t => t.TargetObjectId == Player.Object.ObjectId))
{
if(DataCenter.StateType == StateCommandType.Cancel)
{
DoStateCommandType(StateCommandType.Manual);
}
}
//Auto start at count Down.
else if (Service.Config.StartOnCountdown && Service.CountDownTime > 0)
{
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"ConfigWindow_Param_ClickMistake": "How likely is it that RS will click the wrong action.",
"ConfigWindow_Param_Display": "Display",
"ConfigWindow_Param_Advanced": "Advanced",
"ConfigWindow_Param_PoslockCasting": "Lock the movement when casting or has TenChiJin or PhantomFlurry status.",
"ConfigWindow_Param_PoslockCasting": "Lock the movement when casting or some actions.",
"ConfigWindow_Param_UseStopCasting": "Use stopping casting when target is dead.",
"ConfigWindow_Param_ShowTooltips": "Show tooltips",
"ConfigWindow_Param_InDebug": "Debug Mode",
Expand Down Expand Up @@ -132,8 +132,9 @@
"ConfigWindow_Param_LessMPNoRaise": "Never raise player if MP is less than the set value",
"ConfigWindow_Param_UseTinctures": "Use Tinctures",
"ConfigWindow_Param_UseHealPotions": "Use Heal Potions",
"ConfigWindow_Param_Conditon": "Condition",
"ConfigWindow_Param_Condition": "Condition",
"ConfigWindow_Param_StartOnCountdown": "Auto turn smart on countdown",
"ConfigWindow_Param_StartOnAttackedBySomeone": "Auto turn manual on being attacked by someone.",
"ConfigWindow_Param_EsunaAll": "Esuna All Statuses.",
"ConfigWindow_Param_InterruptibleMoreCheck": "Interrupt the action with action type check.",
"ConfigWindow_Param_HealOutOfCombat": "Heal party members outside of combat.",
Expand Down
6 changes: 4 additions & 2 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal partial class Strings
public string ConfigWindow_Param_ClickMistake { get; set; } = "How likely is it that RS will click the wrong action.";
public string ConfigWindow_Param_Display { get; set; } = "Display";
public string ConfigWindow_Param_Advanced { get; set; } = "Advanced";
public string ConfigWindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting or has TenChiJin or PhantomFlurry status.";
public string ConfigWindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting or some actions.";
public string ConfigWindow_Param_UseStopCasting { get; set; } = "Use stopping casting when target is dead.";
public string ConfigWindow_Param_ShowTooltips { get; set; } = "Show tooltips";
public string ConfigWindow_Param_InDebug { get; set; } = "Debug Mode";
Expand Down Expand Up @@ -190,8 +190,10 @@ internal partial class Strings
public string ConfigWindow_Param_LessMPNoRaise { get; set; } = "Never raise player if MP is less than the set value";
public string ConfigWindow_Param_UseTinctures { get; set; } = "Use Tinctures";
public string ConfigWindow_Param_UseHealPotions { get; set; } = "Use Heal Potions";
public string ConfigWindow_Param_Conditon { get; set; } = "Condition";
public string ConfigWindow_Param_Condition { get; set; } = "Condition";
public string ConfigWindow_Param_StartOnCountdown { get; set; } = "Auto turn smart on countdown";

public string ConfigWindow_Param_StartOnAttackedBySomeone { get; set; } = "Auto turn manual on being attacked by someone.";
public string ConfigWindow_Param_EsunaAll { get; set; } = "Esuna All Statuses.";
public string ConfigWindow_Param_InterruptibleMoreCheck { get; set; } = "Interrupt the action with action type check.";

Expand Down
1 change: 0 additions & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
MajorUpdater.Enable();
Watcher.Enable();
OtherConfiguration.Init();
_dis.Add(new MovingController());
_dis.Add(new LocalizationManager());
#if DEBUG
LocalizationManager.ExportLocalization();
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ internal static (Vector2, Vector2) DrawIAction(IAction action, float width, floa
return result;
}

static (Vector2, Vector2) DrawIAction(nint handle, float width, float percent)
internal static (Vector2, Vector2) DrawIAction(nint handle, float width, float percent)
{
var cursor = ImGui.GetCursorPos();
ImGui.BeginGroup();
Expand Down
13 changes: 0 additions & 13 deletions RotationSolver/UI/RotationConfigWindow_Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,6 @@ private void DrawLastAction()

private unsafe void DrawIcon()
{
var ptr = (IntPtr)AgentMap.Instance();
for (var i = 23064; i < 23079; i++)
{
try
{
var value = *(byte*)(ptr + i);
ImGui.Text($"{i}: {value}");
}
catch
{

}
}
}

private static void DrawAction(ActionID id, string type)
Expand Down
22 changes: 22 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Dalamud.Logging;
using Newtonsoft.Json.Linq;
using RotationSolver.Localization;
using System.Xml.Linq;

namespace RotationSolver.UI;
internal partial class RotationConfigWindow : Window
Expand Down Expand Up @@ -85,6 +86,27 @@ internal static void DrawCheckBox(string name, SettingsCommand command, string d
ImGuiHelper.DisplayCommandHelp(OtherCommandType.Settings, command.ToString());
}

internal static void DrawIconCheckBox(ActionID actionID, ref bool value, bool @default, string description = "", Action otherThing = null)
{
var name = $"##{actionID}";
description = actionID.ToString() + "\n" + description;

ControlWindow.DrawIAction(IconSet.GetTexture(actionID).ImGuiHandle, 40, 1);

ImGuiHelper.HoveredString(description);

ImGui.SameLine();
ImGuiHelper.Spacing();

DrawCheckBox(name, ref value, description, otherThing);

if (value != @default)
{
ImGuiHelper.UndoValue(name, ref value, @default, otherThing);
}
}


internal static void DrawCheckBox(string name, ref bool value, bool @default, string description = "", Action otherThing = null)
{
DrawCheckBox(name, ref value, description, otherThing);
Expand Down
28 changes: 25 additions & 3 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private void DrawParamTab()
DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Delay, DrawParamDelay);
DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Display, DrawParamDisplay);
DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Action, DrawParamAction);
DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Conditon, DrawParamCondition);
DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Condition, DrawParamCondition);
DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Target, DrawParamTarget);
DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_Param_Advanced, DrawParamAdvanced);

Expand Down Expand Up @@ -62,6 +62,9 @@ private void DrawParamBasic()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_StartOnCountdown,
ref Service.Config.StartOnCountdown, Service.Default.StartOnCountdown);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_StartOnAttackedBySomeone,
ref Service.Config.StartOnAttackedBySomeone, Service.Default.StartOnAttackedBySomeone);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseWorkTask,
ref Service.Config.UseWorkTask, Service.Default.UseWorkTask);

Expand Down Expand Up @@ -119,6 +122,7 @@ private void DrawParamDelay()
DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Param_ClickMistake, ref Service.Config.MistakeRatio, Service.Default.MistakeRatio);
}


private void DrawParamAdvanced()
{
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_SayOutStateChanged,
Expand All @@ -134,13 +138,31 @@ private void DrawParamAdvanced()

if (Service.Config.PoslockCasting)
{
ImGui.SameLine();
ImGuiHelper.Spacing();
ImGui.Indent();

DrawCombo(LocalizationManager.RightLang.ConfigWindow_Param_PoslockModifier,
ref Service.Config.PoslockModifier, EnumTranslations.ToName,
ConfigurationHelper.Keys,
LocalizationManager.RightLang.ConfigWindow_Param_PoslockDescription);

DrawIconCheckBox(ActionID.PassageOfArms, ref Service.Config.PosPassageOfArms, Service.Default.PosPassageOfArms);

ImGui.SameLine();
ImGuiHelper.Spacing();

DrawIconCheckBox(ActionID.TenChiJin, ref Service.Config.PosTenChiJin, Service.Default.PosTenChiJin);

ImGui.SameLine();
ImGuiHelper.Spacing();

DrawIconCheckBox(ActionID.FlameThrower, ref Service.Config.PosFlameThrower, Service.Default.PosFlameThrower);

ImGui.SameLine();
ImGuiHelper.Spacing();

DrawIconCheckBox(ActionID.Improvisation, ref Service.Config.PosImprovisation, Service.Default.PosImprovisation);

ImGui.Unindent();
}

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_UseStopCasting,
Expand Down
Loading

0 comments on commit 9b1a62e

Please sign in to comment.