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

Commit

Permalink
fix: fix the MemberHP calculation bug when the count of hps is zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 2, 2023
1 parent 4bf54e3 commit 9dd502a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class PluginConfiguration : IPluginConfiguration
public float InterruptDelayMax = 1;

public bool UseWorkTask = true;
public int WorkTaskDelay = 20;
public int WorkTaskDelay = 10;
public bool ShowWorkTaskFPS = true;

public bool UseStopCasting = false;
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver/Helpers/TargetFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ internal static IEnumerable<T> GetObjectInRadius<T>(this IEnumerable<T> objects,
internal static float DistanceToPlayer(this GameObject obj)
{
if (obj == null) return float.MaxValue;
var distance = Vector3.Distance(Service.ClientState.LocalPlayer.Position, obj.Position) - Service.ClientState.LocalPlayer.HitboxRadius;
var player = Service.ClientState.LocalPlayer;
if (player == null) return float.MaxValue;

var distance = Vector3.Distance(player.Position, obj.Position) - player.HitboxRadius;
distance -= Math.Max(obj.HitboxRadius, Service.Configuration.ObjectMinRadius);
return distance;
}
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Rotations/Healer/AST/AST_Default.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Game.ClientState.JobGauge.Enums;
using RotationSolver.Actions;
using RotationSolver.Configuration.RotationConfig;
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Rotations.Basic;
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Game;
using Dalamud.Logging;
using RotationSolver.Commands;
using System;
using System.Threading.Tasks;
Expand Down
11 changes: 9 additions & 2 deletions RotationSolver/Updaters/TargetUpdater_Friends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,15 @@ private unsafe static void UpdateFriends(IEnumerable<BattleChara> allTargets)
#endregion

PartyMembersHP = PartyMembers.Select(ObjectHelper.GetHealthRatio).Where(r => r > 0);
PartyMembersAverHP = PartyMembersHP.Average();
PartyMembersDifferHP = (float)Math.Sqrt(PartyMembersHP.Average(d => Math.Pow(d - PartyMembersAverHP, 2)));
if (PartyMembersHP.Any())
{
PartyMembersAverHP = PartyMembersHP.Average();
PartyMembersDifferHP = (float)Math.Sqrt(PartyMembersHP.Average(d => Math.Pow(d - PartyMembersAverHP, 2)));
}
else
{
PartyMembersAverHP = PartyMembersDifferHP = 0;
}

UpdateCanHeal(Service.ClientState.LocalPlayer);
}
Expand Down

0 comments on commit 9dd502a

Please sign in to comment.