nice
This commit is contained in:
102
TarkovHax/GuiHelper.cs
Normal file
102
TarkovHax/GuiHelper.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TarkovHax
|
||||
{
|
||||
public static class GuiHelper
|
||||
{
|
||||
private static Texture2D _coloredLineTexture;
|
||||
private static Color _coloredLineColor;
|
||||
|
||||
public static void DrawLine(Vector2 lineStart, Vector2 lineEnd, Color color)
|
||||
{
|
||||
DrawLine(lineStart, lineEnd, color, 1);
|
||||
}
|
||||
|
||||
public static void DrawBox(float x, float y, float w, float h, Color color)
|
||||
{
|
||||
DrawLine(new Vector2(x, y), new Vector2(x + w, y), color);
|
||||
DrawLine(new Vector2(x, y), new Vector2(x, y + h), color);
|
||||
DrawLine(new Vector2(x + w, y), new Vector2(x + w, y + h), color);
|
||||
DrawLine(new Vector2(x, y + h), new Vector2(x + w, y + h), color);
|
||||
}
|
||||
|
||||
public static void DrawLine(Vector2 lineStart, Vector2 lineEnd, Color color, int thickness)
|
||||
{
|
||||
if (_coloredLineTexture == null || _coloredLineColor != color)
|
||||
{
|
||||
_coloredLineColor = color;
|
||||
_coloredLineTexture = new Texture2D(1, 1);
|
||||
_coloredLineTexture.SetPixel(0, 0, _coloredLineColor);
|
||||
_coloredLineTexture.wrapMode = 0;
|
||||
_coloredLineTexture.Apply();
|
||||
}
|
||||
|
||||
DrawLineStretched(lineStart, lineEnd, _coloredLineTexture, thickness);
|
||||
}
|
||||
|
||||
public static void DrawLineStretched(Vector2 lineStart, Vector2 lineEnd, Texture2D texture, int thickness)
|
||||
{
|
||||
var vector = lineEnd - lineStart;
|
||||
float num = 57.29578f * Mathf.Atan(vector.y / vector.x);
|
||||
if (vector.x < 0f)
|
||||
{
|
||||
num += 180f;
|
||||
}
|
||||
|
||||
if (thickness < 1)
|
||||
{
|
||||
thickness = 1;
|
||||
}
|
||||
|
||||
int yOffset = (int)Mathf.Ceil((float)(thickness / 2));
|
||||
|
||||
GUIUtility.RotateAroundPivot(num, lineStart);
|
||||
GUI.DrawTexture(new Rect(lineStart.x, lineStart.y - (float)yOffset, vector.magnitude, (float)thickness), texture);
|
||||
GUIUtility.RotateAroundPivot(-num, lineStart);
|
||||
}
|
||||
|
||||
public static void DrawLine(Vector2 lineStart, Vector2 lineEnd, Texture2D texture)
|
||||
{
|
||||
DrawLine(lineStart, lineEnd, texture, 1);
|
||||
}
|
||||
|
||||
public static void DrawLine(Vector2 lineStart, Vector2 lineEnd, Texture2D texture, int thickness)
|
||||
{
|
||||
var vector = lineEnd - lineStart;
|
||||
float pivot = 57.29578f * Mathf.Atan(vector.y / vector.x);
|
||||
|
||||
if (vector.x < 0f)
|
||||
{
|
||||
pivot += 180f;
|
||||
}
|
||||
|
||||
if (thickness < 1)
|
||||
{
|
||||
thickness = 1;
|
||||
}
|
||||
|
||||
int num2 = (int)Mathf.Ceil((float)(thickness / 2));
|
||||
var rect = new Rect(lineStart.x, lineStart.y - (float)num2, Vector2.Distance(lineStart, lineEnd), (float)thickness);
|
||||
GUIUtility.RotateAroundPivot(pivot, lineStart);
|
||||
GUI.BeginGroup(rect);
|
||||
int num3 = Mathf.RoundToInt(rect.width);
|
||||
int num4 = Mathf.RoundToInt(rect.height);
|
||||
|
||||
for (int i = 0; i < num4; i += texture.height)
|
||||
{
|
||||
for (int j = 0; j < num3; j += texture.width)
|
||||
{
|
||||
GUI.DrawTexture(new Rect((float)j, (float)i, (float)texture.width, (float)texture.height), texture);
|
||||
}
|
||||
}
|
||||
|
||||
GUI.EndGroup();
|
||||
GUIUtility.RotateAroundPivot(-pivot, lineStart);
|
||||
}
|
||||
}
|
||||
}
|
21
TarkovHax/Properties/AssemblyInfo.cs
Normal file
21
TarkovHax/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
[assembly: AssemblyVersion("1.0.6544.33693")]
|
||||
[assembly: CompilationRelaxations(8)]
|
||||
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
|
||||
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
|
||||
[assembly: AssemblyTitle("UnityTest")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UnityTest")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("87a9c8b1-7e18-410f-b75a-4f3b99f20f53")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
53
TarkovHax/TarkovHax.csproj
Normal file
53
TarkovHax/TarkovHax.csproj
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{10B1EFC0-649C-4CFF-8D13-0D36E868F95D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>TarkovHax</RootNamespace>
|
||||
<AssemblyName>TarkovHax</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\References\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\References\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.Networking">
|
||||
<HintPath>..\References\UnityEngine.Networking.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="GuiHelper.cs" />
|
||||
<Compile Include="TarkovHaxBehaviour.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
255
TarkovHax/TarkovHaxBehaviour.cs
Normal file
255
TarkovHax/TarkovHaxBehaviour.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using System;
|
||||
using EFT;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TarkovHax
|
||||
{
|
||||
public class TarkovHaxBehaviour : MonoBehaviour
|
||||
{
|
||||
public static GameObject GameObjectHolder;
|
||||
|
||||
private float _playerNextUpdateTime;
|
||||
private float _lootNextUpdateTime;
|
||||
private float _lootContainerNextUpdateTime;
|
||||
|
||||
private UnityEngine.Object[] _playerObjects;
|
||||
private UnityEngine.Object[] _lootableObjects;
|
||||
private UnityEngine.Object[] _lootableContainerObjects;
|
||||
|
||||
private bool _isESPMenuActive;
|
||||
private bool _showPlayersESP;
|
||||
private bool _showLootESP;
|
||||
private bool _showLootableContainersESP;
|
||||
|
||||
private float _maxDrawingDistance = 15000f;
|
||||
|
||||
private static void Load()
|
||||
{
|
||||
GameObjectHolder = new GameObject();
|
||||
GameObjectHolder.AddComponent<TarkovHaxBehaviour>();
|
||||
|
||||
DontDestroyOnLoad(GameObjectHolder);
|
||||
}
|
||||
|
||||
public static void Unload()
|
||||
{
|
||||
var component = GameObjectHolder.GetComponent<TarkovHaxBehaviour>();
|
||||
if (component != null)
|
||||
{
|
||||
DestroyImmediate(component, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.End))
|
||||
{
|
||||
Unload();
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Insert))
|
||||
{
|
||||
this._isESPMenuActive = !this._isESPMenuActive;
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Keypad0))
|
||||
{
|
||||
OpenDoors();
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Keypad1))
|
||||
{
|
||||
ToggleNightVision();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.KeypadPlus))
|
||||
{
|
||||
IncreaseFov();
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.KeypadMinus))
|
||||
{
|
||||
DecreaseFov();
|
||||
}
|
||||
}
|
||||
|
||||
private void IncreaseFov()
|
||||
{
|
||||
Camera.main.fieldOfView += 1f;
|
||||
}
|
||||
|
||||
private void DecreaseFov()
|
||||
{
|
||||
Camera.main.fieldOfView -= 1f;
|
||||
}
|
||||
|
||||
private void OpenDoors()
|
||||
{
|
||||
var doors = FindObjectsOfType(typeof(Door));
|
||||
foreach (Door door in doors)
|
||||
{
|
||||
if (door.DoorState == WorldInteractiveObject.EDoorState.Locked)
|
||||
{
|
||||
door.DoorState = WorldInteractiveObject.EDoorState.Shut;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _nightVisionOn = false;
|
||||
private void ToggleNightVision()
|
||||
{
|
||||
//var camera = (PlayerCameraController)FindObjectOfType(typeof(PlayerCameraController));
|
||||
//if (_nightVisionOn)
|
||||
//{
|
||||
// var component = camera.gameObject.AddComponent<NightVision>();
|
||||
// if (component != null)
|
||||
// {
|
||||
// DestroyImmediate(component);
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// camera.gameObject.AddComponent<NightVision>();
|
||||
//}
|
||||
|
||||
//_nightVisionOn = !_nightVisionOn;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (this._isESPMenuActive)
|
||||
{
|
||||
DrawESPMenu();
|
||||
}
|
||||
|
||||
GUI.color = Color.red;
|
||||
GUI.Label(new Rect(10f, 10f, 100f, 50f), "tarkov h4x");
|
||||
|
||||
if (Time.time >= this._playerNextUpdateTime)
|
||||
{
|
||||
this._playerObjects = FindObjectsOfType(typeof(Player));
|
||||
this._playerNextUpdateTime = Time.time + 0.5f;
|
||||
}
|
||||
|
||||
if (this._showLootESP && Time.time >= this._lootNextUpdateTime)
|
||||
{
|
||||
this._lootableObjects = FindObjectsOfType(typeof(LootItem));
|
||||
this._lootNextUpdateTime = Time.time + 0.01f;
|
||||
}
|
||||
|
||||
if (this._showLootableContainersESP && Time.time >= this._lootContainerNextUpdateTime)
|
||||
{
|
||||
this._lootableContainerObjects = FindObjectsOfType(typeof(LootableContainer));
|
||||
this._lootContainerNextUpdateTime = Time.time + 0.01f;
|
||||
}
|
||||
|
||||
if (this._showLootESP)
|
||||
{
|
||||
DrawLoot();
|
||||
}
|
||||
|
||||
if (this._showLootableContainersESP)
|
||||
{
|
||||
DrawLootableContainers();
|
||||
}
|
||||
|
||||
if (this._showPlayersESP)
|
||||
{
|
||||
DrawPlayers();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLoot()
|
||||
{
|
||||
foreach (LootItem lootItem in this._lootableObjects)
|
||||
{
|
||||
float distanceToObject = Vector3.Distance(Camera.main.transform.position, lootItem.transform.position);
|
||||
var viewTransform = new Vector3(
|
||||
Camera.main.WorldToScreenPoint(lootItem.transform.position).x,
|
||||
Camera.main.WorldToScreenPoint(lootItem.transform.position).y,
|
||||
Camera.main.WorldToScreenPoint(lootItem.transform.position).z);
|
||||
|
||||
if (distanceToObject <= _maxDrawingDistance && viewTransform.z > 0.01f)
|
||||
{
|
||||
GUI.color = Color.green;
|
||||
GUI.Label(new Rect(viewTransform.x - 50f, (float)Screen.height - viewTransform.y, 100f, 50f), lootItem.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLootableContainers()
|
||||
{
|
||||
foreach (LootableContainer lootableContainer in this._lootableContainerObjects)
|
||||
{
|
||||
float distanceToObject = Vector3.Distance(Camera.main.transform.position, lootableContainer.transform.position);
|
||||
var viewTransform = new Vector3(
|
||||
Camera.main.WorldToScreenPoint(lootableContainer.transform.position).x,
|
||||
Camera.main.WorldToScreenPoint(lootableContainer.transform.position).y,
|
||||
Camera.main.WorldToScreenPoint(lootableContainer.transform.position).z);
|
||||
|
||||
if (distanceToObject <= _maxDrawingDistance && viewTransform.z > 0.01f)
|
||||
{
|
||||
GUI.color = Color.cyan;
|
||||
GUI.Label(new Rect(viewTransform.x - 50f, (float)Screen.height - viewTransform.y, 100f, 50f), lootableContainer.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPlayers()
|
||||
{
|
||||
foreach (Player player in this._playerObjects)
|
||||
{
|
||||
var playerBoundingVector = new Vector3(
|
||||
Camera.main.WorldToScreenPoint(player.Transform.position).x,
|
||||
Camera.main.WorldToScreenPoint(player.Transform.position).y,
|
||||
Camera.main.WorldToScreenPoint(player.Transform.position).z);
|
||||
|
||||
var playerHeadVector = new Vector3(
|
||||
Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).x,
|
||||
Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).y,
|
||||
Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).z);
|
||||
|
||||
float distanceToObject = Vector3.Distance(Camera.main.transform.position, player.Transform.position);
|
||||
float boxXOffset = Camera.main.WorldToScreenPoint(player.Transform.position).x;
|
||||
float boxYOffset = Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).y + 10f;
|
||||
float boxHeight = Math.Abs(Camera.main.WorldToScreenPoint(player.PlayerBones.Head.position).y - Camera.main.WorldToScreenPoint(player.Transform.position).y) + 10f;
|
||||
float boxWidth = boxHeight * 0.65f;
|
||||
|
||||
if (distanceToObject <= _maxDrawingDistance)
|
||||
{
|
||||
var uiColor = player.Profile.Health.IsAlive ? Color.red : Color.white;
|
||||
GUI.color = uiColor;
|
||||
|
||||
GuiHelper.DrawBox(boxXOffset - boxWidth / 2f, (float)Screen.height - boxYOffset, boxWidth, boxHeight, uiColor);
|
||||
GuiHelper.DrawLine(new Vector2(playerHeadVector.x - 2f, (float)Screen.height - playerHeadVector.y), new Vector2(playerHeadVector.x + 2f, (float)Screen.height - playerHeadVector.y), uiColor);
|
||||
GuiHelper.DrawLine(new Vector2(playerHeadVector.x, (float)Screen.height - playerHeadVector.y - 2f), new Vector2(playerHeadVector.x, (float)Screen.height - playerHeadVector.y + 2f), uiColor);
|
||||
|
||||
string playerName = player.Profile.Health.IsAlive ? player.Profile.Info.Nickname : player.Profile.Info.Nickname + " (DEAD)";
|
||||
int playerHealth = (int)player.HealthController.SummaryHealth.CurrentValue / 435 * 100;
|
||||
int distance = (int)distanceToObject;
|
||||
string playerText = $"[{playerHealth}%] {playerName} [{distance}m]";
|
||||
|
||||
var playerTextVector = GUI.skin.GetStyle(playerText).CalcSize(new GUIContent(playerText));
|
||||
GUI.Label(new Rect(playerBoundingVector.x - playerTextVector.x / 2f, (float)Screen.height - boxYOffset - 20f, 300f, 50f), playerText);
|
||||
|
||||
var weaponTextVector = GUI.skin.GetStyle(player.Weapon.Template.ShortName).CalcSize(new GUIContent(player.Weapon.Template.ShortName));
|
||||
GUI.Label(new Rect(playerBoundingVector.x - weaponTextVector.x / 2f, (float)Screen.height - playerBoundingVector.y + 2f, 100f, 20f), player.Weapon.Template.ShortName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawESPMenu()
|
||||
{
|
||||
GUI.color = Color.black;
|
||||
GUI.Box(new Rect(100f, 100f, 190f, 190f), "");
|
||||
|
||||
GUI.color = Color.white;
|
||||
GUI.Label(new Rect(180f, 110f, 50f, 20f), "ESP");
|
||||
|
||||
this._showPlayersESP = GUI.Toggle(new Rect(110f, 140f, 120f, 20f), this._showPlayersESP, " Players");
|
||||
this._showLootESP = GUI.Toggle(new Rect(110f, 160f, 120f, 20f), this._showLootESP, " Loot");
|
||||
this._showLootableContainersESP = GUI.Toggle(new Rect(110f, 180f, 120f, 20f), this._showLootableContainersESP, " Lootables");
|
||||
}
|
||||
|
||||
private double GetDistance(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
return Math.Sqrt(Math.Pow(x2 - x1, 2.0) + Math.Pow(y2 - y1, 2.0));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user