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

Commit

Permalink
fix: add a delay for provoke.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 30, 2023
1 parent 08b1796 commit cd363ec
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 34 deletions.
3 changes: 3 additions & 0 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ public enum PluginConfigFloat : byte
[Default(0.1f, 0.05f, 0.25f)] ClickingDelayMin,
[Default(0.15f)] ClickingDelayMax,

[Default(0.5f, 0f, 10f)] ProvokeDelayMin,
[Default(1f)] ProvokeDelayMax,

[Default(0.5f, 0f, 5f)] HealWhenNothingTodoMin,
[Default(1f)] HealWhenNothingTodoMax,

Expand Down
12 changes: 2 additions & 10 deletions RotationSolver.Basic/Data/RandomDelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Random delay the bool.
/// </summary>
public class RandomDelay
public struct RandomDelay
{
DateTime _startDelayTime = DateTime.Now;
float _delayTime = -1;
Expand All @@ -14,7 +14,7 @@ public class RandomDelay
/// <summary>
///
/// </summary>
public Func<(float min, float max)> GetRange { get; set; } = null;
public Func<(float min, float max)> GetRange { get; init; } = null;

/// <summary>
/// Constructer.
Expand All @@ -25,14 +25,6 @@ public RandomDelay(Func<(float min, float max)> getRange)
GetRange = getRange;
}

/// <summary>
///
/// </summary>
public RandomDelay()
{

}

/// <summary>
/// Delay the bool.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ public static void SetSpecialType(SpecialCommandType specialType)

public static IEnumerable<GameObject> AllTargets { get; set; }

public static bool CanProvoke { get; set; } = false;

public static uint[] TreasureCharas { get; internal set; } = Array.Empty<uint>();
public static bool HasHostilesInRange => NumberOfHostilesInRange > 0;
public static bool HasHostilesInMaxRange => NumberOfHostilesInMaxRange > 0;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private bool AutoDefense(JobRole role, bool helpDefenseAOE, bool helpDefenseSing
//Auto Provoke
if (DataCenter.SetAutoStatus(AutoStatus.Provoke, role == JobRole.Tank
&& (Service.Config.GetValue(PluginConfigBool.AutoProvokeForTank) || DataCenter.AllianceTanks.Count() < 2)
&& TargetFilter.ProvokeTarget(DataCenter.HostileTargets, true).Count() != DataCenter.HostileTargets.Count()))
&& DataCenter.CanProvoke))
{
if (!HasTankStance && TankStance.CanUse(out act)) return true;
if (Provoke.CanUse(out act, CanUseOption.MustUse)) return true;
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/ActionSequencer/BaseCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal abstract class BaseCondition : ICondition
public float DelayMin = 0;
public float DelayMax = 0;

RandomDelay _delay = new RandomDelay();
RandomDelay _delay = default;

[JsonIgnore]
private const float MIN = 0, MAX = 60;
Expand All @@ -17,7 +17,7 @@ public bool IsTrue(ICustomRotation rotation)
{
if(_delay.GetRange == null)
{
_delay.GetRange = () => (DelayMin, DelayMax);
_delay = new(() => (DelayMin, DelayMax));
}
return _delay.Delay(IsTrueInside(rotation));
}
Expand All @@ -32,6 +32,7 @@ public void Draw(ICustomRotation rotation)
{
DelayMin = Math.Max(Math.Min(DelayMin, DelayMax), MIN);
DelayMax = Math.Min(Math.Max(DelayMin, DelayMax), MAX);
_delay = new(() => (DelayMin, DelayMax));
}
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ActionSequencer_Delay_Description);

Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ internal static class ConfigTranslation
PluginConfigFloat.HealthTankRatio => LocalizationManager.RightLang.ConfigWindow_Param_HealthTankRatio,
PluginConfigFloat.MoveTargetAngle => LocalizationManager.RightLang.ConfigWindow_Param_MoveTargetAngle,
PluginConfigFloat.AutoHealTimeToKill => LocalizationManager.RightLang.ConfigWindow_Auto_AutoHealTimeToKill,
PluginConfigFloat.ProvokeDelayMin => LocalizationManager.RightLang.ConfigWindow_Auto_ProvokeDelay,

// target
PluginConfigFloat.BossTimeToKill => LocalizationManager.RightLang.ConfigWindow_Param_BossTimeToKill,
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,4 +724,6 @@ internal partial class Strings

