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

Commit

Permalink
fix: add provoke target list.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 30, 2023
1 parent cd363ec commit 27ec7d5
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
9 changes: 8 additions & 1 deletion RotationSolver.Basic/Configuration/OtherConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class OtherConfiguration
public static SortedList<uint, float> AnimationLockTime = new();

public static Dictionary<uint, string[]> NoHostileNames = new();
public static Dictionary<uint, string[]> NoProvokeNames = new();
public static Dictionary<uint, Vector3[]> BeneficialPositions = new();

public static HashSet<uint> DangerousStatus = new();
Expand All @@ -34,6 +35,8 @@ public static void Init()

Task.Run(() => InitOne(ref NoHostileNames, nameof(NoHostileNames)));

Task.Run(() => InitOne(ref NoProvokeNames, nameof(NoProvokeNames)));

Task.Run(() => InitOne(ref AnimationLockTime, nameof(AnimationLockTime)));

Task.Run(() => InitOne(ref HostileCastingArea, nameof(HostileCastingArea)));
Expand All @@ -55,12 +58,16 @@ public static void Save()
SaveHostileCastingTank();
SaveBeneficialPositions();
SaveRotationSolverRecord();
SaveNoProvokeNames();
}

public static void SaveRotationSolverRecord()
{
Task.Run(() => Save(RotationSolverRecord, nameof(RotationSolverRecord)));
}
public static void SaveNoProvokeNames()
{
Task.Run(() => Save(NoProvokeNames, nameof(NoProvokeNames)));
}

public static void SaveBeneficialPositions()
{
Expand Down
9 changes: 9 additions & 0 deletions RotationSolver.Basic/Helpers/TargetFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using ECommons.GameFunctions;
using ECommons.GameHelpers;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Basic.Configuration;
using System.Data;
using System.Text.RegularExpressions;

namespace RotationSolver.Basic.Helpers;

Expand Down Expand Up @@ -175,6 +177,13 @@ internal static IEnumerable<BattleChara> ProvokeTarget(IEnumerable<BattleChara>

var targets = inputCharas.Where(target =>
{
//Removed the listed names.
IEnumerable<string> names = Array.Empty<string>();
if (OtherConfiguration.NoProvokeNames.TryGetValue(Svc.ClientState.TerritoryType, out var ns1))
names = names.Union(ns1);

if (names.Any(n => !string.IsNullOrEmpty(n) && new Regex(n).Match(target.Name.ToString()).Success)) return false;

//Target can move or two big and has a target
if ((target.GetObjectNPC()?.Unknown12 == 0 || target.HitboxRadius >= 5)
&& (target.TargetObject?.IsValid() ?? false))
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ internal partial class Strings

public string ConfigWindow_List_NoHostile { get; set; } = "No Hostile";
public string ConfigWindow_List_NoHostileDesc { get; set; } = "Add names of targets that will never be attacked.";
public string ConfigWindow_List_NoProvokeDesc { get; set; } = "Add names of targets that will never be provoked.";

#endregion

Expand Down Expand Up @@ -664,6 +665,7 @@ internal partial class Strings

public string ConfigWindow_List_BeneficialPositions { get; set; } = "Beneficial positions";
public string ConfigWindow_List_NoHostilesName { get; set; } = "The name of object that you don't want to attack";
public string ConfigWindow_List_NoProvokeName { get; set; } = "The name of object that you don't want to provoke";

public string ConfigWindow_Basic_AutoSwitch { get; set; } = "Auto Switch";

Expand Down
45 changes: 42 additions & 3 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ private static void DrawListTerritories()
ImGui.PopStyleColor();
ImGui.PopFont();

if (ImGui.BeginTable("Rotation Solver List Territories", 2, ImGuiTableFlags.BordersInner | ImGuiTableFlags.Resizable | ImGuiTableFlags.SizingStretchSame))
if (ImGui.BeginTable("Rotation Solver List Territories", 3, ImGuiTableFlags.BordersInner | ImGuiTableFlags.Resizable | ImGuiTableFlags.SizingStretchSame))
{
ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableNextRow(ImGuiTableRowFlags.Headers);
Expand Down Expand Up @@ -1909,14 +1909,14 @@ private static void DrawListTerritories()
for (int i = 0; i < libs.Length; i++)
{
ImGui.SetNextItemWidth(width);
if(ImGui.InputTextWithHint($"##Rotation Solver Territory Name {i}", LocalizationManager.RightLang.ConfigWindow_List_NoHostilesName, ref libs[i], 1024))
if(ImGui.InputTextWithHint($"##Rotation Solver Territory Target Name {i}", LocalizationManager.RightLang.ConfigWindow_List_NoHostilesName, ref libs[i], 1024))
{
OtherConfiguration.NoHostileNames[territoryId] = libs;
OtherConfiguration.SaveNoHostileNames();
}
ImGui.SameLine();

if (ImGuiEx.IconButton(FontAwesomeIcon.Ban, $"##Rotation Solver Remove Territory Name {i}"))
if (ImGuiEx.IconButton(FontAwesomeIcon.Ban, $"##Rotation Solver Remove Territory Target Name {i}"))
{
removeIndex = i;
}
Expand All @@ -1930,6 +1930,45 @@ private static void DrawListTerritories()
}
ImGui.TableNextColumn();

ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_NoProvokeDesc);

width = ImGui.GetColumnWidth() - ImGuiEx.CalcIconSize(FontAwesomeIcon.Ban).X - ImGui.GetStyle().ItemSpacing.X - 10 * _scale;

if (!OtherConfiguration.NoProvokeNames.TryGetValue(territoryId, out libs))
{
OtherConfiguration.NoProvokeNames[territoryId] = libs = Array.Empty<string>();
}
//Add one.
if (!libs.Any(string.IsNullOrEmpty))
{
OtherConfiguration.NoHostileNames[territoryId] = libs.Append(string.Empty).ToArray();
}
removeIndex = -1;
for (int i = 0; i < libs.Length; i++)
{
ImGui.SetNextItemWidth(width);
if (ImGui.InputTextWithHint($"##Rotation Solver Territory Provoke Name {i}", LocalizationManager.RightLang.ConfigWindow_List_NoProvokeName, ref libs[i], 1024))
{
OtherConfiguration.NoProvokeNames[territoryId] = libs;
OtherConfiguration.SaveNoProvokeNames();
}
ImGui.SameLine();

if (ImGuiEx.IconButton(FontAwesomeIcon.Ban, $"##Rotation Solver Remove Territory Provoke Name {i}"))
{
removeIndex = i;
}
}
if (removeIndex > -1)
{
var list = libs.ToList();
list.RemoveAt(removeIndex);
OtherConfiguration.NoProvokeNames[territoryId] = list.ToArray();
OtherConfiguration.SaveNoProvokeNames();
}

ImGui.TableNextColumn();

if (!OtherConfiguration.BeneficialPositions.TryGetValue(territoryId, out var pts))
{
OtherConfiguration.BeneficialPositions[territoryId] = pts = Array.Empty<Vector3>();
Expand Down

0 comments on commit 27ec7d5

Please sign in to comment.