Skip to content
Permalink
Browse files

Merge PR #2307: Plugin update for latest version of Rocket League

  • Loading branch information...
mkrautz committed May 25, 2016
2 parents 7164d3d + da1d081 commit 3eec33aea62566779163a1e052bbbaad6b4be102
Showing with 56 additions and 24 deletions.
  1. +56 −24 plugins/rl/rl.cpp
@@ -7,47 +7,79 @@

static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) {
for (int i=0;i<3;i++)
avatar_pos[i]=avatar_front[i]=avatar_top[i]=0.0f;
avatar_pos[i]=avatar_front[i]=avatar_top[i]=camera_pos[i]=camera_front[i]=camera_top[i]=0.0f;

// Boolean value to check if game addresses retrieval is successful
bool ok;

// Create containers to stuff our raw data into, so we can convert it to Mumble's coordinate system
float pos_corrector[3];

// Peekproc and assign game addresses to our containers, so we can retrieve positional data
ok = peekProc((BYTE *) pModule + 0x015F4EF0, &pos_corrector, 12);

// Create containers to stuff our raw data into, so we can convert it to Mumble's coordinate system
float avatar_pos_corrector[3], camera_pos_corrector[3], avatar_front_corrector[3], camera_front_corrector[3], camera_top_corrector[3];

// Avatar pointers
BYTE *avatar_base = peekProc<BYTE *>(pModule + 0x016EA900);
if (!avatar_base) return false;
BYTE *avatar_offset_0 = peekProc<BYTE *>(avatar_base + 0x44);
if (!avatar_offset_0) return false;
BYTE *avatar_offset_1 = peekProc<BYTE *>(avatar_offset_0 + 0x4C);
if (!avatar_offset_1) return false;
BYTE *avatar_offset = peekProc<BYTE *>(avatar_offset_1 + 0x1C);
if (!avatar_offset) return false;

// Peekproc and assign game addresses to our containers, so we can retrieve positional data
ok = peekProc((BYTE *) avatar_offset + 0x0, &avatar_pos_corrector, 12) && // Avatar Position values (Z, Y and X).
peekProc((BYTE *) pModule + 0x016EAB30, &camera_pos_corrector, 12) && // Camera Position values (Z, Y and X).
peekProc((BYTE *) avatar_offset + 0xC, &avatar_front_corrector, 12) && // Avatar Front values (Z, Y and X).
peekProc((BYTE *) pModule + 0x016EAB18, &camera_front_corrector, 12) && // Camera Front Vector values (Z, Y and X).
peekProc((BYTE *) pModule + 0x016EAB24, &camera_top_corrector, 12); // Camera Top Vector values (Z, Y and X).

// This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses.
if (! ok)
return false;

// X = pModule + 0x015F4EF8
// Y = pModule + 0x015F4EF4
// Z = pModule + 0x015F4EF0
avatar_pos[0] = pos_corrector[2];
avatar_pos[1] = pos_corrector[1];
avatar_pos[2] = pos_corrector[0];
/*
Mumble | Game
X | Z
Y | Y
Z | X
*/
avatar_pos[0] = avatar_pos_corrector[2];
avatar_pos[1] = avatar_pos_corrector[1];
avatar_pos[2] = avatar_pos_corrector[0];

for (int i=0;i<3;i++)
avatar_pos[i]/=100.0f; // Scale to meters
camera_pos[0] = camera_pos_corrector[2];
camera_pos[1] = camera_pos_corrector[1];
camera_pos[2] = camera_pos_corrector[0];

avatar_front[0] = avatar_front_corrector[2];
avatar_front[1] = avatar_front_corrector[1];
avatar_front[2] = avatar_front_corrector[0];

avatar_top[2] = -1; // This tells Mumble to automatically calculate top vector using front vector.

camera_front[0] = camera_front_corrector[2];
camera_front[1] = camera_front_corrector[1];
camera_front[2] = camera_front_corrector[0];

camera_top[0] = camera_top_corrector[2];
camera_top[1] = camera_top_corrector[1];
camera_top[2] = camera_top_corrector[0];

// Scale from centimeters to meters
for (int i=0;i<3;i++) {
camera_pos[i] = avatar_pos[i];
camera_front[i] = avatar_front[i];
camera_top[i] = avatar_top[i];
avatar_pos[i]/=100.0f;
camera_pos[i]/=100.0f;
}

return true;
}

static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {

if (! initialize(pids, L"RocketLeague.exe"))
if (! initialize(pids, L"RocketLeague.exe")) // Link the game executable
return false;

// Check if we can get meaningful data from it
float apos[3], afront[3], atop[3];
float cpos[3], cfront[3], ctop[3];
float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3];
std::wstring sidentity;
std::string scontext;

@@ -60,11 +92,11 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
}

static const std::wstring longdesc() {
return std::wstring(L"Supports Rocket League version 1.17 without context or identity support yet.");
return std::wstring(L"Supports Rocket League version 1.18 without context or identity support yet."); // Plugin long description
}

static std::wstring description(L"Rocket League (v1.17)");
static std::wstring shortname(L"Rocket League");
static std::wstring description(L"Rocket League (v1.18)"); // Plugin short description
static std::wstring shortname(L"Rocket League"); // Plugin short name

static int trylock1() {
return trylock(std::multimap<std::wstring, unsigned long long int>());

0 comments on commit 3eec33a

Please sign in to comment.
You can’t perform that action at this time.