Item moving with Z key working

This commit is contained in:
Hash Borgir 2024-04-21 00:55:02 -06:00
parent b2f9685c20
commit 155de2c299
5 changed files with 109 additions and 1089 deletions

View File

@ -59,6 +59,7 @@ namespace diablo2 {
static bool get_ui_window_state(ui_window_t window);
static void* get_buysellbtn();
static void play_sound(uint32_t soundId, structures::unit* u, uint32_t ticks, BOOL prePick, uint32_t cache);
static structures::unit* get_unit_by_guid(int32_t type, int32_t guid);

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ static growing_object_pool<damage_label> g_label_pool([]() {
return new damage_label();
});
static const size_t DAMAGE_LABELS_SIZE = 1024;
static const size_t DAMAGE_LABELS_SIZE = 1023;
static damage_label* g_labels[DAMAGE_LABELS_SIZE]{ nullptr };
static size_t g_labels_count = 0;
static uint32_t DISPLAY_TIME = 500;

View File

@ -5,10 +5,22 @@
#include <common/hooking.h>
#include <d2tweaks/common/protocol.h>
#include <d2tweaks/ui/menu.h>
#include <diablo2/d2win.h>
#include <diablo2/d2client.h>
#include <diablo2/d2common.h>
#include <diablo2/d2game.h>
#include <spdlog/spdlog.h>
#include <Windows.h>
diablo2::structures::unit* g_item1;
static LRESULT(__stdcall* g_wnd_proc_original)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
d2_tweaks::ui::ui_manager::ui_manager(token) {
@ -58,11 +70,105 @@ void d2_tweaks::ui::ui_manager::draw() {
}
}
struct D2InventoryGridInfoStrc
{
BYTE nGridX; //0x00
BYTE nGridY; //0x01
WORD pad0x02; //0x02
int nGridLeft; //0x04
int nGridRight; //0x08
int nGridTop; //0x0C
int nGridBottom; //0x10
BYTE nGridBoxWidth; //0x14
BYTE nGridBoxHeight; //0x15
WORD pad0x16; //0x16
};
LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
static auto& instance = singleton<ui_manager>::instance();
bool block;
// Send transmute packet
if (wParam == 'X') {
diablo2::d2_client::send_to_server_7(0x4F, 0x18, 0, 0);
block = true; // block the game from processing this key
}
//// Send item move packet
//if (wParam == 'Z') {
// // 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) {
// 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;
// }
// diablo2::d2_client::send_to_server(&packet, sizeof packet);
// }
// block = true; // block the game from processing this key
//}
// Send item move packet
// Send item move packet
if (wParam == 'Z') {
// 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) {
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;
}
block = true; // block the game from processing this key
}
// Send item move packet
if ((wParam == 'Z') && (GetKeyState(VK_SHIFT) & 0x8000)) {
// 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) {
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
packet.target_page = 0;
}
diablo2::d2_client::send_to_server(&packet, sizeof packet);
}
block = true; // block the game from processing this key
}
switch (msg) {
case WM_LBUTTONDOWN:
{

View File

@ -16,8 +16,6 @@ bool diablo2::d2_client::is_lod() {
return *reinterpret_cast<int*>(get_base() + 0x1077C4) > 0;
}
diablo2::structures::unit* diablo2::d2_client::get_local_player() {
static wrap_func_std<structures::unit * ()> get_local_player(0x883D0, get_base());
return get_local_player();
@ -53,6 +51,7 @@ uint32_t diablo2::d2_client::get_mouse_y() {
return get_mouse_y();
}
bool diablo2::d2_client::get_ui_window_state(const ui_window_t window) {
static auto ui_states = reinterpret_cast<BOOL*>(get_base() + 0x11A6A8);
return ui_states[window];