Stats display refactor using ini file done.

This commit is contained in:
Hash Borgir
2024-05-02 21:43:43 -06:00
parent f8349e6ba1
commit 7fd617abd7
176 changed files with 1731 additions and 1866 deletions

View File

@@ -8,7 +8,6 @@
#include <d2tweaks/client/modules/client_module.h>
#include <d2tweaks/ui/ui_manager.h>
#include <diablo2/structures/unit.h>
#include <diablo2/structures/client_unit_list.h>
#include <WinBase.h>
@@ -45,12 +44,6 @@
std::vector<StatEntry> globalStatsVector;
diablo2::structures::gfxdata g_gfxdata; // global gfxdata
int randStat;
int randStatRangeLow;
int randStatRangeHigh;
int randStatBool;
std::wstring ConvertCharToWString(const std::string& charString) {
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
return converter.from_bytes(charString);
@@ -99,8 +92,6 @@ diablo2::ui_color_t mapColorToEnum(const std::string& colorName) {
return diablo2::ui_color_t::UI_COLOR_WHITE;
}
// Define a struct to hold key-value pairs within a section
struct Section {
std::map<std::string, std::string> assignments;
@@ -166,6 +157,14 @@ void ParseIniFile(const std::string& iniFilePath) {
else if (key == "item_type_id") {
entry.item_type_id = std::stoi(value);
}
// add op and param
else if (key == "op") {
entry.op = std::stoi(value);
}
// add op and param
else if (key == "param") {
entry.param = std::stoi(value);
}
}
}
}
@@ -214,8 +213,8 @@ __declspec (naked) void handle_cs_packet_wrapper() {
__asm {
pushad;
pushfd;
call [d2_tweaks::client::client::handle_cs_packet]
popfd;
call[d2_tweaks::client::client::handle_cs_packet]
popfd;
popad;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sub esp, 0x200;
@@ -223,13 +222,12 @@ __declspec (naked) void handle_cs_packet_wrapper() {
RET_TO_RVA(DLLBASE_D2CLIENT, 0xD856);
}
__declspec (naked) void handle_sc_standart_packet_wrapper() {
__asm {
pushad;
pushfd;
call[d2_tweaks::client::client::handle_standart_packet]
popfd;
popfd;
popad;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sub esp, 0x54;
@@ -239,7 +237,6 @@ __declspec (naked) void handle_sc_standart_packet_wrapper() {
RET_TO_RVA(DLLBASE_D2CLIENT, 0x150B5);
}
static const DLLPatchStrc gpt_handle_cs_packet[] =
{
{D2DLL_D2CLIENT, 0xD850 + 0, PATCH_JMP, FALSE, 0x1},
@@ -248,7 +245,6 @@ static const DLLPatchStrc gpt_handle_cs_packet[] =
{D2DLL_INVALID}
};
static const DLLPatchStrc gpt_handle_sc_standart_packet[] =
{
{D2DLL_D2CLIENT, 0x150B0 + 0, PATCH_JMP, FALSE, 0x1},
@@ -256,7 +252,6 @@ static const DLLPatchStrc gpt_handle_sc_standart_packet[] =
{D2DLL_INVALID}
};
void d2_tweaks::client::client::init() {
// handle packet <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> GamePacketReceivedIntercept
hooking::hook(diablo2::d2_client::get_base() + 0x11CB0, handle_packet, reinterpret_cast<void**>(&g_handle_packet));
@@ -272,23 +267,10 @@ void d2_tweaks::client::client::init() {
if (m_module == nullptr)
break;
//randStat = GetPrivateProfileIntA("RandStat", "stat", 0, lpIniFilePath);
//randStatRangeLow = GetPrivateProfileIntA("RandStat", "statRangeLow", 0, lpIniFilePath);
//randStatRangeHigh = GetPrivateProfileIntA("RandStat", "statRangeHigh", 0, lpIniFilePath);
//randStatBool = GetPrivateProfileIntA("RandStat", "statBool", 0, lpIniFilePath);
//spdlog::info("randStat = {0}", randStat);
//spdlog::info("randStatRangeLow = {0}", randStatRangeLow);
//spdlog::info("randStatRangeHigh = {0}", randStatRangeHigh);
// Load and parse the INI file
ParseIniFile(iniFilePath);
}
D2TEMPLATE_ApplyPatch(gpt_handle_cs_packet);
//D2TEMPLATE_ApplyPatch(gpt_handle_sc_standart_packet);
@@ -300,13 +282,12 @@ void d2_tweaks::client::client::init() {
}
}
static int32_t g_ebp_send_to_client;
void d2_tweaks::client::client::handle_cs_packet(common::packet_header* packet, size_t size) {
#ifndef NDEBUG
__asm {
push [ebp + 0x2C];
pop [g_ebp_send_to_client];
push[ebp + 0x2C];
pop[g_ebp_send_to_client];
}
spdlog::warn("[d2client SEND] Packet {} Message {} Size {} CallFrom {}", (void*)packet->d2_packet_type, (void*)packet->message_type, size, (void*)g_ebp_send_to_client);
#endif
@@ -325,7 +306,6 @@ void d2_tweaks::client::client::handle_cs_packet(common::packet_header* packet,
handler->handle_cs_packet(packet);
}
void d2_tweaks::client::client::handle_standart_packet(common::packet_header* packet, size_t size) {
if (size == -1)
return;
@@ -337,7 +317,6 @@ void d2_tweaks::client::client::handle_standart_packet(common::packet_header* pa
return;
}
void d2_tweaks::client::client::handle_packet(common::packet_header* packet, size_t size) {
static common::packet_header dummy;
static auto& instance = singleton<client>::instance();
@@ -362,10 +341,8 @@ void d2_tweaks::client::client::handle_packet(common::packet_header* packet, siz
handler->handle_packet(packet);
}
static bool g_is_init = false;
void d2_tweaks::client::client::game_tick() {
static auto& instance = singleton<client>::instance(); /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> d2 gl
if (g_is_init == false) {
@@ -380,7 +357,7 @@ void d2_tweaks::client::client::game_tick() {
g_is_init = true;
}
for (auto & tick_handler : instance.m_tick_handlers) {
for (auto& tick_handler : instance.m_tick_handlers) {
if (tick_handler == nullptr)
break;
@@ -390,7 +367,6 @@ void d2_tweaks::client::client::game_tick() {
return;
}
int32_t d2_tweaks::client::client::draw_game_ui() {
static auto& ui = singleton<ui::ui_manager>::instance();
@@ -401,8 +377,6 @@ int32_t d2_tweaks::client::client::draw_game_ui() {
return result;
}
void d2_tweaks::client::client::register_module(modules::client_module* module) {
m_modules[m_module_id_counter++] = module;
}
@@ -439,4 +413,4 @@ diablo2::structures::unit* d2_tweaks::client::client::get_client_unit(uint32_t t
}
return result;
}
}

View File

@@ -67,12 +67,9 @@ public:
}
};
void d2_tweaks::client::modules::auto_gold_pickup::init_early() {
}
void d2_tweaks::client::modules::auto_gold_pickup::init() {
char acPathToIni[MAX_PATH] = { 0 };
const char* pcIniFile = "\\d2tweaks.ini";
@@ -89,7 +86,6 @@ void d2_tweaks::client::modules::auto_gold_pickup::init() {
}
}
void d2_tweaks::client::modules::auto_gold_pickup::tick() {
const auto unit = diablo2::d2_client::get_local_player();
@@ -133,9 +129,8 @@ void d2_tweaks::client::modules::auto_gold_pickup::tick() {
}
}
void d2_tweaks::client::modules::auto_gold_pickup::handle_packet(common::packet_header* packet) {
const auto info = static_cast<common::gold_pickup_info_sc*>(packet);
m_nLastUpdate = GetTickCount();
m_nGoldValue += info->gold;
}
}

View File

@@ -67,7 +67,6 @@ static char m_acPathToIni[MAX_PATH] = { 0 };
static const char* m_pcIniFile = "\\d2tweaks.ini";
void d2_tweaks::client::modules::auto_item_pickup::init_early() {
}
void ReloadFilters(char* szPathToIni) {
@@ -120,7 +119,6 @@ void ReloadFilters(char* szPathToIni) {
}
}
/// Parse ItemCode
dwLenght = lstrlen(m_pcItemListAll);
memcpy(m_pcItemListAllTemp, m_pcItemListAll, dwLenght + 1);
@@ -196,7 +194,6 @@ void ReloadFilters(char* szPathToIni) {
token_string_itemcode = strtok(NULL, " ,|");
}
/// Parse ItemType Code
dwLenght = lstrlen(m_pcItemTypesAll);
memcpy(m_pcItemTypesAllTemp, m_pcItemTypesAll, dwLenght + 1);
@@ -272,7 +269,6 @@ void ReloadFilters(char* szPathToIni) {
}
}
class auto_item_pickup_menu : public d2_tweaks::ui::menu {
d2_tweaks::common::asset* m_buttons_img;
d2_tweaks::ui::controls::button* m_auto_pickup_btn;
@@ -304,7 +300,7 @@ public:
//diablo2::d2_client::print_chat(L"AUTO TRANSMUTE OFF", 2);
m_auto_pickup_btn->set_current_frame(6);
}
if (m_bToggleAutoItemPickup && m_bInventoryFull) {
m_auto_pickup_btn->set_current_frame(7);
}
@@ -359,7 +355,6 @@ private:
}
};
void d2_tweaks::client::modules::auto_item_pickup::init() {
GetCurrentDirectory(MAX_PATH, m_acPathToIni);
lstrcat(m_acPathToIni, m_pcIniFile);
@@ -375,7 +370,6 @@ void d2_tweaks::client::modules::auto_item_pickup::init() {
}
}
bool find_free_space(diablo2::structures::inventory* inv, diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y) {
char data[0x18];
@@ -396,7 +390,6 @@ bool find_free_space(diablo2::structures::inventory* inv, diablo2::structures::u
return false;
}
void d2_tweaks::client::modules::auto_item_pickup::tick() {
static common::item_pickup_info_sc packet;
const auto unit = diablo2::d2_client::get_local_player();
@@ -476,7 +469,6 @@ void d2_tweaks::client::modules::auto_item_pickup::tick() {
}
}
if (itemtype_record_equiv2) {
if (*(DWORD*)itemtype_record_equiv2->code != 0x20202020) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equiv1
@@ -527,7 +519,6 @@ void d2_tweaks::client::modules::auto_item_pickup::tick() {
}
}
for (uint32_t i = 0; i < m_nCountItemListAll; i++)
{
if (record->string_code[0] == m_stItemList[i].code0 &&
@@ -560,7 +551,6 @@ void d2_tweaks::client::modules::auto_item_pickup::tick() {
}
}
void d2_tweaks::client::modules::auto_item_pickup::handle_packet(common::packet_header* packet) {
const auto info = static_cast<common::item_pickup_info_sc*>(packet);
@@ -571,4 +561,4 @@ void d2_tweaks::client::modules::auto_item_pickup::handle_packet(common::packet_
// g_tick_between_item_pickup = g_delay_between_item_pickup;
//}
//g_value += info->gold;
}
}

View File

@@ -140,7 +140,6 @@ public:
ULONGLONG lastSendTime = GetTickCount64();
// Function to split a string into words
std::vector<std::string> split(const std::string& s, char delim) {
std::stringstream ss(s);
@@ -210,9 +209,6 @@ public:
}
}
void draw() override {
auto stats = globalStatsVector;
int textOffset = 40; // Initial offset for the first line
@@ -232,119 +228,72 @@ public:
// Initialize statValue
int32_t statValue = 0;
if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH)) {
diablo2::d2_gfx::draw_filled_rect(130, 48, 640, 155, 5, 50);
}
//if (diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_STASH)) {
// diablo2::d2_gfx::draw_filled_rect(130, 48, 640, 155, 5, 50);
//}
if (m_stats_enabled) {
for (const auto& stat : stats) {
double param = 6;
int param = stat.param;
int op = stat.op;
int32_t spirits = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(185), NULL);
int32_t soulscaptured = statValue = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(184), NULL);
switch (stat.stat) {
// 2. (statValue <- this is probably op stat1 ? * baseValue <- this is probably op base ) / 2 ^ param
auto statline = diablo2::d2_common::get_item_stat_cost_record(stat.stat);
// (op stat1 value * base stat value) / (2 ^ param)
// let's try this fucking thing
auto opBase = statline->wOpBase;
auto opStat = statline->wOpStat[0];
case 190: {
// str/spirits
statValue = static_cast<int32_t>((1 * spirits) / pow(2, param)); // what is the value of opStat_str
break;
}
case 191: {
// dex/spirits
statValue = static_cast<int32_t>((1 * spirits) / pow(2, param)); // what is the value of opStat_str
break;
}
case 192: {
// vit/spirits
statValue = static_cast<int32_t>((1 * spirits) / pow(2, param)); // what is the value of opStat_str
break;
}
case 193: {
// enr/spirits
statValue = static_cast<int32_t>((1 * spirits) / pow(2, param)); // what is the value of opStat_str
break;
}
case 200: {
// skills/souls
param = 8;
statValue = static_cast<int32_t>((1 * soulscaptured) / pow(2, param)); // what is the value of opStat_str
break;
}
auto opBaseValue = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(opBase), NULL);
auto opStatValue = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(opStat), NULL);
case 301: {
for (auto item : items) {
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
if (record->type == 104) {
statValue = diablo2::d2_common::get_stat(item, static_cast<diablo2::unit_stats_t>(stat.stat), NULL);
}
}
break;
}
case 304: {
for (auto item : items) {
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
if (record->type == 104) {
statValue = diablo2::d2_common::get_stat(item, static_cast<diablo2::unit_stats_t>(stat.stat), NULL);
}
}
break;
}
default: {
// By default, get player stats
statValue = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(stat.stat), NULL);
break;
}
}
/*
int32_t diablo2::d2_common::set_stat(structures::unit* unit, unit_stats_t stat, uint32_t value, int16_t param) {
static wrap_func_std_import<int32_t(structures::unit*, int32_t, int32_t, int32_t)> set_stat(10517, get_base());
return set_stat(unit, stat, value, param);
}
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(randStatRangeLow, randStatRangeHigh);
unsigned int randomNumber = dis(gen);
std::random_device rdb;
std::mt19937 genb(rdb());
std::uniform_int_distribution<> randBool(1, 2);
unsigned int randomBool = randBool(genb) - 1;
if (stat.is_item_stat == 1) {
for (auto item : items) {
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
int RandStatValue = diablo2::d2_common::get_stat(item, static_cast<diablo2::unit_stats_t>(randStat), NULL);
if (record->type == stat.item_type_id && RandStatValue != 0) {
// set randStat value to random number 1 and 2^(32) = 4294967296
diablo2::d2_common::set_stat(item, static_cast<diablo2::unit_stats_t>(randStat), randomNumber, 0);
diablo2::d2_common::set_stat(item, static_cast<diablo2::unit_stats_t>(randStatBool), randomBool, 0);
}
if (stat.is_item_stat == 0) {
int32_t statvalue = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(stat.stat), NULL);
int basevalue = 1;
switch (op) {
case 0:
statValue = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(stat.stat), NULL);
break;
case 1: // Formula: opstatbasevalue * statvalue / 100
statValue = static_cast<int32_t>(opBaseValue) / 100;
break;
case 2: // Formula: (statvalue * basevalue) / (2 ^ param)
statValue = static_cast<int32_t>((opBaseValue) / pow(op, param));
break;
case 3: // Percentage-based version of op #2
statValue = static_cast<int32_t>((opBaseValue) / pow(op, param)) / 100;
break;
case 4: // Item-based stat increase
statValue = static_cast<int32_t>((opBaseValue) / pow(op, param));
break;
case 5: // Percentage-based item increase
statValue = static_cast<int32_t>((opBaseValue) / pow(op, param)) / 100;
break;
case 11: // Similar to op #1 and #13
statValue = static_cast<int32_t>((opBaseValue) / pow(op, param)) / 100;
break;
case 13:
statValue = static_cast<int32_t>((opBaseValue) / pow(op, param)) / 100;
break;
default:
statValue = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(stat.stat), NULL);
break;
}
}
else {
// set randStat value to random number 1 and 2^(32) = 4294967296
//diablo2::d2_common::set_stat(player, static_cast<diablo2::unit_stats_t>(randStat), randomNumber, 0);
//diablo2::d2_common::set_stat(player, static_cast<diablo2::unit_stats_t>(randStatBool), randomBool, 0);
int statValue1 = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(randStat), NULL);
int statValue2 = diablo2::d2_common::get_stat(player, static_cast<diablo2::unit_stats_t>(randStatBool), NULL);
if (statValue1 > 0 ) {
diablo2::d2_common::set_stat(player, static_cast<diablo2::unit_stats_t>(randStat), 0, 0);
diablo2::d2_common::set_stat(player, static_cast<diablo2::unit_stats_t>(randStatBool), 0, 0);
for (auto item : items) {
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
if (record->type == stat.item_type_id) {
statValue = diablo2::d2_common::get_stat(item, static_cast<diablo2::unit_stats_t>(stat.stat), NULL);
}
}
}
*/
// write code to get player name and display it using MessageBox
const auto player = diablo2::d2_client::get_local_player();
auto name = player->player_data->name;
auto statValueStr = std::to_wstring(statValue);
std::wstring statText = std::wstring(stat.stat_display_string);// .append(L" " + statValueStr);
@@ -389,13 +338,9 @@ public:
// 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;
@@ -410,14 +355,10 @@ public:
// 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;
// print player health, mana, and stamina bars, lastexp, nextexp, and level
@@ -540,15 +481,6 @@ public:
diablo2::d2_win::set_current_font(diablo2::UI_FONT_16); // Set font to FONT16
if (!should_draw()) {
m_sort_inventory_btn->set_enabled(false);
m_sort_inventory_btn->set_visible(false);

View File

@@ -12,4 +12,4 @@ void d2_tweaks::client::modules::client_module::tick() {}
void d2_tweaks::client::modules::client_module::handle_packet(common::packet_header* packet) {}
void d2_tweaks::client::modules::client_module::handle_cs_packet(common::packet_header* packet) {}
void d2_tweaks::client::modules::client_module::handle_cs_packet(common::packet_header* packet) {}

View File

@@ -48,7 +48,6 @@ struct damage_label {
}
};
static growing_object_pool<damage_label> g_label_pool([]() {
return new damage_label();
});
@@ -99,12 +98,10 @@ static unsigned int g_font_player = 1;
static unsigned int g_player_label_posx = 70;
static unsigned int g_player_label_posy = 500;
HWND findDiabloIIWindow() {
return FindWindow(nullptr, TEXT("Diablo II")); // Change "Diablo II" to the exact title of the game window
}
// Function to draw the health bar using Windows GDI
void drawHealthBar(HWND hWnd, int x, int y, int maxWidth, int height, float healthPercentage, COLORREF fillColor, COLORREF outlineColor) {
HDC hdc = GetDC(hWnd);
@@ -139,15 +136,12 @@ void OnLoad() {
}
static void onDraw(HWND hWnd, int x, int y, int maxWidth, int height, float healthPercentage, COLORREF fillColor, COLORREF outlineColor) {
if (GetTickCount64() >= nEndTime) {
nEndTime = GetTickCount64() + DURATION;
}
drawHealthBar(hWnd, x, y, maxWidth, height, healthPercentage, fillColor, outlineColor);
}
static void draw_damage_labels() {
const auto player = diablo2::d2_client::get_local_player();
@@ -272,18 +266,12 @@ static void draw_damage_labels() {
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();
diablo2::d2_win::set_current_font(diablo2::UI_FONT_6);
diablo2::d2_win::draw_text(const_cast<wchar_t*>(dmgTextPtr), textX + diablo2::d2_win::get_text_pixel_width(const_cast<wchar_t*>(combinedTextPtr)) / 2, my + label->unit_height / 2, textColor, 0);
}
}
}
@@ -309,7 +297,6 @@ static diablo2::ui_color_t damage_type_to_color(d2_tweaks::common::damage_type_t
}
void d2_tweaks::client::modules::damage_display::init_early() {
}
void d2_tweaks::client::modules::damage_display::init() {
@@ -410,5 +397,4 @@ void d2_tweaks::client::modules::damage_display::handle_packet(common::packet_he
}
void d2_tweaks::client::modules::damage_display::tick() {
}
}

View File

@@ -28,7 +28,7 @@ struct message {
char arr_itemtype_codestr_equivstr[20][5];
message(bool active, uint32_t hires_posx, uint32_t hires_posy, uint32_t lowres_posx, uint32_t lowres_posy, uint32_t quality)
: active(active),
: active(active),
text_width(0), quality(quality) {
start = 0;//GetTickCount();
memset(item_text, 0x00, sizeof item_text);
@@ -47,9 +47,9 @@ struct message {
static uint32_t m_nMsgCount = 0;
static message m_stMsg[32];
static wchar_t* m_apwcColorStr[17] = {L"ÿc0", L"ÿc1", L"ÿc2", L"ÿc3", L"ÿc4", L"ÿc5", L"ÿc6", L"ÿc7", L"ÿc8", L"ÿc9", L"ÿc:", L"ÿc;", L"ÿc0", L"ÿc0", L"ÿc0", L"ÿc0", L"ÿc0" };
static wchar_t* m_apwcQualityStr[10] = {L"", L"(Cracked)", L"(Normal)", L"(Superior)", L"(Magic)", L"(Set)", L"(Rare)", L"(Unique)", L"(Crafted)", L"(Tempered)"};
static char* m_apcQualityStr[10] = {"", "(Cracked)", "(Normal)", "(Superior)", "(Magic)", "(Set)", "(Rare)", "(Unique)", "(Crafted)", "(Tempered)"};
static wchar_t* m_apwcColorStr[17] = { L"ÿc0", L"ÿc1", L"ÿc2", L"ÿc3", L"ÿc4", L"ÿc5", L"ÿc6", L"ÿc7", L"ÿc8", L"ÿc9", L"ÿc:", L"ÿc;", L"ÿc0", L"ÿc0", L"ÿc0", L"ÿc0", L"ÿc0" };
static wchar_t* m_apwcQualityStr[10] = { L"", L"(Cracked)", L"(Normal)", L"(Superior)", L"(Magic)", L"(Set)", L"(Rare)", L"(Unique)", L"(Crafted)", L"(Tempered)" };
static char* m_apcQualityStr[10] = { "", "(Cracked)", "(Normal)", "(Superior)", "(Magic)", "(Set)", "(Rare)", "(Unique)", "(Crafted)", "(Tempered)" };
static uint32_t m_nHookMethod = 1;
static uint32_t m_anQualityColor[10] = { 0 };
@@ -77,7 +77,6 @@ public:
}
};
void d2_tweaks::client::modules::item_drop_message::GamePacketReceivedIntercept(uint8_t* packet, size_t size) {
if (packet == 0 || size == 0)
return;
@@ -94,9 +93,8 @@ void d2_tweaks::client::modules::item_drop_message::GamePacketReceivedIntercept(
return;
}
__declspec (naked) void d2_tweaks::client::modules::item_drop_message::GamePacketReceivedInterceptASM() {
__asm
__asm
{
// call our function (__fastcall)
pushad;
@@ -107,16 +105,13 @@ __declspec (naked) void d2_tweaks::client::modules::item_drop_message::GamePacke
popfd;
popad;
jmp [fn_GamePacketReceivedIntercept]
jmp[fn_GamePacketReceivedIntercept]
}
}
void d2_tweaks::client::modules::item_drop_message::init_early() {
}
void d2_tweaks::client::modules::item_drop_message::init() {
char acPathToIni[MAX_PATH] = { 0 };
const char* pcIniFile = "\\d2tweaks.ini";
@@ -156,7 +151,6 @@ void d2_tweaks::client::modules::item_drop_message::init() {
}
}
void d2_tweaks::client::modules::item_drop_message::handle_packet(common::packet_header* packet) {
const auto info = static_cast<common::item_pickup_info_sc*>(packet);
const auto item_dropped_packet = static_cast<common::item_dropped_info_sc*>(packet);
@@ -209,21 +203,21 @@ void d2_tweaks::client::modules::item_drop_message::handle_packet(common::packet
mbstowcs(m_aawcItemtypeEquiv[8], m_stMsg[i].arr_itemtype_codestr_equivstr[9], 4);
mbstowcs(m_aawcItemtypeEquiv[9], m_stMsg[i].arr_itemtype_codestr_equivstr[10], 4);
swprintf_s(buffer, L"%s ÿc0Code: %s Quality: %i %s Type: %s Equiv: %s %s %s %s %s %s %s %s %s %s",
m_stMsg[i].item_text,
m_awcCode,
m_stMsg[i].quality,
m_apwcQualityStr[m_stMsg[i].quality],
swprintf_s(buffer, L"%s ÿc0Code: %s Quality: %i %s Type: %s Equiv: %s %s %s %s %s %s %s %s %s %s",
m_stMsg[i].item_text,
m_awcCode,
m_stMsg[i].quality,
m_apwcQualityStr[m_stMsg[i].quality],
m_awcItemtypeCode,
m_aawcItemtypeEquiv[0],
m_aawcItemtypeEquiv[0],
m_aawcItemtypeEquiv[1],
m_aawcItemtypeEquiv[2],
m_aawcItemtypeEquiv[2],
m_aawcItemtypeEquiv[3],
m_aawcItemtypeEquiv[4],
m_aawcItemtypeEquiv[4],
m_aawcItemtypeEquiv[5],
m_aawcItemtypeEquiv[6],
m_aawcItemtypeEquiv[6],
m_aawcItemtypeEquiv[7],
m_aawcItemtypeEquiv[8],
m_aawcItemtypeEquiv[8],
m_aawcItemtypeEquiv[9]);
}
@@ -264,4 +258,4 @@ void d2_tweaks::client::modules::item_drop_message::handle_packet(common::packet
}
}
}
}
}

View File

@@ -121,10 +121,8 @@ int32_t __fastcall item_click(diablo2::structures::unit* owner, diablo2::structu
}
void d2_tweaks::client::modules::item_move::init_early() {
}
void d2_tweaks::client::modules::item_move::init() {
char acPathToIni[MAX_PATH] = { 0 };
const char* pcIniFile = "\\d2tweaks.ini";
@@ -138,7 +136,6 @@ void d2_tweaks::client::modules::item_move::init() {
}
}
// handle packet coming from the server
void d2_tweaks::client::modules::item_move::handle_packet(common::packet_header* packet) {
static auto& instance = singleton<client>::instance();
@@ -165,4 +162,4 @@ void d2_tweaks::client::modules::item_move::handle_packet(common::packet_header*
diablo2::d2_client::play_sound(itemRecord->drop_sound, nullptr, 0, 0, 0);
else
diablo2::d2_client::play_sound(4, nullptr, 0, 0, 0);
}
}

View File

@@ -28,7 +28,6 @@ static HANDLE __fastcall delete_save_file(char* name, char* a2) {
return g_delete_save_file_original(name, a2);
}
void d2_tweaks::client::modules::loot_filter::init_early() {
char acPathToIni[MAX_PATH] = { 0 };
const char* pcIniFile = "\\d2tweaks.ini";
@@ -42,7 +41,6 @@ void d2_tweaks::client::modules::loot_filter::init_early() {
}
}
void d2_tweaks::client::modules::loot_filter::init() {
char acPathToIni[MAX_PATH] = { 0 };
const char* pcIniFile = "\\d2tweaks.ini";
@@ -54,4 +52,4 @@ void d2_tweaks::client::modules::loot_filter::init() {
singleton<ui::ui_manager>::instance().add_menu(&singleton<loot_filter_settings_menu>::instance());
singleton<ui::ui_manager>::instance().add_menu(&singleton<loot_filter_settings_toggle_menu>::instance());
}
}
}