public string ConfigWindow_Target_OnlyAttackInVisionCone { get; set; } = "Only attack the targets in vision cone";
public string ConfigWindow_Target_VisionCone { get; set; } = "The angle of your vision cone";

public string ConfigWindow_Auto_ProvokeDelay { get; set; } = "The delay of provoke in seconds.";
}
3 changes: 2 additions & 1 deletion RotationSolver/UI/RotationConfigWindow_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ private static void DrawAutoActionCondition()
JobRole.Tank,
}
},
new CheckBoxSearchPlugin(PluginConfigBool.AutoProvokeForTank)
new CheckBoxSearchPlugin(PluginConfigBool.AutoProvokeForTank,
new DragFloatRangeSearchPlugin(PluginConfigFloat.ProvokeDelayMin, PluginConfigFloat.ProvokeDelayMax, 0.05f)
{
JobRoles = new JobRole[]
{
Expand Down
27 changes: 8 additions & 19 deletions RotationSolver/Updaters/TargetUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ private static float JobRange
}
}

static RandomDelay _provokeDelay = new(() => (Service.Config.GetValue(PluginConfigFloat.ProvokeDelayMin), Service.Config.GetValue(PluginConfigFloat.ProvokeDelayMax)));

private unsafe static void UpdateHostileTargets(IEnumerable<BattleChara> allTargets)
{
var deadHP = DataCenter.PartyMembers.Count() > 1 ? 0 : 1;
Expand Down Expand Up @@ -154,6 +156,8 @@ private unsafe static void UpdateHostileTargets(IEnumerable<BattleChara> allTarg
{
DataCenter.IsHostileCastingToTank = DataCenter.IsHostileCastingAOE = false;
}

DataCenter.CanProvoke = _provokeDelay.Delay(TargetFilter.ProvokeTarget(DataCenter.HostileTargets, true).Count() != DataCenter.HostileTargets.Count());
}

private static IEnumerable<BattleChara> GetHostileTargets(IEnumerable<BattleChara> allAttackableTargets)
Expand Down Expand Up @@ -238,21 +242,6 @@ private static bool IsHostileCastingArea(BattleChara h)
return IsHostileCastingBase(h, (act) =>
{
return OtherConfiguration.HostileCastingArea.Contains(act.RowId);

//if ((act.CastType == 1 || act.CastType == 2)
// && act.Range == 0
// && act.EffectRange >= 40)
// return true;

//if (act.CastType == 2
// && act.EffectRange == 6
// && act.Cast100ms == 50
// && act.CanTargetHostile
// && !act.CanTargetSelf
// && act.Range == 100)
// return true;

//return false;
});
}

Expand Down Expand Up @@ -397,10 +386,10 @@ private static IEnumerable<BattleChara> FilterForDeath(IEnumerable<BattleChara>

static (float min, float max) GetHealRange() => (Service.Config.GetValue(PluginConfigFloat.HealDelayMin), Service.Config.GetValue(PluginConfigFloat.HealDelayMax));

static RandomDelay _healDelay1 = new(GetHealRange);
static RandomDelay _healDelay2 = new(GetHealRange);
static RandomDelay _healDelay3 = new(GetHealRange);
static RandomDelay _healDelay4 = new(GetHealRange);
static RandomDelay _healDelay1 = new(GetHealRange),
_healDelay2 = new(GetHealRange),
_healDelay3 = new(GetHealRange),
_healDelay4 = new(GetHealRange);
static void UpdateCanHeal(PlayerCharacter player)
{
var job = (Job)player.ClassJob.Id;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static void ActionFromSelf(ActionEffectSet set)
DataCenter.ApplyStatus = set.GetSpecificTypeEffect(ActionEffectType.ApplyStatusEffectTarget);
foreach ( var effect in set.GetSpecificTypeEffect(ActionEffectType.ApplyStatusEffectSource))
{
DataCenter.ApplyStatus.Add(effect.Key, effect.Value);
DataCenter.ApplyStatus[effect.Key] = effect.Value;
}
DataCenter.MPGain = (uint)set.GetSpecificTypeEffect(ActionEffectType.MpGain).Where(i => i.Key == Player.Object.ObjectId).Sum(i => i.Value);
DataCenter.EffectTime = DateTime.Now;
Expand Down

0 comments on commit cd363ec

Please sign in to comment.