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

Commit

Permalink
fix: fixed clipping check in base item.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Nov 1, 2023
1 parent c997eb4 commit a95cb5f
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"ClickingCount": 42767,
"ClickingCount": 43196,
"SaidUsers": []
}
2 changes: 2 additions & 0 deletions Resources/Supporters.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[
"Vain",
"Abuse",
"Constantinescu Marius",
"lizardbreath",
"Kito Kito ✨",
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver.Basic/Actions/BaseItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ public virtual unsafe bool CanUse(out IAction item, bool clippingCheck = true)

var remain = RecastTimeOneChargeRaw - RecastTimeElapsedRaw;

if (DataCenter.WeaponRemain > 0)
if (clippingCheck && DataCenter.WeaponRemain > 0)
{
if (DataCenter.NextAbilityToNextGCD > AnimationLockTime + DataCenter.Ping) return false;
if (DataCenter.NextAbilityToNextGCD < AnimationLockTime + DataCenter.Ping) return false;

if (clippingCheck && remain > DataCenter.ActionRemain) return false;
if (remain > DataCenter.ActionRemain) return false;
}

if (ItemCheck != null && !ItemCheck()) return false;
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver.Basic/RotationSolver.Basic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<EnforceCodeStyleInBuild>False</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<Using Include="System.ComponentModel" />
<Using Include="Dalamud.Game.ClientState.JobGauge.Types" />
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void DoAction()

#if DEBUG
//if (nextAction is BaseAction acti)
// Svc.Chat.Print($"Will Do {acti}");
// Svc.Log.Debug($"Will Do {acti}");
#endif

if (Service.Config.GetValue(PluginConfigBool.KeyBoardNoise))
Expand All @@ -72,7 +72,7 @@ public static void DoAction()

if (act.ShouldEndSpecial) ResetSpecial();
#if DEBUG
//Svc.Chat.Print($"{act}, {act.Target.Name}, {ActionUpdater.AbilityRemainCount}, {ActionUpdater.WeaponElapsed}");
//Svc.Log.Debug($"{act}, {act.Target.Name}");
#endif
//Change Target
if (act.Target != null && act.Target != Player.Object && !DataCenter.IsManual
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"TargetConditionType_MP": "MP",
"TargetConditionType_TargetName": "Target Name",
"TargetConditionType_ObjectEffect": "Object Effect",
"TargetConditionType_Vfx": "Vfx",
"TerritoryConditionType_TerritoryContentType": "Territory Content Type",
"TerritoryConditionType_TeritoryName": "Teritory Name",
"TerritoryConditionType_DutyName": "Duty Name",
Expand Down Expand Up @@ -550,6 +551,7 @@
"ConfigWindow_Actions_HealRatio": "The HP ratio to auto heal",
"ConfigWindow_Actions_ConditionDescription": "Forced Conditions have a higher priority. If Forced Conditions are met, Disabled Condition will be ignored.",
"ConfigWindow_Auto_UseResourcesAction": "Use actions that use resources",
"ConfigWindow_Auto_OnlyHealselfWhenNoHealer": "Only Healself When No Healer",
"ConfigWindow_Auto_HealthForAutoDefense": "HP Ratio about defense single of Tanks",
"ConfigWindow_Basic_SayHelloToUsers": "Say hello to the users of Rotation Solver.",
"ConfigWindow_Basic_SayHelloToUsersDesc": "It can only be disabled for users, not authors and contributors.\nIf you want to be greeted by other users, please DM ArchiTed in Discord Server with your Hash!",
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver/RotationSolver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>full</DebugType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
Expand Down
8 changes: 5 additions & 3 deletions RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ void DrawStatusIcon()
ImGui.SameLine();
const float MIN = 0, MAX = 60;

ImGui.SetNextItemWidth(150 * ImGuiHelpers.GlobalScale);
ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale);
if (ImGui.DragFloatRange2($"##TimeOffset {targetCondition.GetHashCode()}", ref targetCondition.DistanceOrTime, ref targetCondition.TimeEnd, 0.1f, MIN, MAX))
{
targetCondition.DistanceOrTime = Math.Max(Math.Min(targetCondition.DistanceOrTime, targetCondition.TimeEnd), MIN);
Expand All @@ -992,6 +992,8 @@ void DrawStatusIcon()
ImGui.SameLine();

ImGui.Text("Vfx Path:");
ImGui.SameLine();

ImGuiHelper.SetNextWidthWithName(targetCondition.CastingActionName);
ImGui.InputText($"Name##TargetName{targetCondition.GetHashCode()}", ref targetCondition.CastingActionName, 128);

Expand All @@ -1000,7 +1002,7 @@ void DrawStatusIcon()
ImGui.Text("Time Offset:");
ImGui.SameLine();

ImGui.SetNextItemWidth(150 * ImGuiHelpers.GlobalScale);
ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale);
if (ImGui.DragFloatRange2($"##TimeOffset {targetCondition.GetHashCode()}", ref targetCondition.DistanceOrTime, ref targetCondition.TimeEnd, 0.1f, MIN, MAX))
{
targetCondition.DistanceOrTime = Math.Max(Math.Min(targetCondition.DistanceOrTime, targetCondition.TimeEnd), MIN);
Expand Down Expand Up @@ -1100,7 +1102,7 @@ private static void DrawAfter(this TerritoryCondition territoryCondition, ICusto
ImGui.SameLine();
const float MIN = 0, MAX = 60;

ImGui.SetNextItemWidth(150 * ImGuiHelpers.GlobalScale);
ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale);
if (ImGui.DragFloatRange2($"##TimeOffset {territoryCondition.GetHashCode()}", ref territoryCondition.TimeStart, ref territoryCondition.TimeEnd, 0.1f, MIN, MAX))
{
territoryCondition.TimeStart = Math.Max(Math.Min(territoryCondition.TimeStart, territoryCondition.TimeEnd), MIN);
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ private static void DrawAutoActionCondition()
private static readonly ISearchable[] _autoActionConditionSearchable_Heal = new ISearchable[]
{
new AutoHealCheckBox(
new CheckBoxSearchPlugin(PluginConfigBool.UseHealWhenNotAHealer,
new CheckBoxSearchPlugin(PluginConfigBool.OnlyHealselfWhenNoHealer))
new CheckBoxSearchPlugin(PluginConfigBool.UseHealWhenNotAHealer)
{
JobRoles = new JobRole[]
{
Expand All @@ -662,6 +661,8 @@ private static void DrawAutoActionCondition()
new DragFloatSearchPlugin(PluginConfigFloat.AutoHealTimeToKill, 0.02f),
new DragFloatSearchPlugin(PluginConfigFloat.HealthDifference, 0.02f)),

new CheckBoxSearchPlugin(PluginConfigBool.OnlyHealselfWhenNoHealer),

new CheckBoxSearchPlugin(PluginConfigBool.OnlyHotOnTanks)
{
JobRoles = new JobRole[]
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ internal unsafe static bool CanDoAction()

var timeToNext = DataCenter.ActionRemain;

//No time to use 0gcd
if (timeToNext + nextAction.AnimationLockTime
> DataCenter.WeaponRemain) return false;
////No time to use 0gcd
//if (timeToNext + nextAction.AnimationLockTime
// > DataCenter.WeaponRemain) return false;

//Skip when casting
if (DataCenter.WeaponElapsed <= DataCenter.CastingTotal) return false;
Expand Down
45 changes: 26 additions & 19 deletions RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ private static float JobRange

private unsafe static void UpdateHostileTargets(IEnumerable<BattleChara> allTargets)
{
var deadHP = DataCenter.PartyMembers.Count() > 1 ? 0 : 1;

allTargets = allTargets.Where(b =>
{
if (!b.IsNPCEnemy()) return false;

//Dead.
if (b.CurrentHp <= deadHP) return false;
if (b.CurrentHp <= 1) return false;

if (!b.IsTargetable) return false;

Expand Down Expand Up @@ -145,19 +143,8 @@ private unsafe static void UpdateHostileTargets(IEnumerable<BattleChara> allTarg
DataCenter.MobsTime = DataCenter.HostileTargets.Count(o => o.DistanceToPlayer() <= JobRange && o.CanSee())
>= Service.Config.GetValue(PluginConfigInt.AutoDefenseNumber);

DataCenter.IsHostileCastingToTank = DataCenter.HostileTargets.Any(IsHostileCastingTank);
DataCenter.IsHostileCastingAOE = DataCenter.HostileTargets.Any(IsHostileCastingArea);
//if (DataCenter.HostileTargets.Count() == 1)
//{
// var tar = DataCenter.HostileTargets.FirstOrDefault();

// DataCenter.IsHostileCastingToTank = IsHostileCastingTank(tar);
// DataCenter.IsHostileCastingAOE = IsHostileCastingArea(tar);
//}
//else
//{
// DataCenter.IsHostileCastingToTank = DataCenter.IsHostileCastingAOE = false;
//}
DataCenter.IsHostileCastingToTank = IsCastingTankVfx() || DataCenter.HostileTargets.Any(IsHostileCastingTank);
DataCenter.IsHostileCastingAOE = IsCastingAreaVfx() || DataCenter.HostileTargets.Any(IsHostileCastingArea);

DataCenter.CanProvoke = _provokeDelay.Delay(TargetFilter.ProvokeTarget(DataCenter.HostileTargets, true).Count() != DataCenter.HostileTargets.Count());
}
Expand Down Expand Up @@ -231,6 +218,29 @@ private static unsafe uint[] GetEnemies()
return list.ToArray();
}

private static bool IsCastingTankVfx()
{
return false;
}

private static bool IsCastingAreaVfx()
{
return false;
}

private static bool IsCastingVfx(Func<string, bool> isVfx)
{
if (isVfx == null) return false;
foreach (var item in DataCenter.VfxNewDatas.Reverse())
{
if (item.TimeDuration.TotalSeconds is > 1 and < 5)
{
if (isVfx(item.Path)) return true;
}
}
return false;
}

private static bool IsHostileCastingTank(BattleChara h)
{
return IsHostileCastingBase(h, (act) =>
Expand All @@ -242,7 +252,6 @@ private static bool IsHostileCastingTank(BattleChara h)

private static bool IsHostileCastingArea(BattleChara h)
{
//TODO: Add some stack effects here!
return IsHostileCastingBase(h, (act) =>
{
return OtherConfiguration.HostileCastingArea.Contains(act.RowId);
Expand All @@ -265,7 +274,6 @@ private static bool IsHostileCastingBase(BattleChara h, Func<Action, bool> check
}
return false;
}

#endregion

#region Friends
Expand Down Expand Up @@ -421,7 +429,6 @@ static void UpdateCanHeal(PlayerCharacter player)
}

//Delay

DataCenter.CanHealSingleAbility = DataCenter.SetAutoStatus(AutoStatus.HealSingleAbility,
_healDelay1.Delay(DataCenter.CanHealSingleAbility));
DataCenter.CanHealSingleSpell = DataCenter.SetAutoStatus(AutoStatus.HealSingleSpell,
Expand Down

0 comments on commit a95cb5f

Please sign in to comment.