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

Commit

Permalink
fix: add casting action check list.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 30, 2023
1 parent 22b275c commit ab4c248
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 25 deletions.
1 change: 1 addition & 0 deletions Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions Resources/HostileCastingTank.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
28 changes: 23 additions & 5 deletions RotationSolver.Basic/Configuration/OtherConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace RotationSolver.Basic.Configuration;

public class OtherConfiguration
{
public static SortedSet<uint> HostileCastingArea = new SortedSet<uint>();
public static SortedSet<uint> HostileCastingTank = new SortedSet<uint>();

public static SortedList<uint, float> AnimationLockTime = new SortedList<uint, float>();

public static Dictionary<uint, string[]> NoHostileNames = new Dictionary<uint, string[]>();
Expand Down Expand Up @@ -39,9 +42,9 @@ public class OtherConfiguration

public static SortedSet<uint> InvincibleStatus = new SortedSet<uint>()
{
(uint)StatusID.StoneSkin,
(uint)StatusID.IceSpikesInvincible,
(uint)StatusID.VortexBarrier,
151, //StoneSkin
198, //IceSpikesInvincible
3012, //VortexBarrier
};

public static void Init()
Expand All @@ -50,13 +53,18 @@ public static void Init()
{
Directory.CreateDirectory(Service.Interface.ConfigDirectory.FullName);
}

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

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

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

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

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

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

public static void Save()
Expand All @@ -65,6 +73,18 @@ public static void Save()
SaveInvincibleStatus();
SaveNoHostileNames();
SaveAnimationLockTime();
SaveHostileCastingArea();
SaveHostileCastingTank();
}

public static void SaveHostileCastingArea()
{
Task.Run(() => Save(HostileCastingArea, nameof(HostileCastingArea)));
}

public static void SaveHostileCastingTank()
{
Task.Run(() => Save(HostileCastingTank, nameof(HostileCastingTank)));
}

public static void SaveDangerousStatus()
Expand Down Expand Up @@ -137,6 +157,4 @@ private static void InitOne<T>(ref T value, string name)
}
}
}


}
5 changes: 0 additions & 5 deletions RotationSolver.Basic/Data/StatusID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,6 @@ public enum StatusID : ushort
RespellingSpray = 556,
Magitek = 2166,

StoneSkin = 151,
IceSpikesInvincible = 198,

CircleOfPower = 738,

Aetherpact = 1223,
Expand All @@ -501,7 +498,5 @@ public enum StatusID : ushort

TheBlackestNight = 1178,

VortexBarrier = 3012,

LivingDead = 810,
}
4 changes: 4 additions & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@
"ConfigWindow_List_InvincibilityDesc": "If target get one of this status, it'll never attack it.",
"ConfigWindow_List_DangerousStatus": "Dangerous Status",
"ConfigWindow_List_DangerousStatusDesc": "If one of your party member get this status, Esuna immediately.",
"ConfigWindow_List_HostileCastingTank": "Tank Buster",
"ConfigWindow_List_HostileCastingTankDesc": "If the target is casting the action like this, it'll reduction.",
"ConfigWindow_List_HostileCastingArea": "AOE",
"ConfigWindow_List_HostileCastingAreaDesc": "If the target is casting the action like this, it'll defense area.",
"ConfigWindow_List_Rotations": "Rotations",
"ConfigWindow_List_NoHostile": "No Hostile",
"ConfigWindow_List_NoHostileDesc": "Add a name of target that never be the hostile for you.",
Expand Down
10 changes: 10 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,17 @@ internal partial class Strings
public string ConfigWindow_List_Invincibility { get; set; } = "Invincibility";
public string ConfigWindow_List_InvincibilityDesc { get; set; } = "If target get one of this status, it'll never attack it.";
public string ConfigWindow_List_DangerousStatus { get; set; } = "Dangerous Status";

public string ConfigWindow_List_DangerousStatusDesc { get; set; } = "If one of your party member get this status, Esuna immediately.";

public string ConfigWindow_List_HostileCastingTank { get; set; } = "Tank Buster";

public string ConfigWindow_List_HostileCastingTankDesc { get; set; } = "If the target is casting the action like this, it'll reduction.";

public string ConfigWindow_List_HostileCastingArea { get; set; } = "AOE";

public string ConfigWindow_List_HostileCastingAreaDesc { get; set; } = "If the target is casting the action like this, it'll defense area.";

public string ConfigWindow_List_Rotations { get; set; } = "Rotations";
public string ConfigWindow_List_NoHostile { get; set; } = "No Hostile";
public string ConfigWindow_List_NoHostileDesc { get; set; } = "Add a name of target that never be the hostile for you.";
Expand Down
23 changes: 23 additions & 0 deletions RotationSolver/TextureItems/ActionTexture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Lumina.Excel.GeneratedSheets;
using Action = Lumina.Excel.GeneratedSheets.Action;

namespace RotationSolver.TextureItems;

internal class ActionTexture : ITexture
{
readonly Action _action;

public uint IconID => _action.Icon;

public string Name => $"{_action.Name} ({_action.RowId})";

public uint ID => _action.RowId;

public string Description => string.Empty;
public bool IsEnabled { get; set; } = true;

public ActionTexture(Action action)
{
_action = action;
}
}
137 changes: 137 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RotationSolver.TextureItems;
using RotationSolver.Updaters;
using System.Xml.Linq;
using Action = Lumina.Excel.GeneratedSheets.Action;

namespace RotationSolver.UI;

