diff --git a/build/Debug/D2tweaks.ilk b/build/Debug/D2tweaks.ilk index faa5867..729bdf3 100644 Binary files a/build/Debug/D2tweaks.ilk and b/build/Debug/D2tweaks.ilk differ diff --git a/build/Debug/D2tweaks.tlog/CL.command.1.tlog b/build/Debug/D2tweaks.tlog/CL.command.1.tlog index c3aef5c..38fc941 100644 Binary files a/build/Debug/D2tweaks.tlog/CL.command.1.tlog and b/build/Debug/D2tweaks.tlog/CL.command.1.tlog differ diff --git a/build/Debug/D2tweaks.tlog/CL.read.1.tlog b/build/Debug/D2tweaks.tlog/CL.read.1.tlog index 9664f2a..5c80550 100644 Binary files a/build/Debug/D2tweaks.tlog/CL.read.1.tlog and b/build/Debug/D2tweaks.tlog/CL.read.1.tlog differ diff --git a/build/Debug/D2tweaks.tlog/CL.write.1.tlog b/build/Debug/D2tweaks.tlog/CL.write.1.tlog index 73a6bf3..90ff45c 100644 Binary files a/build/Debug/D2tweaks.tlog/CL.write.1.tlog and b/build/Debug/D2tweaks.tlog/CL.write.1.tlog differ diff --git a/build/Debug/D2tweaks.tlog/link.read.1.tlog b/build/Debug/D2tweaks.tlog/link.read.1.tlog index 5597e98..3cd0a7f 100644 Binary files a/build/Debug/D2tweaks.tlog/link.read.1.tlog and b/build/Debug/D2tweaks.tlog/link.read.1.tlog differ diff --git a/build/Debug/src/d2tweaks/client/client.obj b/build/Debug/src/d2tweaks/client/client.obj index 2512122..f583c40 100644 Binary files a/build/Debug/src/d2tweaks/client/client.obj and b/build/Debug/src/d2tweaks/client/client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj b/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj index a148a3f..0d1d620 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj and b/build/Debug/src/d2tweaks/client/modules/auto_gold_pickup/auto_gold_pickup_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj b/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj index 89982ef..11829cd 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj and b/build/Debug/src/d2tweaks/client/modules/auto_item_pickup/auto_item_pickup_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj b/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj index b629645..25d7028 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj and b/build/Debug/src/d2tweaks/client/modules/autosort/autosort_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/client_module.obj b/build/Debug/src/d2tweaks/client/modules/client_module.obj index 90136e5..583c108 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/client_module.obj and b/build/Debug/src/d2tweaks/client/modules/client_module.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj b/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj index 3ef60be..425631b 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj and b/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj b/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj index d0f4c48..308ab0d 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj and b/build/Debug/src/d2tweaks/client/modules/item_drop_message/item_drop_message_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj b/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj index ccf9d04..5f626d0 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj and b/build/Debug/src/d2tweaks/client/modules/item_move/item_move_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj index 7a545cc..77b690e 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj and b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj index 1342611..f6028eb 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj and b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj index ec48c2c..8bb4465 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj and b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj b/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj index 60ab557..7b9825a 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj and b/build/Debug/src/d2tweaks/client/modules/trader_update/trader_update_client.obj differ diff --git a/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj b/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj index 752a258..6be8bca 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj and b/build/Debug/src/d2tweaks/client/modules/transmute/transmute_client.obj differ diff --git a/build/Debug/src/d2tweaks/common/common.obj b/build/Debug/src/d2tweaks/common/common.obj index 8f78fd8..28f63bb 100644 Binary files a/build/Debug/src/d2tweaks/common/common.obj and b/build/Debug/src/d2tweaks/common/common.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj b/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj index a51b8e7..f59596d 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj and b/build/Debug/src/d2tweaks/server/modules/auto_gold_pickup/auto_gold_pickup_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj b/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj index 0c779e3..d6f8033 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj and b/build/Debug/src/d2tweaks/server/modules/auto_item_pickup/auto_item_pickup_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj b/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj index e17d7d8..119ab85 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj and b/build/Debug/src/d2tweaks/server/modules/autosort/autosort_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj b/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj index f6d8a23..0b6075f 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj and b/build/Debug/src/d2tweaks/server/modules/damage_display/damage_display_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj b/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj index 31e637c..66331a1 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj and b/build/Debug/src/d2tweaks/server/modules/identify_on_pickup/identify_on_pickup_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj b/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj index 730ebf8..1cc8b7c 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj and b/build/Debug/src/d2tweaks/server/modules/item_drop_message/item_drop_message_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj b/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj index f6d1a95..bb1aa5c 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj and b/build/Debug/src/d2tweaks/server/modules/item_move/item_move_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/server_module.obj b/build/Debug/src/d2tweaks/server/modules/server_module.obj index 22385f6..f149fcf 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/server_module.obj and b/build/Debug/src/d2tweaks/server/modules/server_module.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj b/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj index 65f8e2e..b80ec95 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj and b/build/Debug/src/d2tweaks/server/modules/trader_update/trader_update_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj b/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj index 00ab895..03a3e11 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj and b/build/Debug/src/d2tweaks/server/modules/transmute/transmute_server.obj differ diff --git a/build/Debug/src/d2tweaks/server/server.obj b/build/Debug/src/d2tweaks/server/server.obj index 420ec1a..512e66e 100644 Binary files a/build/Debug/src/d2tweaks/server/server.obj and b/build/Debug/src/d2tweaks/server/server.obj differ diff --git a/build/Debug/src/d2tweaks/ui/ui_manager.obj b/build/Debug/src/d2tweaks/ui/ui_manager.obj index 527f148..272ba84 100644 Binary files a/build/Debug/src/d2tweaks/ui/ui_manager.obj and b/build/Debug/src/d2tweaks/ui/ui_manager.obj differ diff --git a/build/Debug/src/diablo2/d2common.obj b/build/Debug/src/diablo2/d2common.obj index 312d79d..ca2dbd7 100644 Binary files a/build/Debug/src/diablo2/d2common.obj and b/build/Debug/src/diablo2/d2common.obj differ diff --git a/build/Debug/src/main.obj b/build/Debug/src/main.obj index 362db51..d83b0e7 100644 Binary files a/build/Debug/src/main.obj and b/build/Debug/src/main.obj differ diff --git a/build/Debug/vc143.pdb b/build/Debug/vc143.pdb index d65fa4f..2daacc0 100644 Binary files a/build/Debug/vc143.pdb and b/build/Debug/vc143.pdb differ diff --git a/d2tweaks-rnd2k.code-workspace b/d2tweaks-rnd2k.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/d2tweaks-rnd2k.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/include/d2tweaks/common/protocol.h b/include/d2tweaks/common/protocol.h index e5d153e..d7849e7 100644 --- a/include/d2tweaks/common/protocol.h +++ b/include/d2tweaks/common/protocol.h @@ -239,6 +239,7 @@ namespace d2_tweaks { uint8_t target_page; uint32_t bag_guid = 0; bool updateBag; + bool removeFromBag; int prop; int val; diff --git a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp index 4c6306e..b6f20f9 100644 --- a/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp +++ b/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_toggle_menu.cpp @@ -25,7 +25,7 @@ #include // For ShellExecute using namespace d2_tweaks::client::modules; -bool m_stats_enabled = false; +bool m_stats_enabled = true; bool m_help_enabled = false; d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settings_toggle_menu(token) { diff --git a/src/d2tweaks/server/modules/item_move/item_move_server.cpp b/src/d2tweaks/server/modules/item_move/item_move_server.cpp index 97f45da..77bbbea 100644 --- a/src/d2tweaks/server/modules/item_move/item_move_server.cpp +++ b/src/d2tweaks/server/modules/item_move/item_move_server.cpp @@ -24,35 +24,6 @@ #include // 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(&item)[i] = static_cast(byte); - } - return item; - } - } - // Item code not found - throw std::invalid_argument("Item code not found"); -} #include // For std::setw @@ -69,8 +40,6 @@ void serialize_item(const std::string& itemcode, const diablo2::structures::unit file << std::endl; } - - MODULE_INIT(item_move) 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 bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::game* game, 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); 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 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) return true; //block further packet processing - - - const auto inventoryIndex = diablo2::d2_common::get_inventory_index(player, itemMove->target_page, game->item_format == 101); 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); + 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) { diff --git a/src/d2tweaks/ui/ui_manager.cpp b/src/d2tweaks/ui/ui_manager.cpp index 4261d74..7f4e929 100644 --- a/src/d2tweaks/ui/ui_manager.cpp +++ b/src/d2tweaks/ui/ui_manager.cpp @@ -141,8 +141,109 @@ HWND g_hEditBox = nullptr; // Declare a variable to store the input text std::vector 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 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(&item)[i] = static_cast(byte); +// } +// return item; +// } +// } +// // Item code not found +// throw std::invalid_argument("Item code not found"); +//} + +#include + +// 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(&item)[i / 2] = static_cast(byte); + } + + return item; +} LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static auto& instance = singleton::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 } + // 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::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::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 if (wParam == 'Z') { // 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') { const auto g_hoverItem = *reinterpret_cast(diablo2::d2_client::get_base() + 0x1158F4); if (g_hoverItem != nullptr) { @@ -349,7 +558,9 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, //} } } - + */ + + switch (msg) { case WM_LBUTTONDOWN: { @@ -365,27 +576,59 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, case WM_RBUTTONDOWN: { + const auto player = diablo2::d2_client::get_local_player(); + auto pInventory = player->inventory; + int32_t gemBagGuid = 0; const auto g_hoverItem = *reinterpret_cast(diablo2::d2_client::get_base() + 0x1158F4); + if (g_hoverItem != nullptr) { const auto record = diablo2::d2_common::get_item_record(g_hoverItem->data_record_index); char* normCode = record->string_code; + /* if (strncmp(normCode, "ib1", 3) == 0) { - // display Messagebox with normCode //MessageBoxA(0, normCode, "normCode", 0); // we need to accept user input here // 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 items; diablo2::structures::unit* gemBag{}; @@ -495,7 +738,7 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, for (const auto& gem : gemTypes) { // Accessing key and value const std::string& _key = gem.first; - key = gem.first.c_str(); + key = gem.first.c_str(); const GemType& value = gem.second; if (strncmp(normCode, key, 3) == 0) { @@ -518,13 +761,224 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, packet.val = itemProperty.nMin; packet.target_page = 99; diablo2::d2_client::send_to_server(&packet, sizeof packet); + } + } + } + } + + + static std::unordered_map 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::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);