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

Commit

Permalink
fix: add two target is boss conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Nov 7, 2023
1 parent 540a836 commit 1902edb
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ClickingCount": 56901,
"ClickingCount": 56909,
"SayingHelloCount": 0,
"SaidUsers": [
"Ig4lHXUohMZNIeheUtAtRg=="
Expand Down
12 changes: 1 addition & 11 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ public float TimeToKill
}
}

/// <summary>
/// Is this action's target dead?
/// </summary>
public bool IsTargetDying => Target?.IsDying() ?? false;

/// <summary>
/// Is this action's target is a boss?
/// </summary>
public bool IsTargetBoss => Target?.IsBoss() ?? false;

/// <summary>
/// Is this action single target?
/// </summary>
Expand Down Expand Up @@ -281,7 +271,7 @@ private bool TargetAreaFriend(float range, bool mustUse, PlayerCharacter player)
}

if (Svc.Targets.Target is BattleChara b && b.DistanceToPlayer() < range &&
b.IsBoss() && b.HasPositional() && b.HitboxRadius <= 8)
b.IsBossFromIcon() && b.HasPositional() && b.HitboxRadius <= 8)
{
Position = b.Position;
}
Expand Down
10 changes: 0 additions & 10 deletions RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,6 @@ public interface IBaseAction : IAction
/// </summary>
BattleChara Target { get; }

/// <summary>
/// Is target a boss.
/// </summary>
bool IsTargetBoss { get; }

/// <summary>
/// Is target will die immediately.
/// </summary>
bool IsTargetDying { get; }

/// <summary>
/// Is this action's target type is target only one.
/// </summary>
Expand Down
14 changes: 11 additions & 3 deletions RotationSolver.Basic/Configuration/Conditions/TargetCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ protected override bool IsTrueInside(ICustomRotation rotation)
result = tar.HasStatus(FromSelf, StatusId);
break;

case TargetConditionType.IsBoss:
result = tar.IsBoss();
case TargetConditionType.IsBossFromTTK:
result = tar.IsBossFromTTK();
break;

case TargetConditionType.IsBossFromIcon:
result = tar.IsBossFromIcon();
break;

case TargetConditionType.IsDying:
Expand Down Expand Up @@ -246,7 +250,8 @@ internal enum TargetConditionType : byte
IsNull,
HasStatus,
IsDying,
IsBoss,
IsBossFromTTK,
IsBossFromIcon,
InCombat,
Distance,
StatusEnd,
Expand All @@ -260,4 +265,7 @@ internal enum TargetConditionType : byte
TargetName,
ObjectEffect,
Vfx,

[Obsolete("Please use Target type instead.")]
IsBoss = IsBossFromTTK,
}
46 changes: 31 additions & 15 deletions RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ public static unsafe bool IsOthersPlayers(this GameObject obj)
return false;
}

/// <summary>
/// Is this target an enemy (can be attacked).
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
[Obsolete("Please use IsEnemy instead", true)]
public static bool IsNPCEnemy(this GameObject obj) => obj.IsEnemy();

/// <summary>
/// Is this target an enemy (can be attacked).
/// </summary>
Expand Down Expand Up @@ -113,7 +105,6 @@ or 71344 //Major Quest
}

internal static unsafe uint GetNamePlateIcon(this GameObject obj) => obj.Struct()->NamePlateIconId;
internal static unsafe void SetNamePlateIcon(this GameObject obj, uint id) => obj.Struct()->NamePlateIconId = id;
internal static unsafe EventHandlerType GetEventType(this GameObject obj) => obj.Struct()->EventId.Type;

/// <summary>
Expand Down Expand Up @@ -155,18 +146,43 @@ internal static bool CanInterrupt(this BattleChara b)
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
[Obsolete("Please use IsBossFromTTK or IsBossFromIcon instead", true)]
public static bool IsBoss(this BattleChara obj)
{
return IsBossFromTTK(obj);
}

