Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MillerTheBest committed Oct 8, 2024
2 parents 5ebeb82 + 71f1dea commit 64fccae
Show file tree
Hide file tree
Showing 22 changed files with 311 additions and 121 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/ActionBasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ internal readonly bool BasicCheck(bool skipStatusProvideCheck, bool skipComboChe

private bool IsActionEnabled() => _action.Config.IsEnabled;

private bool IsActionDisabled() => DataCenter.DisabledActionSequencer?.Contains(ID) ?? false;
private bool IsActionDisabled() => !IBaseAction.ForceEnable && (DataCenter.DisabledActionSequencer?.Contains(ID) ?? false);

private bool HasEnoughMP() => DataCenter.CurrentMp >= MPNeed;

Expand Down
68 changes: 41 additions & 27 deletions RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,12 @@ private bool CheckTimeToKill(IGameObject gameObject)
{
if (canAffects == null || player == null) return null;

// Check if the action's range is zero and handle it as targeting self
if (range == 0)
{
return new TargetResult(player, GetAffects(player.Position, canAffects).ToArray(), player.Position);
}

var strategy = Service.Config.BeneficialAreaStrategy;
switch (strategy)
{
Expand All @@ -458,6 +464,7 @@ private bool CheckTimeToKill(IGameObject gameObject)
OtherConfiguration.BeneficialPositions.TryGetValue(Svc.ClientState.TerritoryType, out var pts);
pts ??= Array.Empty<Vector3>();

// Use fallback points if no beneficial positions are found
if (pts.Length == 0)
{
if (DataCenter.TerritoryContentType == TerritoryContentType.Trials ||
Expand All @@ -470,6 +477,7 @@ private bool CheckTimeToKill(IGameObject gameObject)
}
}

// Find the closest point and apply a random offset
if (pts.Length > 0)
{
var closest = pts.MinBy(p => Vector3.Distance(player.Position, p));
Expand All @@ -478,12 +486,15 @@ private bool CheckTimeToKill(IGameObject gameObject)
var radius = random.NextDouble();
closest.X += (float)(Math.Sin(rotation) * radius);
closest.Z += (float)(Math.Cos(rotation) * radius);

// Check if the closest point is within the effect range
if (Vector3.Distance(player.Position, closest) < player.HitboxRadius + EffectRange)
{
return new TargetResult(player, GetAffects(closest, canAffects).ToArray(), closest);
}
}

// Return null if strategy is OnlyOnLocations and no valid point is found
if (strategy == BeneficialAreaStrategy.OnlyOnLocations) return null;
break;

Expand All @@ -494,40 +505,43 @@ private bool CheckTimeToKill(IGameObject gameObject)
return new TargetResult(target, GetAffects(target?.Position, canAffects).ToArray(), target?.Position);
}
break;
}

if (Svc.Targets.Target is IBattleChara b && b.DistanceToPlayer() < range &&
b.IsBossFromIcon() && b.HasPositional() && b.HitboxRadius <= 8)
{
return new TargetResult(b, GetAffects(b.Position, canAffects).ToArray(), b.Position);
}
else
{
var effectRange = EffectRange;
var attackT = FindTargetByType(DataCenter.AllianceMembers.GetObjectInRadius(range + effectRange),
TargetType.BeAttacked, action.Config.AutoHealRatio, action.Setting.SpecialType);

if (attackT == null)
{
return new TargetResult(player, GetAffects(player.Position, canAffects).ToArray(), player.Position);
}
else
{
var disToTankRound = Vector3.Distance(player.Position, attackT.Position) + attackT.HitboxRadius;

if (disToTankRound < effectRange
|| disToTankRound > 2 * effectRange - player.HitboxRadius)
case BeneficialAreaStrategy.OnCalculated: // OnCalculated
if (Svc.Targets.Target is IBattleChara b && b.DistanceToPlayer() < range &&
b.IsBossFromIcon() && b.HasPositional() && b.HitboxRadius <= 8)
{
return new TargetResult(player, GetAffects(player.Position, canAffects).ToArray(), player.Position);
return new TargetResult(b, GetAffects(b.Position, canAffects).ToArray(), b.Position);
}
else
{
Vector3 directionToTank = attackT.Position - player.Position;
var moveDirection = directionToTank / directionToTank.Length() * Math.Max(0, disToTankRound - effectRange);
return new TargetResult(player, GetAffects(player.Position, canAffects).ToArray(), player.Position + moveDirection);
var effectRange = EffectRange;
var attackT = FindTargetByType(DataCenter.AllianceMembers.GetObjectInRadius(range + effectRange),
TargetType.BeAttacked, action.Config.AutoHealRatio, action.Setting.SpecialType);

if (attackT == null)
{
return new TargetResult(player, GetAffects(player.Position, canAffects).ToArray(), player.Position);
}
else
{
var disToTankRound = Vector3.Distance(player.Position, attackT.Position) + attackT.HitboxRadius;

if (disToTankRound < effectRange
|| disToTankRound > 2 * effectRange - player.HitboxRadius)
{
return new TargetResult(player, GetAffects(player.Position, canAffects).ToArray(), player.Position);
}
else
{
Vector3 directionToTank = attackT.Position - player.Position;
var moveDirection = directionToTank / directionToTank.Length() * Math.Max(0, disToTankRound - effectRange);
return new TargetResult(player, GetAffects(player.Position, canAffects).ToArray(), player.Position + moveDirection);
}
}
}
}
}

return null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ protected override bool IsTrueInside(ICustomRotation rotation)
return _action.Cooldown.MaxCharges == Param1;
}
break;
case ActionConditionType.CanUse:
return _action.CanUse(out var act);
break;

}
return false;
}
Expand Down
19 changes: 17 additions & 2 deletions RotationSolver.Basic/Configuration/Conditions/TargetCondition.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ECommons.DalamudServices;
using ECommons.GameFunctions;
using ECommons.GameHelpers;
using Lumina.Excel.GeneratedSheets;

