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

Commit

Permalink
fix: api for stopmoving.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 1, 2023
1 parent 255c3db commit 57ea0f3
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 41 deletions.
1 change: 1 addition & 0 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
"7518": 0.6,
"7519": 0.6,
"7520": 0.6,
"7524": 0.1,
"7531": 0.6,
"7533": 0.6,
"7535": 0.6,
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public static TargetingType TargetingType
}
}

public unsafe static bool IsMoving => AgentMap.Instance()->IsPlayerMoving > 0;
public static bool IsMoving { get; internal set; }
public static float StopMovingRaw { get; internal set; }

public static unsafe ushort FateId
{
Expand Down
22 changes: 3 additions & 19 deletions RotationSolver.Basic/Helpers/TargetFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ internal static BattleChara GetDeathPeople(IEnumerable<BattleChara> deathAll, IE
if (deathParty.Any())
{
//确认一下死了的T有哪些。

var deathT = deathParty.GetJobCategory(JobRole.Tank);
int TCount = DataCenter.PartyTanks.Count();

Expand Down Expand Up @@ -250,28 +249,17 @@ public unsafe static IEnumerable<BattleChara> GetDeath(this IEnumerable<BattleCh

if (!item.IsTargetable()) return false;

//如果已经有复活的Buff了,那就算了。
if (item.HasStatus(false, StatusID.Raise)) return false;

//如果濒死了,那给我TMD冷静冷静!等着另一个奶大发慈悲吧。
if (!Service.Config.RaiseBrinkOfDeath && item.HasStatus(false, StatusID.BrinkOfDeath)) return false;

//如果有人在对着他咏唱,那就算了。
if (DataCenter.AllianceMembers.Any(c => c.CastTargetObjectId == item.ObjectId)) return false;

return true;
});

public static IEnumerable<BattleChara> GetJobCategory(this IEnumerable<BattleChara> objects, params JobRole[] roles)
{
return roles.SelectMany(role =>
{
return objects.Where(obj =>
{
return obj.IsJobCategory(role);
});
});
}
=> roles.SelectMany(role => objects.Where(obj => obj.IsJobCategory(role)));

public static bool IsJobCategory(this BattleChara obj, JobRole role)
{
Expand Down Expand Up @@ -346,13 +334,10 @@ private static BattleChara RandomObject(IEnumerable<BattleChara> objs)
/// <param name="radius"></param>
/// <returns></returns>
public static IEnumerable<T> GetObjectInRadius<T>(this IEnumerable<T> objects, float radius) where T : GameObject
{
return objects.Where(o => o.DistanceToPlayer() <= radius);
}
=> objects.Where(o => o.DistanceToPlayer() <= radius)

private static IEnumerable<BattleChara> DefaultTargetingType(IEnumerable<BattleChara> charas)
{
return DataCenter.TargetingType switch
=> DataCenter.TargetingType switch
{
TargetingType.Small => charas.OrderBy(p => p.HitboxRadius),
TargetingType.HighHP => charas.OrderByDescending(p => p.CurrentHp),
Expand All @@ -361,5 +346,4 @@ private static IEnumerable<BattleChara> DefaultTargetingType(IEnumerable<BattleC
TargetingType.LowMaxHP => charas.OrderBy(p => p.MaxHp),
_ => charas.OrderByDescending(p => p.HitboxRadius),
};
}
}
24 changes: 20 additions & 4 deletions RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ protected static bool IsLastAction(bool isAdjust, params IAction[] actions)
protected static bool IsLastAction(params ActionID[] ids)
=> IActionHelper.IsLastAction(ids);

/// <summary>
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="GCD"></param>
/// <returns></returns>
protected static bool CombatElapsedLessGCD(int GCD) => CombatElapsedLess(GCD * DataCenter.WeaponTotal);

/// <summary>
/// Whether the battle lasted less than <paramref name="time"/> seconds
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
Expand All @@ -230,15 +237,24 @@ protected static bool IsLastAction(params ActionID[] ids)

protected static float CombatTime => InCombat ? DataCenter.CombatTimeRaw + DataCenter.WeaponRemain : 0;

protected static float GCDTime(uint gcdCount = 0, float offset = 0)
=> DataCenter.GCDTime(gcdCount, offset);

/// <summary>
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="GCD"></param>
/// <returns></returns>
protected static bool CombatElapsedLessGCD(int GCD) => CombatElapsedLess(GCD * DataCenter.WeaponTotal);
protected static bool StopMovingElapsedLessGCD(int GCD) => StopMovingElapsedLess(GCD * DataCenter.WeaponTotal);

/// <summary>
/// <br>WARNING: Do Not make this method the main of your rotation.</br>
/// </summary>
/// <param name="time">time in second.</param>
/// <returns></returns>
protected static bool StopMovingElapsedLess(float time) => StopMovingTime <= time;

protected static float StopMovingTime => IsMoving ? 0 : DataCenter.StopMovingRaw + DataCenter.WeaponRemain;

protected static float GCDTime(uint gcdCount = 0, float offset = 0)
=> DataCenter.GCDTime(gcdCount, offset);

public MethodInfo[] AllLast => GetType().GetStaticBoolMethodInfo(m =>
{
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ConfigWindow_ParamItem": "Param",
"ConfigWindow_ListItem": "List",
"ConfigWindow_EventItem": "Event",
"ConfigWindow_ActionItem": "Action",
"ConfigWindow_ActionItem": "Action Rules",
"ConfigWindow_ControlItem": "Control",
"ConfigWindow_HelpItem": "Help",
"ConfigWindow_ActionItem_Description": "Modify the usage for each action.",
Expand Down Expand Up @@ -72,6 +72,7 @@
"ConfigWindow_Param_InterruptDelay": "Set the range of random delay for interrupting hostile targets in second.",
"ConfigWindow_Param_WeakenDelay": "Set the range of random delay for esuna weakens in second.",
"ConfigWindow_Param_HealDelay": "Set the range of random delay for healing people in second.",
"ConfigWindow_Param_CountdownDelay": "Set the range of random delay for count down in the party.",
"ConfigWindow_Param_NotInCombatDelay": "Set the range of random delay for Not In Combat in second.",
"ConfigWindow_Param_ClickingDelay": "Set the range of random delay for the interval of clicking actions.",
"ConfigWindow_Param_StopCastingDelay": "Set the range of random delay for stopping casting when target is no need to cast in second.",
Expand Down
51 changes: 40 additions & 11 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using RotationSolver.Commands;
using RotationSolver.Localization;
using RotationSolver.UI;
Expand All @@ -12,7 +13,6 @@ namespace RotationSolver.Updaters;

internal static class ActionUpdater
{
static DateTime _startCombatTime = DateTime.MinValue;
internal static DateTime _cancelTime = DateTime.MinValue;

static RandomDelay _GCDDelay = new(() => (Service.Config.WeaponDelayMin, Service.Config.WeaponDelayMax));
Expand Down Expand Up @@ -98,25 +98,60 @@ static bool CheckAction()
internal unsafe static void UpdateActionInfo()
{
UpdateWeaponTime();
UpdateTimeInfo();
UpdateCombatTime();
UpdateBluSlots();
UpdateMPTimer();
}
private unsafe static void UpdateBluSlots()
{
for (int i = 0; i < DataCenter.BluSlots.Length; i++)
{
DataCenter.BluSlots[i] = ActionManager.Instance()->GetActiveBlueMageActionInSlot(i);
}
}

private unsafe static void UpdateTimeInfo()
static DateTime _stopMovingTime = DateTime.MinValue;
private unsafe static void UpdateMoving()
{
var last = DataCenter.IsMoving;
DataCenter.IsMoving = AgentMap.Instance()->IsPlayerMoving > 0;
if (last && !DataCenter.IsMoving)
{
_stopMovingTime = DateTime.Now;
}
else if (DataCenter.IsMoving)
{
_stopMovingTime = DateTime.MinValue;
}

if (_stopMovingTime == DateTime.MinValue)
{
DataCenter.StopMovingRaw = 0;
}
else
{
DataCenter.StopMovingRaw = (float)(DateTime.Now - _stopMovingTime).TotalSeconds;
}
}

static DateTime _startCombatTime = DateTime.MinValue;
private static void UpdateCombatTime()
{
var last = DataCenter.InCombat;
DataCenter.InCombat = Svc.Condition[ConditionFlag.InCombat];
if(!last && DataCenter.InCombat)
if (!last && DataCenter.InCombat)
{
_startCombatTime = DateTime.Now;
}
else if(last && !DataCenter.InCombat)
else if (last && !DataCenter.InCombat)
{
_startCombatTime = DateTime.MinValue;
if (Service.Config.AutoOffAfterCombat > 0)
{
_cancelTime = DateTime.Now.AddSeconds(Service.Config.AutoOffAfterCombat);
}
}

if (_startCombatTime == DateTime.MinValue)
{
DataCenter.CombatTimeRaw = 0;
Expand All @@ -125,12 +160,6 @@ private unsafe static void UpdateTimeInfo()
{
DataCenter.CombatTimeRaw = (float)(DateTime.Now - _startCombatTime).TotalSeconds;
}

for (int i = 0; i < DataCenter.BluSlots.Length; i++)
{
DataCenter.BluSlots[i] = ActionManager.Instance()->GetActiveBlueMageActionInSlot(i);
}
UpdateMPTimer();
}

private static unsafe void UpdateWeaponTime()
Expand Down
9 changes: 4 additions & 5 deletions RotationSolver/Updaters/SocialUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace RotationSolver.Updaters;
internal class SocialUpdater
{
public static bool InPvp { get; private set; }
public static bool InHouse { get; private set; }
//public static bool InHouse { get; private set; }

private static readonly List<string> _macroToAuthor = new()
{
Expand All @@ -38,8 +38,8 @@ internal class SocialUpdater
static bool _canSaying = false;
public static TerritoryType[] HighEndDuties { get; private set; } = Array.Empty<TerritoryType>();

public static bool IsHouseArea(TerritoryType territory)
=> territory?.Bg.RawString.Contains("/hou/") ?? false;
//public static bool IsHouseArea(TerritoryType territory)
// => territory?.Bg.RawString.Contains("/hou/") ?? false;

public static string GetDutyName(TerritoryType territory)
{
Expand Down Expand Up @@ -96,7 +96,7 @@ static void ClientState_TerritoryChanged(object sender, ushort e)
_canSaying = true;
}
InPvp = territory?.IsPvpZone ?? false;
InHouse = IsHouseArea(territory);
//InHouse = IsHouseArea(territory);
//if (PainterManager._painter != null) PainterManager._painter.Enable = !InHouse;
DataCenter.TerritoryContentType = (TerritoryContentType)(territory?.ContentFinderCondition?.Value?.ContentType?.Value?.RowId ?? 0);
DataCenter.InHighEndDuty = HighEndDuties.Any(t => t.RowId == territory.RowId);
Expand Down Expand Up @@ -134,7 +134,6 @@ static void DutyState_DutyStarted(object sender, ushort e)
new TextPayload("Rotation Solver"),
UIForegroundPayload.UIForegroundOff,
RawPayload.LinkTerminator,

new TextPayload(": " + message)),
Type = Dalamud.Game.Text.XivChatType.ErrorMessage,
});
Expand Down

0 comments on commit 57ea0f3

Please sign in to comment.