/// <summary>
/// Is character a boss? Calculate from ttk.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static bool IsBossFromTTK(this BattleChara obj)
{
if (obj == null) return false;

if (obj.IsDummy() && !Service.Config.GetValue(Configuration.PluginConfigBool.ShowTargetTimeToKill)) return true;

//Fate
if (obj.GetTimeToKill(true) >= Service.Config.GetValue(Configuration.PluginConfigFloat.BossTimeToKill)) return true;

return false;
}

/// <summary>
/// Is character a boss? Calculated from the icon.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static bool IsBossFromIcon(this BattleChara obj)
{
if (obj == null) return false;
if (obj is PlayerCharacter) return false;

if (obj.IsDummy() && !Service.Config.GetValue(Configuration.PluginConfigBool.ShowTargetTimeToKill)) return true;

//Icon
if (obj.GetObjectNPC()?.Rank is 1 or 2 /*or 4*/ or 6) return true;

//Fate
if (obj.FateId() != 0 && obj.GetTimeToKill(true) >= Service.Config.GetValue(Configuration.PluginConfigFloat.BossTimeToKill)) return true;
return false;
}

Expand Down Expand Up @@ -237,11 +253,11 @@ public static float GetTimeToKill(this BattleChara b, bool wholeTime = false)
/// <returns></returns>
public static bool IsAttacked(this BattleChara b)
{
foreach (var item in DataCenter.AttackedTargets)
foreach (var (id, time) in DataCenter.AttackedTargets)
{
if (item.id == b.ObjectId)
if (id == b.ObjectId)
{
return DateTime.Now - item.time > TimeSpan.FromSeconds(1);
return DateTime.Now - time > TimeSpan.FromSeconds(1);
}
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.
{
FilterForHostiles = bs => bs.Where((Func<BattleChara, bool>)(b =>
{
if (b.IsBoss() || CustomRotation.IsMoving || b.CastActionId == 0) return false;
if (b.IsBossFromIcon() || IsMoving || b.CastActionId == 0) return false;

if (!b.IsCastInterruptible || Interject.IsCoolingDown) return true;
return false;
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/Localization/EnumTranslations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ internal static class EnumTranslations
{
TargetConditionType.HasStatus => LocalizationManager.RightLang.TargetConditionType_HasStatus,
TargetConditionType.IsDying => LocalizationManager.RightLang.TargetConditionType_IsDying,
TargetConditionType.IsBoss => LocalizationManager.RightLang.TargetConditionType_IsBoss,
TargetConditionType.IsBossFromTTK => LocalizationManager.RightLang.TargetConditionType_IsBossFromTTK,
TargetConditionType.IsBossFromIcon => LocalizationManager.RightLang.TargetConditionType_IsBossFromIcon,
TargetConditionType.InCombat => LocalizationManager.RightLang.TargetConditionType_InCombat,
TargetConditionType.Distance => LocalizationManager.RightLang.TargetConditionType_Distance,
TargetConditionType.StatusEnd => LocalizationManager.RightLang.TargetConditionType_StatusEnd,
Expand Down Expand Up @@ -131,7 +132,7 @@ internal static class EnumTranslations
_ => string.Empty,
};

internal static string ToStateString(this StateCommandType type, JobRole role) => type switch
internal static string ToStateString(this StateCommandType type, JobRole _) => type switch
{
StateCommandType.Auto => LocalizationManager.RightLang.SpecialCommandType_Smart + DataCenter.TargetingType.ToName(),
StateCommandType.Manual => LocalizationManager.RightLang.SpecialCommandType_Manual,
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ internal class Strings
#region TargetConditionType
public string TargetConditionType_HasStatus { get; set; } = "Has Status";
public string TargetConditionType_IsDying { get; set; } = "Is Dying";
public string TargetConditionType_IsBoss { get; set; } = "Is Boss";
public string TargetConditionType_IsBossFromTTK { get; set; } = "Is Boss From TTK";
public string TargetConditionType_IsBossFromIcon { get; set; } = "Is Boss From Icon";
public string TargetConditionType_InCombat { get; set; } = "In Combat";
public string TargetConditionType_Distance { get; set; } = "Distance";
public string TargetConditionType_StatusEnd { get; set; } = "Status End";
Expand Down

0 comments on commit 1902edb

Please sign in to comment.