Rejuv potiuons added to extractor

This commit is contained in:
Hash Borgir 2024-05-06 23:00:55 -06:00
parent a61dce8f03
commit 408aee62c1
5 changed files with 165 additions and 18 deletions

View File

@ -91,6 +91,9 @@ namespace d2_tweaks {
bool m_show_quartz;
bool m_show_tiger_eye;
bool m_show_rejuv_potion;
bool m_show_full_rejuv_potion;
bool quality_settings[static_cast<size_t>(diablo2::structures::item_quality_t::ITEM_QUALITY_COUNT)];

View File

@ -104,8 +104,8 @@ namespace d2_tweaks {
ui::controls::checkbox* m_show_spectacular;
ui::controls::checkbox* m_show_legendary;
ui::controls::checkbox* m_show_legendary_cut;
ui::controls::checkbox* m_show_rejuv_potion;
ui::controls::checkbox* m_show_full_rejuv_potion;
void(__fastcall* m_draw_dropped_items_names_original)(void*, void*);
void(__fastcall* m_handle_dropped_items_original)(void*, void*);
@ -126,8 +126,6 @@ namespace d2_tweaks {
void register_misc_checkboxes();
void register_quality_checkboxes();
void extract_rune(bool value, uint32_t runeCode, uint32_t minValue, int propertyRowID);
void update_alt_only(bool value);
void extract_r01(bool value);
void extract_r02(bool value);
@ -197,13 +195,17 @@ namespace d2_tweaks {
void extract_legendary(bool value);
void extract_legendary_cut(bool value);
void extract_flourite(bool value);
void extract_jade(bool value);
void extract_argonite(bool value);
void extract_azurite(bool value);
void extract_sulpher(bool value);
void extract_quartz(bool value);
void extract_tiger_eye(bool value);
void extract_rejuv_potion(bool value);
void extract_full_rejuv_potion(bool value);
//void extract_flourite(bool value);
//void extract_jade(bool value);
//void extract_argonite(bool value);
//void extract_azurite(bool value);
//void extract_sulpher(bool value);
//void extract_quartz(bool value);
//void extract_tiger_eye(bool value);
void update_show_gold(bool value);
void update_show_runes(bool value);

View File

@ -945,7 +945,7 @@ namespace diablo2 {
UNIT_STAT_UNUSED_67 = 483,
UNIT_STAT_UNUSED_68 = 484,
UNIT_STAT_UNUSED_69 = 485,
UNIT_STAT_UNUSED_70 = 486,
UNIT_STAT_gembag_Potions = 486,
UNIT_STAT_gembag_Stones_Flourite = 487,
UNIT_STAT_gembag_Stones_Jade = 488,
UNIT_STAT_gembag_Stones_Argonite = 489,

View File

@ -379,6 +379,24 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::register_misc_checkb
m_show_legendary = get_control<ui::controls::checkbox>("m_show_legendary");
m_show_legendary_cut = get_control<ui::controls::checkbox>("m_show_legendary_cut");
m_show_rejuv_potion = get_control<ui::controls::checkbox>("m_show_rejuv_potion");
m_show_full_rejuv_potion = get_control<ui::controls::checkbox>("m_show_full_rejuv_potion");
// potions
{
if (m_show_rejuv_potion) {
m_show_rejuv_potion->set_state(loot_filter_settings::get().m_show_rejuv_potion);
m_show_rejuv_potion->set_on_click(std::bind(&loot_filter_settings_menu::extract_rejuv_potion,
this, std::placeholders::_1));
}
if (m_show_full_rejuv_potion) {
m_show_full_rejuv_potion->set_state(loot_filter_settings::get().m_show_full_rejuv_potion);
m_show_full_rejuv_potion->set_on_click(std::bind(&loot_filter_settings_menu::extract_full_rejuv_potion,
this, std::placeholders::_1));
}
}
// gems
{
if (m_show_amethyst) {
@ -824,6 +842,87 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::update_alt_only(bool
loot_filter_settings::get().save(diablo2::d2_client::get_local_player_name());
}
// potions
void d2_tweaks::client::modules::loot_filter_settings_menu::extract_rejuv_potion(bool value) {
MessageBoxA(NULL, "extract_rejuv_potion", "extract_rejuv_potion", MB_OK);
loot_filter_settings::get().m_show_rejuv_potion = value;
auto player = diablo2::d2_client::get_local_player();
auto inventory = player->inventory;
diablo2::structures::unit* bag;
uint32_t bagGuid = -1;
uint32_t statValue = 0;
for (auto item = 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);
auto recordType = diablo2::d2_common::get_item_type_record(record->type);
char* normCode1 = record->string_code;
if (strncmp(normCode1, "ib1", 3) == 0) {
bag = item;
bagGuid = item->guid;
statValue = diablo2::d2_common::get_stat(item, diablo2::UNIT_STAT_gembag_Potions, NULL);
}
}
if (statValue >= 1) {
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = bagGuid;
packet.bag_guid = bagGuid;
packet.target_page = 0;
packet.extract = 1;
packet.iCode = 'rvs ';
packet.prop = 396 - 3;
packet.val = -1;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = 396 - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = -1;
itemProperty.nMax = -1;
diablo2::d2_common::add_property(bag, &itemProperty, 0);
}
}
void d2_tweaks::client::modules::loot_filter_settings_menu::extract_full_rejuv_potion(bool value) {
loot_filter_settings::get().m_show_full_rejuv_potion = value;
auto player = diablo2::d2_client::get_local_player();
auto inventory = player->inventory;
diablo2::structures::unit* bag;
uint32_t bagGuid = -1;
uint32_t statValue = 0;
for (auto item = 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);
auto recordType = diablo2::d2_common::get_item_type_record(record->type);
char* normCode1 = record->string_code;
if (strncmp(normCode1, "ib1", 3) == 0) {
bag = item;
bagGuid = item->guid;
statValue = diablo2::d2_common::get_stat(item, diablo2::UNIT_STAT_gembag_Potions, NULL);
}
}
if (statValue >= 3) {
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = bagGuid;
packet.bag_guid = bagGuid;
packet.target_page = 0;
packet.extract = 1;
packet.iCode = 'rvl ';
packet.prop = 396 - 3;
packet.val = -3;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = 396 - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = -3;
itemProperty.nMax = -3;
diablo2::d2_common::add_property(bag, &itemProperty, 0);
}
}
// gems extraction functions
void d2_tweaks::client::modules::loot_filter_settings_menu::extract_amethyst(bool value) {}
@ -4211,7 +4310,12 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::extract_r33(bool val
}
}
// Rune Extraction Functions
// End Rune Extraction Functions
// Rejuv Potions
void d2_tweaks::client::modules::loot_filter_settings_menu::update_show_gold(bool value) {
loot_filter_settings::get().show_gold = value;

View File

@ -169,7 +169,6 @@ const char* ITEMS_gems_and_runes[] = {
"r05", "r06", "r07", "r08", "r09", "r10", "r11", "r12", "r13", "r14",
"r15", "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", "r24",
"r25", "r26", "r27", "r28", "r29", "r30", "r31", "r32", "r33", "ib2",
};
const char* ITEMS_Stones[] = {
@ -201,7 +200,6 @@ struct GemType {
// Gem/Rune Extractors
static std::unordered_map<std::string, GemType> stoneTypes = {
};
// Gems/runes and their corresponding codes and properties.txt line numbers
@ -222,7 +220,7 @@ static std::unordered_map<std::string, GemType> gemTypes = {
{"gfy", {3, 386}}, // Flawed Topaz
{"gsv", {9, 382}}, // Amethyst
{"gsw", {9, 383}}, // Diamond
{"gsg", {9, 384}}, // Emerald
{"gsg", {9, 384}}, // Emerald`
{"gsr", {9, 381}}, // Ruby
{"gsb", {9, 385}}, // Sapphire
{"sku", {9, 387}}, // Skull
@ -742,7 +740,7 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
const char* key;
// Check if the current page is the stash or inventory, right click on gem/rune will
// add it to the cube and send it to page 99 which is non existent
// add it to the cube and send it to page 99 which is non existent
// (hope it doesn't bloat save file size and actualy disappears from memory)
if (currentPage == 0 || currentPage == 4) {
// Check if the stash or inventory window is open
@ -1058,7 +1056,7 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
// Check if the wheel is scrolled downwards
else if (zDelta < 0) {
// Process the mouse wheel input by scrolling downwards
// Calculate the memory address of the hover item in the game
// by adding an offset to the base address of the client
const auto g_hoverItem = *reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4);
@ -1143,6 +1141,7 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
diablo2::structures::unit* box{};
diablo2::structures::unit* harvester{};
// 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);
@ -1163,6 +1162,45 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
}
}
if (strncmp(normCode, "rvs", 3) == 0) {
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.bag_guid = gemBagGuid;
packet.updateBag = 1;
packet.iCode = 'rvs ';
packet.prop = 396 - 3;
packet.val = 1;
packet.item_guid = g_hoverItem->guid;
packet.target_page = 99;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = 396 - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = 1;
itemProperty.nMax = 1;
diablo2::d2_common::add_property(gemBag, &itemProperty, 0);
}
if (strncmp(normCode, "rvl", 3) == 0) {
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.bag_guid = gemBagGuid;
packet.updateBag = 1;
packet.iCode = 'rvl ';
packet.prop = 396 - 3;
packet.val = 3;
packet.item_guid = g_hoverItem->guid;
packet.target_page = 99;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = 396 - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = 3;
itemProperty.nMax = 3;
diablo2::d2_common::add_property(gemBag, &itemProperty, 0);
}
if (isArmorOrWeaponCode(normCode)
|| record->type == 61 - 3 // jewel
|| record->type == 43 - 3 // key