Skip to content

Commit

Permalink
Merge pull request #588 from DeviousCrypto/PVPHunterKiller
Browse files Browse the repository at this point in the history
PvP Targeting Modes. PvP TTK, PCT/BLM actions, Debugging stuff
  • Loading branch information
LTS-FFXIV authored Jan 20, 2025
2 parents 5545c8c + 6987448 commit 882c93d
Show file tree
Hide file tree
Showing 9 changed files with 395 additions and 36 deletions.
39 changes: 24 additions & 15 deletions RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,24 +1155,33 @@ private readonly bool CanGetTarget(IGameObject target, IGameObject subTarget)
{
return null;
}

var orderedGameObjects = DataCenter.TargetingType switch
{
TargetingType.Small => IGameObjects.OrderBy<IGameObject, float>(p => p.HitboxRadius),
TargetingType.HighHP => IGameObjects.OrderByDescending<IGameObject, uint>(p => p is IBattleChara b ? b.CurrentHp : 0),
TargetingType.LowHP => IGameObjects.OrderBy<IGameObject, uint>(p => p is IBattleChara b ? b.CurrentHp : 0),
TargetingType.HighHPPercent => IGameObjects.OrderByDescending<IGameObject, float>(p => p is IBattleChara b ? b.CurrentHp / b.MaxHp : 0),
TargetingType.LowHPPercent => IGameObjects.OrderBy<IGameObject, float>(p => p is IBattleChara b ? b.CurrentHp / b.MaxHp : 0),
TargetingType.HighMaxHP => IGameObjects.OrderByDescending<IGameObject, uint>(p => p is IBattleChara b ? b.MaxHp : 0),
TargetingType.LowMaxHP => IGameObjects.OrderBy<IGameObject, uint>(p => p is IBattleChara b ? b.MaxHp : 0),
TargetingType.Nearest => IGameObjects.OrderBy<IGameObject, float>(p => p.DistanceToPlayer()),
TargetingType.Farthest => IGameObjects.OrderByDescending<IGameObject, float>(p => p.DistanceToPlayer()),
_ => IGameObjects.OrderByDescending<IGameObject, float>(p => p.HitboxRadius),
{
TargetingType.Small => IGameObjects.OrderBy<IGameObject, float>(p => p.HitboxRadius),
TargetingType.HighHP => IGameObjects.OrderByDescending<IGameObject, uint>(p => p is IBattleChara b ? b.CurrentHp : 0),
TargetingType.LowHP => IGameObjects.OrderBy<IGameObject, uint>(p => p is IBattleChara b ? b.CurrentHp : 0),
TargetingType.HighHPPercent => IGameObjects.OrderByDescending<IGameObject, float>(p => p is IBattleChara b ? b.CurrentHp / b.MaxHp : 0),
TargetingType.LowHPPercent => IGameObjects.OrderBy<IGameObject, float>(p => p is IBattleChara b ? b.CurrentHp / b.MaxHp : 0),
TargetingType.HighMaxHP => IGameObjects.OrderByDescending<IGameObject, uint>(p => p is IBattleChara b ? b.MaxHp : 0),
TargetingType.LowMaxHP => IGameObjects.OrderBy<IGameObject, uint>(p => p is IBattleChara b ? b.MaxHp : 0),
TargetingType.Nearest => IGameObjects.OrderBy<IGameObject, float>(p => p.DistanceToPlayer()),
TargetingType.Farthest => IGameObjects.OrderByDescending<IGameObject, float>(p => p.DistanceToPlayer()),
TargetingType.HunterKillerHealers => IGameObjects.Where(p => p.IsJobs(JobRole.Healer.ToJobs())).OrderBy<IGameObject, float>(p => p.DistanceToPlayer()).Any()
? IGameObjects.Where(p => p.IsJobs(JobRole.Healer.ToJobs())).OrderBy<IGameObject, float>(p => p.DistanceToPlayer())
: IGameObjects.OrderBy<IGameObject, float>(p => p.DistanceToPlayer()),
TargetingType.HunterKillerTanks => IGameObjects.Where(p => p.IsJobs(JobRole.Tank.ToJobs())).OrderBy<IGameObject, float>(p => p.DistanceToPlayer()).Any()
? IGameObjects.Where(p => p.IsJobs(JobRole.Tank.ToJobs())).OrderBy<IGameObject, float>(p => p.DistanceToPlayer())
: IGameObjects.OrderBy<IGameObject, float>(p => p.DistanceToPlayer()),
TargetingType.HunterKillerDPS => IGameObjects.Where(p => p.IsJobs(JobRole.AllDPS.ToJobs())).OrderBy<IGameObject, float>(p => p.DistanceToPlayer()).Any()
? IGameObjects.Where(p => p.IsJobs(JobRole.AllDPS.ToJobs())).OrderBy<IGameObject, float>(p => p.DistanceToPlayer())
: IGameObjects.OrderBy<IGameObject, float>(p => p.DistanceToPlayer()),
_ => IGameObjects.OrderByDescending<IGameObject, float>(p => p.HitboxRadius),
};

return orderedGameObjects.FirstOrDefault() as IBattleChara;
};

