This commit is contained in:
Hash Borgir 2024-04-29 02:48:40 -06:00
parent 78fcd692b2
commit 27d93fa91e
39 changed files with 491 additions and 43 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

View File

@ -239,6 +239,7 @@ namespace d2_tweaks {
uint8_t target_page; uint8_t target_page;
uint32_t bag_guid = 0; uint32_t bag_guid = 0;
bool updateBag; bool updateBag;
bool removeFromBag;
int prop; int prop;
int val; int val;

View File

@ -25,7 +25,7 @@
#include <shellapi.h> // For ShellExecute #include <shellapi.h> // For ShellExecute
using namespace d2_tweaks::client::modules; using namespace d2_tweaks::client::modules;
bool m_stats_enabled = false; bool m_stats_enabled = true;
bool m_help_enabled = false; bool m_help_enabled = false;
d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settings_toggle_menu(token) { d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settings_toggle_menu(token) {

View File

@ -24,35 +24,6 @@
#include <windows.h> // Include Windows API header for MessageBox #include <windows.h> // Include Windows API header for MessageBox
// Define your deserialization method for the item structure
diablo2::structures::unit unserialize_item(const std::string& itemcode, std::ifstream& file) {
// Read each line from the file
std::string line;
while (std::getline(file, line)) {
// Split the line into item code and serialized data
std::istringstream iss(line);
std::string code;
std::getline(iss, code, ':');
if (code == itemcode) {
// Found matching item code, extract serialized data
std::string serializedData;
std::getline(iss, serializedData);
// Convert serialized data from hexadecimal string to binary
std::istringstream hexStream(serializedData);
diablo2::structures::unit item;
for (size_t i = 0; i < sizeof(item); ++i) {
int byte;
if (!(hexStream >> std::hex >> byte)) {
throw std::invalid_argument("Error reading serialized data");
}
reinterpret_cast<char*>(&item)[i] = static_cast<char>(byte);
}
return item;
}
}
// Item code not found
throw std::invalid_argument("Item code not found");
}
#include <iomanip> // For std::setw #include <iomanip> // For std::setw
@ -69,8 +40,6 @@ void serialize_item(const std::string& itemcode, const diablo2::structures::unit
file << std::endl; file << std::endl;
} }
MODULE_INIT(item_move) MODULE_INIT(item_move)
void d2_tweaks::server::modules::item_move::init() { void d2_tweaks::server::modules::item_move::init() {
@ -86,6 +55,7 @@ void d2_tweaks::server::modules::item_move::init() {
} }
// handle packet coming from the client // handle packet coming from the client
bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::game* game, bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::game* game,
diablo2::structures::unit* player, common::packet_header* packet) { diablo2::structures::unit* player, common::packet_header* packet) {
@ -99,6 +69,10 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
//MessageBox(NULL, key, "Item code", MB_OK | MB_ICONINFORMATION); //MessageBox(NULL, key, "Item code", MB_OK | MB_ICONINFORMATION);
const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
const char* itemcode = itemMove->item_code; const char* itemcode = itemMove->item_code;
const auto bag = instance.get_server_unit(game, itemMove->bag_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item const auto bag = instance.get_server_unit(game, itemMove->bag_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
@ -113,9 +87,6 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
if (item == nullptr) if (item == nullptr)
return true; //block further packet processing return true; //block further packet processing
const auto inventoryIndex = diablo2::d2_common::get_inventory_index(player, itemMove->target_page, game->item_format == 101); const auto inventoryIndex = diablo2::d2_common::get_inventory_index(player, itemMove->target_page, game->item_format == 101);
uint32_t tx, ty; uint32_t tx, ty;
@ -142,6 +113,20 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
diablo2::d2_net::send_to_client(1, client->client_id, &resp, sizeof resp); diablo2::d2_net::send_to_client(1, client->client_id, &resp, sizeof resp);
if (itemMove->removeFromBag == 1) {
// here we need to add item to inventory
diablo2::structures::unit* item;
// or I can do something like this,
// when extractor is clicked, send the bag and extractor to cube,
const auto player = diablo2::d2_client::get_local_player();
}
if (itemMove->updateBag == 1) { if (itemMove->updateBag == 1) {

View File

@ -141,8 +141,109 @@ HWND g_hEditBox = nullptr;
// Declare a variable to store the input text // Declare a variable to store the input text
std::vector<char> g_inputText(256, '\0'); // Adjust the size according to your needs std::vector<char> g_inputText(256, '\0'); // Adjust the size according to your needs
// Function to read the first line from the file and extract hex bytes after ':'
std::string readFirstLineAndExtractHex(const std::string& fileName) {
std::ifstream file(fileName);
if (!file.is_open()) {
std::cerr << "Error opening file: " << fileName << std::endl;
return "";
}
std::string line;
std::getline(file, line); // Read the first line from the file
file.close(); // Close the file
// Find the position of ':' in the line
size_t colonPos = line.find(':');
if (colonPos == std::string::npos) {
std::cerr << "Colon not found in the first line of file: " << fileName << std::endl;
return "";
}
// Extract hex bytes after ':' and return
std::string hexBytes = line.substr(colonPos + 1);
return hexBytes;
}
// Function to delete the first line from the file
void deleteFirstLine(const std::string& fileName) {
std::ifstream inFile(fileName);
if (!inFile.is_open()) {
std::cerr << "Error opening file: " << fileName << std::endl;
return;
}
// Read the contents of the file except the first line
std::vector<std::string> lines;
std::string line;
while (std::getline(inFile, line)) {
lines.push_back(line);
}
inFile.close();
// Write the contents back to the file, excluding the first line
std::ofstream outFile(fileName);
if (!outFile.is_open()) {
std::cerr << "Error opening file: " << fileName << std::endl;
return;
}
for (size_t i = 1; i < lines.size(); ++i) {
outFile << lines[i] << std::endl;
}
outFile.close();
}
//// Define your deserialization method for the item structure
//diablo2::structures::unit unserialize_item(const std::string& itemcode, std::ifstream& file) {
// // Read each line from the file
// std::string line;
// while (std::getline(file, line)) {
// // Split the line into item code and serialized data
// std::istringstream iss(line);
// std::string code;
// std::getline(iss, code, ':');
// if (code == itemcode) {
// // Found matching item code, extract serialized data
// std::string serializedData;
// std::getline(iss, serializedData);
// // Convert serialized data from hexadecimal string to binary
// std::istringstream hexStream(serializedData);
// diablo2::structures::unit item;
// for (size_t i = 0; i < sizeof(item); ++i) {
// int byte;
// if (!(hexStream >> std::hex >> byte)) {
// throw std::invalid_argument("Error reading serialized data");
// }
// reinterpret_cast<char*>(&item)[i] = static_cast<char>(byte);
// }
// return item;
// }
// }
// // Item code not found
// throw std::invalid_argument("Item code not found");
//}
#include <stdexcept>
// Unserialize the hexadecimal string to an item structure
diablo2::structures::unit unserialize_item(const std::string& hexString) {
if (hexString.size() % 2 != 0) {
throw std::invalid_argument("Invalid hex string length");
}
// Create an item object
diablo2::structures::unit item;
// Convert the hexadecimal string to binary data
for (size_t i = 0; i < hexString.size(); i += 2) {
std::string byteStr = hexString.substr(i, 2);
unsigned int byte;
std::istringstream(byteStr) >> std::hex >> byte;
reinterpret_cast<unsigned char*>(&item)[i / 2] = static_cast<unsigned char>(byte);
}
return item;
}
LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
static auto& instance = singleton<ui_manager>::instance(); static auto& instance = singleton<ui_manager>::instance();
@ -155,6 +256,113 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
block = true; // block the game from processing this key block = true; // block the game from processing this key
} }
// Send item move packet + transmute packet for certain codes only for runes and gems
if (wParam == 'G') {
// Call the item_click function using the function pointer
const auto g_hoverItem = (*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4));
if (g_hoverItem != 0) {
const auto record = diablo2::d2_common::get_item_record(g_hoverItem->data_record_index);
char* normCode = record->string_code;
if (strncmp(normCode, "gcv", 3) == 0 ||
strncmp(normCode, "gcw", 3) == 0 ||
strncmp(normCode, "gcg", 3) == 0 ||
strncmp(normCode, "gcr", 3) == 0 ||
strncmp(normCode, "gcb", 3) == 0 ||
strncmp(normCode, "skc", 3) == 0 ||
strncmp(normCode, "gcy", 3) == 0 ||
strncmp(normCode, "gfv", 3) == 0 ||
strncmp(normCode, "gfw", 3) == 0 ||
strncmp(normCode, "gfg", 3) == 0 ||
strncmp(normCode, "gfr", 3) == 0 ||
strncmp(normCode, "gfb", 3) == 0 ||
strncmp(normCode, "skf", 3) == 0 ||
strncmp(normCode, "gfy", 3) == 0 ||
strncmp(normCode, "gsv", 3) == 0 ||
strncmp(normCode, "gsw", 3) == 0 ||
strncmp(normCode, "gsg", 3) == 0 ||
strncmp(normCode, "gsr", 3) == 0 ||
strncmp(normCode, "gsb", 3) == 0 ||
strncmp(normCode, "sku", 3) == 0 ||
strncmp(normCode, "gsy", 3) == 0 ||
strncmp(normCode, "gzv", 3) == 0 ||
strncmp(normCode, "glw", 3) == 0 ||
strncmp(normCode, "glg", 3) == 0 ||
strncmp(normCode, "glr", 3) == 0 ||
strncmp(normCode, "glb", 3) == 0 ||
strncmp(normCode, "skl", 3) == 0 ||
strncmp(normCode, "gly", 3) == 0 ||
strncmp(normCode, "gpv", 3) == 0 ||
strncmp(normCode, "gpw", 3) == 0 ||
strncmp(normCode, "gpg", 3) == 0 ||
strncmp(normCode, "gpr", 3) == 0 ||
strncmp(normCode, "gpb", 3) == 0 ||
strncmp(normCode, "skz", 3) == 0 ||
strncmp(normCode, "gpy", 3) == 0 ||
strncmp(normCode, "ib1", 3) == 0 ||
// Runes
strncmp(normCode, "r01", 3) == 0 ||
strncmp(normCode, "r02", 3) == 0 ||
strncmp(normCode, "r03", 3) == 0 ||
strncmp(normCode, "r04", 3) == 0 ||
strncmp(normCode, "r05", 3) == 0 ||
strncmp(normCode, "r06", 3) == 0 ||
strncmp(normCode, "r07", 3) == 0 ||
strncmp(normCode, "r08", 3) == 0 ||
strncmp(normCode, "r09", 3) == 0 ||
strncmp(normCode, "r10", 3) == 0 ||
strncmp(normCode, "r11", 3) == 0 ||
strncmp(normCode, "r12", 3) == 0 ||
strncmp(normCode, "r13", 3) == 0 ||
strncmp(normCode, "r14", 3) == 0 ||
strncmp(normCode, "r15", 3) == 0 ||
strncmp(normCode, "r16", 3) == 0 ||
strncmp(normCode, "r17", 3) == 0 ||
strncmp(normCode, "r18", 3) == 0 ||
strncmp(normCode, "r19", 3) == 0 ||
strncmp(normCode, "r20", 3) == 0 ||
strncmp(normCode, "r21", 3) == 0 ||
strncmp(normCode, "r22", 3) == 0 ||
strncmp(normCode, "r23", 3) == 0 ||
strncmp(normCode, "r24", 3) == 0 ||
strncmp(normCode, "r25", 3) == 0 ||
strncmp(normCode, "r26", 3) == 0 ||
strncmp(normCode, "r27", 3) == 0 ||
strncmp(normCode, "r28", 3) == 0 ||
strncmp(normCode, "r29", 3) == 0 ||
strncmp(normCode, "r30", 3) == 0 ||
strncmp(normCode, "r31", 3) == 0 ||
strncmp(normCode, "r32", 3) == 0 ||
strncmp(normCode, "r33", 3) == 0 ||
strncmp(normCode, "ib2", 3) == 0
) {
char currentPage = diablo2::d2_common::get_item_page(g_hoverItem);
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = g_hoverItem->guid;
if (currentPage == 0) { //item is in inventory
if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH))
packet.target_page = 4;
if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_CUBE))
packet.target_page = 3;
}
else {
packet.target_page = 0;
}
diablo2::d2_client::send_to_server(&packet, sizeof packet);
(*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4)) = nullptr;
diablo2::d2_client::send_to_server_7(0x4F, 0x18, 0, 0);
}
}
block = true; // block the game from processing this key
}
// Send item move packet + transmute packet for certain codes // Send item move packet + transmute packet for certain codes
if (wParam == 'Z') { if (wParam == 'Z') {
// Call the item_click function using the function pointer // Call the item_click function using the function pointer
@ -281,9 +489,10 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
} }
} }
block = true; // block the game from processing this key
} }
/*
if (wParam == 'G') { if (wParam == 'G') {
const auto g_hoverItem = *reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4); const auto g_hoverItem = *reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4);
if (g_hoverItem != nullptr) { if (g_hoverItem != nullptr) {
@ -349,6 +558,8 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
//} //}
} }
} }
*/
switch (msg) { switch (msg) {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
@ -365,14 +576,18 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
{ {
const auto player = diablo2::d2_client::get_local_player();
auto pInventory = player->inventory;
int32_t gemBagGuid = 0; int32_t gemBagGuid = 0;
const auto g_hoverItem = *reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4); const auto g_hoverItem = *reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4);
if (g_hoverItem != nullptr) { if (g_hoverItem != nullptr) {
const auto record = diablo2::d2_common::get_item_record(g_hoverItem->data_record_index); const auto record = diablo2::d2_common::get_item_record(g_hoverItem->data_record_index);
char* normCode = record->string_code; char* normCode = record->string_code;
/*
if (strncmp(normCode, "ib1", 3) == 0) { if (strncmp(normCode, "ib1", 3) == 0) {
// display Messagebox with normCode // display Messagebox with normCode
//MessageBoxA(0, normCode, "normCode", 0); //MessageBoxA(0, normCode, "normCode", 0);
@ -380,12 +595,40 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
// we need to get the user input and store it in a variable // we need to get the user input and store it in a variable
// we need to use win32 api to get the user input using editbox control, simple inputbox, not using resources.rc // we need to use win32 api to get the user input using editbox control, simple inputbox, not using resources.rc
// Get the player name
const auto player = diablo2::d2_client::get_local_player();
std::string playerName = player->player_data->name;
// Construct the file name
std::string fileName = "./Save/" + playerName + ".boh";
// Read the first line from the file and extract hex bytes after ':'
std::string hexBytes = readFirstLineAndExtractHex(fileName);
if (hexBytes.empty()) {
// Error handling
return 1;
}
// Output the extracted hex bytes using MessageBox
MessageBoxA(0, hexBytes.c_str(), "Extracted hex bytes", 0);
diablo2::structures::unit item = unserialize_item(hexBytes);
// Display the item guid using MessageBox
MessageBoxA(0, std::to_string(item.guid).c_str(), "Item GUID", 0);
// Delete the first line from the file
deleteFirstLine(fileName);
const auto record1 = diablo2::d2_common::get_item_record(item.data_record_index);
char* normCode = record1->string_code;
MessageBoxA(0, normCode, "normCode", 0);
} }
*/
const auto player = diablo2::d2_client::get_local_player();
auto pInventory = player->inventory;
std::vector<diablo2::structures::unit*> items; std::vector<diablo2::structures::unit*> items;
diablo2::structures::unit* gemBag{}; diablo2::structures::unit* gemBag{};
@ -518,13 +761,224 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
packet.val = itemProperty.nMin; packet.val = itemProperty.nMin;
packet.target_page = 99; packet.target_page = 99;
diablo2::d2_client::send_to_server(&packet, sizeof packet); diablo2::d2_client::send_to_server(&packet, sizeof packet);
}
}
}
}
static std::unordered_map<std::string, GemType> exTypes = {
{"gcv", {-1, 382}}, // Chipped Amethyst
{"gcw", {-1, 383}}, // Chipped Diamond
{"gcg", {-1, 384}}, // Chipped Emerald
{"gcr", {-1, 381}}, // Chipped Ruby
{"gcb", {-1, 385}}, // Chipped Sapphire
{"skc", {-1, 387}}, // Chipped Skull
{"gcy", {-1, 386}}, // Chipped Topaz
{"gfv", {-3, 382}}, // Flawed Amethyst
{"gfw", {-3, 383}}, // Flawed Diamond
{"gfg", {-3, 384}}, // Flawed Emerald
{"gfr", {-3, 381}}, // Flawed Ruby
{"gfb", {-3, 385}}, // Flawed Sapphire
{"skf", {-3, 387}}, // Flawed Skull
{"gfy", {-3, 386}}, // Flawed Topaz
{"gsv", {-9, 382}}, // Amethyst
{"gsw", {-9, 383}}, // Diamond
{"gsg", {-9, 384}}, // Emerald
{"gsr", {-9, 381}}, // Ruby
{"gsb", {-9, 385}}, // Sapphire
{"sku", {-9, 387}}, // Skull
{"gsy", {-9, 386}}, // Topaz
{"gzv", {-27, 382}}, // Flawless Amethyst
{"glw", {-27, 383}}, // Flawless Diamond
{"glg", {-27, 384}}, // Flawless Emerald
{"glr", {-27, 381}}, // Flawless Ruby
{"glb", {-27, 385}}, // Flawless Sapphire
{"skl", {-27, 387}}, // Flawless Skull
{"gly", {-27, 386}}, // Flawless Topaz
{"gpv", {-81, 382}}, // Perfect Amethyst
{"gpw", {-81, 383}}, // Perfect Diamond
{"gpg", {-81, 384}}, // Perfect Emerald
{"gpr", {-81, 381}}, // Perfect Ruby
{"gpb", {-81, 385}}, // Perfect Sapphire
{"skz", {-81, 387}}, // Perfect Skull
{"gpy", {-81, 386}}, // Perfect Topaz
{"x01", {-1, 388}}, // El Rune
{"x02", {-3, 388}}, // Eld Rune
{"x03", {-9, 388}}, // Tir Rune
{"x04", {-27, 388}}, // Nef Rune
{"x05", {-81, 388}}, // Eth Rune
{"x06", {-243, 388}}, // Ith Rune
{"x07", {-1, 389}}, // Tal Rune
{"x08", {-3, 389}}, // Ral Rune
{"x09", {-9, 389}}, // Ort Rune
{"x10", {-27, 389}}, // Thul Rune
{"x11", {-81, 389}}, // Amn Rune
{"x12", {-243, 389}}, // Sol Rune
{"x13", {-1, 390}}, // Shael Rune
{"x14", {-3, 390}}, // Dol Rune
{"x15", {-9, 390}}, // Hel Rune
{"x16", {-27, 390}}, // Io Rune
{"x17", {-81, 390}}, // Lum Rune
{"x18", {-243, 390}}, // Ko Rune
{"x19", {-1, 391}}, // Fal Rune
{"x20", {-3, 391}}, // Lem Rune
{"x21", {-9, 391}}, // Pul Rune
{"x22", {-27, 391}}, // Um Rune
{"x23", {-81, 3901}}, // Mal Rune
{"x24", {-243, 391}}, // Ist Rune
{"x25", {-1, 392}}, // Gul Rune
{"x26", {-3, 392}}, // Vex Rune
{"x27", {-9, 392}}, // Ohm Rune
{"x28", {-27, 392}}, // Lo Rune
{"x29", {-81, 392}}, // Sur Rune
{"x30", {-243, 392}}, // Ber Rune
{"x31", {-1, 393}}, // Jah Rune
{"x32", {-2, 393}}, // Cham Rune
{"x33", {-4, 393}} // Zod Rune
};
/*
if (currentPage == 0 || currentPage == 3 || currentPage == 4) {
if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH) || diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_CUBE) || diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_INVENTORY)) {
for (const auto& gem : exTypes) {
// Accessing key and value
const std::string& _key = gem.first;
key = gem.first.c_str();
const GemType& value = gem.second;
if (strncmp(normCode, key, 3) == 0) {
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = value.rowID - 3;
itemProperty.nLayer = 0;
itemProperty.nMin = value.chippedCount;
itemProperty.nMax = value.chippedCount;
diablo2::d2_common::add_property(gemBag, &itemProperty, 0);
diablo2::d2_client::play_sound(record->drop_sound, nullptr, 0, 0, 0);
//MessageBoxA(0, key, "key", 0);
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = g_hoverItem->guid;
packet.item_code = key;
packet.bag_guid = gemBagGuid;
packet.updateBag = 1;
packet.removeFromBag = 1;
packet.prop = itemProperty.nProperty;
packet.val = itemProperty.nMin;
packet.target_page = 99;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
}
}
}
}
*/
// If Cube is open, then if we right click certain item codes, they should be moved to the cube, send transmute packet, and then move the item back to the inventory
if (currentPage == 0 || currentPage == 3 || currentPage == 4) {
if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH) || diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_CUBE) || diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_INVENTORY)) {
for (const auto& gem : exTypes) {
// Accessing key and value
const std::string& _key = gem.first;
key = gem.first.c_str();
const GemType& value = gem.second;
if (strncmp(normCode, key, 3) == 0) {
char currentPage = diablo2::d2_common::get_item_page(g_hoverItem);
// Create the packet to send hover item to cube
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = g_hoverItem->guid;
packet.target_page = 3;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
static d2_tweaks::common::item_move_cs packetBag;
packetBag.item_guid = gemBag->guid;
packetBag.target_page = 3;
diablo2::d2_client::send_to_server(&packetBag, sizeof packetBag);
// send transmute button packet
diablo2::d2_client::send_to_server_7(0x4F, 0x18, 0, 0);
(*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4)) = nullptr;
// Create the packet to send bag back to inventory
//static d2_tweaks::common::item_move_cs packetItemBack;
//packetItemBack.item_guid = gemBag->guid;
//packetItemBack.target_page = 0;
//diablo2::d2_client::send_to_server(&packetItemBack, sizeof packetItemBack);
//static d2_tweaks::common::item_move_cs packetBagBack;
//packetBagBack.item_guid = gemBag->guid;
//packetBagBack.target_page = 0;
//diablo2::d2_client::send_to_server(&packetBagBack, sizeof packetBagBack);
/*
// Create the packet to send bag to cube
packet.item_guid = gemBag->guid;
if (currentPage == 0) { //item is in inventory
if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH))
packet.target_page = 4;
if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_CUBE))
packet.target_page = 3;
}
else {
packet.target_page = 0;
}
diablo2::d2_client::send_to_server(&packet, sizeof packet);
// send transmute button packet
diablo2::d2_client::send_to_server_7(0x4F, 0x18, 0, 0);
// after transmute, move item and bag back to inventory
packet.item_guid = gemBag->guid;
packet.target_page = 0;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
packet.item_guid = g_hoverItem->guid;
packet.target_page = 0;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
*/
} }
} }
} }
} }
// Move items from cube to inventory
const auto player = diablo2::d2_client::get_local_player();
for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) {
if (item->item_data->page == 1) { // Item is in the cube
// display item guid in a messagebox
MessageBoxA(0, std::to_string(item->guid).c_str(), "Item GUID", 0);
static d2_tweaks::common::item_move_cs movePacket;
movePacket.item_guid = item->guid;
movePacket.target_page = 0; // Move to inventory
diablo2::d2_client::send_to_server(&movePacket, sizeof movePacket);
}
}
} }
block = instance.process_right_mouse(false); block = instance.process_right_mouse(false);