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

Commit

Permalink
fix: fixed soem calculating bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 5, 2023
1 parent 6cc5b8c commit f0829e1
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 33 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public class PluginConfiguration : IPluginConfiguration
public bool ShowGCDCooldown = false;
public bool UseOriginalCooldown = true;
public int CooldownActionOneLine = 15;
public float CooldownFontSize = 24;
public float CooldownFontSize = 16;

public Vector4 ControlWindowLockBg = new Vector4(0, 0, 0, 0.6f);
public Vector4 ControlWindowUnlockBg = new Vector4(0, 0, 0, 0.9f);
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected static bool EndAfter(float remain, float remainNeed)
public static bool CombatElapsedLess(float time)
{
if (!InCombat) return true;
return CooldownHelper.ElapsedAfter(time, DataCenter.CombatTime + DataCenter.WeaponRemain);
return (DataCenter.CombatTime + DataCenter.WeaponRemain).IsLessThan(time);
}

public static bool CombatElapsedLessGCD(int GCD) => CombatElapsedLess(GCD * DataCenter.WeaponTotal);
Expand Down
31 changes: 23 additions & 8 deletions RotationSolver.Default/Ranged/MCH_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public sealed class MCH_Default : MCH_Base

protected override IAction CountDownAction(float remainTime)
{
if (remainTime < Service.Config.CountDownAhead)
{
if (AirAnchor.CanUse(out var act1)) return act1;
else if(!AirAnchor.EnoughLevel && HotShot.CanUse(out act1)) return act1;
}
if (remainTime < 2 && UseBurstMedicine(out var act)) return act;
if (remainTime < 5 && Reassemble.CanUse(out act, CanUseOption.EmptyOrSkipCombo)) return act;
return base.CountDownAction(remainTime);
Expand All @@ -30,8 +35,10 @@ protected override bool GeneralGCD(out IAction act)
if (AirAnchor.CanUse(out act)) return true;
else if (!AirAnchor.EnoughLevel && HotShot.CanUse(out act)) return true;


if (Drill.CanUse(out act)) return true;
}

if (!CombatElapsedLessGCD(4) && ChainSaw.CanUse(out act, CanUseOption.MustUse)) return true;

//Aoe
Expand Down Expand Up @@ -65,16 +72,17 @@ protected override bool AttackAbility(byte abilitiesRemaining, out IAction act)
{
if (UseBurstMedicine(out act)) return true;
if ((IsLastAbility(false, Hypercharge) || Heat >= 50)
&& !CombatElapsedLess(12)
&& Wildfire.CanUse(out act)) return true;
}

if (CanUseHypercharge(out act)) return true;
if (!CombatElapsedLess(12) && CanUseHypercharge(out act)) return true;
if (!AirAnchorBlockTime(8)
&& RookAutoturret.CanUse(out act)) return true;

if (BarrelStabilizer.CanUse(out act)) return true;

if (CombatElapsedLessGCD(3)) return false;
if (CombatElapsedLess(10)) return false;

var option = CanUseOption.MustUse | CanUseOption.EmptyOrSkipCombo;
if (GaussRound.CurrentCharges <= Ricochet.CurrentCharges)
Expand All @@ -88,7 +96,7 @@ protected override bool AttackAbility(byte abilitiesRemaining, out IAction act)

private static bool AirAnchorBlockTime(float time)
{
if (!AirAnchor.EnoughLevel)
if (AirAnchor.EnoughLevel)
{
return AirAnchor.IsCoolingDown && AirAnchor.WillHaveOneCharge(time);
}
Expand All @@ -98,12 +106,19 @@ private static bool AirAnchorBlockTime(float time)
}
}

const float REST_TIME = 7f;
const float REST_TIME = 6f;
private static bool CanUseHypercharge(out IAction act)
{
act = null;

if (AirAnchorBlockTime(4)) return false;
if(BarrelStabilizer.IsCoolingDown && BarrelStabilizer.WillHaveOneChargeGCD(8))
{
if (AirAnchorBlockTime(8)) return false;
}
else
{
if (AirAnchorBlockTime(12)) return false;
}

//Check recast.
if (!SpreadShot.CanUse(out _))
Expand All @@ -114,11 +129,11 @@ private static bool CanUseHypercharge(out IAction act)
}
else
{
if (HotShot.WillHaveOneCharge(REST_TIME)) return false;
if (HotShot.EnoughLevel && HotShot.WillHaveOneCharge(REST_TIME)) return false;
}
}
if (Drill.WillHaveOneCharge(REST_TIME)) return false;
if (ChainSaw.WillHaveOneCharge(REST_TIME)) return false;
if (Drill.EnoughLevel && Drill.WillHaveOneCharge(REST_TIME)) return false;
if (ChainSaw.EnoughLevel && ChainSaw.WillHaveOneCharge(REST_TIME)) return false;