Expand All @@ -24,6 +25,8 @@ internal class TargetCondition : DelayCondition

public string CastingActionName = string.Empty;

public string CombatRole = string.Empty;

/// <summary>
/// Checks if the condition is true inside the rotation.
/// </summary>
Expand Down Expand Up @@ -63,7 +66,8 @@ protected override bool IsTrueInside(ICustomRotation rotation)
TargetConditionType.HPRatio => CheckHPRatio(tar),
TargetConditionType.MP => CheckMP(tar),
TargetConditionType.TargetName => CheckTargetName(tar),
_ => false,
TargetConditionType.TargetRole => CheckTargetRole(tar),
_ => false,
};
}

Expand Down Expand Up @@ -158,6 +162,14 @@ private bool CheckTargetName(IBattleChara tar)
}
return tar.Name.TextValue == CastingActionName;
}
private bool CheckTargetRole(IBattleChara tar)
{
if (string.IsNullOrEmpty(CombatRole))
{
return false;
}
return tar.GetRole().ToString() == CombatRole;
}
}

internal enum TargetType : byte
Expand Down Expand Up @@ -221,4 +233,7 @@ internal enum TargetConditionType : byte

[Description("Target Name")]
TargetName,
}

[Description("Target Role")]
TargetRole,
}
50 changes: 19 additions & 31 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ public const string
Filter = BasicAutoSwitch)]
private static readonly bool _autoOffWhenDutyCompleted = true;

[ConditionBool, UI("Select only Fate targets in Fate",
Filter = TargetConfig, Section = 1)]
private static readonly bool _changeTargetForFate = true;

[ConditionBool, UI("Use movement actions towards the object/mob in the center of the screen",
Description = "Use movement actions towards the object/mob in the center of the screen, otherwise toward object/mob your character is facing.",
Filter = TargetConfig, Section = 2)]
Expand Down Expand Up @@ -115,7 +111,11 @@ public const string
[ConditionBool, UI("Automatically use MP Potions", Description = "Experimental.",
Filter = AutoActionUsage)]
private static readonly bool _useMpPotions = false;


[JobConfig, UI("MP threshold under which to use Lucid Dreaming", Filter = AutoActionUsage)]
[Range(0, 10000, ConfigUnitType.None)]
public int LucidDreamingMpThreshold { get; set; } = 6000;

[ConditionBool, UI("Prioritize mob/object targets with attack markers",
Filter = TargetConfig)]
private static readonly bool _chooseAttackMark = true;
Expand All @@ -139,10 +139,6 @@ public const string
[ConditionBool, UI("Teaching mode", Filter = UiInformation)]
private static readonly bool _teachingMode = false;

//[ConditionBool, UI("Use task for overlay window.",
// Parent = nameof(TeachingMode))]
//private static readonly bool _useTasksForOverlay = false;

[ConditionBool, UI("Simulate the effect of pressing abilities",
Filter = UiInformation)]
private static readonly bool _keyBoardNoise = true;
Expand Down Expand Up @@ -176,7 +172,7 @@ public const string
Filter = TargetConfig, Section = 3)]
private static readonly bool _switchTargetFriendly = false;

[ConditionBool, UI("Use interrupt abilities if possible.",
[JobConfig, UI("Use interrupt abilities if possible.",
Filter = AutoActionUsage, Section = 3,
PvEFilter = JobFilterType.Interrupt,
PvPFilter = JobFilterType.NoJob)]
Expand All @@ -202,11 +198,6 @@ public const string
Filter = TargetConfig, Section = 1)]
private static readonly bool _onlyAttackInVisionCone = false;

[ConditionBool, UI("Use single target healing over time actions only on tanks",
Filter = HealingActionCondition, Section = 1,
PvEFilter = JobFilterType.Healer, PvPFilter = JobFilterType.Healer)]
private static readonly bool _onlyHotOnTanks = false;

[ConditionBool, UI("Debug Mode", Filter = Debug)]
private static readonly bool _inDebug = false;

Expand Down Expand Up @@ -270,19 +261,18 @@ public const string
Filter = UiInformation)]
private static readonly bool _showTooltips = true;

