Skip to content

Commit

Permalink
Added Player class and Health
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinPtrl committed Mar 16, 2022
1 parent fe5517e commit cba459c
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 53 deletions.
42 changes: 42 additions & 0 deletions SoTCoreExternal/Game/Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoT.Game
{
public class Player : UE4Actor
{
private UHealthComponent HealthComponent
{
get
{
return SotCore.Instance.Memory.ReadProcessMemory<UHealthComponent>(SotCore.Instance.Memory.ReadProcessMemory<ulong>(Address + 2136));
}
}
public float MaxHealth
{
get
{
return HealthComponent.MaxHealth;
}
}

public float CurrentHealth
{
get
{
return HealthComponent.CurrentHealth;
}
}

public Player(UEObject ueobject) : base(ueobject.Address)
{
}

public Player(ulong address) : base(address)
{
}
}
}
50 changes: 50 additions & 0 deletions SoTCoreExternal/Game/SotStructs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using SoT.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace SoT.Game
{
public struct FTransform
{
public Quaternion Rotation;
public Vector3 Translation;
public Vector3 Scale3D;
};

[StructLayout(LayoutKind.Explicit)]
public struct SceneComponent
{
[FieldOffset(0x140)]
public FTransform transform;
}

[StructLayout(LayoutKind.Explicit)]
public struct AActor
{
[FieldOffset(0x18)]
public int ObjectID;


[FieldOffset(0x170)]
private ulong RootComponentPtr;

public SceneComponent GetRootComponent()
{
return SotCore.Instance.Memory.ReadProcessMemory<SceneComponent>(RootComponentPtr);
}
}

[StructLayout(LayoutKind.Explicit)]
public struct UHealthComponent
{
[FieldOffset(0x00E0)]
public float MaxHealth;

[FieldOffset(0x00E4)]
public float CurrentHealth;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,9 @@
using System.Text;
using System.Threading.Tasks;

namespace SoT.UE4
namespace SoT.Game
{
public struct FTransform
{
public Quaternion Rotation;
public Vector3 Translation;
public Vector3 Scale3D;
};

[StructLayout(LayoutKind.Explicit)]
public struct SceneComponent
{
[FieldOffset(0x140)]
public FTransform transform;
}

[StructLayout(LayoutKind.Explicit)]
public struct AActor
{
[FieldOffset(0x18)]
public int ObjectID;


[FieldOffset(0x170)]
private ulong RootComponentPtr;

public SceneComponent GetRootComponent()
{
return SotCore.Instance.Memory.ReadProcessMemory<SceneComponent>(RootComponentPtr);
}
}


public class UE4Actor : UEObject
public class UE4Actor : UEObject
{
String _Name;
public String Name
Expand Down Expand Up @@ -90,6 +59,14 @@ public Quaternion Rotation
}
}

public Vector3 Scale
{
get
{
return actor.GetRootComponent().transform.Scale3D;
}
}

public UE4Actor(ulong address) : base(address)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
using System.Threading.Tasks;

namespace SoT.UE4
namespace SoT.Game
{
public class UE4Engine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
using System.Threading.Tasks;

namespace SoT.UE4
namespace SoT.Game
{
public class UEObject
{
Expand Down
9 changes: 5 additions & 4 deletions SoTCoreExternal/SoTCoreExternal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Data\Quaternion.cs" />
<Compile Include="Game\Player.cs" />
<Compile Include="Game\SotStructs.cs" />
<Compile Include="SotCore.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SotStuff.cs" />
<Compile Include="UE4\UE4Actor.cs" />
<Compile Include="UE4\UE4Engine.cs" />
<Compile Include="UE4\UEObject.cs" />
<Compile Include="Game\UE4Actor.cs" />
<Compile Include="Game\UE4Engine.cs" />
<Compile Include="Game\UEObject.cs" />
<Compile Include="Util\Memory.cs" />
<Compile Include="Util\SigScan.cs" />
<Compile Include="Data\Vector3.cs" />
Expand Down
2 changes: 1 addition & 1 deletion SoTCoreExternal/SotCore.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SoT.Util;
using System;
using SoT.UE4;
using SoT.Game;

namespace SoT
{
Expand Down
12 changes: 0 additions & 12 deletions SoTCoreExternal/SotStuff.cs

This file was deleted.

9 changes: 8 additions & 1 deletion SotCoreTest/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading;
using SoT;
using SoT.UE4;
using SoT.Game;

namespace SotEspCoreTest
{
Expand All @@ -18,6 +18,13 @@ static void Main(string[] args)
{
Console.WriteLine("Name : {0} Class Name : {1} Parent Class Name {2}", actor.Name, actor.ClassName, actor.ParentClassName);
Console.WriteLine(actor.Position);

if(actor.Name.Equals("BP_PlayerPirate_C"))
{
Player player = new Player(actor);
Console.WriteLine("Current Health {0} : Max Health {1}", player.CurrentHealth, player.MaxHealth);
Console.ReadKey();
}
}
}
}
Expand Down

0 comments on commit cba459c

Please sign in to comment.