return orderedGameObjects.FirstOrDefault() as IBattleChara;
}

IBattleChara? FindBeAttackedTarget()
{
if (IGameObjects == null || !IGameObjects.Any())
Expand Down
10 changes: 8 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public ActionConfig Config
{
get
{
if (!Service.Config.RotationActionConfig.TryGetValue(ID, out var value))
if (!Service.Config.RotationActionConfig.TryGetValue(ID, out var value) || DataCenter.ResetActionConfigs)
{
value = Setting.CreateConfig?.Invoke() ?? new ActionConfig();
Service.Config.RotationActionConfig[ID] = value;
Expand Down Expand Up @@ -150,7 +150,13 @@ public bool CanUse(out IAction act, bool isLastAbility = false, bool isFirstAbil

if (!skipTTKCheck)
{
if (!IsTimeToKillValid()) return false;
switch (DataCenter.IsPvP)
{
case true when Service.Config.IgnorePvPttk:
break;
case false when !IsTimeToKillValid():
return false;
}
}

PreviewTarget = TargetInfo.FindTarget(skipAoeCheck, skipStatusProvideCheck);
Expand Down
6 changes: 4 additions & 2 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,11 @@ public const string
#endregion

#region PvP

[ConditionBool, UI("Ignore TTK for PvP purposes.", Filter = PvPSpecificControls)]
private static readonly bool _ignorePvPTTK = true;

[JobConfig, UI("Ignore Invincibility for PvP purposes.", Filter = PvPSpecificControls)]
private readonly bool _ignorePvPInvincibility = false;
private static readonly bool _ignorePvPInvincibility = false;

[ConditionBool, UI("Auto turn off when dead in PvP.",
Filter = PvPSpecificControls)]
Expand Down
9 changes: 9 additions & 0 deletions RotationSolver.Basic/Data/JobRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public enum JobRole : byte
/// Disciple of the Hand role.
/// </summary>
DiscipleOfTheHand = 8,

/// <summary>
/// All DPS Roles
/// </summary>
AllDPS = 9
}

/// <summary>
Expand Down Expand Up @@ -98,6 +103,10 @@ public static Job[] ToJobs(this JobRole role)
JobRole.Melee => [Job.MNK, Job.DRG, Job.NIN, Job.SAM, Job.RPR, Job.VPR],
JobRole.RangedPhysical => [Job.BRD, Job.MCH, Job.DNC],
JobRole.RangedMagical => [Job.BLM, Job.SMN, Job.RDM, Job.BLU, Job.PCT],
JobRole.AllDPS => JobRole.Melee.ToJobs()
.Concat(JobRole.RangedPhysical.ToJobs())
.Concat(JobRole.RangedMagical.ToJobs())
.ToArray(),
_ => [],
};
}
Expand Down
18 changes: 18 additions & 0 deletions RotationSolver.Basic/Data/TargetType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,22 @@ public enum TargetingType
/// </summary>
[Description("Farthest")]
Farthest,

/// <summary>
/// PVP: Find the nearest Healer.
/// </summary>
[Description("Hunter Killer: Healers")]
HunterKillerHealers,

/// <summary>
/// PVP: Find the nearest Tank.
/// </summary>
[Description("Hunter Killer: Tanks")]
HunterKillerTanks,

/// <summary>
/// PVP: Find the nearest DPS.
/// </summary>
[Description("Hunter Killer: DPS")]
HunterKillerDPS
}
2 changes: 2 additions & 0 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace RotationSolver.Basic;
internal static class DataCenter
{
private static ulong _hostileTargetId = 0;

public static bool ResetActionConfigs { get; set; } = false;

public static bool IsActivated() => State || IsManual || Service.Config.TeachingMode;

Expand Down
23 changes: 23 additions & 0 deletions RotationSolver.Basic/Rotations/Basic/BlackMageRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ static partial void ModifyFlareStarPvE(ref ActionSetting setting)
static partial void ModifyFirePvP(ref ActionSetting setting)
{
setting.StatusProvide = [StatusID.Paradox, StatusID.AstralFire_3212];
setting.CreateConfig = () => new ActionConfig()
{
ShouldCheckStatus = false
};
}

static partial void ModifyBlizzardPvP(ref ActionSetting setting)
Expand Down Expand Up @@ -510,12 +514,20 @@ static partial void ModifyFireIiiPvP(ref ActionSetting setting)
{
setting.StatusNeed = [StatusID.AstralFire_3212];
setting.StatusProvide = [StatusID.AstralFireIi_3213];
setting.CreateConfig = () => new ActionConfig()
{
ShouldCheckStatus = false
};
}

static partial void ModifyFireIvPvP(ref ActionSetting setting)
{
setting.StatusNeed = [StatusID.AstralFireIi_3213];
setting.StatusProvide = [StatusID.AstralFireIii_3381];
setting.CreateConfig = () => new ActionConfig()
{
ShouldCheckStatus = false
};
}

static partial void ModifyHighFireIiPvP(ref ActionSetting setting)
Expand All @@ -525,6 +537,7 @@ static partial void ModifyHighFireIiPvP(ref ActionSetting setting)
setting.CreateConfig = () => new ActionConfig()
{
AoeCount = 1,
ShouldCheckStatus = false,
};
}

Expand All @@ -542,12 +555,20 @@ static partial void ModifyBlizzardIiiPvP(ref ActionSetting setting)
{
setting.StatusNeed = [StatusID.UmbralIce_3214];
setting.StatusProvide = [StatusID.UmbralIceIi_3215];
setting.CreateConfig = () => new ActionConfig()
{
ShouldCheckStatus = false
};
}

static partial void ModifyBlizzardIvPvP(ref ActionSetting setting)
{
setting.StatusNeed = [StatusID.UmbralIceIi_3215];
setting.StatusProvide = [StatusID.UmbralIceIii_3382];
setting.CreateConfig = () => new ActionConfig()
{
ShouldCheckStatus = false
};
}

static partial void ModifyHighBlizzardIiPvP(ref ActionSetting setting)
Expand All @@ -557,6 +578,7 @@ static partial void ModifyHighBlizzardIiPvP(ref ActionSetting setting)
setting.CreateConfig = () => new ActionConfig()
{
AoeCount = 1,
ShouldCheckStatus = false,
};
}

Expand All @@ -578,6 +600,7 @@ static partial void ModifyWreathOfFirePvP(ref ActionSetting setting)
static partial void ModifyWreathOfIcePvP(ref ActionSetting setting)
{
setting.ActionCheck = () => WreathOfIceReady;
setting.IsFriendly = true;
}

static partial void ModifyFlareStarPvP(ref ActionSetting setting)
Expand Down
Loading

0 comments on commit 882c93d

Please sign in to comment.