[ConditionBool, UI("Target Fate priority",
Filter = TargetConfig, Section = 1)]
private static readonly bool _targetFatePriority = true;

[ConditionBool, UI("Target Hunt/Relic/Leve priority. (Relic behaviour bugged)",
Filter = TargetConfig, Section = 1)]
private static readonly bool _targetHuntingRelicLevePriority = true;

[ConditionBool, UI("Target quest priority.",
Filter = TargetConfig, Section = 1)]

private static readonly bool _targetQuestPriority = true;

[ConditionBool, UI("Block targetting quest mobs belonging to other players (Broken).",
Filter = TargetConfig, Section = 1)]
private static readonly bool targetQuestThings = true;

[ConditionBool, UI("Ignore target dummies",
Filter = TargetConfig, Section = 1)]
private static readonly bool _disableTargetDummys = false;
Expand Down Expand Up @@ -320,8 +310,7 @@ public const string
[ConditionBool, UI("Use movement speed increase abilities when out of combat.", Parent = nameof(UseAbility))]
private static readonly bool _autoSpeedOutOfCombat = true;

[ConditionBool, UI("Use beneficial ground-targeted actions", Parent = nameof(UseAbility),
PvEFilter = JobFilterType.Healer)]
[ConditionBool, UI("Use beneficial ground-targeted actions", Parent = nameof(UseAbility))]
private static readonly bool _useGroundBeneficialAbility = true;

[ConditionBool, UI("Use beneficial AoE actions when moving.", Parent = nameof(UseGroundBeneficialAbility))]
Expand All @@ -333,6 +322,10 @@ public const string
[ConditionBool, UI("Record AOE actions", Filter = List)]
private static readonly bool _recordCastingArea = true;

[ConditionBool, UI("Target Fate priority",
Filter = TargetConfig, Section = 1)]
private static readonly bool _targetFatePriority = true;

[ConditionBool, UI("Auto turn off RSR when combat is over more for more then...",
Filter = BasicAutoSwitch)]
private static readonly bool _autoOffAfterCombat = true;
Expand Down Expand Up @@ -410,22 +403,22 @@ public const string
[Range(0, 1, ConfigUnitType.Percent, 0.02f)]
public float HealthHealerRatio { get; set; } = 0.4f;

[ConditionBool, UI("Hard cast Raise players while Swiftcast is on cooldown", Description = "If this is enabled and Swiftcast is on cooldown, you will only attempt to raise while standing still.",
[JobConfig, UI("Hard cast Raise players while Swiftcast is on cooldown", Description = "If this is enabled and Swiftcast is on cooldown, you will only attempt to raise while standing still.",
Filter = HealingActionCondition, Section = 2,
PvEFilter = JobFilterType.Raise, PvPFilter = JobFilterType.NoJob)]
private static readonly bool _raisePlayerByCasting = true;

[ConditionBool, UI("Raise player by using Swiftcast/Dualcast if avaliable", Description = "If this is disabled, you will never use Swiftcast/Dualcast to raise players.",
[JobConfig, UI("Raise player by using Swiftcast/Dualcast if avaliable", Description = "If this is disabled, you will never use Swiftcast/Dualcast to raise players.",
Filter = HealingActionCondition, Section = 2,
PvEFilter = JobFilterType.None)]
PvEFilter = JobFilterType.Raise, PvPFilter = JobFilterType.NoJob)]
private static readonly bool _raisePlayerBySwift = true;

[JobConfig, UI("Raise styles",
Filter = HealingActionCondition, Section = 2,
PvEFilter = JobFilterType.Raise, PvPFilter = JobFilterType.NoJob)]
private readonly RaiseType _RaiseType = RaiseType.PartyOnly;

[ConditionBool, UI("Raise players that have the Brink of Death debuff",
[JobConfig, UI("Raise players that have the Brink of Death debuff",
Filter = HealingActionCondition, Section = 2,
PvEFilter = JobFilterType.Raise, PvPFilter = JobFilterType.NoJob)]
private static readonly bool _raiseBrinkOfDeath = true;
Expand Down Expand Up @@ -510,11 +503,6 @@ public const string
[Range(0, 5, ConfigUnitType.Seconds, 0.05f)]
public Vector2 HealWhenNothingTodoDelay { get; set; } = new(0.5f, 1);

[UI("Auto Heal delay range",
Parent = nameof(AutoHeal))]
[Range(0, 3, ConfigUnitType.Seconds, 0.002f)]
public Vector2 HealDelay { get; set; } = new(0.5f, 1);

[UI("How soon before countdown is finished to start casting or attacking.",
Filter = BasicTimer, Section = 1, PvPFilter = JobFilterType.NoJob)]
[Range(0, 0.7f, ConfigUnitType.Seconds, 0.002f)]
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Data/VfxNewData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace RotationSolver.Basic.Data;
/// <summary>
/// Represents new VFX data.
/// </summary>
public readonly struct VfxNewData
public readonly record struct VfxNewData
{
/// <summary>
/// Gets the object ID.
Expand Down
Loading

0 comments on commit 64fccae

Please sign in to comment.