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

Commit

Permalink
TargetID rework
Browse files Browse the repository at this point in the history
Reworked Target and TargetID on BaseAction in order to prevent issues with null references. Should fix various abilities getting "stuck" like ninja mudra
  • Loading branch information
NostraThomas99 committed Feb 14, 2024
1 parent 44ba260 commit e36edec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
11 changes: 7 additions & 4 deletions RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ public unsafe virtual bool CanUse(out IAction act, CanUseOption option = CanUseO
Target = target;
AffectedTargets = affectedTargets;

if (!option.HasFlag(CanUseOption.IgnoreTarget)) _targetId = target.ObjectId;
//if (!option.HasFlag(CanUseOption.IgnoreTarget)) _targetId = target.ObjectId; // Disabled because no longer needed?
return true;
}

private bool CheckForCombo()
{
if (ComboIdsNot != null)
Expand Down Expand Up @@ -224,19 +223,23 @@ private bool CheckForCombo()
public unsafe bool Use()
{
var adjustId = AdjustedID;
//Svc.Log.Verbose($"Action use requested for {adjustId}");
if (_action.TargetArea && adjustId == ID)
{
var loc = new FFXIVClientStructs.FFXIV.Common.Math.Vector3() { X = Position.X, Y = Position.Y, Z = Position.Z };

//Svc.Log.Verbose($"Action has a target area, must specify target of {loc.X}, {loc.Y}, {loc.Z}");
return ActionManager.Instance()->UseActionLocation(ActionType.Action, ID, Player.Object.ObjectId, &loc);
}
else if (Svc.Objects.SearchById(_targetId) == null)
else if (Svc.Objects.SearchById(TargetID) == null)
{
//Svc.Log.Verbose($"{TargetID} not found, dropping action");
return false;
}
else
{
return ActionManager.Instance()->UseAction(ActionType.Action, adjustId, _targetId);
//Svc.Log.Verbose($"Using action {adjustId} on target {TargetID}");
return ActionManager.Instance()->UseAction(ActionType.Action, adjustId, TargetID);
}
}
}
19 changes: 17 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ public float TimeToKill
/// <summary>
/// The action's target.
/// </summary>
public BattleChara Target { get; private set; } = Player.Object;
public BattleChara Target { get; private set; }

public uint TargetID
{
get
{
if (Target == null)
{
return Svc.ClientState.LocalPlayer.ObjectId;
}
else
{
return Target.ObjectId;
}
}
}

/// <inheritdoc/>
public BattleChara[] AffectedTargets { get; private set; } = Array.Empty<BattleChara>();
Expand All @@ -64,7 +79,7 @@ public float TimeToKill
/// The position
/// </summary>
public Vector3 Position { get; private set; } = default;
private uint _targetId = Player.Object?.ObjectId ?? 0;
//private uint _targetId = 0;

private Func<IEnumerable<BattleChara>, bool, BattleChara> _choiceTarget = null;

Expand Down

0 comments on commit e36edec

Please sign in to comment.