Skip to content

Commit

Permalink
- Added API GetInventoryItemTransmog for transmogrification
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostAtom committed Oct 31, 2022
1 parent 9a0048c commit ea70d19
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 1 deletion.
11 changes: 11 additions & 0 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[C_NamePlates](#c_nameplate) - [Inventory](#inventory) - [Misc](#misc)

# C_NamePlate
Backported C-Lua interfaces from retail

Expand Down Expand Up @@ -45,6 +47,15 @@ Default: **43**

Sets the display distance of nameplates in yards

# Inventory

## GetInventoryItemTransmog`API`
Arguments: **unitId**`string`, **slot**`number`

Returns: **itemId**`number`, **enchantId**`number`

Returns info about item transmogrification

# Misc

## FlashWindow`API`
Expand Down
2 changes: 1 addition & 1 deletion src/AwesomeWotlkLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_library(
"Entry.cpp"

GameClient.h
"NamePlates.h" "NamePlates.cpp" "Hooks.h" "Hooks.cpp" "Misc.h" "Misc.cpp" "BugFixes.h" "BugFixes.cpp" "Utils.h" "Utils.cpp" "CommandLine.cpp" "CommandLine.h")
"NamePlates.h" "NamePlates.cpp" "Hooks.h" "Hooks.cpp" "Misc.h" "Misc.cpp" "BugFixes.h" "BugFixes.cpp" "Utils.h" "Utils.cpp" "CommandLine.cpp" "CommandLine.h" "Inventory.cpp" "Inventory.h")

target_include_directories(
${PROJECT_NAME} PRIVATE
Expand Down
2 changes: 2 additions & 0 deletions src/AwesomeWotlkLib/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "NamePlates.h"
#include "Misc.h"
#include "Hooks.h"
#include "Inventory.h"
#include <Windows.h>
#include <Detours/detours.h>

Expand Down Expand Up @@ -32,6 +33,7 @@ static void OnAttach()
Hooks::initialize();
BugFixes::initialize();
CommandLine::initialize();
Inventory::initialize();
NamePlates::initialize();
Misc::initialize();
DetourTransactionCommit();
Expand Down
38 changes: 38 additions & 0 deletions src/AwesomeWotlkLib/GameClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ struct lua_State;
struct WorldFrame;
struct Camera;
struct Object;
struct Unit;
struct Player;

struct Frame {
int gap[2];
Expand Down Expand Up @@ -41,6 +43,33 @@ struct ObjectEntry {
};
static_assert(sizeof(ObjectEntry) == 0x18);

struct UnitEntry : ObjectEntry {
char gap[0x250 - sizeof(ObjectEntry)];
};
static_assert(sizeof(UnitEntry) == 0x250);

struct PlayerQuest {
int a1, a2, a3, a4, a5;
};
static_assert(sizeof(PlayerQuest) == 0x14);

struct PlayerVisibleItem {
int entryId;
int enchant;
};
static_assert(sizeof(PlayerVisibleItem) == 0x8);

struct PlayerEntry : UnitEntry {
guid_t duelArbiter;
uint32_t flags;
uint32_t guildId, guildRank;
uint32_t bytes1, bytes2, bytes3;
uint32_t duelTeam;
uint32_t guildTimestamp;
PlayerQuest quests[25];
PlayerVisibleItem visibleItems[19];
};

struct Object {
ObjectVtbl* vmt;
int field4;
Expand All @@ -49,6 +78,14 @@ struct Object {
Frame* nameplate;
};

struct Unit : Object {
void* dummy;
};

struct Player : Unit {
void* dummy;
};

enum ObjectFlags : uint32_t {
ObjectFlags_Unit = 0x8,
};
Expand Down Expand Up @@ -367,6 +404,7 @@ typedef struct luaL_Reg {

inline void luaL_checktype(lua_State* L, int idx, int t) { return ((decltype(&luaL_checktype))0x0084F960)(L, idx, t); }
inline const char* luaL_checklstring(lua_State* L, int idx, size_t* len) { return ((decltype(&luaL_checklstring))0x0084F9F0)(L, idx, len); }
inline lua_Number luaL_checknumber(lua_State* L, int idx) { return ((decltype(&luaL_checknumber))0x84FAB0)(L, idx); }
inline void* lua_touserdata(lua_State* L, int idx) { return ((decltype(&lua_touserdata))0x0084E1C0)(L, idx); }
inline void lua_pushstring(lua_State* L, const char* str) { return ((decltype(&lua_pushstring))0x0084E350)(L, str); }
inline void lua_pushvalue(lua_State* L, int idx) { return ((decltype(&lua_pushvalue))0x0084DE50)(L, idx); }
Expand Down
28 changes: 28 additions & 0 deletions src/AwesomeWotlkLib/Inventory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Inventory.h"
#include "Hooks.h"
#include "GameClient.h"


static int lua_GetInventoryItemTransmog(lua_State* L)
{
const char* unit = luaL_checkstring(L, 1);
int id = luaL_checknumber(L, 2) - 1;
Player* player = (Player*)ObjectMgr::Get(unit, ObjectFlags_Unit);
if (!player || (id < 0 || id >= 19)) return 0;
PlayerEntry* entry = (PlayerEntry*)player->entry;
lua_pushnumber(L, entry->visibleItems[id].entryId);
lua_pushnumber(L, entry->visibleItems[id].enchant);
return 2;
}

static int lua_openlibinventory(lua_State* L)
{
lua_pushcfunction(L, lua_GetInventoryItemTransmog);
lua_setglobal(L, "GetInventoryItemTransmog");
return 0;
}

void Inventory::initialize()
{
Hooks::FrameXML::registerLuaLib(lua_openlibinventory);
}
5 changes: 5 additions & 0 deletions src/AwesomeWotlkLib/Inventory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

namespace Inventory {
void initialize();
}

0 comments on commit ea70d19

Please sign in to comment.