Right click gem add to bag working

This commit is contained in:
Hash Borgir
2024-04-25 19:09:19 -06:00
parent f32b70b4bb
commit f915859023
37 changed files with 1093 additions and 29 deletions

View File

@@ -342,6 +342,26 @@ public:
float manaPercentage = static_cast<float>(statMana) / static_cast<float>(statMaxMana);
float staminaPercentage = static_cast<float>(statStamina) / static_cast<float>(statMaxStamina);
//spdlog::info("healthPercentage: {}", healthPercentage);
// Define default bar color
DWORD barColor = 0;
// Determine bar color based on health percentage
if (healthPercentage > .80) {
barColor = 118;
}
else if (healthPercentage > .50) {
barColor = 13;
}
else {
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
@@ -362,20 +382,21 @@ public:
int filledManaWidth = static_cast<int>(manaPercentage * barWidth);
int filledStaminaWidth = static_cast<int>(staminaPercentage * barWidth);
// at 345 we need to minus the width of the text
int sWCenter = barX + 100 - (diablo2::d2_win::get_text_pixel_width(const_cast<wchar_t*>(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, 10, 255);
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<wchar_t*>(life.c_str()), barX + 20, barY_HP + 15, stat.colorStatValue, 0);
diablo2::d2_win::draw_text(const_cast<wchar_t*>(life.c_str()), sWCenter, barY_HP + 15, stat.colorStatValue, 0);
// Draw the filled Mana bar
diablo2::d2_gfx::draw_filled_rect(barX, barY_Mana, barX + filledManaWidth, barY_Mana + barHeight, 156, 255);
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<wchar_t*>(mana.c_str()), barX + 20, barY_Mana + 15, stat.colorStatValue, 0);
diablo2::d2_win::draw_text(const_cast<wchar_t*>(mana.c_str()), sWCenter, barY_Mana + 15, stat.colorStatValue, 0);
/*
// Define the number of separators

View File

@@ -235,6 +235,20 @@ static void draw_damage_labels() {
uint32_t textX = mx;
uint32_t textY = my;
// Define default bar color
diablo2::ui_color_t barColor;
// Determine bar color based on health percentage
if (healthPercentage > .80) {
barColor = diablo2::ui_color_t::UI_COLOR_DARK_GREEN;
}
else if (healthPercentage > .50) {
barColor = diablo2::ui_color_t::UI_COLOR_DARK_GOLD;
}
else {
barColor = diablo2::ui_color_t::UI_COLOR_RED;
}
// Draw the combined text (health percentage and bar text)
//diablo2::d2_win::draw_text(const_cast<wchar_t*>(combinedTcombinedTextext.c_str()), textX, textY, textColor, 0);
//diablo2::d2_win::draw_boxed_text(const_cast<wchar_t*>(fractionStr.c_str()), textX + label->unit_width/2, textY - 12, 0, 0, textColor);
@@ -248,12 +262,16 @@ static void draw_damage_labels() {
int _barHeight = GetPrivateProfileIntA("Options", "barHeight", 0, "./D2Tweaks.ini");
diablo2::d2_win::draw_text(const_cast<wchar_t*>(combinedText.c_str()), textX, textY, textColor, 0);
diablo2::d2_gfx::draw_filled_rect(textX, textY, textX + healthPercentage * 60, textY + _barHeight, 9, 255);
diablo2::d2_win::set_current_font(diablo2::UI_FONT_6); // Set font to FONT16
diablo2::d2_win::draw_text(const_cast<wchar_t*>(combinedText.c_str()), textX, textY, barColor, 0);
diablo2::d2_gfx::draw_filled_rect(textX, textY, textX + healthPercentage * 60, textY + _barHeight, 5, 255);
const auto offset = static_cast<int32_t>(lerp(static_cast<float>(label->unit_height) + 5.f, static_cast<float>(label->unit_height) + 30.f, static_cast<float>(delta) / static_cast<float>(DISPLAY_TIME)));
my -= offset;
// Draw damage label
std::wstring dmgText = L" " + std::to_wstring(label->damage) + L" ";
const wchar_t* dmgTextPtr = dmgText.c_str();

View File

@@ -19,6 +19,53 @@
#include <Windows.h>
#include <d2tweaks/client/modules/autosort/autosort_client.h>
#include <d2tweaks/client/client.h>
#include <spdlog/spdlog.h>
#include <d2tweaks/common/common.h>
#include <d2tweaks/common/protocol.h>
#include <d2tweaks/common/asset_manager.h>
#include <d2tweaks/ui/menu.h>
#include <d2tweaks/ui/ui_manager.h>
#include <d2tweaks/ui/controls/control.h>
#include <d2tweaks/ui/controls/button.h>
#include <diablo2/d2common.h>
#include <diablo2/d2client.h>
#include <diablo2/d2win.h>
#include <diablo2/d2gfx.h>
#include <diablo2/d2cmp.h>
#include <diablo2/structures/unit.h>
#include <diablo2/structures/inventory.h>
#include <diablo2/structures/item_data.h>
#include <diablo2/structures/player_data.h>
#include <diablo2/structures/path.h>
#include <diablo2/structures/game.h>
#include <diablo2/structures/data/items_line.h>
#include <diablo2/structures/data/item_types_line.h>
#include <iostream>
#include <fstream>
#include <string>
#include <filesystem>
#include <unordered_map>
#include <time.h>
#include <cmath>
#include <random>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
diablo2::structures::unit* g_item1;
static LRESULT(__stdcall* g_wnd_proc_original)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -84,6 +131,8 @@ struct D2InventoryGridInfoStrc
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();
@@ -95,7 +144,7 @@ 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
// Send item move packet + transmute packet for certain codes
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));
@@ -121,9 +170,363 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
diablo2::d2_client::send_to_server(&packet, sizeof packet);
(*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4)) = nullptr;
}
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
}
if (wParam == 'G') {
const auto g_hoverItem = *reinterpret_cast<diablo2::structures::unit**>(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;
const auto player = diablo2::d2_client::get_local_player();
std::vector<diablo2::structures::unit*> items;
diablo2::structures::unit* gemBag{};
// get the gembag item
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);
if (record->type == 101) {
gemBag = item;
}
}
// 378 is ruby
// 379 is amathyst
// 380 is diamond
// 381 is emerald
// 382 is saphhire
// 383 is topaz
// 384 is skull
// 385 is El Runes
// 386 is Sol Runes
// 387 is Mal Runes
// properties.txt row number - 3
if (strncmp(normCode, "gcv", 3) == 0) { // Use strncmp for string comparison
int32_t stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
MessageBoxA(0, std::to_string(stat).c_str(), "stat", 0);
stat++;
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = 382 - 3;
itemProperty.nLayer = 0;
itemProperty.nMin = 1;
itemProperty.nMax = 1;
//diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat, 0);
diablo2::d2_common::add_property(gemBag, &itemProperty, 0);
int32_t stat1 = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
MessageBoxA(0, std::to_string(stat1).c_str(), "stat", 0);
}
// check to see if gembag is actually right
//const auto bagrecord = diablo2::d2_common::get_item_record(gemBag->data_record_index);
//char* bagcode = bagrecord->string_code;
//MessageBoxA(0, bagcode, "bag code", 0);
//if (normCode == "gcv") {
// int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
// diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat + 1, 0);
// MessageBoxA(0, normCode, "normCode", 0);
//}
}
/*
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);
if (record->type == 101) {
gemBag = item;
MessageBoxA(0, "Gem Bag Found", "Gem Bag Found", 0);
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
char* normCode = record->string_code;
MessageBoxA(0, normCode, "normCode", 0);
if (normCode == "gcv") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat + 1, 0);
MessageBoxA(0, normCode, "normCode", 0);
}
else if (normCode == "gcy") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, stat + 1, 0);
}
else if (normCode == "gcb") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, stat + 1, 0);
}
else if (normCode == "gcr") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, stat + 1, 0);
}
else if (normCode == "gcg") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, stat + 1, 0);
}
else if (normCode == "gcw") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, stat + 1, 0);
}
else if (normCode == "skc") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, stat + 1, 0);
}
if (normCode == "gfv") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat + 3, 0);
}
else if (normCode == "gfy") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, stat + 3, 0);
}
else if (normCode == "gfb") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, stat + 3, 0);
}
else if (normCode == "gfr") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, stat + 3, 0);
}
else if (normCode == "gfg") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, stat + 3, 0);
}
else if (normCode == "gfw") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, stat + 3, 0);
}
else if (normCode == "skf") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, stat + 3, 0);
}
if (normCode == "gsv") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat + 9, 0);
}
else if (normCode == "gsy") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, stat + 9, 0);
}
else if (normCode == "gsb") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, stat + 9, 0);
}
else if (normCode == "gsr") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, stat + 9, 0);
}
else if (normCode == "gsg") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, stat + 9, 0);
}
else if (normCode == "gsw") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, stat + 9, 0);
}
else if (normCode == "sku") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, stat + 9, 0);
}
if (normCode == "gzv") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat + 27, 0);
}
else if (normCode == "gly") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, stat + 27, 0);
}
else if (normCode == "glb") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, stat + 27, 0);
}
else if (normCode == "glr") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, stat + 27, 0);
}
else if (normCode == "glg") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, stat + 27, 0);
}
else if (normCode == "glw") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, stat + 27, 0);
}
else if (normCode == "skl") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, stat + 27, 0);
}
if (normCode == "gpv") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat + 81, 0);
}
else if (normCode == "gpy") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Topaz, stat + 81, 0);
}
else if (normCode == "gpb") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Sapphire, stat + 81, 0);
}
else if (normCode == "gpr") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Ruby, stat + 81, 0);
}
else if (normCode == "gpg") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Emerald, stat + 81, 0);
}
else if (normCode == "gpw") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Diamond, stat + 81, 0);
}
else if (normCode == "skz") {
int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, NULL);
diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Skull, stat + 81, 0);
}
}
}
*/
}
switch (msg) {
@@ -141,6 +544,91 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
case WM_RBUTTONDOWN:
{
const auto g_hoverItem = *reinterpret_cast<diablo2::structures::unit**>(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;
const auto player = diablo2::d2_client::get_local_player();
const auto pInventory = player->inventory;
std::vector<diablo2::structures::unit*> items;
diablo2::structures::unit* gemBag{};
// get the gembag item
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);
if (record->type == 101) {
gemBag = item;
}
}
// 378 is ruby
// 379 is amathyst
// 380 is diamond
// 381 is emerald
// 382 is saphhire
// 383 is topaz
// 384 is skull
// 385 is El Runes
// 386 is Sol Runes
// 387 is Mal Runes
// properties.txt row number - 3
if (strncmp(normCode, "gcv", 3) == 0) { // Use strncmp for string comparison
int32_t stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
//MessageBoxA(0, std::to_string(stat).c_str(), "stat", 0);
stat++;
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = 382 - 3;
itemProperty.nLayer = 0;
itemProperty.nMin = 1;
itemProperty.nMax = 1;
//diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat, 0);
diablo2::d2_common::add_property(gemBag, &itemProperty, 0);
diablo2::d2_common::inv_remove_item(pInventory, g_hoverItem);
int32_t stat1 = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
//MessageBoxA(0, std::to_string(stat1).c_str(), "stat", 0);
}
// check to see if gembag is actually right
//const auto bagrecord = diablo2::d2_common::get_item_record(gemBag->data_record_index);
//char* bagcode = bagrecord->string_code;
//MessageBoxA(0, bagcode, "bag code", 0);
//if (normCode == "gcv") {
// int stat = diablo2::d2_common::get_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, NULL);
// diablo2::d2_common::set_stat(gemBag, diablo2::unit_stats_t::UNIT_STAT_gembag_Amethyst, stat + 1, 0);
// MessageBoxA(0, normCode, "normCode", 0);
//}
}
block = instance.process_right_mouse(false);
break;
}