Skip to content

Commit

Permalink
Merge commit 'refs/pull/339/head' of https://github.com/awgil/ffxiv_b…
Browse files Browse the repository at this point in the history
…ossmod

# Conflicts:
#	BossMod/Autorotation/DRG/DRGActions.cs
  • Loading branch information
awgil committed May 5, 2024
2 parents 5be4686 + 8ba847e commit cdcd56f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
25 changes: 14 additions & 11 deletions BossMod/Autorotation/CommonActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class CommonActions : IDisposable

public enum ActionSource { Automatic, Planned, Manual, Emergency }

public record struct NextAction(ActionID Action, Actor? Target, Vector3 TargetPos, ActionSource Source);
public record struct NextAction(ActionID Action, Actor? Target, Vector3 TargetPos, Angle? FacingAngle, ActionSource Source);
public record struct Targeting(AIHints.Enemy Target, float PreferredRange = 3, Positional PreferredPosition = Positional.Any, bool PreferTanking = false);

public class SupportedAction(ActionDefinition definition, bool isGT)
Expand All @@ -22,6 +22,7 @@ public class SupportedAction(ActionDefinition definition, bool isGT)
public int PlaceholderForAuto; // if set, attempting to execute this action would instead initiate auto-strategy
public Func<ActionID>? TransformAction;
public Func<Actor?, Actor?>? TransformTarget;
public Func<Angle?>? TransformAngle;

