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

Commit

Permalink
fix: add mobs time.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 25, 2023
1 parent fbc972a commit b2f15dd
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 19 deletions.
13 changes: 1 addition & 12 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,18 +575,7 @@ internal unsafe bool CanUseTo(GameObject tar)
if (!IsTargetArea && (ActionID)ID != ActionID.AethericMimicry
&& !ActionManager.CanUseActionOnTarget(AdjustedID, tarAddress)) return false;

var point = Player.Object.Position + Vector3.UnitY * Player.GameObject->Height;
var tarPt = tar.Position + Vector3.UnitY * tar.Struct()->Height;
var direction = tarPt - point;

int* unknown = stackalloc int[] { 0x4000, 0, 0x4000, 0 };

RaycastHit hit = default;

if( FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->BGCollisionModule
->RaycastEx(&hit, point, direction, direction.Length(), 1, unknown)) return false;

return true;
return tar.CanSee();
}

private static bool NoAOE
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public interface IBaseAction : IAction
/// <param name="act"></param>
/// <param name="option">Options about using this method.</param>
/// <param name="aoeCount">How many targets do you want this skill to affect</param>
/// <param name="gcdCountForAbility">The count of gcd for ability to delay. Only used in BLM right now</param>
/// <param name="gcdCountForAbility">The count of gcd for ability to delay. Make it use it earlier when max stack.</param>
/// <returns>Should I use.</returns>
bool CanUse(out IAction act, CanUseOption option = CanUseOption.None, byte aoeCount = 0, byte gcdCountForAbility = 0);

Expand Down
1 change: 1 addition & 0 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public static void SetSpecialType(SpecialCommandType specialType)
public static bool HasHostilesInMaxRange => NumberOfHostilesInMaxRange > 0;
public static int NumberOfHostilesInRange { get; internal set; }
public static int NumberOfHostilesInMaxRange { get; internal set; }
public static bool MobsTime { get; internal set; }
public static float AverageDeadTime { get; internal set; }

public static bool IsHostileCastingAOE { get; internal set; }
Expand Down
20 changes: 20 additions & 0 deletions RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Event;
using FFXIVClientStructs.FFXIV.Common.Component.BGCollision;
using Lumina.Excel.GeneratedSheets;

namespace RotationSolver.Basic.Helpers;
Expand Down Expand Up @@ -221,6 +222,25 @@ public static bool IsAttacked(this BattleChara b)
return false;
}

/// <summary>
/// Can the player see the object.
/// </summary>
/// <param name="b"></param>
/// <returns></returns>
public static unsafe bool CanSee(this GameObject b)
{
var point = Player.Object.Position + Vector3.UnitY * Player.GameObject->Height;
var tarPt = b.Position + Vector3.UnitY * b.Struct()->Height;
var direction = tarPt - point;

int* unknown = stackalloc int[] { 0x4000, 0, 0x4000, 0 };

RaycastHit hit = default;

return !FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->BGCollisionModule
->RaycastEx(&hit, point, direction, direction.Length(), 1, unknown);
}

/// <summary>
/// Get the <paramref name="b"/>'s current HP percentage.
/// </summary>
Expand Down
11 changes: 9 additions & 2 deletions RotationSolver.Basic/Rotations/Basic/WAR_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,26 @@ public abstract class WAR_Base : CustomRotation
/// <summary>
/// 1
/// </summary>
public static IBaseAction Overpower { get; } = new BaseAction(ActionID.Overpower);
public static IBaseAction Overpower { get; } = new BaseAction(ActionID.Overpower)
{
AOECount = 2,
};

/// <summary>
/// 2
/// </summary>
public static IBaseAction MythrilTempest { get; } = new BaseAction(ActionID.MythrilTempest);
public static IBaseAction MythrilTempest { get; } = new BaseAction(ActionID.MythrilTempest)
{
AOECount = 2,
};

/// <summary>
///
/// </summary>
public static IBaseAction SteelCyclone { get; } = new BaseAction(ActionID.SteelCyclone)
{
ActionCheck = InnerBeast.ActionCheck,
AOECount = 2,
};

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.DalamudServices;
using RotationSolver.Basic.Configuration;

namespace RotationSolver.Basic.Rotations;
public abstract partial class CustomRotation
Expand Down Expand Up @@ -173,6 +174,11 @@ public static bool IsLongerThan(float time)
if (IsInHighEndDuty) return true;
return AverageDeadTime > time;
}

/// <summary>
/// Now, it is attacking the mobs!
/// </summary>
public static bool MobsTime => DataCenter.MobsTime;
#endregion

#region Command
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ internal partial class Strings
{ nameof(CustomRotation.ShowStatus), "Show the status"},
{ nameof(CustomRotation.AverageDeadTime), "Average dead time"},

{ nameof(CustomRotation.MobsTime), "Mobs Time"},
#endregion

#region AST
Expand Down
3 changes: 0 additions & 3 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
using RotationSolver.UI.SearchableSettings;
using RotationSolver.Updaters;
using System.Diagnostics;
using System.Drawing;
using System.Security.Policy;
using System.Windows.Forms;
using GAction = Lumina.Excel.GeneratedSheets.Action;

namespace RotationSolver.UI;
Expand Down
4 changes: 3 additions & 1 deletion RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ private unsafe static void UpdateHostileTargets(IEnumerable<BattleChara> allTarg
{
if (!Svc.GameGui.WorldToScreen(b.Position, out _)) return false;
}

return true;
})));

Expand All @@ -125,6 +124,9 @@ private unsafe static void UpdateHostileTargets(IEnumerable<BattleChara> allTarg

DataCenter.NumberOfHostilesInMaxRange = DataCenter.HostileTargets.Count(o => o.DistanceToPlayer() <= 25);

DataCenter.MobsTime = DataCenter.HostileTargets.Count(o => o.DistanceToPlayer() <= JobRange && o.CanSee())
>= Service.Config.GetValue(PluginConfigInt.AutoDefenseNumber);

if (DataCenter.HostileTargets.Count() == 1)
{
var tar = DataCenter.HostileTargets.FirstOrDefault();
Expand Down

0 comments on commit b2f15dd

Please sign in to comment.