This commit is contained in:
Hash Borgir 2024-05-06 00:57:34 -06:00
parent ee810d5f38
commit 4e02101d5d
72 changed files with 797 additions and 408 deletions

Binary file not shown.

View File

@ -1,2 +1,2 @@
 ui_manager.cpp
 loot_filter_settings_menu.cpp
D2tweaks.vcxproj -> D:\Diablo II\MODS\ironman-dev\D2tweaks.dll

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -187,6 +187,29 @@ static std::unordered_map<std::string, GemType> gemTypes = {
};
void d2_tweaks::client::modules::loot_filter_settings_menu::gem_checkbox_clicked(const std::string& gem) {
// Set the state of the clicked checkbox to true
if (m_show_amethyst && gem == "amethyst") {
m_show_amethyst->set_state(true);
}
else if (m_show_ruby && gem == "ruby") {
m_show_ruby->set_state(true);
}
else if (m_show_sapphire && gem == "sapphire") {
m_show_sapphire->set_state(true);
}
else if (m_show_emerald && gem == "emerald") {
m_show_emerald->set_state(true);
}
else if (m_show_diamond && gem == "diamond") {
m_show_diamond->set_state(true);
}
else if (m_show_topaz && gem == "topaz") {
m_show_topaz->set_state(true);
}
else if (m_show_skull && gem == "skull") {
m_show_skull->set_state(true);
}
// Uncheck all other gem checkboxes
if (m_show_amethyst && gem != "amethyst") {
m_show_amethyst->set_state(false);
@ -212,9 +235,14 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::gem_checkbox_clicked
// Update the selected gem
m_selected_gem = gem;
// display m_selected_gem in a messagebox
//MessageBoxA(NULL, m_selected_gem.c_str(), "Selected Gem", MB_OK);
}
void d2_tweaks::client::modules::loot_filter_settings_menu::register_misc_checkboxes() {
m_altonly = get_control<ui::controls::checkbox>("m_altonly");
m_show_gold = get_control<ui::controls::checkbox>("m_show_gold");
@ -274,46 +302,27 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::register_misc_checkb
// gems
{
if (m_show_amethyst) {
m_show_amethyst->set_state(loot_filter_settings::get().m_show_amethyst);
m_show_amethyst->set_on_click(std::bind(&loot_filter_settings_menu::extract_amethyst,
this, std::placeholders::_1));
m_show_amethyst->set_on_click(std::bind(&loot_filter_settings_menu::gem_checkbox_clicked, this, "amethyst"));
}
if (m_show_diamond) {
m_show_diamond->set_state(loot_filter_settings::get().m_show_diamond);
m_show_diamond->set_on_click(std::bind(&loot_filter_settings_menu::extract_diamond,
this, std::placeholders::_1));
}
if (m_show_emerald) {
m_show_emerald->set_state(loot_filter_settings::get().m_show_emerald);
m_show_emerald->set_on_click(std::bind(&loot_filter_settings_menu::extract_emerald,
this, std::placeholders::_1));
}
if (m_show_ruby) {
m_show_ruby->set_state(loot_filter_settings::get().m_show_ruby);
m_show_ruby->set_on_click(std::bind(&loot_filter_settings_menu::extract_ruby,
this, std::placeholders::_1));
m_show_ruby->set_on_click(std::bind(&loot_filter_settings_menu::gem_checkbox_clicked, this, "ruby"));
}
if (m_show_sapphire) {
m_show_sapphire->set_state(loot_filter_settings::get().m_show_sapphire);
m_show_sapphire->set_on_click(std::bind(&loot_filter_settings_menu::extract_sapphire,
this, std::placeholders::_1));
m_show_sapphire->set_on_click(std::bind(&loot_filter_settings_menu::gem_checkbox_clicked, this, "sapphire"));
}
if (m_show_skull) {
m_show_skull->set_state(loot_filter_settings::get().m_show_skull);
m_show_skull->set_on_click(std::bind(&loot_filter_settings_menu::extract_skull,
this, std::placeholders::_1));
if (m_show_emerald) {
m_show_emerald->set_on_click(std::bind(&loot_filter_settings_menu::gem_checkbox_clicked, this, "emerald"));
}
if (m_show_diamond) {
m_show_diamond->set_on_click(std::bind(&loot_filter_settings_menu::gem_checkbox_clicked, this, "diamond"));
}
if (m_show_topaz) {
m_show_topaz->set_state(loot_filter_settings::get().m_show_topaz);
m_show_topaz->set_on_click(std::bind(&loot_filter_settings_menu::extract_topaz,
this, std::placeholders::_1));
m_show_topaz->set_on_click(std::bind(&loot_filter_settings_menu::gem_checkbox_clicked, this, "topaz"));
}
if (m_show_skull) {
m_show_skull->set_on_click(std::bind(&loot_filter_settings_menu::gem_checkbox_clicked, this, "skull"));
}
}
@ -628,33 +637,413 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::extract_topaz(bool v
// qualities extraction functions
void d2_tweaks::client::modules::loot_filter_settings_menu::extract_chipped(bool value) {
if (value) {
// Checkbox is checked
// Perform actions when the checkbox is checked
uint32_t gemCode;
int gemPropRowID;
diablo2::unit_stats_t stat;
if (m_selected_gem == "amethyst") {
gemCode = 'gcv ';
gemPropRowID = 382;
stat = diablo2::UNIT_STAT_gembag_Amethyst;
MessageBoxA(NULL, value ? "Checked" : "Unchecked", "Checkbox value true", MB_OK);
}
else {
// Checkbox is unchecked
// Perform actions when the checkbox is unchecked
MessageBoxA(NULL, value ? "Checked" : "Unchecked", "Checkbox value false", MB_OK);
else if (m_selected_gem == "ruby") {
gemCode = 'gcr ';
gemPropRowID = 381;
stat = diablo2::UNIT_STAT_gembag_Ruby;
}
else if (m_selected_gem == "sapphire") {
gemCode = 'gcb ';
gemPropRowID = 385;
stat = diablo2::UNIT_STAT_gembag_Sapphire;
}
else if (m_selected_gem == "emerald") {
gemCode = 'gcg ';
gemPropRowID = 384;
stat = diablo2::UNIT_STAT_gembag_Emerald;
}
else if (m_selected_gem == "diamond") {
gemCode = 'gcw ';
gemPropRowID = 383;
stat = diablo2::UNIT_STAT_gembag_Diamond;
}
else if (m_selected_gem == "topaz") {
gemCode = 'gcy ';
gemPropRowID = 386;
stat = diablo2::UNIT_STAT_gembag_Topaz;
}
else if (m_selected_gem == "skull") {
gemCode = 'skc ';
gemPropRowID = 387;
stat = diablo2::UNIT_STAT_gembag_Skull;
}
loot_filter_settings::get().m_show_chipped = value;
auto player = diablo2::d2_client::get_local_player();
auto inventory = player->inventory;
diablo2::structures::unit* bag;
uint32_t bagGuid;
uint32_t statValue;
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;
// get item stat
statValue = diablo2::d2_common::get_stat(item, stat, NULL);
}
}
// dump out gemPropRowID in a messagebox
std::string gemPropRowIDStr = std::to_string(gemPropRowID);
MessageBoxA(NULL, gemPropRowIDStr.c_str(), "gemPropRowID Client side", MB_OK);
if (statValue > 1) {
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = bagGuid;
packet.bag_guid = bagGuid;
packet.target_page = 0;
packet.extract = 1;
packet.val = 1;
packet.prop = gemPropRowID - 3;
packet.iCode = gemCode;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = gemPropRowID - 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_flawed(bool value) {
// Implementation goes here
uint32_t gemCode;
int gemPropRowID;
diablo2::unit_stats_t stat;
if (m_selected_gem == "amethyst") {
gemCode = 'gfv ';
gemPropRowID = 382;
stat = diablo2::UNIT_STAT_gembag_Amethyst;
}
else if (m_selected_gem == "ruby") {
gemCode = 'gfr ';
gemPropRowID = 381;
stat = diablo2::UNIT_STAT_gembag_Ruby;
}
else if (m_selected_gem == "sapphire") {
gemCode = 'gfb ';
gemPropRowID = 385;
stat = diablo2::UNIT_STAT_gembag_Sapphire;
}
else if (m_selected_gem == "emerald") {
gemCode = 'gfg ';
gemPropRowID = 384;
stat = diablo2::UNIT_STAT_gembag_Emerald;
}
else if (m_selected_gem == "diamond") {
gemCode = 'gfw ';
gemPropRowID = 383;
stat = diablo2::UNIT_STAT_gembag_Diamond;
}
else if (m_selected_gem == "topaz") {
gemCode = 'gfy ';
gemPropRowID = 386;
stat = diablo2::UNIT_STAT_gembag_Topaz;
}
else if (m_selected_gem == "skull") {
gemCode = 'skf ';
gemPropRowID = 387;
stat = diablo2::UNIT_STAT_gembag_Skull;
}
loot_filter_settings::get().m_show_chipped = value;
auto player = diablo2::d2_client::get_local_player();
auto inventory = player->inventory;
diablo2::structures::unit* bag;
uint32_t bagGuid;
uint32_t statValue;
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;
// get item stat
statValue = diablo2::d2_common::get_stat(item, stat, NULL);
}
}
// dump out gemPropRowID in a messagebox
std::string gemPropRowIDStr = std::to_string(gemPropRowID);
MessageBoxA(NULL, gemPropRowIDStr.c_str(), "gemPropRowID Client side", MB_OK);
if (statValue > 3) {
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = bagGuid;
packet.bag_guid = bagGuid;
packet.target_page = 0;
packet.extract = 1;
packet.prop = gemPropRowID - 3;
packet.val = 3;
packet.iCode = gemCode;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = gemPropRowID - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = -3;
itemProperty.nMax = -3;
diablo2::d2_common::add_property(bag, &itemProperty, 0);
}
}
void d2_tweaks::client::modules::loot_filter_settings_menu::extract_normal(bool value) {
// Implementation goes here
uint32_t gemCode;
int gemPropRowID;
diablo2::unit_stats_t stat;
if (m_selected_gem == "amethyst") {
gemCode = 'gsv ';
gemPropRowID = 382;
stat = diablo2::UNIT_STAT_gembag_Amethyst;
}
else if (m_selected_gem == "ruby") {
gemCode = 'gsr ';
gemPropRowID = 381;
stat = diablo2::UNIT_STAT_gembag_Ruby;
}
else if (m_selected_gem == "sapphire") {
gemCode = 'gsb ';
gemPropRowID = 385;
stat = diablo2::UNIT_STAT_gembag_Sapphire;
}
else if (m_selected_gem == "emerald") {
gemCode = 'gsg ';
gemPropRowID = 384;
stat = diablo2::UNIT_STAT_gembag_Emerald;
}
else if (m_selected_gem == "diamond") {
gemCode = 'gsw ';
gemPropRowID = 383;
stat = diablo2::UNIT_STAT_gembag_Diamond;
}
else if (m_selected_gem == "topaz") {
gemCode = 'gsy ';
gemPropRowID = 386;
stat = diablo2::UNIT_STAT_gembag_Topaz;
}
else if (m_selected_gem == "skull") {
gemCode = 'sku ';
gemPropRowID = 387;
stat = diablo2::UNIT_STAT_gembag_Skull;
}
loot_filter_settings::get().m_show_chipped = value;
auto player = diablo2::d2_client::get_local_player();
auto inventory = player->inventory;
diablo2::structures::unit* bag;
uint32_t bagGuid;
uint32_t statValue;
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;
// get item stat
statValue = diablo2::d2_common::get_stat(item, stat, NULL);
}
}
if (statValue > 9) {
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = bagGuid;
packet.bag_guid = bagGuid;
packet.target_page = 0;
packet.extract = 1;
packet.val = 9;
packet.prop = gemPropRowID - 3;
packet.iCode = gemCode;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = gemPropRowID - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = -9;
itemProperty.nMax = -9;
diablo2::d2_common::add_property(bag, &itemProperty, 0);
}
}
void d2_tweaks::client::modules::loot_filter_settings_menu::extract_flawless(bool value) {
// Implementation goes here
uint32_t gemCode;
int gemPropRowID;
diablo2::unit_stats_t stat;
if (m_selected_gem == "amethyst") {
gemCode = 'gzv ';
gemPropRowID = 382;
stat = diablo2::UNIT_STAT_gembag_Amethyst;
}
else if (m_selected_gem == "ruby") {
gemCode = 'glr ';
gemPropRowID = 381;
stat = diablo2::UNIT_STAT_gembag_Ruby;
}
else if (m_selected_gem == "sapphire") {
gemCode = 'glb ';
gemPropRowID = 385;
stat = diablo2::UNIT_STAT_gembag_Sapphire;
}
else if (m_selected_gem == "emerald") {
gemCode = 'glg ';
gemPropRowID = 384;
stat = diablo2::UNIT_STAT_gembag_Emerald;
}
else if (m_selected_gem == "diamond") {
gemCode = 'glw ';
gemPropRowID = 383;
stat = diablo2::UNIT_STAT_gembag_Diamond;
}
else if (m_selected_gem == "topaz") {
gemCode = 'gly ';
gemPropRowID = 386;
stat = diablo2::UNIT_STAT_gembag_Topaz;
}
else if (m_selected_gem == "skull") {
gemCode = 'skl ';
gemPropRowID = 387;
stat = diablo2::UNIT_STAT_gembag_Skull;
}
loot_filter_settings::get().m_show_chipped = value;
auto player = diablo2::d2_client::get_local_player();
auto inventory = player->inventory;
diablo2::structures::unit* bag;
uint32_t bagGuid;
uint32_t statValue;
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;
// get item stat
statValue = diablo2::d2_common::get_stat(item, stat, NULL);
}
}
if (statValue > 27) {
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = bagGuid;
packet.bag_guid = bagGuid;
packet.target_page = 0;
packet.extract = 1;
packet.val = 27;
packet.prop = gemPropRowID - 3;
packet.iCode = gemCode;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = gemPropRowID - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = -27;
itemProperty.nMax = -27;
diablo2::d2_common::add_property(bag, &itemProperty, 0);
}
}
void d2_tweaks::client::modules::loot_filter_settings_menu::extract_perfect(bool value) {
// Implementation goes here
uint32_t gemCode;
int gemPropRowID;
diablo2::unit_stats_t stat;
if (m_selected_gem == "amethyst") {
gemCode = 'gpv ';
gemPropRowID = 382;
stat = diablo2::UNIT_STAT_gembag_Amethyst;
}
else if (m_selected_gem == "ruby") {
gemCode = 'gpr ';
gemPropRowID = 381;
stat = diablo2::UNIT_STAT_gembag_Ruby;
}
else if (m_selected_gem == "sapphire") {
gemCode = 'gpb ';
gemPropRowID = 385;
stat = diablo2::UNIT_STAT_gembag_Sapphire;
}
else if (m_selected_gem == "emerald") {
gemCode = 'gpg ';
gemPropRowID = 384;
stat = diablo2::UNIT_STAT_gembag_Emerald;
}
else if (m_selected_gem == "diamond") {
gemCode = 'gpw ';
gemPropRowID = 383;
stat = diablo2::UNIT_STAT_gembag_Diamond;
}
else if (m_selected_gem == "topaz") {
gemCode = 'gpy ';
gemPropRowID = 386;
stat = diablo2::UNIT_STAT_gembag_Topaz;
}
else if (m_selected_gem == "skull") {
gemCode = 'skz ';
gemPropRowID = 387;
stat = diablo2::UNIT_STAT_gembag_Skull;
}
loot_filter_settings::get().m_show_chipped = value;
auto player = diablo2::d2_client::get_local_player();
auto inventory = player->inventory;
diablo2::structures::unit* bag;
uint32_t bagGuid;
uint32_t statValue;
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;
// get item stat
statValue = diablo2::d2_common::get_stat(item, stat, NULL);
}
}
if (statValue > 81) {
// Create the packet
static d2_tweaks::common::item_move_cs packet;
packet.item_guid = bagGuid;
packet.bag_guid = bagGuid;
packet.target_page = 0;
packet.extract = 1;
packet.val = 81;
packet.prop = gemPropRowID - 3;
packet.iCode = gemCode;
diablo2::d2_client::send_to_server(&packet, sizeof packet);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = gemPropRowID - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = -81;
itemProperty.nMax = -81;
diablo2::d2_common::add_property(bag, &itemProperty, 0);
}
}

View File

@ -80,10 +80,10 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
//MessageBox(NULL, bag_guid.c_str(), "Bag GUID", MB_OK | MB_ICONINFORMATION);
D2PropertyStrc itemProperty = {};
itemProperty.nProperty = 388 - 3; // Adjust the property ID
itemProperty.nProperty = itemMove->prop - 3; // Adjust the property ID
itemProperty.nLayer = 0;
itemProperty.nMin = -1;
itemProperty.nMax = -1;
itemProperty.nMin = itemMove->val;
itemProperty.nMax = itemMove->val;
// Add the gem property to the gem bag
diablo2::d2_common::add_property(bag, &itemProperty, 0);