View File

@@ -82,5 +82,4 @@ void loot_filter_settings::remove(const char* name) {
std::filesystem::remove(buffer);
memset(g_buffer, 0x00, sizeof g_buffer);
}
}

View File

@@ -56,25 +56,25 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::register_misc_checkb
if (m_altonly) {
m_altonly->set_state(loot_filter_settings::get().alt_only);
m_altonly->set_on_click(std::bind(&loot_filter_settings_menu::update_alt_only,
this, std::placeholders::_1));
this, std::placeholders::_1));
}
if (m_show_gold) {
m_show_gold->set_state(loot_filter_settings::get().show_gold);
m_show_gold->set_on_click(std::bind(&loot_filter_settings_menu::update_show_gold,
this, std::placeholders::_1));
this, std::placeholders::_1));
}
if (m_show_runes) {
m_show_runes->set_state(loot_filter_settings::get().show_runes);
m_show_runes->set_on_click(std::bind(&loot_filter_settings_menu::update_show_runes,
this, std::placeholders::_1));
this, std::placeholders::_1));
}
if (m_show_gems) {
m_show_gems->set_state(loot_filter_settings::get().show_gems);
m_show_gems->set_on_click(std::bind(&loot_filter_settings_menu::update_show_gems,
this, std::placeholders::_1));
this, std::placeholders::_1));
}
}
@@ -113,13 +113,13 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::update_show_gems(boo
}
void d2_tweaks::client::modules::loot_filter_settings_menu::update_quality_allowance(bool value,
diablo2::structures::item_quality_t quality) {
diablo2::structures::item_quality_t quality) {
loot_filter_settings::get().quality_settings[static_cast<uint32_t>(quality)] = value;
loot_filter_settings::get().save(diablo2::d2_client::get_local_player_name());
}
void d2_tweaks::client::modules::loot_filter_settings_menu::register_quality_checkbox(const std::string& name,
diablo2::structures::item_quality_t quality) {
diablo2::structures::item_quality_t quality) {
auto control = get_control<ui::controls::checkbox>(name);
if (!control)
@@ -127,7 +127,7 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::register_quality_che
control->set_state(loot_filter_settings::get().quality_settings[static_cast<size_t>(quality)]);
control->set_on_click(std::bind(&loot_filter_settings_menu::update_quality_allowance,
this, std::placeholders::_1, quality));
this, std::placeholders::_1, quality));
}
void d2_tweaks::client::modules::loot_filter_settings_menu::setup_hooks() {
@@ -148,7 +148,7 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::setup_alt_hook() con
asm_code asmCode;
asmCode.add({ 0x83, 0x7D, 0x00, 0x04 }); //cmp dword ptr [ebp+0], 4
asmCode.add({ 0x0F, 0x85 },
new asm_address_relative(2, 6, diablo2::d2_client::get_base() + 0x6A399)); //jnz D2Client.dll+6A399
new asm_address_relative(2, 6, diablo2::d2_client::get_base() + 0x6A399)); //jnz D2Client.dll+6A399
asmCode.add({ 0x56 }); //push esi
asmCode.add({ 0xB8 }, new asm_address_static(1, check_alt_item)); //mov eax, check_alt_item
@@ -158,9 +158,9 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::setup_alt_hook() con
asmCode.add({ 0x84, 0xC0 }); //test al, al
asmCode.add({ 0x0F, 0x84 },
new asm_address_relative(2, 6, diablo2::d2_client::get_base() + 0x6A399)); //je D2Client.dll+6A399
new asm_address_relative(2, 6, diablo2::d2_client::get_base() + 0x6A399)); //je D2Client.dll+6A399
asmCode.add({ 0xE9 },
new asm_address_relative(1, 5, diablo2::d2_client::get_base() + 0x6A027)); //jmp D2Client.dll+6A027
new asm_address_relative(1, 5, diablo2::d2_client::get_base() + 0x6A027)); //jmp D2Client.dll+6A027
auto addr = diablo2::d2_client::get_base() + 0x6A022;
@@ -283,7 +283,7 @@ bool d2_tweaks::client::modules::loot_filter_settings_menu::check_alt_item(diabl
}
void d2_tweaks::client::modules::loot_filter_settings_menu::draw_dropped_items_names(diablo2::structures::unit* unit,
void* edx) {
void* edx) {
static auto& instance = singleton<loot_filter_settings_menu>::instance();
if (!unit || unit->type != diablo2::structures::unit_type_t::UNIT_TYPE_ITEM) {
@@ -315,7 +315,7 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::draw_dropped_items_n
}
void d2_tweaks::client::modules::loot_filter_settings_menu::handle_dropped_items(diablo2::structures::unit* unit,
void* edx) {
void* edx) {
static auto& instance = singleton<loot_filter_settings_menu>::instance();
if (!unit || unit->type != diablo2::structures::unit_type_t::UNIT_TYPE_ITEM) {
@@ -344,4 +344,4 @@ void d2_tweaks::client::modules::loot_filter_settings_menu::handle_dropped_items
return;
instance.m_handle_dropped_items_original(unit, edx);
}
}

View File

@@ -9,7 +9,6 @@
#include <DllNotify.h>
#include <D2Template.h>
#include <diablo2/d2gfx.h>
#include <string>
@@ -98,10 +97,10 @@
#pragma pack(push, 1)
using namespace d2_tweaks::client::modules;
bool m_stats_enabled = false;
bool m_stats_enabled = true;
bool m_help_enabled = false;
bool m_cube_enabled = false;
bool m_stash_enabled = false;
bool m_stash_enabled = true;
d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settings_toggle_menu(token) {
m_show = false;
@@ -124,13 +123,11 @@ d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settin
m_filter_settings_menu = singleton<ui::ui_manager>::instance().get_menu("loot_filter_settings_menu");
m_btn_toggle_stats = static_cast<ui::controls::button*>(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));
m_btn_toggle_help = static_cast<ui::controls::button*>(get_control("m_toggle_help"));
m_btn_toggle_help->set_enabled(true);
m_btn_toggle_help->set_visible(true);
@@ -142,21 +139,25 @@ d2_tweaks::client::modules::loot_filter_settings_toggle_menu::loot_filter_settin
m_btn_toggle_cube->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_cube_click, this));
m_btn_toggle_stash = static_cast<ui::controls::button*>(get_control("m_toggle_stash"));
m_btn_toggle_stash->set_enabled(false);
m_btn_toggle_stash->set_visible(false);
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;
}
}
m_btn_toggle_stash->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_stash_click, this));
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);
// }
//}
m_btn_toggle_stash->set_on_click(std::bind(&loot_filter_settings_toggle_menu::toggle_stash_click, this));
}
void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_filter_settings_click() {
@@ -173,7 +174,6 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_stats_
m_stats_enabled = !m_stats_enabled;
}
void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_cube_click() {
m_cube_enabled = !m_cube_enabled;
if (m_cube_enabled) {
@@ -197,7 +197,7 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_cube_c
//uint8_t MsgID; // 0x02
uint32_t guid; // 0x06
uint32_t tx; // 0x07
uint32_t ty; // 0x09
uint32_t ty; // 0x09
};
D2GSPacketClt20 packet;
packet.PacketId = 0x20;
@@ -211,11 +211,8 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_cube_c
// send to server7 to close cube packet 0x4F
diablo2::d2_client::send_to_server_7(0x4F, 0x17, 0, 0);
}
}
void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_stash_click() {
m_stash_enabled = !m_stash_enabled;
if (m_stash_enabled) {
const auto player = diablo2::d2_client::get_local_player();
@@ -237,7 +234,7 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_stash_
uint8_t PacketId; // 0x01
uint32_t guid; // 0x06
uint32_t tx; // 0x07
uint32_t ty; // 0x09
uint32_t ty; // 0x09
};
D2GSPacketClt20 packet;
packet.PacketId = 0x20;
@@ -247,16 +244,14 @@ 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);
}
}
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
@@ -271,7 +266,6 @@ void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::toggle_help_c
// Unsupported platform
// You can add handling for other platforms here
#endif
}
void d2_tweaks::client::modules::loot_filter_settings_toggle_menu::draw() {

View File

@@ -39,4 +39,4 @@ void d2_tweaks::client::modules::small_patches::init() {
// //Window auto-hiding on focus loss
// hooking::hook<10026>(diablo2::d2_gfx::get_base(), is_iconic, &g_is_iconic_original);
//}
}
}

