Code Monkey home page Code Monkey logo

battlefield-2042-internal-sdk's Introduction

battlefield-2042-internal-sdk

Internal Software Development Kit for Battlefield 2042

SDK Includes the following:

  • Entity Classes
  • Player Classes
  • Vehicle Classes
  • Weapon Classes
  • GameContext Class
  • GameRenderer Class
  • ClientPlayerManager Class
  • WorldToScreen Utility
  • Other Useful Utilities

Note: SDK may have issues as it is not fully complete yet, I am still working on it. Entity list iteration is kind of broken as I cannot find the array count to properly iterate it

Usage:

        /* Initialize Module Address and Resolution */
        SDK::Init();
	
	const auto GameRenderer = cGameRenderer::GetInstance();

	if (!IsValidPtr((void*)GameRenderer))
		return;

	const auto RenderView = GameRenderer->GetRenderView();

	if (!IsValidPtr((void*)RenderView))
		return;

	const auto GameContext = cGameContext::GetInstance();

	if (!IsValidPtr((void*)GameContext))
		return;

	const auto ClientPlayerManager = GameContext->GetClientPlayerMgr();

	if (!IsValidPtr((void*)ClientPlayerManager))
		return;

	const auto LocalPlayer = ClientPlayerManager->GetLocalPlayer();

	if (!IsValidPtr((void*)LocalPlayer))
		return;

	const auto lpTeamId = LocalPlayer->GetTeamId();

	const auto lpSoldierEntity = LocalPlayer->GetSoldierEntity();

	if (!IsValidPtr((void*)lpSoldierEntity))
		return;

	const auto lpPosition = lpSoldierEntity->GetPosition();

	if (lpPosition.empty())
		return;

	const auto ClientPlayerArray = ClientPlayerManager->GetClientPlayersArray();

	if (!IsValidPtr((void*)ClientPlayerArray))
		return;

	auto IsSoldier = [](cClientEntity* const clPlayer) -> bool {
		return IsValidPtr((void*)static_cast<cClientPlayer*>(clPlayer)->GetSoldierEntity());
	};

	auto IsInVehicle = [](cClientEntity* const clPlayer) -> bool {
		return IsValidPtr((void*)static_cast<cClientVehicle*>(clPlayer)->GetVehicleEntity());
	};

	for (const auto ClientPlayer : 
		ClientPlayerManager->GetAllClientPlayers(ClientPlayerArray, LocalPlayer))
	{
		if (IsSoldier(ClientPlayer))
		{
			const auto SoldierEntity = static_cast<cClientPlayer*>(ClientPlayer)->GetSoldierEntity();

			if (!IsValidPtr((void*)SoldierEntity))
				continue;

			const auto TeamId = static_cast<cClientPlayer*>(ClientPlayer)->GetTeamId();

			if (TeamId == lpTeamId)
				continue;

			const auto HealthComponent = SoldierEntity->GetHealthComponent();

			if (!IsValidPtr((void*)HealthComponent))
				continue;

			auto Health = HealthComponent->GetHealth();
			auto MaxHealth = HealthComponent->GetMaxHealth();

			if (Health <= 0.f || MaxHealth <= 0.f)
				continue;

			auto PlayerName = static_cast<cClientPlayer*>(ClientPlayer)->GetName().c_str();

			const auto CurrentPosition = SoldierEntity->GetPosition();

			if (CurrentPosition.empty())
				continue;

			auto Distance = lpPosition.distance(CurrentPosition);

			utils::maths::vec3_t ScreenPosition;
			if (!functions::WorldToScreen(RenderView, CurrentPosition, &ScreenPosition))
				continue;

			if (ConfigSys.esp_player)
			{
				rendering::Renderer::GetInstance()->DrawNameTag(PlayerName,
					{ ScreenPosition.x, ScreenPosition.y + 5.f },
					{ 139.f, 69.f, 19.f, 255.f },
					Distance,
					ConfigSys.font_size,
					true,
					Health,
					MaxHealth);
			}
		}

		if (IsInVehicle(ClientPlayer))
		{
			const auto VehicleEnity = static_cast<cClientVehicle*>(ClientPlayer)->GetVehicleEntity();

			if (!IsValidPtr((void*)VehicleEnity))
				continue;

			utils::maths::vec3_t CurrentPosition;
			if (!VehicleEnity->GetPosition(&CurrentPosition))
				continue;

			if (CurrentPosition.empty())
				continue;

			utils::maths::vec3_t ScreenPosition;
			if (!functions::WorldToScreen(RenderView, CurrentPosition, &ScreenPosition))
				continue;
        
			auto Distance = lpPosition.distance(CurrentPosition);

			if (ConfigSys.esp_player)
			{
				rendering::Renderer::GetInstance()->DrawNameTag("Vehicle",
					{ ScreenPosition.x, ScreenPosition.y + 5.f },
					{ 119.f, 80.f, 19.f, 255.f },
					Distance,
					ConfigSys.font_size,
					false);
			}
		}
	}  

battlefield-2042-internal-sdk's People

Contributors

skengdo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.