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

Commit

Permalink
style: add more info about battle character.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 12, 2023
1 parent f414e98 commit c729c1c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
30 changes: 18 additions & 12 deletions RotationSolver/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,33 @@ internal static bool HasPositional(this GameObject obj)
internal static unsafe bool IsOthersPlayers(this GameObject obj)
{
//SpecialType but no NamePlateIcon
if (_eventType.Contains(obj.GetAddress()->EventId.Type))
if (_eventType.Contains(obj.GetEventType()))
{
return obj.GetNamePlateIcon() == 0;
}
return false;
}

internal static unsafe bool IsNPCEnemy(this GameObject obj) => obj.GetObjectKind() == ObjectKind.BattleNpc
&& obj.GetBattleNPCSubkind() == BattleNpcSubKind.Enemy;
static readonly EventHandlerType[] _someSpecialEvent = new EventHandlerType[]
{
EventHandlerType.PublicContentDirector, //Island Sanctuary..
EventHandlerType.FateDirector, //Island Sanctuary..
};
internal static unsafe bool IsNPCEnemy(this GameObject obj)
=> obj.GetObjectKind() == ObjectKind.BattleNpc
&& obj.GetBattleNPCSubkind() == BattleNpcSubKind.Enemy
&& !_someSpecialEvent.Contains(obj.GetEventType())
&& obj.CanAttack();

private unsafe static bool CanAttack(this GameObject actor)
{
return ((delegate*<long, IntPtr, long>)Service.Address.CanAttackFunction)(142L, actor.Address) == 1;
}

internal static unsafe ObjectKind GetObjectKind(this GameObject obj) => (ObjectKind)obj.GetAddress()->ObjectKind;

internal static unsafe uint GetNamePlateIcon(this GameObject obj) => obj.GetAddress()->NamePlateIconId;
internal static unsafe EventHandlerType GetEventType(this GameObject obj) => obj.GetAddress()->EventId.Type;

internal static unsafe BattleNpcSubKind GetBattleNPCSubkind(this GameObject obj) => (BattleNpcSubKind)obj.GetAddress()->SubKind;

Expand Down Expand Up @@ -127,7 +141,7 @@ internal static bool CanDot(this BattleChara b)
return b.CurrentHp >= GetHealthFromMulty(1.5f);
}

internal static EnemyPositional FindEnemyLocation(this GameObject enemy)
internal static EnemyPositional FindEnemyPositional(this GameObject enemy)
{
Vector3 pPosition = enemy.Position;
float rotation = enemy.Rotation;
Expand All @@ -143,14 +157,6 @@ internal static EnemyPositional FindEnemyLocation(this GameObject enemy)
return EnemyPositional.Flank;
}

//public unsafe static bool CanAttack(this GameObject actor)
//{
// if (actor == null) return false;
// if (actor is not BattleChara b) return false;
// if (b.CurrentHp == 0) return false;
// return ((delegate*<long, IntPtr, long>)Service.Address.CanAttackFunction)(142L, actor.Address) == 1;
//}

#if DEBUG
internal static uint GetHealthFromMulty(float mult)
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private protected virtual bool EmergencyAbility(byte abilitiesRemaining, IAction

if (Service.Configuration.AutoUseTrueNorth && abilitiesRemaining == 1 && action.EnermyPositonal != EnemyPositional.None && action.Target != null)
{
if (action.EnermyPositonal != action.Target.FindEnemyLocation() && action.Target.HasPositional())
if (action.EnermyPositonal != action.Target.FindEnemyPositional() && action.Target.HasPositional())
{
if (TrueNorth.CanUse(out act, emptyOrSkipCombo: true)) return true;
}
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/SigReplacers/PluginAddressResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace RotationSolver.SigReplacers;
internal class PluginAddressResolver : BaseAddressResolver
{
public IntPtr IsActionIdReplaceable { get; private set; }
//public IntPtr CanAttackFunction { get; private set; }
public IntPtr CanAttackFunction { get; private set; }
public IntPtr MovingController { get; private set; }
public IntPtr ReceiveAbilty { get; private set; }
public IntPtr CountdownTimerAdress { get; private set; }
Expand All @@ -22,7 +22,7 @@ protected override void Setup64Bit(SigScanner scanner)
IsActionIdReplaceable = scanner.ScanText("E8 ?? ?? ?? ?? 84 C0 74 4C 8B D3");

//IDK
//CanAttackFunction = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8B DA 8B F9 E8 ?? ?? ?? ?? 4C 8B C3 ");
CanAttackFunction = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8B DA 8B F9 E8 ?? ?? ?? ?? 4C 8B C3 ");
MovingController = scanner.ScanText("40 55 53 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 83 79 ?? ??");
ReceiveAbilty = scanner.ScanText("4C 89 44 24 ?? 55 56 41 54 41 55 41 56");
CountdownTimerAdress = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 40 8B 41");
Expand Down
5 changes: 2 additions & 3 deletions RotationSolver/Updaters/TargetUpdater_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ internal static partial class TargetUpdater
internal static IEnumerable<GameObject> AllTargets { get; private set; }
internal static void UpdateTarget()
{
var wholeTargets = Service.ObjectTable.GetObjectInRadius(60);
AllTargets = wholeTargets.GetObjectInRadius(30);
AllTargets = Service.ObjectTable.GetObjectInRadius(30);
var battles = AllTargets.OfType<BattleChara>();
UpdateHostileTargets(battles);
UpdateFriends(battles);
UpdateNamePlate(wholeTargets.OfType<BattleChara>());
UpdateNamePlate(Service.ObjectTable.OfType<BattleChara>());
}
}
}
2 changes: 1 addition & 1 deletion RotationSolver/Windows/OverlayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private static void DrawLocation()
}
pts.Add(scrPos);

bool wrong = ShouldPositional != EnemyLocationTarget.FindEnemyLocation();
bool wrong = ShouldPositional != EnemyLocationTarget.FindEnemyPositional();
var color = wrong ? new Vector3(0.3f, 0.8f, 0.2f) : new Vector3(1, 1, 1);

pts.ForEach(pt => ImGui.GetWindowDrawList().PathLineTo(pt));
Expand Down
10 changes: 6 additions & 4 deletions RotationSolver/Windows/RotationConfigWindow_Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ private unsafe void DrawTargetData()
{
if (Service.TargetManager.Target is BattleChara b)
{
ImGui.Text("HP: " + b.CurrentHp + " / " + b.MaxHp);
ImGui.Text("Is Boss: " + b.IsBoss().ToString());
ImGui.Text("Has Positional: " + b.HasPositional().ToString());
ImGui.Text("Is Dying: " + b.IsDying().ToString());
ImGui.Text("NamePlate: " + b.GetAddress()->NamePlateIconId.ToString());
ImGui.Text("Kind: " + b.GetAddress()->ObjectKind.ToString());
ImGui.Text("Subkind: " + b.GetAddress()->SubKind.ToString());
ImGui.Text("EventType: " + b.GetAddress()->EventId.Type.ToString());
ImGui.Text("Kind: " + b.GetObjectKind().ToString());
ImGui.Text("Subkind: " + b.GetBattleNPCSubkind().ToString());
ImGui.Text("EventType: " + b.GetEventType().ToString());
ImGui.Text("NamePlate: " + b.GetNamePlateIcon().ToString());
ImGui.Text("StatusFlags: " + b.StatusFlags.ToString());

foreach (var status in b.StatusList)
{
Expand Down

0 comments on commit c729c1c

Please sign in to comment.