View File

@@ -61,7 +61,6 @@ private:
static test_menu* g_test_menu;
void d2_tweaks::client::modules::test::init_early() {
}
void d2_tweaks::client::modules::test::init() {

View File

@@ -48,7 +48,6 @@ enum trader_command {
COMMAND_ABORT
};
class trader_update_menu : public d2_tweaks::ui::menu {
d2_tweaks::common::asset* m_buttons_img;
d2_tweaks::ui::controls::button* m_trader_update_btn;
@@ -98,7 +97,7 @@ private:
void trader_update_click() {
const auto unit = diablo2::d2_client::get_local_player();
static d2_tweaks::common::trader_update_cs request_packet_cs;
request_packet_cs.client_id = unit->guid;
request_packet_cs.npc_id = diablo2::d2_client::current_vendor_guid();
@@ -116,12 +115,9 @@ private:
}
};
void d2_tweaks::client::modules::trader_update::init_early() {
}
void d2_tweaks::client::modules::trader_update::init() {
char szDir[MAX_PATH];
char szPath[MAX_PATH];
@@ -139,28 +135,25 @@ void d2_tweaks::client::modules::trader_update::init() {
}
}
void d2_tweaks::client::modules::trader_update::tick() {
// const auto unit = diablo2::d2_client::get_local_player();
// const auto unit = diablo2::d2_client::get_local_player();
}
void d2_tweaks::client::modules::trader_update::handle_cs_packet(common::packet_header* packet) {
static auto& instance = singleton<client>::instance();
const auto income_packet_cs = static_cast<common::d2_entity_action_cs*>(packet);
#ifndef NDEBUG
spdlog::debug("[D2CLIENT C > S] ENTITY ACTION! message {} action {} entity_id {} complement {}", (uint8_t) income_packet_cs->message_type, (void*)(income_packet_cs->action >> 24), (void*)(income_packet_cs->entity_id >> 24), (void*)income_packet_cs->complement);
spdlog::debug("[D2CLIENT C > S] ENTITY ACTION! message {} action {} entity_id {} complement {}", (uint8_t)income_packet_cs->message_type, (void*)(income_packet_cs->action >> 24), (void*)(income_packet_cs->entity_id >> 24), (void*)income_packet_cs->complement);
#endif
m_nMenuOpen = (uint8_t)income_packet_cs->message_type; // 1 = trade, 2 = gamble
m_nNpcId = (income_packet_cs->action >> 24);
}
void d2_tweaks::client::modules::trader_update::handle_packet(common::packet_header* packet) {
static auto& instance = singleton<client>::instance();
const auto income_packet_sc = static_cast<common::trader_update_sc*>(packet);
if (!diablo2::d2_client::get_ui_window_state(diablo2::UI_WINDOW_NPCSHOP))
return;
@@ -200,5 +193,4 @@ void d2_tweaks::client::modules::trader_update::handle_packet(common::packet_hea
diablo2::d2_client::send_to_server(&request_packet_cs, sizeof request_packet_cs);
}
}
}
}

