Skip to content

Commit

Permalink
Tank autorot fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taurenkey committed Nov 24, 2024
1 parent 366c3f2 commit f249bfe
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
54 changes: 37 additions & 17 deletions XIVSlothCombo/AutoRotation/AutoRotationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using ECommons.GameHelpers;
using ECommons.Throttlers;
using FFXIVClientStructs.FFXIV.Client.Game;
using Lumina.Excel.Sheets;
using System;
using System.Linq;
using XIVSlothCombo.Combos;
Expand Down Expand Up @@ -307,18 +308,36 @@ public static class AutoRotationHelper
{
if (rotationMode is DPSRotationMode dpsmode)
{
IGameObject? target = dpsmode switch
if (Player.Object.GetRole() is CombatRole.Tank)
{
DPSRotationMode.Manual => Svc.Targets.Target,
DPSRotationMode.Highest_Max => DPSTargeting.GetHighestMaxTarget(),
DPSRotationMode.Lowest_Max => DPSTargeting.GetLowestMaxTarget(),
DPSRotationMode.Highest_Current => DPSTargeting.GetHighestCurrentTarget(),
DPSRotationMode.Lowest_Current => DPSTargeting.GetLowestCurrentTarget(),
DPSRotationMode.Tank_Target => DPSTargeting.GetTankTarget(),
DPSRotationMode.Nearest => DPSTargeting.GetNearestTarget(),
DPSRotationMode.Furthest => DPSTargeting.GetFurthestTarget(),
};
return target;
IGameObject? target = dpsmode switch
{
DPSRotationMode.Manual => Svc.Targets.Target,
DPSRotationMode.Highest_Max => TankTargeting.GetHighestMaxTarget(),
DPSRotationMode.Lowest_Max => TankTargeting.GetLowestMaxTarget(),
DPSRotationMode.Highest_Current => TankTargeting.GetHighestCurrentTarget(),
DPSRotationMode.Lowest_Current => TankTargeting.GetLowestCurrentTarget(),
DPSRotationMode.Tank_Target => Svc.Targets.Target,
DPSRotationMode.Nearest => DPSTargeting.GetNearestTarget(),
DPSRotationMode.Furthest => DPSTargeting.GetFurthestTarget(),
};
return target;
}
else
{
IGameObject? target = dpsmode switch
{
DPSRotationMode.Manual => Svc.Targets.Target,
DPSRotationMode.Highest_Max => DPSTargeting.GetHighestMaxTarget(),
DPSRotationMode.Lowest_Max => DPSTargeting.GetLowestMaxTarget(),
DPSRotationMode.Highest_Current => DPSTargeting.GetHighestCurrentTarget(),
DPSRotationMode.Lowest_Current => DPSTargeting.GetLowestCurrentTarget(),
DPSRotationMode.Tank_Target => DPSTargeting.GetTankTarget(),
DPSRotationMode.Nearest => DPSTargeting.GetNearestTarget(),
DPSRotationMode.Furthest => DPSTargeting.GetFurthestTarget(),
};
return target;
}
}
if (rotationMode is HealerRotationMode healermode)
{
Expand Down Expand Up @@ -466,11 +485,12 @@ public static uint InvokeCombo(CustomComboPreset preset, Presets.PresetAttribute

public class DPSTargeting
{
public static System.Collections.Generic.IEnumerable<IGameObject> BaseSelection => Svc.Objects.Any(x => x is IBattleChara chara && x.IsHostile() && CustomComboFunctions.IsInRange(x) && !x.IsDead && CustomComboFunctions.IsInLineOfSight(x) && IsPriority(x)) ? Svc.Objects.Where(x => x is IBattleChara chara && x.IsHostile() && CustomComboFunctions.IsInRange(x) && !x.IsDead && x.IsTargetable && CustomComboFunctions.IsInLineOfSight(x) && IsPriority(x)) :
Svc.Objects.Where(x => x is IBattleChara chara && x.IsHostile() && CustomComboFunctions.IsInRange(x) && !x.IsDead && x.IsTargetable && CustomComboFunctions.IsInLineOfSight(x));
public static System.Collections.Generic.IEnumerable<IGameObject> BaseSelection => Svc.Objects.Any(x => x is IBattleChara chara && chara.IsHostile() && CustomComboFunctions.IsInRange(chara) && !chara.IsDead && CustomComboFunctions.IsInLineOfSight(chara) && IsPriority(chara)) ? Svc.Objects.Where(x => x is IBattleChara chara && chara.IsHostile() && CustomComboFunctions.IsInRange(chara) && !chara.IsDead && chara.IsTargetable && CustomComboFunctions.IsInLineOfSight(chara) && IsPriority(chara)) :
Svc.Objects.Where(x => x is IBattleChara chara && chara.IsHostile() && CustomComboFunctions.IsInRange(chara) && !chara.IsDead && chara.IsTargetable && CustomComboFunctions.IsInLineOfSight(chara));

private static bool IsPriority(IGameObject x)
{
if (!x.IsTargetable() || !x.IsHostile()) return false;
bool isFate = Service.Configuration.RotationConfig.DPSSettings.FATEPriority && x.Struct()->FateId != 0 && CustomComboFunctions.InFATE();
bool isQuest = Service.Configuration.RotationConfig.DPSSettings.QuestPriority && CustomComboFunctions.IsQuestMob(x);
if (Player.Object.GetRole() is CombatRole.Tank && x.TargetObjectId != Player.Object.GameObjectId)
Expand Down Expand Up @@ -577,31 +597,31 @@ public static class TankTargeting
{
public static IGameObject? GetLowestCurrentTarget()
{
return Svc.Objects.Where(x => x is IBattleChara && x.IsHostile() && CustomComboFunctions.IsInRange(x) && !x.IsDead && x.IsTargetable)
return DPSTargeting.BaseSelection
.OrderByDescending(x => x.TargetObject?.GameObjectId != Player.Object?.GameObjectId)
.ThenBy(x => (x as IBattleChara).CurrentHp)
.ThenBy(x => CustomComboFunctions.GetTargetHPPercent(x)).FirstOrDefault();
}

public static IGameObject? GetHighestCurrentTarget()
{
return Svc.Objects.Where(x => x is IBattleChara && x.IsHostile() && CustomComboFunctions.IsInRange(x) && !x.IsDead && x.IsTargetable)
return DPSTargeting.BaseSelection
.OrderByDescending(x => x.TargetObject?.GameObjectId != Player.Object?.GameObjectId)
.ThenByDescending(x => (x as IBattleChara).CurrentHp)
.ThenBy(x => CustomComboFunctions.GetTargetHPPercent(x)).FirstOrDefault();
}

public static IGameObject? GetLowestMaxTarget()
{
return Svc.Objects.Where(x => x is IBattleChara && x.IsHostile() && CustomComboFunctions.IsInRange(x) && !x.IsDead && x.IsTargetable)
return DPSTargeting.BaseSelection
.OrderByDescending(x => x.TargetObject?.GameObjectId != Player.Object?.GameObjectId)
.OrderBy(x => (x as IBattleChara).MaxHp)
.ThenBy(x => CustomComboFunctions.GetTargetHPPercent(x)).FirstOrDefault();
}

public static IGameObject? GetHighestMaxTarget()
{
return Svc.Objects.Where(x => x is IBattleChara && x.IsHostile() && CustomComboFunctions.IsInRange(x) && !x.IsDead && x.IsTargetable)
return DPSTargeting.BaseSelection
.OrderByDescending(x => x.TargetObject?.GameObjectId != Player.Object?.GameObjectId)
.ThenByDescending(x => (x as IBattleChara).MaxHp)
.ThenBy(x => CustomComboFunctions.GetTargetHPPercent(x)).FirstOrDefault();
Expand Down
2 changes: 1 addition & 1 deletion XIVSlothCombo/XIVSlothCombo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<Authors>Team Wrath</Authors>
<Company>-</Company>
<Version>1.0.0.2</Version>
<Version>1.0.0.3</Version>
<!-- This is the version that will be used when pushing to the repo.-->
<Description>XIVCombo for lazy players</Description>
<Copyright>Copyleft attick 2021 thanks attick UwU</Copyright>
Expand Down

0 comments on commit f249bfe

Please sign in to comment.