public bool Allowed(Actor player, Actor target)
{
Expand Down Expand Up @@ -199,7 +200,7 @@ public bool HandleUserActionRequest(ActionID action, Actor? target, Vector3? for
{
if (forcedGTPos != null)
{
_mq.Push(action, null, forcedGTPos.Value, supportedAction.Definition, supportedAction.Condition);
_mq.Push(action, null, forcedGTPos.Value, null, supportedAction.Definition, supportedAction.Condition);
return true;
}

Expand All @@ -211,7 +212,7 @@ public bool HandleUserActionRequest(ActionID action, Actor? target, Vector3? for
var pos = ActionManagerEx.Instance!.GetWorldPosUnderCursor();
if (pos == null)
return false; // same as manual...
_mq.Push(action, null, pos.Value, supportedAction.Definition, supportedAction.Condition);
_mq.Push(action, null, pos.Value, null, supportedAction.Definition, supportedAction.Condition);
return true;
}
}
Expand All @@ -220,7 +221,9 @@ public bool HandleUserActionRequest(ActionID action, Actor? target, Vector3? for
{
target = supportedAction.TransformTarget(target);
}
_mq.Push(action, target, new(), supportedAction.Definition, supportedAction.Condition);

Angle? angleOverride = supportedAction.TransformAngle?.Invoke();
_mq.Push(action, target, new(), angleOverride, supportedAction.Definition, supportedAction.Condition);
return true;
}

Expand All @@ -229,26 +232,26 @@ public NextAction CalculateNextAction()
// check emergency mode
var mqEmergency = _mq.PeekEmergency();
if (mqEmergency != null)
return new(mqEmergency.Action, mqEmergency.Target, mqEmergency.TargetPos, ActionSource.Emergency);
return new(mqEmergency.Action, mqEmergency.Target, mqEmergency.TargetPos, mqEmergency.FacingAngle, ActionSource.Emergency);

var effAnimLock = Autorot.EffAnimLock;
var animLockDelay = Autorot.AnimLockDelay;

// see if we have any GCD (queued or automatic)
var mqGCD = _mq.PeekGCD();
var nextGCD = mqGCD != null ? new NextAction(mqGCD.Action, mqGCD.Target, mqGCD.TargetPos, ActionSource.Manual) : AutoAction != AutoActionNone ? CalculateAutomaticGCD() : new();
var nextGCD = mqGCD != null ? new NextAction(mqGCD.Action, mqGCD.Target, mqGCD.TargetPos, mqGCD.FacingAngle, ActionSource.Manual) : AutoAction != AutoActionNone ? CalculateAutomaticGCD() : new();
float ogcdDeadline = nextGCD.Action ? Autorot.WorldState.Client.Cooldowns[CommonDefinitions.GCDGroup].Remaining : float.MaxValue;
//Log($"{nextGCD.Action} = {ogcdDeadline}");

// search for any oGCDs that we can execute without delaying GCD
var mqOGCD = _mq.PeekOGCD(effAnimLock, animLockDelay, ogcdDeadline);
if (mqOGCD != null)
return new(mqOGCD.Action, mqOGCD.Target, mqOGCD.TargetPos, ActionSource.Manual);
return new(mqOGCD.Action, mqOGCD.Target, mqOGCD.TargetPos, mqOGCD.FacingAngle, ActionSource.Manual);

// see if there is anything high-priority from cooldown plan to be executed
var cpActionHigh = Autorot.Hints.PlannedActions.FirstOrDefault(x => !x.lowPriority && CanExecutePlannedAction(x.action, x.target, effAnimLock, animLockDelay, ogcdDeadline));
if (cpActionHigh.action)
return new(cpActionHigh.action, cpActionHigh.target, new(), ActionSource.Planned);
return new(cpActionHigh.action, cpActionHigh.target, new(), null, ActionSource.Planned);

// note: we intentionally don't check that automatic oGCD really does not clip GCD - we provide utilities that allow module checking that, but also allow overriding if needed
var nextOGCD = AutoAction != AutoActionNone ? CalculateAutomaticOGCD(ogcdDeadline) : new();
Expand All @@ -258,7 +261,7 @@ public NextAction CalculateNextAction()
// finally see whether there are any low-priority planned actions
var cpActionLow = Autorot.Hints.PlannedActions.FirstOrDefault(x => x.lowPriority && CanExecutePlannedAction(x.action, x.target, effAnimLock, animLockDelay, ogcdDeadline));
if (cpActionLow.action)
return new(cpActionLow.action, cpActionLow.target, new(), ActionSource.Planned);
return new(cpActionLow.action, cpActionLow.target, new(), null, ActionSource.Planned);

// no ogcds, execute gcd instead
return nextGCD;
Expand Down Expand Up @@ -296,7 +299,7 @@ protected NextAction MakeResult(ActionID action, Actor? target)
return new();
if (data.Definition.Range == 0)
target = Player; // override range-0 actions to always target player
return target != null && data.Allowed(Player, target) ? new(action, target, new(), ActionSource.Automatic) : new();
return target != null && data.Allowed(Player, target) ? new(action, target, new(), null, ActionSource.Automatic) : new();
}
protected NextAction MakeResult<AID>(AID aid, Actor? target) where AID : Enum => MakeResult(ActionID.MakeSpell(aid), target);

Expand All @@ -305,7 +308,7 @@ protected void SimulateManualActionForAI(ActionID action, Actor? target, bool en
if (enable)
{
var data = SupportedActions[action];
_mq.Push(action, target, new(), data.Definition, data.Condition, true);
_mq.Push(action, target, new(), null, data.Definition, data.Condition, true);
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions BossMod/Autorotation/DRG/DRGActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ private void OnConfigModified(DRGConfig config)

// smart targets
SupportedSpell(AID.DragonSight).TransformTarget = config.SmartDragonSightTarget ? SmartTargetDragonSight : null;

// elusive jump aiming
SupportedSpell(AID.ElusiveJump).TransformAngle = config.ElusiveJump switch
{
DRGConfig.ElusiveJumpBehavior.CharacterForward => () => Player.Rotation + 180.Degrees(),
DRGConfig.ElusiveJumpBehavior.CameraBackward => () => Camera.Instance!.CameraAzimuth.Radians() + 180.Degrees(),
DRGConfig.ElusiveJumpBehavior.CameraForward => () => Camera.Instance!.CameraAzimuth.Radians(),
_ => null
};
}

private bool WithoutDOT(Actor a) => Rotation.RefreshDOT(_state, StatusDetails(a, SID.ChaosThrust, Player.InstanceID).Left);
Expand Down
19 changes: 19 additions & 0 deletions BossMod/Autorotation/DRG/DRGConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,23 @@ class DRGConfig : ConfigNode

[PropertyDisplay("Smart targeting for Dragon Sight (target if friendly, otherwise mouseover if friendly, otherwise best player by class ranking)")]
public bool SmartDragonSightTarget = true;

// TODO: generalize to common utility
public enum ElusiveJumpBehavior : uint
{
[PropertyDisplay("Game default (character-relative, backwards)")]
Default = 0,

[PropertyDisplay("Character-relative, forwards")]
CharacterForward = 1,

[PropertyDisplay("Camera-relative, backwards")]
CameraBackward = 2,

[PropertyDisplay("Camera-relative, forwards")]
CameraForward = 3,
}

[PropertyDisplay("Elusive Jump direction")]
public ElusiveJumpBehavior ElusiveJump = ElusiveJumpBehavior.Default;
}
11 changes: 6 additions & 5 deletions BossMod/Autorotation/ManualActionOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
// - trying to queue an oGCD action while it is already queued (double tapping) activates 'emergency mode': all preceeding queued actions are removed and this action is returned even if it would delay GCD
class ManualActionOverride(WorldState ws)
{
public class Entry(ActionID action, Actor? target, Vector3 targetPos, ActionDefinition definition, Func<Actor?, bool>? condition, DateTime expireAt)
public class Entry(ActionID action, Actor? target, Vector3 targetPos, Angle? facingAngle, ActionDefinition definition, Func<Actor?, bool>? condition, DateTime expireAt)
{
public ActionID Action = action;
public Actor? Target = target;
public Vector3 TargetPos = targetPos;
public Angle? FacingAngle = facingAngle;
public ActionDefinition Definition = definition;
public Func<Actor?, bool>? Condition = condition;
public DateTime ExpireAt = expireAt;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void RemoveExpired()
_queue.RemoveAll(CheckExpired);
}

public void Push(ActionID action, Actor? target, Vector3 targetPos, ActionDefinition def, Func<Actor?, bool>? condition, bool simulated = false)
public void Push(ActionID action, Actor? target, Vector3 targetPos, Angle? facingAngle, ActionDefinition def, Func<Actor?, bool>? condition, bool simulated = false)
{
bool isGCD = def.CooldownGroup == CommonDefinitions.GCDGroup;
float expire = isGCD ? 1.0f : 3.0f;
Expand All @@ -63,7 +64,7 @@ public void Push(ActionID action, Actor? target, Vector3 targetPos, ActionDefini
if (index < 0)
{
Service.Log($"[MAO] Queueing {action} @ {target}");
_queue.Add(new(action, target, targetPos, def, condition, expireAt));
_queue.Add(new(action, target, targetPos, facingAngle, def, condition, expireAt));
return;
}

Expand All @@ -72,7 +73,7 @@ public void Push(ActionID action, Actor? target, Vector3 targetPos, ActionDefini
{
Service.Log($"[MAO] Replacing queued {e.Action} with {action} @ {target}");
_queue.RemoveAt(index);
_queue.Add(new(action, target, targetPos, def, condition, expireAt));
_queue.Add(new(action, target, targetPos, facingAngle, def, condition, expireAt));
}
else if (isGCD)
{
Expand All @@ -84,7 +85,7 @@ public void Push(ActionID action, Actor? target, Vector3 targetPos, ActionDefini
Service.Log($"[MAO] Entering emergency mode for {e.Action}");
// spamming oGCD - enter emergency mode
_queue.Clear();
_queue.Add(new(action, target, targetPos, def, condition, expireAt));
_queue.Add(new(action, target, targetPos, facingAngle, def, condition, expireAt));
_emergencyMode = true;
}
}
Expand Down
3 changes: 3 additions & 0 deletions BossMod/Framework/ActionManagerEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ private void UpdateDetour(ActionManager* self)
var status = GetActionStatus(actionAdj, targetID);
if (status == 0)
{
if (AutoQueue.FacingAngle != null)
FaceDirection(AutoQueue.FacingAngle.Value.ToDirection());

var res = AutoQueue.Action.Type switch
{
ActionType.Item => UseActionRaw(actionAdj, targetID, AutoQueue.TargetPos, 65535),
Expand Down

0 comments on commit cdcd56f

Please sign in to comment.