View File

@@ -149,7 +149,7 @@ private:
//request_packet_cs.transmute_start_flag = m_bToggleTransmute;
//request_packet_cs.command = COMMAND_TRANSMUTE_START;
//diablo2::d2_client::send_to_server(&request_packet_cs, sizeof request_packet_cs);
if (m_bToggleTransmute) {
diablo2::d2_client::print_chat(L"AUTO TRANSMUTE ON", 1);
}
@@ -170,7 +170,7 @@ void __fastcall hook_play_sound(uint32_t soundId, uint32_t* unit, const uint32_t
return;
}
void __stdcall hook_game_end () {
void __stdcall hook_game_end() {
m_game_init_done = false;
m_bToggleTransmute = false;
return;
@@ -184,12 +184,11 @@ __declspec (naked) void hook_game_end_asm() {
popfd;
popad;
jmp [fn_hook_game_end];
jmp[fn_hook_game_end];
}
}
void d2_tweaks::client::modules::transmute::init_early() {
}
void d2_tweaks::client::modules::transmute::init() {
@@ -229,8 +228,8 @@ void d2_tweaks::client::modules::transmute::init() {
sprintf_s(m_acBuffer, sizeof(m_acBuffer), "ItemList%d", i + 1);
dwLenght = config.GetString("AutoTransmute", m_acBuffer, m_aacItemList[i], MAX_STRING_LENGHT - 1);
if (dwLenght != 0) {
lstrcat(m_acItemListAll, m_aacItemList[i]);
lstrcat(m_acItemListAll, "|");
lstrcat(m_acItemListAll, m_aacItemList[i]);
lstrcat(m_acItemListAll, "|");
}
}
@@ -238,12 +237,12 @@ void d2_tweaks::client::modules::transmute::init() {
sprintf_s(m_acBuffer, sizeof(m_acBuffer), "ItemTypeList%d", i + 1);
dwLenght = config.GetString("AutoTransmute", m_acBuffer, m_aacItemTypes[i], MAX_STRING_LENGHT - 1);
if (dwLenght != 0) {
lstrcat(m_acItemTypesAll, m_aacItemTypes[i]);
lstrcat(m_acItemTypesAll, m_aacItemTypes[i]);
lstrcat(m_acItemTypesAll, "|");
}
}
/////// Parse ItemCode
/////// Parse ItemCode
dwLenght = lstrlen(m_acItemListAll);
memcpy(m_acItemListAllTemp, m_acItemListAll, dwLenght + 1);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -316,8 +315,7 @@ void d2_tweaks::client::modules::transmute::init() {
token_string_itemcode = strtok(NULL, " ,|");
}
/////// Parse ItemType
/////// Parse ItemType
dwLenght = lstrlen(m_acItemTypesAll);
memcpy(m_acItemTypesAllTemp, m_acItemTypesAll, dwLenght + 1);
char* token_string_itemtype_code = strtok(m_acItemTypesAllTemp, ",|");
@@ -394,7 +392,7 @@ void d2_tweaks::client::modules::transmute::init() {
if (m_nTransmuteSound == false) {
hooking::hook(diablo2::d2_client::get_base() + 0xB5820, hook_play_sound, reinterpret_cast<void**>(&fn_hook_play_sound));
}
hooking::hook(diablo2::d2_client::get_base() + 0xB528, hook_game_end_asm, reinterpret_cast<void**>(&fn_hook_game_end));
singleton<ui::ui_manager>::instance().add_menu(new auto_transmute_menu());
@@ -403,7 +401,6 @@ void d2_tweaks::client::modules::transmute::init() {
}
}
void d2_tweaks::client::modules::transmute::tick() {
const auto unit = diablo2::d2_client::get_local_player();
@@ -412,7 +409,7 @@ void d2_tweaks::client::modules::transmute::tick() {
m_bToggleTransmute = false;
}
if (!unit)
if (!unit)
return;
if (unit->type != diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER)
@@ -421,7 +418,7 @@ void d2_tweaks::client::modules::transmute::tick() {
if (!m_bToggleTransmute)
return;
if (m_nCountFrames > m_nDelayFrames)
if (m_nCountFrames > m_nDelayFrames)
{
m_nCountFrames = 0;
@@ -449,7 +446,7 @@ void d2_tweaks::client::modules::transmute::tick() {
// index second code in array
uint32_t index_arr_itemtype = 1;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equiv1
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equiv1
if (itemtype_record_equiv1) {
if (*(DWORD*)itemtype_record_equiv1->code != 0x20202020) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equiv1
@@ -529,7 +526,6 @@ L1:;
m_nCountFrames++;
}
void d2_tweaks::client::modules::transmute::handle_packet(common::packet_header* packet) {
static auto& instance = singleton<client>::instance();
const auto income_packet_sc = static_cast<common::transmute_info_sc*>(packet);
@@ -554,12 +550,12 @@ void d2_tweaks::client::modules::transmute::handle_packet(common::packet_header*
// send 'transmute' command
request_packet_cs.command = COMMAND_CALL_TRANSMUTE;
diablo2::d2_client::send_to_server(&request_packet_cs, sizeof request_packet_cs);
//diablo2::d2_client::send_to_server_7(0x4F, 0x18, 0, 0);
}
if (income_packet_sc->command == COMMAND_ABORT) {
m_bToggleTransmute = false;
diablo2::d2_client::print_chat(L"WRONG RECIPE, AUTO TRANSMUTE OFF", 2);
diablo2::d2_client::print_chat(L"WRONG RECIPE, AUTO TRANSMUTE OFF", 2);
}
}
}

View File

@@ -71,9 +71,9 @@ d2_tweaks::common::asset* d2_tweaks::common::asset_manager::get_mpq_file(const s
void* d2_tweaks::common::asset_manager::load_asset_data(const std::string& path, mpq_file_type_t type) {
switch (type) {
case MPQ_FILE_TYPE_DC6:
return diablo2::d2_client::load_gfx_resource(const_cast<char*>(path.c_str()));
default:
return nullptr;
case MPQ_FILE_TYPE_DC6:
return diablo2::d2_client::load_gfx_resource(const_cast<char*>(path.c_str()));
default:
return nullptr;
}
}
}

View File

@@ -18,8 +18,8 @@ static int32_t g_ebp_send_to_server;
static int32_t g_ebp_send_to_client;
static int32_t __stdcall net_send_to_server(int32_t queue, d2_tweaks::common::packet_header* packet, size_t size) {
__asm {
push [ebp + 4]
pop [g_ebp_send_to_server]
push[ebp + 4]
pop[g_ebp_send_to_server]
}
spdlog::debug("[d2net SEND C >>> S] Queue {} Packet {} Size {} CallFrom {}", queue, (void*)packet->d2_packet_type, size, (void*)g_ebp_send_to_server);
@@ -29,8 +29,8 @@ static int32_t __stdcall net_send_to_server(int32_t queue, d2_tweaks::common::pa
static int32_t __stdcall net_send_to_client(int32_t queue, int32_t clientId, d2_tweaks::common::packet_header* packet, size_t size) {
__asm {
push [ebp+4]
pop [g_ebp_send_to_client]
push[ebp + 4]
pop[g_ebp_send_to_client]
}
spdlog::error("[d2net SEND S >>> C] Queue {} Packet {} Size {} ClientID {} CallFrom {}", queue, (void*)packet->d2_packet_type, size, clientId, (void*)g_ebp_send_to_client);
@@ -88,94 +88,94 @@ void d2_tweaks::common::common::init() {
bool d2_tweaks::common::common::get_packet_size_cs(packet_header* packet, size_t& size) {
switch (packet->message_type) {
case MESSAGE_TYPE_ITEM_MOVE:
{
size = sizeof item_move_cs;
return true;
}
case MESSAGE_TYPE_INVENTORY_SORT:
{
size = sizeof inventory_sort_cs;
return true;
}
case MESSAGE_TYPE_DAMAGE_INFO:
{
size = sizeof damage_info_cs;
return true;
}
case MESSAGE_TYPE_GOLD_PICKUP_INFO:
{
size = sizeof gold_pickup_info_cs;
return true;
}
case MESSAGE_TYPE_ITEM_PICKUP_INFO:
{
size = sizeof item_pickup_info_cs;
return true;
}
case MESSAGE_TYPE_ITEM_DROPPED_INFO:
{
size = sizeof item_dropped_info_cs;
return true;
}
case MESSAGE_TYPE_TRANSMUTE:
{
size = sizeof transmute_info_cs;
return true;
}
case MESSAGE_TYPE_TRADER_UPDATE:
{
size = sizeof trader_update_cs;
return true;
}
default:
return false;
case MESSAGE_TYPE_ITEM_MOVE:
{
size = sizeof item_move_cs;
return true;
}
case MESSAGE_TYPE_INVENTORY_SORT:
{
size = sizeof inventory_sort_cs;
return true;
}
case MESSAGE_TYPE_DAMAGE_INFO:
{
size = sizeof damage_info_cs;
return true;
}
case MESSAGE_TYPE_GOLD_PICKUP_INFO:
{
size = sizeof gold_pickup_info_cs;
return true;
}
case MESSAGE_TYPE_ITEM_PICKUP_INFO:
{
size = sizeof item_pickup_info_cs;
return true;
}
case MESSAGE_TYPE_ITEM_DROPPED_INFO:
{
size = sizeof item_dropped_info_cs;
return true;
}
case MESSAGE_TYPE_TRANSMUTE:
{
size = sizeof transmute_info_cs;
return true;
}
case MESSAGE_TYPE_TRADER_UPDATE:
{
size = sizeof trader_update_cs;
return true;
}
default:
return false;
}
}
bool d2_tweaks::common::common::get_packet_size_sc(packet_header* packet, size_t& size) {
switch (packet->message_type) {
case MESSAGE_TYPE_ITEM_MOVE:
{
size = sizeof item_move_sc;
return true;
}
case MESSAGE_TYPE_INVENTORY_SORT:
{
size = sizeof inventory_sort_sc;
return true;
}
case MESSAGE_TYPE_DAMAGE_INFO:
{
size = sizeof damage_info_sc;
return true;
}
case MESSAGE_TYPE_GOLD_PICKUP_INFO:
{
size = sizeof gold_pickup_info_sc;
return true;
}
case MESSAGE_TYPE_ITEM_PICKUP_INFO:
{
size = sizeof item_pickup_info_sc;
return true;
}
case MESSAGE_TYPE_ITEM_DROPPED_INFO:
{
size = sizeof item_dropped_info_sc;
return true;
}
case MESSAGE_TYPE_TRANSMUTE:
{
size = sizeof transmute_info_sc;
return true;
}
case MESSAGE_TYPE_TRADER_UPDATE:
{
size = sizeof trader_update_sc;
return true;
}
default:
return false;
case MESSAGE_TYPE_ITEM_MOVE:
{
size = sizeof item_move_sc;
return true;
}
}
case MESSAGE_TYPE_INVENTORY_SORT:
{
size = sizeof inventory_sort_sc;
return true;
}
case MESSAGE_TYPE_DAMAGE_INFO:
{
size = sizeof damage_info_sc;
return true;
}
case MESSAGE_TYPE_GOLD_PICKUP_INFO:
{
size = sizeof gold_pickup_info_sc;
return true;
}
case MESSAGE_TYPE_ITEM_PICKUP_INFO:
{
size = sizeof item_pickup_info_sc;
return true;
}
case MESSAGE_TYPE_ITEM_DROPPED_INFO:
{
size = sizeof item_dropped_info_sc;
return true;
}
case MESSAGE_TYPE_TRANSMUTE:
{
size = sizeof transmute_info_sc;
return true;
}
case MESSAGE_TYPE_TRADER_UPDATE:
{
size = sizeof trader_update_sc;
return true;
}
default:
return false;
}
}

View File

@@ -25,7 +25,6 @@ void d2_tweaks::server::modules::auto_gold_pickup::init() {
}
}
bool d2_tweaks::server::modules::auto_gold_pickup::handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) {
const auto income_packet_cs = static_cast<common::gold_pickup_info_cs*>(packet);
static auto& instance = singleton<server>::instance();
@@ -39,7 +38,6 @@ bool d2_tweaks::server::modules::auto_gold_pickup::handle_packet(diablo2::struct
return true;
}
bool d2_tweaks::server::modules::auto_gold_pickup::au_pickup_gold(diablo2::structures::game* game, diablo2::structures::unit* unit, diablo2::structures::unit* item)
{
static common::gold_pickup_info_sc packet;
@@ -58,9 +56,8 @@ bool d2_tweaks::server::modules::auto_gold_pickup::au_pickup_gold(diablo2::struc
return TRUE;
}
void d2_tweaks::server::modules::auto_gold_pickup::tick(diablo2::structures::game* game,
diablo2::structures::unit* unit) {
diablo2::structures::unit* unit) {
//static common::gold_pickup_info_sc packet;
//static auto& instance = singleton<d2_tweaks::server::server>::instance();
//if (!game || !unit)
@@ -101,5 +98,4 @@ void d2_tweaks::server::modules::auto_gold_pickup::tick(diablo2::structures::gam
// continue;
//}
}
}

View File

@@ -30,7 +30,7 @@ void d2_tweaks::server::modules::auto_item_pickup::init() {
}
void d2_tweaks::server::modules::auto_item_pickup::tick(diablo2::structures::game* game,
diablo2::structures::unit* unit) {
diablo2::structures::unit* unit) {
//static common::item_pickup_info_sc packet;
//static auto& instance = singleton<d2_tweaks::server::server>::instance();
//if (!game || !unit)
@@ -44,7 +44,6 @@ void d2_tweaks::server::modules::auto_item_pickup::tick(diablo2::structures::gam
//if (!room)
// return;
//for (auto item = room->unit; item; item = item->prev_unit_in_room) {
// if (!item)
// continue;
@@ -92,7 +91,6 @@ void d2_tweaks::server::modules::auto_item_pickup::tick(diablo2::structures::gam
// }
// }
// if (itemtype_record_equiv2) {
// if (*(DWORD*)itemtype_record_equiv2->code != 0x20202020) {
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equiv1
@@ -110,7 +108,6 @@ void d2_tweaks::server::modules::auto_item_pickup::tick(diablo2::structures::gam
// }
// }
// for (uint32_t i = 0; i < g_pickup_count_itemtype_code; i++)
// {
// for (uint32_t count = 0; count < index_arr_itemtype; count++)
@@ -126,7 +123,6 @@ void d2_tweaks::server::modules::auto_item_pickup::tick(diablo2::structures::gam
// }
// }
// for (uint32_t i = 0; i < g_pickup_count_all_items; i++)
// {
// if (record->string_code[0] == g_pickup_itemcode_st[i].code0 &&
@@ -148,7 +144,6 @@ void d2_tweaks::server::modules::auto_item_pickup::tick(diablo2::structures::gam
////spdlog::info("current {0}", g_tick_between_item_pickup);
}
bool d2_tweaks::server::modules::auto_item_pickup::au_pickup_item(diablo2::structures::game* game, diablo2::structures::unit* unit, uint32_t guid)
{
static common::item_pickup_info_sc packet;
@@ -156,17 +151,16 @@ bool d2_tweaks::server::modules::auto_item_pickup::au_pickup_item(diablo2::struc
uint32_t ptrNull = 0;
//if (g_tick_between_item_pickup >= 25) {
// true - if item picked up, false - if inventory full
if (diablo2::d2_game::pickup_item(game, unit, guid, &ptrNull) != true)
{
//packet.inventory_full = true;
//singleton<server>::instance().send_packet(unit->player_data->net_client, &packet, sizeof packet);
}
if (diablo2::d2_game::pickup_item(game, unit, guid, &ptrNull) != true)
{
//packet.inventory_full = true;
//singleton<server>::instance().send_packet(unit->player_data->net_client, &packet, sizeof packet);
}
//}
return true;
}
bool d2_tweaks::server::modules::auto_item_pickup::handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) {
const auto income_packet_cs = static_cast<common::item_pickup_info_cs*>(packet);
static auto& instance = singleton<server>::instance();

View File

@@ -36,17 +36,17 @@ struct packed_area {
uint8_t h;
};
// Define the inventory zone
int iminValidX = 0;
int imaxValidX = 15;
int iminValidY = 0;
int imaxValidY = 12;
// Define variables to store the inventory zone values
int iminValidX = GetPrivateProfileInt("InventoryZone", "iminValidX", 0, "./D2Tweaks.ini");
int imaxValidX = GetPrivateProfileInt("InventoryZone", "imaxValidX", 0, "./D2Tweaks.ini");
int iminValidY = GetPrivateProfileInt("InventoryZone", "iminValidY", 0, "./D2Tweaks.ini");
int imaxValidY = GetPrivateProfileInt("InventoryZone", "imaxValidY", 0, "./D2Tweaks.ini");
// Define the charm zone
int cminValidX = 0;
int cmaxValidX = 15;
int cminValidY = 12;
int cmaxValidY = 15;
// Define variables to store the charm zone values
int cminValidX = GetPrivateProfileInt("CharmZone", "cminValidX", 0, "./D2Tweaks.ini");
int cmaxValidX = GetPrivateProfileInt("CharmZone", "cmaxValidX", 0, "./D2Tweaks.ini");
int cminValidY = GetPrivateProfileInt("CharmZone", "cminValidY", 0, "./D2Tweaks.ini");
int cmaxValidY = GetPrivateProfileInt("CharmZone", "cmaxValidY", 0, "./D2Tweaks.ini");
void d2_tweaks::server::modules::autosort::init() {
char acPathToIni[MAX_PATH] = { 0 };
@@ -61,8 +61,7 @@ void d2_tweaks::server::modules::autosort::init() {
}
bool d2_tweaks::server::modules::autosort::handle_packet(diablo2::structures::game* game,
diablo2::structures::unit* player, common::packet_header* packet) {
diablo2::structures::unit* player, common::packet_header* packet) {
if (static_cast<common::inventory_sort_cs*>(packet)->remItem == 1) {
diablo2::d2_common::inv_remove_item(player->inventory, static_cast<common::inventory_sort_cs*>(packet)->item_to_remove);
diablo2::d2_game::update_inventory_items(game, player);
@@ -71,12 +70,9 @@ bool d2_tweaks::server::modules::autosort::handle_packet(diablo2::structures::ga
for (auto item = player->inventory->first_item; item != nullptr; item = item->item_data->pt_next_item) {
if (item == static_cast<common::inventory_sort_cs*>(packet)->item_to_remove) {
diablo2::d2_common::inv_remove_item(player->inventory, item);
diablo2::d2_game::update_inventory_items(game, player);
}
}
MessageBoxA(NULL, "Item removed", "Item removed", MB_OK);
@@ -148,7 +144,7 @@ bool d2_tweaks::server::modules::autosort::sort(diablo2::structures::game* game,
spdlog::info("is_charm: {0}\n\n", is_charm);
}
if (occupied_cells > inventoryHeight* inventoryWidth) {
if (occupied_cells > inventoryHeight * inventoryWidth) {
//should never be happen in normal cases
spdlog::warn("occupied_cells > inventoryHeight* inventoryWidth");
return false;
@@ -163,11 +159,9 @@ bool d2_tweaks::server::modules::autosort::sort(diablo2::structures::game* game,
const auto itemsCount = items.size();
const auto charmsCount = charms.size();
if (itemsCount == 0)
return true; //there's nothing to sort
auto success = NULL;
if (itemsCount > 0) {
@@ -219,7 +213,6 @@ bool d2_tweaks::server::modules::autosort::sort(diablo2::structures::game* game,
items_typed.erase(sorted_item->data_record_index);
}
}
if (charmsCount > 0) {
@@ -365,7 +358,8 @@ bool d2_tweaks::server::modules::autosort::find_free_space(diablo2::structures::
}
}
return false;
} else {
}
else {
for (x = minValidX; x <= maxValidX - record->inv_width + 1; x++) {
for (y = minValidY; y <= inventoryMaxValidY - record->inv_height + 1; y++) {
diablo2::structures::unit* blockingUnit = nullptr;
@@ -378,4 +372,4 @@ bool d2_tweaks::server::modules::autosort::find_free_space(diablo2::structures::
}
return false;
}
}
}

View File

@@ -14,14 +14,13 @@
#include <diablo2/structures/data/monstats_line.h>
MODULE_INIT(damage_display)
static char(__fastcall* g_apply_attack_results_origin)(diablo2::structures::game* game,
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
BOOL recalculateDamage,
diablo2::structures::damage* dmg);
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
BOOL recalculateDamage,
diablo2::structures::damage* dmg);
#define PRINT_DMG_DELIMITER(name, delimiter) if(dmg->name > 0) spdlog::debug(#name ": {0}", dmg->name / delimiter)
#define PRINT_DMG(name) PRINT_DMG_DELIMITER(name, 256)
@@ -76,7 +75,6 @@ static void send_damage_data(diablo2::structures::unit* defender,
spdlog::info("maxHp: {0}", packet.maxHp);
spdlog::info("damage: {0}", packet.damage);
if (packet.damage_type == d2_tweaks::common::DAMAGE_TYPE_UNKNOWN)
return;
@@ -87,23 +85,23 @@ static void send_damage_data(diablo2::structures::unit* defender,
}
static bool has_players(diablo2::structures::unit* attacker,
diablo2::structures::unit* defender) {
diablo2::structures::unit* defender) {
return attacker->type == diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER ||
defender->type == diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER;
}
static bool has_hirelings(diablo2::structures::unit* attacker,
diablo2::structures::unit* defender) {
diablo2::structures::unit* defender) {
return attacker && attacker->is_hireling() || defender && defender->is_hireling();
}
static bool has_pets(diablo2::structures::unit* attacker,
diablo2::structures::unit* defender) {
diablo2::structures::unit* defender) {
return attacker && attacker->is_pet() || defender && defender->is_pet();
}
static diablo2::structures::unit* get_hireling_owner(diablo2::structures::game* game,
diablo2::structures::unit* unit) {
diablo2::structures::unit* unit) {
static auto& instance = singleton<d2_tweaks::server::server>::instance();
if (!unit)
@@ -123,7 +121,7 @@ static diablo2::structures::unit* get_hireling_owner(diablo2::structures::game*
}
return true;
});
});
if (guid == 0)
return nullptr;
@@ -134,7 +132,7 @@ static diablo2::structures::unit* get_hireling_owner(diablo2::structures::game*
}
static diablo2::structures::unit* get_pet_owner(diablo2::structures::game* game,
diablo2::structures::unit* unit) {
diablo2::structures::unit* unit) {
static auto& instance = singleton<d2_tweaks::server::server>::instance();
if (!unit)
@@ -148,14 +146,14 @@ static diablo2::structures::unit* get_pet_owner(diablo2::structures::game* game,
instance.iterate_server_units(game, diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER, [&](diablo2::structures::unit* player) {
diablo2::d2_game::iterate_unit_pets(
game, player, [&](diablo2::structures::game*, diablo2::structures::unit*, diablo2::structures::unit* u) {
if (u != unit)
return;
if (u != unit)
return;
guid = player->guid;
});
guid = player->guid;
});
return guid == 0;
});
});
if (guid == 0)
return nullptr;
@@ -166,8 +164,8 @@ static diablo2::structures::unit* get_pet_owner(diablo2::structures::game* game,
}
static void process_players_damage(diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
diablo2::structures::damage* dmg) {
diablo2::structures::unit* defender,
diablo2::structures::damage* dmg) {
diablo2::structures::net_client* client = nullptr;
if (attacker->type == diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER)
@@ -179,14 +177,15 @@ static void process_players_damage(diablo2::structures::unit* attacker,
}
static void process_hireling_damage(diablo2::structures::game* game,
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
diablo2::structures::damage* dmg) {
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
diablo2::structures::damage* dmg) {
diablo2::structures::unit* owner = nullptr;
if (attacker->is_hireling()) {
owner = get_hireling_owner(game, attacker);
} else if (defender->is_hireling()) {
}
else if (defender->is_hireling()) {
owner = get_hireling_owner(game, defender);
}
@@ -197,14 +196,15 @@ static void process_hireling_damage(diablo2::structures::game* game,
}
static void process_pet_damage(diablo2::structures::game* game,
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
diablo2::structures::damage* dmg) {
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
diablo2::structures::damage* dmg) {
diablo2::structures::unit* owner = nullptr;
if (attacker->is_pet()) {
owner = get_pet_owner(game, attacker);
} else if (defender->is_pet()) {
}
else if (defender->is_pet()) {
owner = get_pet_owner(game, defender);
}
@@ -215,10 +215,10 @@ static void process_pet_damage(diablo2::structures::game* game,
}
static char __fastcall apply_attack_results(diablo2::structures::game* game,
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
BOOL recalculateDamage,
diablo2::structures::damage* dmg) {
diablo2::structures::unit* attacker,
diablo2::structures::unit* defender,
BOOL recalculateDamage,
diablo2::structures::damage* dmg) {
static auto& instance = singleton<d2_tweaks::server::server>::instance();
static char result = 0;
@@ -257,8 +257,8 @@ void d2_tweaks::server::modules::damage_display::init() {
}
bool d2_tweaks::server::modules::damage_display::handle_packet(diablo2::structures::game* game,
diablo2::structures::unit* player, common::packet_header* packet) {
diablo2::structures::unit* player, common::packet_header* packet) {
return true;
}
void d2_tweaks::server::modules::damage_display::tick(diablo2::structures::game* game, diablo2::structures::unit* unit) {}
void d2_tweaks::server::modules::damage_display::tick(diablo2::structures::game* game, diablo2::structures::unit* unit) {}

View File

@@ -19,12 +19,12 @@ static unsigned int g_item_Crafted = 0;
static unsigned int g_item_Tempered = 0;
static uint32_t(__fastcall* g_pickup_item_original)(diablo2::structures::game*,
diablo2::structures::unit*,
uint32_t, uint32_t);
diablo2::structures::unit*,
uint32_t, uint32_t);
static uint32_t __fastcall pickup_item(diablo2::structures::game* game,
diablo2::structures::unit* player,
uint32_t guid,
uint32_t a4) {
diablo2::structures::unit* player,
uint32_t guid,
uint32_t a4) {
static auto& instance = singleton<d2_tweaks::server::server>::instance();
if (!game || !player || player->type != diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER)
@@ -66,12 +66,12 @@ static uint32_t __fastcall pickup_item(diablo2::structures::game* game,
}
static uint32_t(__fastcall* g_pickup_item_cursor_original)(diablo2::structures::game*,
diablo2::structures::unit*,
uint32_t, uint32_t);
diablo2::structures::unit*,
uint32_t, uint32_t);
static uint32_t __fastcall pickup_item_cursor(diablo2::structures::game* game,
diablo2::structures::unit* player,
uint32_t guid,
uint32_t a4) {
diablo2::structures::unit* player,
uint32_t guid,
uint32_t a4) {
static auto& instance = singleton<d2_tweaks::server::server>::instance();
if (!game || !player || player->type != diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER)
@@ -132,5 +132,4 @@ void d2_tweaks::server::modules::identify_on_pickup::init() {
g_item_Crafted = GetPrivateProfileInt("IdentifyOnPickup", "Crafted", 1, acPathToIni);
g_item_Tempered = GetPrivateProfileInt("IdentifyOnPickup", "Tempered", 1, acPathToIni);
}
}
}

View File

@@ -34,7 +34,6 @@ static char m_acBuffer[1024] = { 0 };
static item_code* m_stItemList;
static item_type* m_stItemTypes;
void d2_tweaks::server::modules::item_drop_message::init() {
uint32_t dwLenght = 0;
char acPathToIni[MAX_PATH] = { 0 };
@@ -62,7 +61,7 @@ void d2_tweaks::server::modules::item_drop_message::init() {
}
}
/////// Parse ItemCode
/////// Parse ItemCode
dwLenght = lstrlen(m_acItemListAll);
memcpy(m_acItemListAllTemp, m_acItemListAll, dwLenght + 1);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -137,8 +136,7 @@ void d2_tweaks::server::modules::item_drop_message::init() {
token_string_itemcode = strtok(NULL, " ,|");
}
/// Parse ItemType
/// Parse ItemType
dwLenght = lstrlen(m_acItemTypesAll);
memcpy(m_acItemTypesAllTemp, m_acItemTypesAll, dwLenght + 1);
char* token_string_itemtype_code = strtok(m_acItemTypesAllTemp, ",|");
@@ -218,7 +216,7 @@ void d2_tweaks::server::modules::item_drop_message::init() {
}
void d2_tweaks::server::modules::item_drop_message::tick(diablo2::structures::game* game,
diablo2::structures::unit* unit) {
diablo2::structures::unit* unit) {
static common::item_pickup_info_sc packet;
static auto& instance = singleton<d2_tweaks::server::server>::instance();
if (!game || !unit)
@@ -228,12 +226,11 @@ void d2_tweaks::server::modules::item_drop_message::tick(diablo2::structures::ga
return;
}
bool d2_tweaks::server::modules::item_drop_message::handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) {
const auto income_item_dropped_packet = static_cast<common::item_dropped_info_cs*>(packet);
static common::item_dropped_info_sc response_item_dropped_packet;
switch (income_item_dropped_packet->message_type)
switch (income_item_dropped_packet->message_type)
{
case common::message_types_t::MESSAGE_TYPE_ITEM_DROPPED_INFO:
auto current_unit = diablo2::d2_game::get_server_unit(game, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM, income_item_dropped_packet->item_id);
@@ -248,7 +245,7 @@ bool d2_tweaks::server::modules::item_drop_message::handle_packet(diablo2::struc
const auto itemtype_record = diablo2::d2_common::get_item_type_record(record->type);
auto itemtype_record_equiv1 = diablo2::d2_common::get_item_type_record(itemtype_record->equiv1);
auto itemtype_record_equiv2 = diablo2::d2_common::get_item_type_record(itemtype_record->equiv2);
wcstombs(string_mb, string_wc, 256);
memset(response_item_dropped_packet.arr_itemtype_codestr_equivstr, 0, sizeof response_item_dropped_packet.arr_itemtype_codestr_equivstr);
@@ -258,7 +255,7 @@ bool d2_tweaks::server::modules::item_drop_message::handle_packet(diablo2::struc
uint32_t index_arr_itemtype = 1;
if (itemtype_record_equiv1) {
//
//
if (*(DWORD*)itemtype_record_equiv1->code != 0x20202020) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equiv1
*(DWORD*)response_item_dropped_packet.arr_itemtype_codestr_equivstr[index_arr_itemtype] = *(DWORD*)itemtype_record_equiv1->code;
@@ -269,13 +266,12 @@ bool d2_tweaks::server::modules::item_drop_message::handle_packet(diablo2::struc
itemtype_record_equiv1 = diablo2::d2_common::get_item_type_record(itemtype_record_equiv1->equiv1);
if (*(DWORD*)itemtype_record_equiv1->code != 0x20202020) {
*(DWORD*)response_item_dropped_packet.arr_itemtype_codestr_equivstr[index_arr_itemtype] = *(DWORD*)itemtype_record_equiv1->code;
}
}
else break;
}
}
}
if (itemtype_record_equiv2) {
if (*(DWORD*)itemtype_record_equiv2->code != 0x20202020) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> equiv1
@@ -293,7 +289,6 @@ bool d2_tweaks::server::modules::item_drop_message::handle_packet(diablo2::struc
}
}
if (GetKeyState(VK_SCROLL) != 0) {
response_item_dropped_packet.item = income_item_dropped_packet->item_id;
response_item_dropped_packet.code[0] = record->string_code[0];
@@ -312,7 +307,6 @@ bool d2_tweaks::server::modules::item_drop_message::handle_packet(diablo2::struc
break;
}
for (uint32_t i = 0; i < m_nCountItemTypesAll; i++)
{
for (uint32_t count = 0; count < index_arr_itemtype; count++)
@@ -342,7 +336,6 @@ bool d2_tweaks::server::modules::item_drop_message::handle_packet(diablo2::struc
}
}
for (uint32_t i = 0; i < m_nCountItemListAll; i++)
{
if (record->string_code[0] == m_stItemList[i].code0 &&

View File

@@ -24,7 +24,6 @@
#include <windows.h> // Include Windows API header for MessageBox
#include <iomanip> // For std::setw
void serialize_item(const std::string& itemcode, const diablo2::structures::unit& item, std::ofstream& file) {
@@ -54,11 +53,9 @@ void d2_tweaks::server::modules::item_move::init() {
}
}
// handle packet coming from the client
bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::game* game,
diablo2::structures::unit* player, common::packet_header* packet) {
diablo2::structures::unit* player, common::packet_header* packet) {
static common::item_move_sc resp;
static auto& instance = singleton<server>::instance();
@@ -71,7 +68,6 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
const auto item = instance.get_server_unit(game, itemMove->item_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
const auto record = diablo2::d2_common::get_item_record(item->data_record_index);
const char* itemcode = itemMove->item_code;
const auto bag = instance.get_server_unit(game, itemMove->bag_guid, diablo2::structures::unit_type_t::UNIT_TYPE_ITEM); //0x4 = item
@@ -83,7 +79,6 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
itemProperty.nMax = itemMove->val;
diablo2::d2_common::add_property(bag, &itemProperty, 1);
if (item == nullptr)
return true; //block further packet processing
@@ -114,24 +109,17 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
diablo2::d2_net::send_to_client(1, client->client_id, &resp, sizeof resp);
if (itemMove->removeFromBag == 1) {
// here we need to add item to inventory
diablo2::structures::unit* item;
// or I can do something like this,
// when extractor is clicked, send the bag and extractor to cube,
// or I can do something like this,
// when extractor is clicked, send the bag and extractor to cube,
const auto player = diablo2::d2_client::get_local_player();
}
if (itemMove->updateBag == 1) {
// Serialize item data into binary file
std::string playerName = player->player_data->name;
std::string fileName = "./Save/" + playerName + ".boh";
@@ -146,12 +134,11 @@ bool d2_tweaks::server::modules::item_move::handle_packet(diablo2::structures::g
outFile.close();
}
return true;
}
bool d2_tweaks::server::modules::item_move::find_free_space(diablo2::structures::inventory* inv,
diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y) {
diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y) {
char data[0x18];
diablo2::d2_common::get_inventory_data(inventoryIndex, 0, data);
@@ -170,4 +157,4 @@ bool d2_tweaks::server::modules::item_move::find_free_space(diablo2::structures:
}
return false;
}
}

View File

@@ -7,9 +7,9 @@ d2_tweaks::server::modules::server_module::server_module() {
}
bool d2_tweaks::server::modules::server_module::handle_packet(diablo2::structures::game* game,
diablo2::structures::unit* player, common::packet_header* packet) {
diablo2::structures::unit* player, common::packet_header* packet) {
return false;
}
void d2_tweaks::server::modules::server_module::tick(diablo2::structures::game* game,
diablo2::structures::unit* unit) {}
diablo2::structures::unit* unit) {}

View File

@@ -10,14 +10,13 @@
MODULE_INIT(test)
static int(__stdcall* g_set_stat_original)(diablo2::structures::unit* unit,
diablo2::unit_stats_t stat,
uint32_t value, int16_t param);
diablo2::unit_stats_t stat,
uint32_t value, int16_t param);
static int __stdcall set_stat(diablo2::structures::unit* unit,
diablo2::unit_stats_t stat,
uint32_t value, int16_t param) {
diablo2::unit_stats_t stat,
uint32_t value, int16_t param) {
if (unit->type == diablo2::structures::unit_type_t::UNIT_TYPE_PLAYER &&
stat == diablo2::UNIT_STAT_GOLD) {
spdlog::debug("Setting UNIT_STAT_GOLD stat!");
}
@@ -25,7 +24,7 @@ static int __stdcall set_stat(diablo2::structures::unit* unit,
}
static int32_t(__stdcall* g_set_stat_in_list_original)(void*, diablo2::unit_stats_t stat,
uint32_t value, uint32_t param);
uint32_t value, uint32_t param);
static int32_t __stdcall set_stat_in_list(void* a1, diablo2::unit_stats_t stat, uint32_t value, uint32_t param) {
if (stat == diablo2::UNIT_STAT_GOLD) {
spdlog::debug("Setting UNIT_STAT_GOLD stat!");
@@ -46,4 +45,4 @@ void d2_tweaks::server::modules::test::init() {
hooking::hook<10517>(diablo2::d2_common::get_base(), set_stat, &g_set_stat_original);
hooking::hook(diablo2::d2_game::get_base() + 0x50F80, regen_tick, &g_regen_tick_original);
}
}

View File

@@ -78,7 +78,7 @@ static uint32_t m_nParam4 = 1;
//__declspec (naked) void click_trade_menu() {
// __asm {
// pushad; //+0x24 esp
// pushfd; //
// pushfd; //
// //mov eax, [esp + 0x28];//+0x4
// //mov [m_nNpcId], eax;
// mov eax, [esp + 0x34];//+0x10
@@ -99,7 +99,7 @@ static uint32_t m_nParam4 = 1;
//__declspec (naked) void click_gamble_menu() {
// __asm {
// pushad; //+0x24 esp
// pushfd; //
// pushfd; //
// //mov eax, [esp + 0x28];//+0x4
// //mov [m_nNpcId], eax;
// mov eax, [esp + 0x34];//+0x10
@@ -133,7 +133,6 @@ static uint32_t m_nParam4 = 1;
// {D2DLL_INVALID}
//};
void d2_tweaks::server::modules::trader_update::init() {
char szDir[MAX_PATH];
char szPath[MAX_PATH];
@@ -151,30 +150,27 @@ void d2_tweaks::server::modules::trader_update::init() {
}
}
void d2_tweaks::server::modules::trader_update::tick(diablo2::structures::game* game, diablo2::structures::unit* unit) {
return;
}
struct ClientFromNumber {
uint8_t padding[0x174];
diablo2::structures::net_client* net_cleint;
};
bool d2_tweaks::server::modules::trader_update::handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) {
const auto income_packet_cs = static_cast<common::trader_update_cs*>(packet);
static common::trader_update_sc response_packet_sc;
diablo2::structures::unit* temp_ptNPC = diablo2::d2_game::get_server_unit(game, diablo2::structures::unit_type_t::UNIT_TYPE_MONSTER, income_packet_cs->npc_id);
diablo2::structures::npc_record* npcrecord = diablo2::d2_game::get_npc_record(game, temp_ptNPC, &temp_ptNPC);
diablo2::structures::unit* ptNPC = diablo2::d2_game::get_server_unit(game, diablo2::structures::unit_type_t::UNIT_TYPE_MONSTER, income_packet_cs->npc_id);
if (!ptNPC)
return true;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (income_packet_cs->command == COMMAND_FREE_NPC_INVENTORY) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// id net client - 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 3, 5, 7, 9, 11, 13, 15
@@ -189,7 +185,6 @@ bool d2_tweaks::server::modules::trader_update::handle_packet(diablo2::structure
}
}
if (income_packet_cs->command == COMMAND_FREE_NPC_GAMBLE) {
npcrecord->pGamble->pInventory = 0;
npcrecord->pGamble->dwGUID = 0;
@@ -200,7 +195,6 @@ bool d2_tweaks::server::modules::trader_update::handle_packet(diablo2::structure
singleton<server>::instance().send_packet(player->player_data->net_client, &response_packet_sc, sizeof response_packet_sc);
}
if (income_packet_cs->command == COMMAND_FILL_NPC_INVENTORY) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
npcrecord->bRefreshInventory = true;
@@ -220,7 +214,6 @@ bool d2_tweaks::server::modules::trader_update::handle_packet(diablo2::structure
}
}
if (income_packet_cs->command == COMMAND_FILL_NPC_GAMBLE) {
diablo2::d2_game::create_vendor_cache1(game, player, ptNPC, 1, true);
response_packet_sc.command = COMMAND_FILL_NPC_GAMBLE;
@@ -230,4 +223,4 @@ bool d2_tweaks::server::modules::trader_update::handle_packet(diablo2::structure
}
return true;
}
}

View File

@@ -53,7 +53,6 @@ void d2_tweaks::server::modules::transmute::tick(diablo2::structures::game* game
return;
}
inline uint64_t TimeStart() {
_asm {
cpuid
@@ -61,33 +60,31 @@ inline uint64_t TimeStart() {
}
}
inline uint64_t TimeEnd() {
_asm {
rdtsc
}
}
bool d2_tweaks::server::modules::transmute::handle_packet(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) {
const auto income_packet_cs = static_cast<common::transmute_info_cs*>(packet);
static common::transmute_info_sc response_packet_sc;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (income_packet_cs->command == COMMAND_CALL_TRANSMUTE) {
#ifndef NDEBUG
#ifndef NDEBUG
uint64_t time = TimeStart();
#endif
#endif
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> item, <20><><EFBFBD> getmaxcuberecipes <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (diablo2::d2_game::transmogrify(game, player) == diablo2::d2_common::get_max_cube_recipes()) {
response_packet_sc.command = COMMAND_ABORT;
singleton<server>::instance().send_packet(player->player_data->net_client, &response_packet_sc, sizeof response_packet_sc);
//diablo2::d2_net::send_to_client(1, client->client_id, &response_packet_sc, sizeof response_packet_sc);
}
#ifndef NDEBUG
#ifndef NDEBUG
time = (TimeEnd() - time);
spdlog::debug("Time {}", time);
#endif
#endif
}
if (income_packet_cs->command == COMMAND_MOVE_ITEM) {
@@ -97,8 +94,6 @@ bool d2_tweaks::server::modules::transmute::handle_packet(diablo2::structures::g
return true;
}
bool d2_tweaks::server::modules::transmute::move_item_to(diablo2::structures::game* game, diablo2::structures::unit* player, common::packet_header* packet) {
static common::transmute_info_sc resp;
static auto& instance = singleton<server>::instance();
@@ -134,8 +129,6 @@ bool d2_tweaks::server::modules::transmute::move_item_to(diablo2::structures::ga
return true;
}
bool d2_tweaks::server::modules::transmute::find_free_space(diablo2::structures::inventory* inv,
diablo2::structures::unit* item, int32_t inventoryIndex, char page, uint32_t& x, uint32_t& y) {
char data[0x18];
@@ -156,5 +149,4 @@ bool d2_tweaks::server::modules::transmute::find_free_space(diablo2::structures:
}
return false;
}
}

View File

@@ -17,13 +17,13 @@
#include <d2tweaks/server/modules/server_module.h>
#include <common/hooking.h>
#include <D2Template.h>
#include <filesystem>
static int32_t(__fastcall* g_get_incoming_packet_info_original)(d2_tweaks::common::packet_header* data, unsigned int dataSize, size_t* packetSizeOut, size_t* someOffset, int* packetGroup, int32_t* a6, int a7, int a8);
static int32_t(__fastcall* g_handle_packet_original)(diablo2::structures::game* game, diablo2::structures::unit* player, d2_tweaks::common::packet_header* data, size_t size);
static int32_t(__fastcall* g_net_tick_original)(diablo2::structures::game*, diablo2::structures::unit*, int32_t, int32_t);
//returns some kind of processing type (i.e. resultGroup == 0x04 means drop packet)
static int32_t __fastcall get_incoming_packet_info(d2_tweaks::common::packet_header* data, unsigned int dataSize, size_t* packetSizeOut, size_t* someOffset, int* packetGroup, int32_t* a6, int a7, int a8) {
static d2_tweaks::common::packet_header dummy;
@@ -69,8 +69,8 @@ static int32_t g_ebp_send_to_client;
void __fastcall hook_sc_packet_before_sent(uint32_t* client_strc, d2_tweaks::common::packet_header* packet, size_t size) {
#ifndef NDEBUG
__asm {
push [ebp + 0x30];
pop [g_ebp_send_to_client];
push[ebp + 0x30];
pop[g_ebp_send_to_client];
}
if (size == -1)
@@ -82,20 +82,19 @@ void __fastcall hook_sc_packet_before_sent(uint32_t* client_strc, d2_tweaks::com
return;
}
__declspec (naked) void hook_sc_packet_before_sent_wrapper() {
__asm {
pushad;
pushfd;
push [esp+0x28]
call [hook_sc_packet_before_sent]
popfd;
push[esp + 0x28]
call[hook_sc_packet_before_sent]
popfd;
popad;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
push ecx
push ebp
push esi
mov esi, ecx
push ebp
push esi
mov esi, ecx
}
RET_TO_RVA(DLLBASE_D2GAME, 0xC715);
}
@@ -108,7 +107,6 @@ static const DLLPatchStrc gpt_hook_sc_packet_before_sent[] =
{D2DLL_INVALID}
};
void d2_tweaks::server::server::init() {
hooking::hook(reinterpret_cast<void*>(diablo2::d2_game::get_base() + 0x59320), ::handle_packet, &g_handle_packet_original);
hooking::hook(reinterpret_cast<void*>(diablo2::d2_game::get_base() + 0x50F80), net_tick, &g_net_tick_original);
@@ -137,8 +135,8 @@ void d2_tweaks::server::server::send_packet(diablo2::structures::net_client* cli
}
bool d2_tweaks::server::server::handle_packet(diablo2::structures::game* game,
diablo2::structures::unit* player,
common::packet_header* packet) {
diablo2::structures::unit* player,
common::packet_header* packet) {
auto handler = m_packet_handlers[packet->message_type];
if (!handler)
@@ -187,7 +185,7 @@ diablo2::structures::unit* d2_tweaks::server::server::get_server_unit(diablo2::s
}
void d2_tweaks::server::server::iterate_server_units(diablo2::structures::game* game, diablo2::structures::unit_type_t type,
const std::function<bool(diablo2::structures::unit*)>& cb) {
const std::function<bool(diablo2::structures::unit*)>& cb) {
if (!cb)
return;
@@ -225,4 +223,4 @@ int32_t d2_tweaks::server::server::net_tick(diablo2::structures::game* game, dia
}
return g_net_tick_original(game, unit, a3, a4);
}
}

View File

@@ -10,13 +10,13 @@
#include <common/string_utils.h>
d2_tweaks::ui::controls::button::button(menu* menu,
const rect& rect, const std::function<void()>& onClick,
common::asset* image,
int32_t frameDown, int32_t frameUp, int32_t clickSound) : control(menu,
rect.get_x(),
rect.get_y(),
rect.get_width(),
rect.get_height()) {
const rect& rect, const std::function<void()>& onClick,
common::asset* image,
int32_t frameDown, int32_t frameUp, int32_t clickSound) : control(menu,
rect.get_x(),
rect.get_y(),
rect.get_width(),
rect.get_height()) {
control::set_enabled(true);
control::set_visible(true);
@@ -42,8 +42,6 @@ d2_tweaks::ui::controls::button::button(menu* menu,
// uint32_t pos_y;
//};
d2_tweaks::ui::controls::button::button(menu* menu, const pugi::xml_node& node) : control(menu, 0, 0, 0, 0) {
char buf[32] = { 0 };
@@ -51,7 +49,7 @@ d2_tweaks::ui::controls::button::button(menu* menu, const pugi::xml_node& node)
auto cy = node.attribute("default_pos_y").as_int(0);
m_res_count = node.attribute("resolution_count").as_int(1);
respos temp;
for (uint32_t i = 1; i <= m_res_count; i++) {
sprintf_s(buf, "res%d_x", i);
@@ -143,9 +141,9 @@ void d2_tweaks::ui::controls::button::draw(int32_t offsetX, int32_t offsetY) {
!m_popup.empty()) {
diablo2::d2_win::set_current_font(diablo2::UI_FONT_16);
diablo2::d2_win::set_popup_properties(const_cast<wchar_t*>(m_popup.c_str()),
get_x() + offsetX + m_rect.get_width() / 2,
get_y() + offsetY - m_rect.get_height(),
diablo2::UI_COLOR_WHITE, TRUE);
get_x() + offsetX + m_rect.get_width() / 2,
get_y() + offsetY - m_rect.get_height(),
diablo2::UI_COLOR_WHITE, TRUE);
diablo2::d2_win::draw_popup();
}
@@ -185,4 +183,4 @@ void d2_tweaks::ui::controls::button::left_mouse(int32_t offsetX, int32_t offset
void d2_tweaks::ui::controls::button::right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) {}
void d2_tweaks::ui::controls::button::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
void d2_tweaks::ui::controls::button::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}

View File

@@ -9,13 +9,13 @@
const int32_t PADDING = 3;
d2_tweaks::ui::controls::checkbox::checkbox(menu* menu, const std::wstring& text, const rect& rect,
const std::function<void()>& onClick,
common::asset* image, int32_t frameChecked, int32_t frameUnchecked, int32_t clickSound)
const std::function<void()>& onClick,
common::asset* image, int32_t frameChecked, int32_t frameUnchecked, int32_t clickSound)
: control(menu,
rect.get_x(),
rect.get_y(),
rect.get_width(),
rect.get_height()) {
rect.get_x(),
rect.get_y(),
rect.get_width(),
rect.get_height()) {
control::set_enabled(true);
control::set_visible(true);
@@ -72,7 +72,7 @@ d2_tweaks::ui::controls::checkbox::checkbox(menu* menu, const pugi::xml_node& no
m_image = new image(menu, cimg, cx, cy, m_frame_unchecked);
m_label = new label(menu, string_utils::string_to_wstring(ctext), cx + m_image->get_width() + PADDING, cy,
static_cast<diablo2::ui_color_t>(ccolor), static_cast<diablo2::ui_font_t>(cfont));
static_cast<diablo2::ui_color_t>(ccolor), static_cast<diablo2::ui_font_t>(cfont));
checkbox::set_x(cx);
checkbox::set_y(cy);
@@ -103,9 +103,9 @@ void d2_tweaks::ui::controls::checkbox::draw(int32_t offsetX, int32_t offsetY) {
!m_popup.empty()) {
diablo2::d2_win::set_current_font(diablo2::UI_FONT_16);
diablo2::d2_win::set_popup_properties(const_cast<wchar_t*>(m_popup.c_str()),
get_x() + offsetX + m_rect.get_width() / 2,
get_y() + offsetY - m_rect.get_height(),
diablo2::UI_COLOR_WHITE, TRUE);
get_x() + offsetX + m_rect.get_width() / 2,
get_y() + offsetY - m_rect.get_height(),
diablo2::UI_COLOR_WHITE, TRUE);
diablo2::d2_win::draw_popup();
}
@@ -152,4 +152,4 @@ void d2_tweaks::ui::controls::checkbox::left_mouse(int32_t offsetX, int32_t offs
void d2_tweaks::ui::controls::checkbox::right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) {}
void d2_tweaks::ui::controls::checkbox::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
void d2_tweaks::ui::controls::checkbox::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}

View File

@@ -88,7 +88,7 @@ void d2_tweaks::ui::controls::group::right_mouse(int32_t offsetX, int32_t offset
}
void d2_tweaks::ui::controls::group::key_event(int32_t offsetX, int32_t offsetY,
uint32_t key, bool up, bool& block) {
uint32_t key, bool up, bool& block) {
for (auto control : m_controls) {
if (!control->get_enabled())
continue;
@@ -105,4 +105,4 @@ void d2_tweaks::ui::controls::group::add_control(control* control) {
return;
get_menu()->add_control(control);
}
}

View File

@@ -92,4 +92,4 @@ void d2_tweaks::ui::controls::image::right_mouse(int32_t offsetX, int32_t offset
block = m_rect.contains(diablo2::d2_client::get_mouse_x(), diablo2::d2_client::get_mouse_y(), offsetX, offsetY);
}
void d2_tweaks::ui::controls::image::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
void d2_tweaks::ui::controls::image::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}

View File

@@ -3,7 +3,7 @@
#include <diablo2/d2client.h>
d2_tweaks::ui::controls::label::label(menu* menu, const std::wstring& text, int32_t x, int32_t y, diablo2::ui_color_t color,
diablo2::ui_font_t font) : control(menu, x, y, 0, 0) {
diablo2::ui_font_t font) : control(menu, x, y, 0, 0) {
control::set_enabled(true);
control::set_visible(true);
@@ -97,4 +97,4 @@ void d2_tweaks::ui::controls::label::left_mouse(int32_t offsetX, int32_t offsetY
void d2_tweaks::ui::controls::label::right_mouse(int32_t offsetX, int32_t offsetY, bool up, bool& block) {}
void d2_tweaks::ui::controls::label::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}
void d2_tweaks::ui::controls::label::key_event(int32_t offsetX, int32_t offsetY, uint32_t key, bool up, bool& block) {}

View File

@@ -70,7 +70,6 @@ bool d2_tweaks::ui::menu::load_xml(const char* path) {
m_respos.push_back(temp);
}
m_name = menuNode.node().attribute("name").as_string();
m_width = menuNode.node().attribute("width").as_int(-1);
m_height = menuNode.node().attribute("height").as_int(-1);
@@ -220,7 +219,6 @@ bool d2_tweaks::ui::menu::mouse_wheel(bool up) {
return block;
}
bool d2_tweaks::ui::menu::key_event(uint32_t key, bool up) {
auto block = false;
@@ -234,4 +232,4 @@ bool d2_tweaks::ui::menu::key_event(uint32_t key, bool up) {
}
return block;
}
}

View File

@@ -69,6 +69,8 @@
#include <string>
#include <CommCtrl.h> // Include for edit control
#include <d2tweaks/client/client.h>
#pragma pack(push, 1)
using namespace std;
@@ -220,7 +222,7 @@ diablo2::structures::unit unserialize_item(const std::string& hexString) {
}
// Create an item object
diablo2::structures::unit item;
diablo2::structures::unit item{};
// Convert the hexadecimal string to binary data
for (size_t i = 0; i < hexString.size(); i += 2) {
@@ -244,6 +246,38 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
block = true; // block the game from processing this key
}
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
@@ -1607,7 +1641,6 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
|| record->type == 53 - 3
) {
// open the cube
struct D2GSPacketClt20 {
uint8_t PacketId; // 0x01
@@ -1655,7 +1688,6 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
}
diablo2::d2_client::send_to_server(&packet, sizeof packet);
diablo2::d2_client::send_to_server_7(0x4F, 0x18, 0, 0);
// now move the harvester back to the inv
//static d2_tweaks::common::item_move_cs h1packet;
@@ -1664,7 +1696,6 @@ LRESULT d2_tweaks::ui::ui_manager::wnd_proc(HWND hWnd, UINT msg, WPARAM wParam,
//diablo2::d2_client::send_to_server(&h1packet, sizeof h1packet);
(*reinterpret_cast<diablo2::structures::unit**>(diablo2::d2_client::get_base() + 0x1158F4)) = nullptr;
}
}