diff --git a/ClassDiagram.cd b/ClassDiagram.cd new file mode 100644 index 0000000..7b89419 --- /dev/null +++ b/ClassDiagram.cd @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/D2tweaks.vcxproj b/D2tweaks.vcxproj index b3ebdc3..7bd1f67 100644 --- a/D2tweaks.vcxproj +++ b/D2tweaks.vcxproj @@ -180,6 +180,7 @@ + diff --git a/build/Debug/D2tweaks.ilk b/build/Debug/D2tweaks.ilk index a789d5e..161f944 100644 Binary files a/build/Debug/D2tweaks.ilk and b/build/Debug/D2tweaks.ilk differ diff --git a/build/Debug/D2tweaks.log b/build/Debug/D2tweaks.log index ae7cdff..80bf905 100644 --- a/build/Debug/D2tweaks.log +++ b/build/Debug/D2tweaks.log @@ -1,11 +1,2 @@ - autosort_client.cpp -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(197,15): warning C4018: '<': signed/unsigned mismatch -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(197,66): warning C4018: '<=': signed/unsigned mismatch -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(252,41): warning C4244: '=': conversion from 'double' to 'int32_t', possible loss of data -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(255,43): warning C4244: '=': conversion from 'double' to 'int32_t', possible loss of data -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(258,41): warning C4244: '=': conversion from 'double' to 'int32_t', possible loss of data -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(261,43): warning C4244: '=': conversion from 'double' to 'int32_t', possible loss of data -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(264,41): warning C4244: '=': conversion from 'double' to 'int32_t', possible loss of data -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(282,41): warning C4244: '=': conversion from 'double' to 'int32_t', possible loss of data -D:\VSCode\d2tweaks-rnd2k\src\d2tweaks\client\modules\autosort\autosort_client.cpp(288,41): warning C4244: '=': conversion from 'double' to 'int32_t', possible loss of data + ui_manager.cpp D2tweaks.vcxproj -> D:\Diablo II\MODS\ironman-dev\D2tweaks.dll diff --git a/build/Debug/D2tweaks.tlog/CL.command.1.tlog b/build/Debug/D2tweaks.tlog/CL.command.1.tlog index edf5b32..a3c2d44 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 56a34b9..f27937e 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 509a5ea..6bfc0be 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..23975a3 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 fc8d246..f073a6b 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 72ed981..63511c6 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 2e1893a..c1f1dd1 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 0f01f22..5de6405 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/damage_display/damage_display_client.obj b/build/Debug/src/d2tweaks/client/modules/damage_display/damage_display_client.obj index ec43548..5755354 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 82df900..971d65e 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 fc2d283..12a6176 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_settings_menu.obj b/build/Debug/src/d2tweaks/client/modules/loot_filter/loot_filter_settings_menu.obj index 58bd88a..e6040e3 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 7e79c27..3b04eb2 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/test/test.obj b/build/Debug/src/d2tweaks/client/modules/test/test.obj index 6926f5f..2b1220b 100644 Binary files a/build/Debug/src/d2tweaks/client/modules/test/test.obj and b/build/Debug/src/d2tweaks/client/modules/test/test.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 e23cff3..3cb104c 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 e83204f..fb1958d 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 ec17bf7..1d098bf 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 7c3f467..3e66845 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 7be5b70..62875cf 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 6090204..0fba90f 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 56d6994..b2e8dab 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 49990e9..9a1d8fd 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 51df1b4..ae0c6f3 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 9a8bd94..01c8688 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 5d74cd3..309bf70 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/test/test.obj b/build/Debug/src/d2tweaks/server/modules/test/test.obj index 412667d..fc943fe 100644 Binary files a/build/Debug/src/d2tweaks/server/modules/test/test.obj and b/build/Debug/src/d2tweaks/server/modules/test/test.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 f12b4d2..3f3c3e4 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 208bf4a..3db4bbe 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 b6d6635..526b943 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 a1e2b03..1103bc0 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 08617ba..dc8330a 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/diablo2/d2game.obj b/build/Debug/src/diablo2/d2game.obj index ce19ca2..dd07b84 100644 Binary files a/build/Debug/src/diablo2/d2game.obj and b/build/Debug/src/diablo2/d2game.obj differ diff --git a/build/Debug/src/diablo2/d2lang.obj b/build/Debug/src/diablo2/d2lang.obj index d07f666..38bd9ca 100644 Binary files a/build/Debug/src/diablo2/d2lang.obj and b/build/Debug/src/diablo2/d2lang.obj differ diff --git a/build/Debug/src/diablo2/utils/screen.obj b/build/Debug/src/diablo2/utils/screen.obj index ab679ef..5547358 100644 Binary files a/build/Debug/src/diablo2/utils/screen.obj and b/build/Debug/src/diablo2/utils/screen.obj differ diff --git a/build/Debug/src/main.obj b/build/Debug/src/main.obj index 85f753d..209dfa0 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 93a3328..872201f 100644 Binary files a/build/Debug/vc143.pdb and b/build/Debug/vc143.pdb differ diff --git a/include/diablo2/d2common.h b/include/diablo2/d2common.h index aada8d3..fed8504 100644 --- a/include/diablo2/d2common.h +++ b/include/diablo2/d2common.h @@ -1044,5 +1044,11 @@ namespace diablo2 { // Write a function signature for this function static structures::D2ItemStatCostTxt* get_item_stat_cost_record(int nStatId); + //D2Common.0x6FD57720 (#10602) + //int __stdcall DATATBLS_GetItemIdFromItemCode(uint32_t dwCode) + static int get_item_id_from_item_code(uint32_t dwCode); + + + }; } diff --git a/include/diablo2/d2game.h b/include/diablo2/d2game.h index 0adc437..2a81318 100644 --- a/include/diablo2/d2game.h +++ b/include/diablo2/d2game.h @@ -47,5 +47,8 @@ namespace diablo2 { static void update_inventory_items(structures::game* game, structures::unit* player); static uint32_t __fastcall diablo2::d2_game::transmogrify(diablo2::structures::game* game, diablo2::structures::unit* player); + + //D2Game.0x6FC4ED80 + structures::unit* __fastcall D2GAME_CreateItemEx_6FC4ED80(structures::game* pGame, structures::D2ItemDropStrc* pItemDrop, int32_t a3); }; } diff --git a/include/diablo2/structures/unit.h b/include/diablo2/structures/unit.h index 965ce97..e2718e6 100644 --- a/include/diablo2/structures/unit.h +++ b/include/diablo2/structures/unit.h @@ -1,6 +1,8 @@ #pragma once #include +#include "room.h" +#include #pragma pack(push, 1) @@ -74,6 +76,50 @@ namespace diablo2 { ITEMFLAG_ITEM = 0x08000000 }; + struct D2SeedStrc + { + union + { + struct + { + uint32_t nLowSeed; //0x00 + uint32_t nHighSeed; //0x04 + }; + uint64_t lSeed; //0x00 + }; + }; + + struct D2ItemDropStrc + { + diablo2::structures::unit* pUnit; //0x00 + D2SeedStrc* pSeed; //0x04 + diablo2::structures::game* pGame; //0x08 + int32_t nItemLvl; //0x0C + uint32_t unk0x10; //0x10 + int32_t nId; //0x14 + int32_t nSpawnType; //0x18 [3 for ground spawn, 4 for inv spawn] + int32_t nX; //0x1C + int32_t nY; //0x20 + diablo2::structures::room* pRoom; //0x24 + uint16_t wUnitInitFlags; //0x28 + uint16_t wItemFormat; //0x2A [ptGame0x0x78] + BOOL bForce; //0x2C + int32_t nQuality; //0x30 + int32_t nQuantity; //0x34 + int32_t nMinDur; //0x38 + int32_t nMaxDur; //0x3C + int32_t nItemIndex; //0x40 + uint32_t dwFlags1; //0x44 - itemflag override (used when force is true) + uint32_t dwSeed; //0x48 - overrides the seed, used when force is true + uint32_t dwItemSeed; //0x4C - overrides the item seed when force is true + int32_t eEarLvl; //0x50 + int32_t nQtyOverride; //0x54 + char szName[16]; //0x58 + int32_t nPrefix[3]; //0x68 + int32_t nSuffix[3]; //0x74 + uint32_t dwFlags2; //0x80 + }; + struct unit { unit_type_t type; diff --git a/src/d2tweaks/client/modules/autosort/autosort_client.cpp b/src/d2tweaks/client/modules/autosort/autosort_client.cpp index 83262bf..f789d63 100644 --- a/src/d2tweaks/client/modules/autosort/autosort_client.cpp +++ b/src/d2tweaks/client/modules/autosort/autosort_client.cpp @@ -236,15 +236,9 @@ public: for (const auto& stat : stats) { int param = stat.param; int op = stat.op; - - int32_t spirits = diablo2::d2_common::get_stat(player, static_cast(185), NULL); - int32_t soulscaptured = statValue = diablo2::d2_common::get_stat(player, static_cast(184), NULL); - auto statline = diablo2::d2_common::get_item_stat_cost_record(stat.stat); - auto opBase = statline->wOpBase; auto opStat = statline->wOpStat[0]; - auto opBaseValue = diablo2::d2_common::get_stat(player, static_cast(opBase), NULL); auto opStatValue = diablo2::d2_common::get_stat(player, static_cast(opStat), NULL); @@ -299,8 +293,6 @@ public: if (!diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH) && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_CHARACTER) - // && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_INVENTORY) - // && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_SKILL) && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_CHAT) && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_NPCMENU) && !diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_MAINMENU) @@ -329,34 +321,25 @@ public: //diablo2::d2_win::draw_boxed_text(const_cast(statText.c_str()), stat.x1, stat.y1 + textOffset, 1, 0, stat.colorStat); //diablo2::d2_win::draw_boxed_text(const_cast(statValueStr.c_str()), stat.x2, stat.y2 + textOffset, 1, 4, stat.colorStatValue); - // diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16 - //diablo2::structures::d2_cmp::init_gfx_data(&g_gfxdata); - //diablo2::d2_gfx::draw_image(&g_gfxdata, 200, 200, 1, 5, 0); - // instead try to load direct jpg with gdi and insetad ofloading jpg file, specify it bb64 encoded and decode it. } } if (m_help_enabled) { - const int windowWidth = 1280; - const int windowHeight = 768; - - const int boxWidth = 1000; - const int boxHeight = 680; - - const int boxX = (windowWidth - boxWidth) / 2; - const int boxY = (windowHeight - boxHeight) / 2; - - const std::string helpText = "This is a sample help screen! You can put help text in here!?"; - - // Draw filled background box - diablo2::d2_gfx::draw_filled_rect(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0, 255); - - // Draw justified text inside the box with padding - drawJustifiedTextInBox(helpText, boxX, boxY, boxWidth, boxHeight, 0); + //const int windowWidth = 1280; + //const int windowHeight = 768; + //const int boxWidth = 1000; + //const int boxHeight = 680; + //const int boxX = (windowWidth - boxWidth) / 2; + //const int boxY = (windowHeight - boxHeight) / 2; + //const std::string helpText = "This is a sample help screen! You can put help text in here!?"; + //// Draw filled background box + //diablo2::d2_gfx::draw_filled_rect(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0, 255); + //// Draw justified text inside the box with padding + //drawJustifiedTextInBox(helpText, boxX, boxY, boxWidth, boxHeight, 0); } diablo2::ui_color_t::UI_COLOR_WHITE; @@ -391,8 +374,6 @@ public: int sHCenter = sHeight / 2; int sWCenter = sWidth / 2; - //spdlog::info("healthPercentage: {}", healthPercentage); - // Define default bar color DWORD barColor = 0; @@ -407,42 +388,54 @@ public: barColor = 5; } - //spdlog::info("barColor: {}", barColor); - // Define the dimensions for the bars - int barWidth = 200; // Width of the bars - int barHeight = 16; // Height of the bars + int pbarWidth = GetPrivateProfileIntA("Options", "pbarWidth", 200, "./d2tweaks.ini"); + int pbarHeight = GetPrivateProfileIntA("Options", "pbarHeight", 16, "./d2tweaks.ini"); + // Define the coordinates for the bars int barX = 245; // Left coordinate of the bars int barY_HP = 728; // Top coordinate of the HP bar - int barY_Mana = barY_HP + barHeight + 4; // Top coordinate of the Mana bar with separator - int barY_Stamina = barY_Mana + barHeight + 4; // Top coordinate of the Stamina bar with separator + int barY_Mana = barY_HP + pbarHeight + 4; // Top coordinate of the Mana bar with separator + int barY_Stamina = barY_Mana + pbarHeight + 4; // Top coordinate of the Stamina bar with separator std::wstring life = strHP + L" / " + strMaxHP; std::wstring mana = strMana + L" / " + strMaxMana; std::wstring stamina = strStamina + L" / " + strMaxStamina; // Calculate the filled widths of the bars - int filledHPWidth = static_cast(healthPercentage * barWidth); - int filledManaWidth = static_cast(manaPercentage * barWidth); - int filledStaminaWidth = static_cast(staminaPercentage * barWidth); + int filledHPWidth = static_cast(healthPercentage * pbarWidth); + int filledManaWidth = static_cast(manaPercentage * pbarWidth); + int filledStaminaWidth = static_cast(staminaPercentage * pbarWidth); // at 345 we need to minus the width of the text sWCenter = barX + 100 - (diablo2::d2_win::get_text_pixel_width(const_cast(mana.c_str())) / 2); HWND diabloIIWnd = FindDiabloIIWindow(); - // Draw the filled HP bar - diablo2::d2_gfx::draw_filled_rect(barX, barY_HP, barX + filledHPWidth, barY_HP + barHeight, barColor, 255); - //DrawFilledRect(diabloIIWnd, barX, barY_HP, barX + filledHPWidth, barY_HP + barHeight, RGB(255, 0, 0)); // Red color for HP - diablo2::d2_win::draw_text(const_cast(life.c_str()), sWCenter, barY_HP + 15, diablo2::UI_COLOR_WHITE, 0); + // Get player_bars_enabled from [Options] in d2tweaks.ini + int player_bars_enabled_hp = GetPrivateProfileIntA("Options", "player_bars_hp_enabled", 1, "./d2tweaks.ini"); + int player_bars_X_hp = GetPrivateProfileIntA("Options", "player_bars_hp_X", barX, "./d2tweaks.ini"); + int player_bars_Y_hp = GetPrivateProfileIntA("Options", "player_bars_hp_Y", barY_HP, "./d2tweaks.ini"); - // Draw the filled Mana bar - diablo2::d2_gfx::draw_filled_rect(barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, 140, 255); - //DrawFilledRect(diabloIIWnd, barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, RGB(100, 100, 255)); // Blue color for Mana - diablo2::d2_win::draw_text(const_cast(mana.c_str()), sWCenter, barY_Mana + 15, diablo2::UI_COLOR_WHITE, 0); + int player_bars_enabled_mana = GetPrivateProfileIntA("Options", "player_bars_mana_enabled", 1, "./d2tweaks.ini"); + int player_bars_X_mana = GetPrivateProfileIntA("Options", "player_bars_mana_X", barX, "./d2tweaks.ini"); + int player_bars_Y_mana = GetPrivateProfileIntA("Options", "player_bars_mana_Y", barY_Mana, "./d2tweaks.ini"); + + + if (player_bars_enabled_hp == 1) { + // Draw the filled HP bar + diablo2::d2_gfx::draw_filled_rect(player_bars_X_hp, player_bars_Y_hp, barX + filledHPWidth, barY_HP + pbarHeight, barColor, 255); + //DrawFilledRect(diabloIIWnd, barX, barY_HP, barX + filledHPWidth, barY_HP + barHeight, RGB(255, 0, 0)); // Red color for HP + diablo2::d2_win::draw_text(const_cast(life.c_str()), sWCenter, barY_HP + 15, diablo2::UI_COLOR_WHITE, 0); + } + if (player_bars_enabled_mana == 1) { + // Draw the filled Mana bar + diablo2::d2_gfx::draw_filled_rect(player_bars_X_mana, player_bars_Y_mana, barX + filledManaWidth, barY_Mana + pbarHeight, 140, 255); + //DrawFilledRect(diabloIIWnd, barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, RGB(100, 100, 255)); // Blue color for Mana + diablo2::d2_win::draw_text(const_cast(mana.c_str()), sWCenter, barY_Mana + 15, diablo2::UI_COLOR_WHITE, 0); + } /* // Define the number of separators int numColors = 256; 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 b6836b9..bede0df 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 @@ -5,91 +5,45 @@ #include #include #include -#include +#include #include #include - -#include - -#include -#include -#include - -#include -#include -#include - -#include // For system function - -#include // For ShellExecute #include #include - +#include // For system function +#include // For ShellExecute #include #include - #include - #include - #include - -#include -#include -#include -#include #include - -#include - #include - -#include - -#include - #include -#include #include - -#include -#include #include -#include - -#include -#include #include -#include #include - #include #include #include #include - #include #include #include #include - #include #include -#include #include #include #include #include #include -#include #include #include - #include // For std::setw #include #include // For std::invalid_argument - -#include #include #include #include // Include for edit control @@ -123,40 +77,57 @@ d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settin m_filter_settings_menu = singleton::instance().get_menu("loot_filter_settings_menu"); + // toggle stats button m_btn_toggle_stats = static_cast(get_control("m_toggle_stats")); m_btn_toggle_stats->set_enabled(true); m_btn_toggle_stats->set_visible(true); m_btn_toggle_stats->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_stats_settings_click, this)); + // help button m_btn_toggle_help = static_cast(get_control("m_toggle_help")); m_btn_toggle_help->set_enabled(true); m_btn_toggle_help->set_visible(true); m_btn_toggle_help->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_help_click, this)); + // toggle open/close cube button m_btn_toggle_cube = static_cast(get_control("m_toggle_cube")); m_btn_toggle_cube->set_enabled(true); m_btn_toggle_cube->set_visible(true); + auto player = diablo2::d2_client::get_local_player(); + //iterate over all items in player inventory + for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) { + const auto record = diablo2::d2_common::get_item_record(item->data_record_index); + char* normCode1 = record->string_code; + if (strncmp(normCode1, "box", 3) == 0) { + m_btn_toggle_cube->set_enabled(true); + m_btn_toggle_cube->set_visible(true); + break; + } + else { + m_btn_toggle_cube->set_enabled(false); + m_btn_toggle_cube->set_visible(false); + } + } m_btn_toggle_cube->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_cube_click, this)); + // toggle open/close stash button m_btn_toggle_stash = static_cast(get_control("m_toggle_stash")); - m_btn_toggle_stash->set_enabled(true); m_btn_toggle_stash->set_visible(true); - //auto player = diablo2::d2_client::get_local_player(); - ////iterate over all items in player inventory - //for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) { - // const auto record = diablo2::d2_common::get_item_record(item->data_record_index); - // char* normCode1 = record->string_code; - // if (strncmp(normCode1, "st0", 3) == 0) { - // m_btn_toggle_stash->set_enabled(true); - // m_btn_toggle_stash->set_visible(true); - // break; - // } - // else { - // m_btn_toggle_stash->set_enabled(false); - // m_btn_toggle_stash->set_visible(false); - // } - //} + //iterate over all items in player inventory + for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) { + const auto record = diablo2::d2_common::get_item_record(item->data_record_index); + char* normCode1 = record->string_code; + if (strncmp(normCode1, "st0", 3) == 0) { + m_btn_toggle_stash->set_enabled(true); + m_btn_toggle_stash->set_visible(true); + break; + } + else { + m_btn_toggle_stash->set_enabled(false); + m_btn_toggle_stash->set_visible(false); + } + } m_btn_toggle_stash->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_stash_click, this)); } @@ -244,9 +215,7 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_stash_ diablo2::d2_client::send_to_server(&packet, sizeof packet); } else { - //run a for loop and send th set_ui_toggle packet 255 times from 1 to 255 diablo2::d2_client::set_ui_toggle(0x19, 1, FALSE); - // send to server7 to close cube packet 0x4F diablo2::d2_client::send_to_server_7(0x4F, 0x17, 0, 0); } @@ -255,7 +224,11 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_stash_ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_help_click() { //m_help_enabled = !m_help_enabled; // Open the default OS browser to the URL - const std::string url = "https://im.stoned.io"; + // read the url from the ./d2tweaks.ini file + char urlBuffer[256]; + GetPrivateProfileStringA("Options", "help_url", "", urlBuffer, sizeof(urlBuffer), "./d2tweaks.ini"); + const std::string url(urlBuffer); + #ifdef _WIN32 // For Windows ShellExecute(nullptr, "open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL); diff --git a/src/d2tweaks/ui/ui_manager.cpp b/src/d2tweaks/ui/ui_manager.cpp index 7145f7c..af77b46 100644 --- a/src/d2tweaks/ui/ui_manager.cpp +++ b/src/d2tweaks/ui/ui_manager.cpp @@ -71,6 +71,12 @@ #include +#include // Include chrono for time-based operations + +// Define a static variable to keep track of the last time the stash window was toggled +static std::chrono::steady_clock::time_point lastToggleTime; + + #pragma pack(push, 1) using namespace std; @@ -247,37 +253,101 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, } if (wParam == 'V') { - const auto player = diablo2::d2_client::get_local_player(); - int32_t st0Guid = 0; - uint32_t st0X = 0; - uint32_t st0Y = 0; - diablo2::structures::unit* box{}; - for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) { - const auto record = diablo2::d2_common::get_item_record(item->data_record_index); - char* st0Code = record->string_code; - if (strncmp(st0Code, "st0", 3) == 0) { - box = item; - st0Guid = box->guid; - st0X = player->path->mapx; - st0Y = player->path->mapy; + // Define a cooldown duration in milliseconds + constexpr int cooldownDuration = 500; // Adjust this value as needed + + // Get the current time + auto currentTime = std::chrono::steady_clock::now(); + + // Calculate the time elapsed since the last stash toggle + auto timeElapsed = std::chrono::duration_cast(currentTime - lastToggleTime).count(); + + // Check if enough time has elapsed since the last toggle + if (timeElapsed >= cooldownDuration) { + // Update the last toggle time + lastToggleTime = currentTime; + + if (!diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH)) { + // Code to open stash + const auto player = diablo2::d2_client::get_local_player(); + int32_t st0Guid = 0; + uint32_t st0X = 0; + uint32_t st0Y = 0; + diablo2::structures::unit* box{}; + for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) { + const auto record = diablo2::d2_common::get_item_record(item->data_record_index); + char* st0Code = record->string_code; + if (strncmp(st0Code, "st0", 3) == 0) { + box = item; + st0Guid = box->guid; + st0X = player->path->mapx; + st0Y = player->path->mapy; + } + } + struct D2GSPacketClt20 { + uint8_t PacketId; // 0x01 + uint32_t guid; // 0x06 + uint32_t tx; // 0x07 + uint32_t ty; // 0x09 + }; + D2GSPacketClt20 packet; + packet.PacketId = 0x20; + packet.guid = st0Guid; + packet.tx = st0X; + packet.ty = st0Y; + diablo2::d2_client::send_to_server(&packet, sizeof packet); + block = true; + + // MessageBoxA(NULL, "Stash opened", "Stash", MB_OK); + // spdlog::info("Stash opened"); + } + else { + // Code to close stash + // Close stash + diablo2::d2_client::set_ui_toggle(0x19, 1, FALSE); + // send to server7 to close cube packet 0x4F + diablo2::d2_client::send_to_server_7(0x4F, 0x17, 0, 0); + block = true; } } - struct D2GSPacketClt20 { - uint8_t PacketId; // 0x01 - uint32_t guid; // 0x06 - uint32_t tx; // 0x07 - uint32_t ty; // 0x09 - }; - D2GSPacketClt20 packet; - packet.PacketId = 0x20; - packet.guid = st0Guid; - packet.tx = st0X; - packet.ty = st0Y; - diablo2::d2_client::send_to_server(&packet, sizeof packet); - m_stash_enabled = false; - block = true; + } + + + + //if (wParam == 'V') { + // const auto player = diablo2::d2_client::get_local_player(); + // int32_t st0Guid = 0; + // uint32_t st0X = 0; + // uint32_t st0Y = 0; + // diablo2::structures::unit* box{}; + // for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) { + // const auto record = diablo2::d2_common::get_item_record(item->data_record_index); + // char* st0Code = record->string_code; + // if (strncmp(st0Code, "st0", 3) == 0) { + // box = item; + // st0Guid = box->guid; + // st0X = player->path->mapx; + // st0Y = player->path->mapy; + // } + // } + // struct D2GSPacketClt20 { + // uint8_t PacketId; // 0x01 + // uint32_t guid; // 0x06 + // uint32_t tx; // 0x07 + // uint32_t ty; // 0x09 + // }; + // D2GSPacketClt20 packet; + // packet.PacketId = 0x20; + // packet.guid = st0Guid; + // packet.tx = st0X; + // packet.ty = st0Y; + // diablo2::d2_client::send_to_server(&packet, sizeof packet); + // m_stash_enabled = false; + // block = true; + //} + // 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 diff --git a/src/diablo2/d2common.cpp b/src/diablo2/d2common.cpp index 399c893..a70199b 100644 --- a/src/diablo2/d2common.cpp +++ b/src/diablo2/d2common.cpp @@ -257,4 +257,13 @@ void diablo2::d2_common::ITEMS_SetItemFlag(structures::unit* item, uint32_t dwFl diablo2::structures::D2ItemStatCostTxt* diablo2::d2_common::get_item_stat_cost_record(int statId) { static wrap_func_fast get_item_stat_cost_record(0x642b0, get_base()); return get_item_stat_cost_record(statId); +} + +//D2Common.0x6FD57720 (#10602) +//int __stdcall DATATBLS_GetItemIdFromItemCode(uint32_t dwCode) +//static int get_item_id_from_item_code(uint32_t dwCode); + +int32_t diablo2::d2_common::get_item_id_from_item_code(uint32_t dwCode) { + static wrap_func_std_import get_item_id_from_item_code(10602, get_base()); + return get_item_id_from_item_code(dwCode); } \ No newline at end of file diff --git a/src/diablo2/d2game.cpp b/src/diablo2/d2game.cpp index 391f992..24c1d7a 100644 --- a/src/diablo2/d2game.cpp +++ b/src/diablo2/d2game.cpp @@ -135,4 +135,11 @@ uint32_t __fastcall diablo2::d2_game::transmogrify(diablo2::structures::game* ga } // d2game:$0x60010 -// int __fastcall CRAFT_Transmogrify(D2GameStrc* pGame, D2UnitStrc* pPlayer, D2CubemainTXT* pCubeTxt, void* pUnknown) \ No newline at end of file +// int __fastcall CRAFT_Transmogrify(D2GameStrc* pGame, D2UnitStrc* pPlayer, D2CubemainTXT* pCubeTxt, void* pUnknown) + +// Add a wrapper for the following function: +// structures::unit* __fastcall D2GAME_CreateItemEx_6FC4ED80(structures::game* pGame, structures::D2ItemDropStrc* pItemDrop, int32_t a3); +diablo2::structures::unit* __fastcall diablo2::d2_game::D2GAME_CreateItemEx_6FC4ED80(diablo2::structures::game* pGame, diablo2::structures::D2ItemDropStrc* pItemDrop, int32_t a3) { + static wrap_func_fast< diablo2::structures::unit* (diablo2::structures::game*, diablo2::structures::D2ItemDropStrc*, int32_t)> D2GAME_CreateItemEx_6FC4ED80(0x1ed80, get_base()); + return D2GAME_CreateItemEx_6FC4ED80(pGame, pItemDrop, a3); +} \ No newline at end of file