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

Commit

Permalink
feat: add an AutoStatus showcase on Control Window.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 1, 2023
1 parent 6f5397e commit 5f89217
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 44 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class PluginConfiguration : IPluginConfiguration
public bool RaisePlayerBySwift = true;
public bool RaiseBrinkOfDeath = true;
public int LessMPNoRaise = 0;
public bool AutoShield = true;
public bool AutoTankStance = true;
public bool AddEnemyListToHostile = true;
public bool UseAOEWhenManual = false;
public bool UseAOEAction = true;
Expand Down
18 changes: 18 additions & 0 deletions RotationSolver.Basic/Data/AutoStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace RotationSolver.Basic.Data;

[Flags]
public enum AutoStatus : ushort
{
None = 0,
Interrupt = 1 << 0,
TankStance = 1 << 1,
Provoke = 1 << 2,
DefenseSingle = 1 << 3,
DefenseArea = 1 << 4,
HealSingleAbility = 1 << 5,
HealSingleSpell = 1 << 6,
HealAreaAbility = 1 << 7,
HealAreaSpell = 1 << 8,
Raise = 1 << 9,
Esuna = 1 << 10,
}
13 changes: 13 additions & 0 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ namespace RotationSolver.Basic;
public static class DataCenter
{
public static bool InHighEndDuty { get; set; } = false;
public static AutoStatus AutoStatus { get; private set; } = AutoStatus.None;
public static bool SetAutoStatus(AutoStatus status, bool keep)
{
if (keep)
{
AutoStatus |= status;
}
else
{
AutoStatus &= ~status;
}
return keep;
}

private static List<NextAct> NextActs = new List<NextAct>();
public static IBaseAction TimeLineAction { internal get; set; }
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/DRK_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected static bool DarkSideEndAfterGCD(uint gctCount = 0, uint abilityCount =
}

public sealed override ClassJobID[] JobIDs => new ClassJobID[] { ClassJobID.DarkKnight };
private sealed protected override IBaseAction Shield => Grit;
private sealed protected override IBaseAction TankStance => Grit;

/// <summary>
/// 重斩
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/GNB_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class GNB_Base : CustomRotation
protected static byte AmmoComboStep => JobGauge.AmmoComboStep;

public sealed override ClassJobID[] JobIDs => new ClassJobID[] { ClassJobID.Gunbreaker };
private sealed protected override IBaseAction Shield => RoyalGuard;
private sealed protected override IBaseAction TankStance => RoyalGuard;

protected override bool CanHealSingleSpell => false;
protected override bool CanHealAreaSpell => false;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/PLD_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class PLD_Base : CustomRotation

public sealed override ClassJobID[] JobIDs => new ClassJobID[] { ClassJobID.Paladin, ClassJobID.Gladiator };

private sealed protected override IBaseAction Shield => IronWill;
private sealed protected override IBaseAction TankStance => IronWill;

protected override bool CanHealSingleSpell => DataCenter.PartyMembers.Count() == 1 && base.CanHealSingleSpell;
protected override bool CanHealAreaAbility => false;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/WAR_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class WAR_Base : CustomRotation

protected static byte BeastGauge => JobGauge.BeastGauge;
public sealed override ClassJobID[] JobIDs => new ClassJobID[] { ClassJobID.Warrior, ClassJobID.Marauder };
private sealed protected override IBaseAction Shield => Defiance;
private sealed protected override IBaseAction TankStance => Defiance;

/// <summary>
/// 守护
Expand Down
30 changes: 17 additions & 13 deletions RotationSolver.Basic/Rotations/CustomRotation_Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ private bool Ability(byte abilitiesRemaining, IAction nextGCD, out IAction act,
private bool InterruptAbility(JobRole role, out IAction act)
{
act = null;
if (!DataCenter.CanInterruptTargets.Any()) return false;
if (!DataCenter.SetAutoStatus(AutoStatus.Interrupt, DataCenter.CanInterruptTargets.Any()))
return false;


switch (role)
{
Expand Down Expand Up @@ -87,16 +89,15 @@ private bool ShirkOrShield(JobRole role, SpecialCommandType specialType, out IAc
break;

case SpecialCommandType.EsunaStanceNorth:
if (Shield.CanUse(out act)) return true;
if (TankStance.CanUse(out act)) return true;
break;
}

if (Service.Config.AutoShield)
if (DataCenter.SetAutoStatus(AutoStatus.TankStance, Service.Config.AutoTankStance
&& !DataCenter.AllianceTanks.Any(t => t.CurrentHp != 0 && t.HasStatus(false, StatusHelper.TankStanceStatus))
&& !HasTankStance && TankStance.CanUse(out act)))
{
if (!DataCenter.AllianceTanks.Any(t => t.CurrentHp != 0 && t.HasStatus(false, StatusHelper.TankStanceStatus)))
{
if (!HasTankStance && Shield.CanUse(out act)) return true;
}
return true;
}

return false;
Expand Down Expand Up @@ -155,16 +156,19 @@ private bool GeneralHealAbility(byte abilitiesRemaining, SpecialCommandType spec
private bool AutoDefense(byte abilitiesRemaining, JobRole role, bool helpDefenseAOE, bool helpDefenseSingle, out IAction act)
{
act = null;

if (!InCombat || !HasHostilesInRange) return false;
if (!InCombat || !HasHostilesInRange)
{
DataCenter.SetAutoStatus(AutoStatus.Provoke, false);
return false;
}

//Auto Provoke
if (role == JobRole.Tank
if (DataCenter.SetAutoStatus(AutoStatus.Provoke, role == JobRole.Tank
&& (Service.Config.AutoProvokeForTank || DataCenter.AllianceTanks.Count() < 2)
&& TargetFilter.ProvokeTarget(DataCenter.HostileTargets, true).Count() != DataCenter.HostileTargets.Count())

&& TargetFilter.ProvokeTarget(DataCenter.HostileTargets, true).Count() != DataCenter.HostileTargets.Count()))
{
if (!HasTankStance && Shield.CanUse(out act)) return true;

if (!HasTankStance && TankStance.CanUse(out act)) return true;
if (Provoke.CanUse(out act, CanUseOption.MustUse)) return true;
}

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 @@ -220,7 +220,7 @@ internal RoleAction(ActionID actionID, JobRole[] roles, bool isFriendly = false,
};

private protected virtual IBaseAction Raise => null;
private protected virtual IBaseAction Shield => null;
private protected virtual IBaseAction TankStance => null;

/// <summary>
/// 当前这个类所有的BaseAction
Expand Down
33 changes: 21 additions & 12 deletions RotationSolver.Basic/Rotations/CustomRotation_GCD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ private IAction GCD(byte abilityRemain, bool helpDefenseAOE, bool helpDefenseSin
if (specialType == SpecialCommandType.DefenseSingle && DefenseSingleGCD(out act)) return act;

//Auto Defense
if (helpDefenseAOE && DefenseAreaGCD(out act)) return act;
if (helpDefenseSingle && DefenseSingleGCD(out act)) return act;
if (DataCenter.SetAutoStatus(AutoStatus.DefenseArea, helpDefenseAOE) && DefenseAreaGCD(out act)) return act;
if (DataCenter.SetAutoStatus(AutoStatus.DefenseSingle, helpDefenseSingle) && DefenseSingleGCD(out act)) return act;

//Esuna
if ((specialType == SpecialCommandType.EsunaStanceNorth || !HasHostilesInRange || Service.Config.EsunaAll)
if (DataCenter.SetAutoStatus(AutoStatus.Esuna, (specialType == SpecialCommandType.EsunaStanceNorth
|| !HasHostilesInRange || Service.Config.EsunaAll)
&& DataCenter.WeakenPeople.Any()
|| DataCenter.DyingPeople.Any())
|| DataCenter.DyingPeople.Any()))
{
if (Job.GetJobRole() == JobRole.Healer && Esuna.CanUse(out act, CanUseOption.MustUse)) return act;
}
Expand All @@ -56,33 +57,41 @@ private IAction GCD(byte abilityRemain, bool helpDefenseAOE, bool helpDefenseSin
private bool RaiseSpell(SpecialCommandType specialType, out IAction act, byte actabilityRemain, bool mustUse)
{
act = null;
if (Raise == null) return false;
if (Player.CurrentMp <= Service.Config.LessMPNoRaise) return false;
if (Raise == null || Player.CurrentMp <= Service.Config.LessMPNoRaise)
{
return DataCenter.SetAutoStatus(AutoStatus.Raise, false);
}

if (specialType == SpecialCommandType.RaiseShirk && DataCenter.DeathPeopleAll.Any()) return true;
if (specialType == SpecialCommandType.RaiseShirk && DataCenter.DeathPeopleAll.Any())
{
return true;
}

if ((Service.Config.RaiseAll ? DataCenter.DeathPeopleAll.Any() : DataCenter.DeathPeopleParty.Any())
&& Raise.CanUse(out act))
{
if (HasSwift)
{
return true;
return DataCenter.SetAutoStatus(AutoStatus.Raise, true);
}
else if (mustUse)
{
if(Swiftcast.CanUse(out act)) return true;
if(Swiftcast.CanUse(out act))
{
return DataCenter.SetAutoStatus(AutoStatus.Raise, true);
}
else
{
act = Raise;
return true;
return DataCenter.SetAutoStatus(AutoStatus.Raise, true);
}
}
else if (Service.Config.RaisePlayerBySwift && !Swiftcast.IsCoolingDown && actabilityRemain > 0)
{
return true;
return DataCenter.SetAutoStatus(AutoStatus.Raise, true);
}
}
return false;
return DataCenter.SetAutoStatus(AutoStatus.Raise, false);
}

protected virtual bool EmergencyGCD(out IAction act)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public bool TryInvoke(out IAction newAction, out IAction gcdAction)
EsunaStanceNorthAbility = role switch
{
JobRole.Melee => TrueNorth.CanUse(out act) ? act : null,
JobRole.Tank => Shield.CanUse(out act) ? act : null,
JobRole.Tank => TankStance.CanUse(out act) ? act : null,
_ => null,
};
RaiseShirkGCD = role switch
Expand Down
8 changes: 1 addition & 7 deletions RotationSolver.Default/Melee/NIN_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,12 @@ private static void SetNinjutsu(INinAction act)
if(_ninActionAim != act)
{
_ninActionAim = act;
#if DEBUG
Service.ChatGui.Print("Set " + act.Name);
#endif
}
}
private static void ClearNinjutsu()
{
if (_ninActionAim != null)
{
#if DEBUG
Service.ChatGui.Print("Clear " + _ninActionAim.Name);
#endif
_ninActionAim = null;
}
}
Expand Down Expand Up @@ -273,7 +267,7 @@ protected override bool GeneralGCD(out IAction act)
//No Ninjutsu
if (AdjustId(ActionID.Ninjutsu) is ActionID.Ninjutsu or ActionID.RabbitMedium)
{
if (!CombatElapsedLess(16) && FleetingRaiju.CanUse(out act)) return true;
if (!CombatElapsedLess(10) && FleetingRaiju.CanUse(out act)) return true;
if (Player.HasStatus(true, StatusID.RaijuReady)) return false;

if (InBurstStatus && PhantomKamaitachi.CanUse(out act)) return true;
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ private static void DrawSpecials()
TargetHostileType.TargetsHaveTarget => LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType3,
_ => string.Empty,
});

ImGui.Text("Auto: " + DataCenter.AutoStatus.ToString());
}

static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType command, Vector4 color)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private void DrawParamAction()
LocalizationManager.RightLang.ConfigWindow_Param_UseDefenceAbilityDesc);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoShield,
ref Service.Config.AutoShield);
ref Service.Config.AutoTankStance);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_AutoProvokeForTank,
ref Service.Config.AutoProvokeForTank,
Expand Down
13 changes: 9 additions & 4 deletions RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,15 @@ static void UpdateCanHeal(PlayerCharacter player)
}