if (Hypercharge.CanUse(out act)) return true;
return false;
Expand Down
12 changes: 7 additions & 5 deletions RotationSolver.Default/Tank/DRK_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ private bool CheckDarkSide

if (CombatLess) return false;

if (Configs.GetBool("TheBlackestNight") && Player.CurrentMp < 6000) return false;

if (InDeliruim || HasDarkArts) return true;

if (Configs.GetBool("TheBlackestNight") && Player.CurrentMp < 6000) return false;

return Player.CurrentMp >= 8500;
}
}
Expand Down Expand Up @@ -90,10 +90,13 @@ protected override bool DefenseAreaAbility(byte abilitiesRemaining, out IAction
[RotationDesc(ActionID.TheBlackestNight, ActionID.Oblation, ActionID.ShadowWall, ActionID.Rampart, ActionID.DarkMind, ActionID.Reprisal)]
protected override bool DefenseSingleAbility(byte abilitiesRemaining, out IAction act)
{
if (TheBlackestNight.CanUse(out act)) return true;
act = null;

//if (Player.HasStatus(true, StatusID.dark)) return false;
if (abilitiesRemaining == 1)
{
if (TheBlackestNight.CanUse(out act)) return true;

//10
if (Oblation.CanUse(out act, CanUseOption.EmptyOrSkipCombo)) return true;
}
Expand All @@ -109,7 +112,6 @@ protected override bool DefenseSingleAbility(byte abilitiesRemaining, out IActio

if (Reprisal.CanUse(out act)) return true;

act = null;
return false;
}

Expand Down Expand Up @@ -147,7 +149,7 @@ protected override bool AttackAbility(byte abilitiesRemaining, out IAction act)

if (InBurst)
{
if(UseBurstMedicine(out act)) return true;
if (UseBurstMedicine(out act)) return true;
if (BloodWeapon.CanUse(out act)) return true;
if (Delirium.CanUse(out act)) return true;
}
Expand Down
23 changes: 15 additions & 8 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,20 +567,24 @@ private unsafe static void Display(this IBaseAction action, bool IsActive) => ac
ImGui.SameLine();
Spacing();

OtherCommandType.ToggleActions.DisplayCommandHelp(action.ToString());


var enable = action.IsInCooldown;
if (ImGui.Checkbox($"CD##{action.Name}InCooldown", ref enable))
{
action.IsInCooldown = enable;
Service.Config.Save();
}

ImGui.SameLine();
Spacing();

OtherCommandType.ToggleActions.DisplayCommandHelp(action.ToString());
if (action.IsTimeline)
{
ImGui.SameLine();
Spacing();

if (action.IsTimeline) OtherCommandType.DoActions.DisplayCommandHelp($"{action}-{5}",
OtherCommandType.DoActions.DisplayCommandHelp($"{action}-{5}",
type => string.Format(LocalizationManager.RightLang.ConfigWindow_Helper_InsertCommand, action), false);
}

if (Service.Config.InDebug)
{
Expand All @@ -598,7 +602,6 @@ private unsafe static void Display(this IBaseAction action, bool IsActive) => ac
ImGui.Text($"Can Use: {action.CanUse(out _)} ");
ImGui.Text("Must Use:" + action.CanUse(out _, CanUseOption.MustUse).ToString());
ImGui.Text("Empty Use:" + action.CanUse(out _, CanUseOption.EmptyOrSkipCombo).ToString());
ImGui.Text("IsUnlocked: " + UIState.Instance()->IsUnlockLinkUnlocked(action.AdjustedID).ToString());
if (action.Target != null)
{
ImGui.Text("Target Name: " + action.Target.Name);
Expand Down Expand Up @@ -809,12 +812,16 @@ public static void Display(this RotationDescAttribute attr, ICustomRotation rota
ImGui.Unindent(ATTR_INDENT);
}

public static ImFontPtr GetFont(float size)
public unsafe static ImFontPtr GetFont(float size)
{
var style = new Dalamud.Interface.GameFonts.GameFontStyle(Dalamud.Interface.GameFonts.GameFontStyle.GetRecommendedFamilyAndSize(Dalamud.Interface.GameFonts.GameFontFamily.Axis, size));
var font = Service.Interface.UiBuilder.GetGameFontHandle(style).ImFont;
font.Scale = size / style.BaseSizePt;

if((IntPtr)font.NativePtr == IntPtr.Zero)
{
return ImGui.GetFont();
}
font.Scale = size / style.BaseSizePt;
return font;
}
}
2 changes: 1 addition & 1 deletion RotationSolver/UI/RotationConfigWindow_Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void DrawControlTab()

DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownActionOneLine, ref Service.Config.CooldownActionOneLine, Service.Default.CooldownActionOneLine, min: 1, max: 30);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownFontSize, ref Service.Config.CooldownFontSize, Service.Default.CooldownFontSize, min: 9.6f, max: 96);
DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownFontSize, ref Service.Config.CooldownFontSize, Service.Default.CooldownFontSize, speed: 0.1f, min: 9.6f, max: 96);
}
}