Expand Down Expand Up @@ -64,6 +65,23 @@ public static StatusTexture[] AllInvStatus
}
}

private static ActionTexture[] _allActions = null;
public static ActionTexture[] AllActions
{
get
{
if (_allActions == null)
{
_allActions = Service.GetSheet<Action>()
.Where(a => !string.IsNullOrEmpty(a.Name) && !a.IsPvP && !a.IsPlayerAction
&& a.ClassJob.Value == null)
.Select(a => new ActionTexture(a))
.ToArray();
}
return _allActions;
}
}

private void DrawListTab()
{
if (ImGuiHelper.IconButton(FontAwesomeIcon.FileDownload, "##Load All"))
Expand Down Expand Up @@ -161,6 +179,39 @@ private void DrawListTab()
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_DangerousStatusDesc);
});

DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingTank, DrawHostileCastingTank, () =>
{
ImGui.SetNextItemWidth(200);
ImGuiHelper.SearchCombo("##AddCastingTank",
LocalizationManager.RightLang.ConfigWindow_Param_AddOne,
ref searchText, AllActions, a =>
{
OtherConfiguration.HostileCastingTank.Add(a.ID);
OtherConfiguration.SaveHostileCastingTank();
});

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

ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingTankDesc);
});

DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingArea, DrawHostileCastingArea, () =>
{
ImGui.SetNextItemWidth(200);
ImGuiHelper.SearchCombo("##AddCastingArea",
LocalizationManager.RightLang.ConfigWindow_Param_AddOne,
ref searchText, AllActions, a =>
{
OtherConfiguration.HostileCastingArea.Add(a.ID);
OtherConfiguration.SaveHostileCastingArea();
});

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

ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_List_HostileCastingAreaDesc);
});

DrawParamTabItem(LocalizationManager.RightLang.ConfigWindow_List_Rotations, DrawRotationDevTab, () =>
{
Expand Down Expand Up @@ -362,6 +413,92 @@ private void DrawRotationDevTab()
}
}

private void DrawHostileCastingTank()
{
uint removeId = 0;
uint addId = 0;
foreach (var actionId in OtherConfiguration.HostileCastingTank)
{
var status = Service.GetSheet<Action>().GetRow(actionId);
ImGui.Image(IconSet.GetTexture(status.Icon).ImGuiHandle, new Vector2(24, 24));

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

ImGui.SetNextItemWidth(150);

ImGuiHelper.SearchCombo($"##SaveHostileCastingTank{actionId}",
$"{status.Name} ({status.RowId})",
ref searchText, AllActions, s =>
{
removeId = actionId;
addId = s.ID;
});

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

if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##SaveHostileCastingTank{actionId}"))
{
removeId = actionId;
}
}

if (removeId != 0)
{
OtherConfiguration.HostileCastingTank.Remove(removeId);
OtherConfiguration.SaveHostileCastingTank();
}
if (addId != 0)
{
OtherConfiguration.HostileCastingTank.Add(addId);
OtherConfiguration.SaveHostileCastingTank();
}
}

private void DrawHostileCastingArea()
{
uint removeId = 0;
uint addId = 0;
foreach (var actionId in OtherConfiguration.HostileCastingArea)
{
var status = Service.GetSheet<Action>().GetRow(actionId);
ImGui.Image(IconSet.GetTexture(status.Icon).ImGuiHandle, new Vector2(24, 24));

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

ImGui.SetNextItemWidth(150);

ImGuiHelper.SearchCombo($"##SaveHostileCastingArea{actionId}",
$"{status.Name} ({status.RowId})",
ref searchText, AllActions, s =>
{
removeId = actionId;
addId = s.ID;
});

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

if (ImGuiHelper.IconButton(FontAwesomeIcon.Ban, $"##SaveHostileCastingArea{actionId}"))
{
removeId = actionId;
}
}

if (removeId != 0)
{
OtherConfiguration.HostileCastingArea.Remove(removeId);
OtherConfiguration.SaveHostileCastingArea();
}
if (addId != 0)
{
OtherConfiguration.HostileCastingArea.Add(addId);
OtherConfiguration.SaveHostileCastingArea();
}
}

private void DrawParamNoHostile()
{
int removeIndex = -1;
Expand Down
34 changes: 19 additions & 15 deletions RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,28 +174,32 @@ private static bool IsHostileCastingTank(BattleChara h)
{
return IsHostileCastingBase(h, (act) =>
{
return h.CastTargetObjectId == h.TargetObjectId;
return OtherConfiguration.HostileCastingTank.Contains(act.RowId);

//return h.CastTargetObjectId == h.TargetObjectId;
});
}

private static bool IsHostileCastingArea(BattleChara h)
{
return IsHostileCastingBase(h, (act) =>
{
if ((act.CastType == 1 || act.CastType == 2)
&& act.Range == 0
&& act.EffectRange >= 40)
return true;

if (act.CastType == 2
&& act.EffectRange == 6
&& act.Cast100ms == 50
&& act.CanTargetHostile
&& !act.CanTargetSelf
&& act.Range == 100)
return true;

return false;
return OtherConfiguration.HostileCastingArea.Contains(act.RowId);

//if ((act.CastType == 1 || act.CastType == 2)
// && act.Range == 0
// && act.EffectRange >= 40)
// return true;

//if (act.CastType == 2
// && act.EffectRange == 6
// && act.Cast100ms == 50
// && act.CanTargetHostile
// && !act.CanTargetSelf
// && act.Range == 100)
// return true;

//return false;
});
}

Expand Down

0 comments on commit ab4c248

Please sign in to comment.