//Delay
DataCenter.CanHealSingleAbility = _healDelay1.Delay(DataCenter.CanHealSingleAbility);
DataCenter.CanHealSingleSpell = _healDelay2.Delay(DataCenter.CanHealSingleSpell);
DataCenter.CanHealAreaAbility = _healDelay3.Delay(DataCenter.CanHealAreaAbility);
DataCenter.CanHealAreaSpell = _healDelay4.Delay(DataCenter.CanHealAreaSpell);

DataCenter.CanHealSingleAbility = DataCenter.SetAutoStatus(AutoStatus.HealSingleAbility,
_healDelay1.Delay(DataCenter.CanHealSingleAbility));
DataCenter.CanHealSingleSpell = DataCenter.SetAutoStatus(AutoStatus.HealSingleSpell,
_healDelay2.Delay(DataCenter.CanHealSingleSpell));
DataCenter.CanHealAreaAbility = DataCenter.SetAutoStatus(AutoStatus.HealAreaAbility,
_healDelay3.Delay(DataCenter.CanHealAreaAbility));
DataCenter.CanHealAreaSpell = DataCenter.SetAutoStatus(AutoStatus.HealAreaSpell,
_healDelay4.Delay(DataCenter.CanHealAreaSpell));

DataCenter.PartyMembersMinHP = DataCenter.PartyMembersHP.Any() ? DataCenter.PartyMembersHP.Min() : 0;
DataCenter.HPNotFull = DataCenter.PartyMembersMinHP < 1;
Expand Down

0 comments on commit 5f89217

Please sign in to comment.