Expand Down
3 changes: 3 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ private void DrawNextAction()
ActionUpdater.NextAction?.Display(false);
ImGui.Text("Ability Remain: " + DataCenter.AbilityRemain.ToString());
ImGui.Text("Ability Count: " + DataCenter.AbilityRemainCount.ToString());
ImGui.Text("Weapon Remain: " + DataCenter.WeaponRemain.ToString());
ImGui.Text("Elapsed: " + CustomRotation.CombatElapsedLess(10).ToString());
ImGui.Text("Time: " + (DataCenter.CombatTime + DataCenter.WeaponRemain).ToString());

}
private void DrawLastAction()
Expand Down
14 changes: 10 additions & 4 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ static bool CheckAction(uint actionID)
}
else return false;
}

internal unsafe static void UpdateActionInfo()
{
UpdateWeaponTime();
UpdateTimeInfo();
}

private unsafe static void UpdateTimeInfo()
{
var last = DataCenter.InCombat;
DataCenter.InCombat = Service.Conditions[ConditionFlag.InCombat];
Expand Down Expand Up @@ -105,7 +110,7 @@ internal unsafe static void UpdateActionInfo()
UpdateMPTimer();
}

internal static unsafe void UpdateWeaponTime()
private static unsafe void UpdateWeaponTime()
{
var player = Service.Player;
if (player == null) return;
Expand All @@ -127,7 +132,8 @@ internal static unsafe void UpdateWeaponTime()

//确认能力技的相关信息
var interval = Service.Config.AbilitiesInterval;
if (DataCenter.WeaponRemain < interval || DataCenter.WeaponElapsed == 0)
if (DataCenter.WeaponRemain < interval + Service.Config.ActionAhead * 2
|| DataCenter.WeaponElapsed == 0)
{
DataCenter.AbilityRemain = 0;
if (DataCenter.WeaponRemain > 0)
Expand All @@ -136,7 +142,7 @@ internal static unsafe void UpdateWeaponTime()
}
DataCenter.AbilityRemainCount = 0;
}
else if (DataCenter.WeaponRemain < 2 * interval)
else if (DataCenter.WeaponRemain < 2 * interval + Service.Config.ActionAhead * 2)
{
DataCenter.AbilityRemain = DataCenter.WeaponRemain - interval;
DataCenter.AbilityRemainCount = 1;
Expand Down
3 changes: 1 addition & 2 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static void FrameworkUpdate(Framework framework)
{
SocialUpdater.UpdateSocial();
PreviewUpdater.UpdatePreview();
ActionUpdater.UpdateWeaponTime();
ActionUpdater.UpdateActionInfo();

ActionUpdater.DoAction();

Expand Down Expand Up @@ -88,7 +88,6 @@ private static void UpdateWork()
{
PreviewUpdater.UpdateCastBarState();
TargetUpdater.UpdateTarget();
ActionUpdater.UpdateActionInfo();

RotationUpdater.UpdateRotation();

Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static IEnumerable<IGrouping<string, IAction>> AllGroupedActions
{
string result;

if (act.IsGeneralGCD)
if (act.IsRealGCD)
{
result = "GCD";
}
Expand All @@ -101,7 +101,7 @@ public static IEnumerable<IGrouping<string, IAction>> AllGroupedActions
result += "-" + LocalizationManager.RightLang.Action_Friendly;
if (act.IsEot)
{
result += "Hot";
result += "-Hot";
}
}
else
Expand All @@ -110,7 +110,7 @@ public static IEnumerable<IGrouping<string, IAction>> AllGroupedActions

if (act.IsEot)
{
result += "Dot";
result += "-Dot";
}
}
return result;
Expand Down

0 comments on commit f0829e1

Please sign in to comment.