Skip to content

Commit

Permalink
Added QualityOfLife plugin - Allows right click to move items like in…
Browse files Browse the repository at this point in the history
… d2maphack if d2maphack.dll is not loaded
  • Loading branch information
nooperation committed Apr 30, 2021
1 parent 0cbdc0a commit ce67ffc
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 0 deletions.
7 changes: 7 additions & 0 deletions D2Hackit/D2Hackit/D2hackit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AutoOre", "..\Modules\autoO
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "autoTinker", "..\Modules\autoTinker\autoTinker.vcxproj", "{117F3113-ACE4-4FC4-BF9E-80FE8827BB69}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QualityOfLife", "..\Modules\QualityOfLife\QualityOfLife.vcxproj", "{EA69AB6D-FFC2-4CB7-83C8-5D43CDAFF036}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -169,6 +171,10 @@ Global
{117F3113-ACE4-4FC4-BF9E-80FE8827BB69}.Debug|Win32.Build.0 = Debug|Win32
{117F3113-ACE4-4FC4-BF9E-80FE8827BB69}.Release|Win32.ActiveCfg = Release|Win32
{117F3113-ACE4-4FC4-BF9E-80FE8827BB69}.Release|Win32.Build.0 = Release|Win32
{EA69AB6D-FFC2-4CB7-83C8-5D43CDAFF036}.Debug|Win32.ActiveCfg = Debug|Win32
{EA69AB6D-FFC2-4CB7-83C8-5D43CDAFF036}.Debug|Win32.Build.0 = Debug|Win32
{EA69AB6D-FFC2-4CB7-83C8-5D43CDAFF036}.Release|Win32.ActiveCfg = Release|Win32
{EA69AB6D-FFC2-4CB7-83C8-5D43CDAFF036}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -200,6 +206,7 @@ Global
{FF4D7C7F-7217-4447-F996-98DBF93EF41C} = {B633F61A-62D5-4159-BA82-8C17FFE77E9C}
{832CCF50-B3EA-4201-9FFF-90C6FD82FF3A} = {B633F61A-62D5-4159-BA82-8C17FFE77E9C}
{117F3113-ACE4-4FC4-BF9E-80FE8827BB69} = {B633F61A-62D5-4159-BA82-8C17FFE77E9C}
{EA69AB6D-FFC2-4CB7-83C8-5D43CDAFF036} = {B633F61A-62D5-4159-BA82-8C17FFE77E9C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7DAE5C20-C224-4A1A-8147-796AF2BFCA24}
Expand Down
121 changes: 121 additions & 0 deletions D2Hackit/Modules/QualityOfLife/QualityOfLife.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#include "../../Includes/ClientCore.cpp"

#define CONFIG_FILE ".\\plugin\\QualityOfLife.ini"

int isRightClickItemTransfer = 0;

void ReadConfig();
void OnRightClick();

CLIENTINFO
(
0,1,
"",
"",
"QualityOfLife",
""
)

BOOL CALLBACK ClientWndProc(LRESULT *pResult, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_RBUTTONDOWN:
{
OnRightClick();
break;
}
}

return FALSE;
}

void OnRightClick()
{
if (!isRightClickItemTransfer)
{
return;
}

const auto isStashOpen = me->IsUIOpened(UI_STASH);
const auto isInventoryOpen = me->IsUIOpened(UI_INVENTORY);
const auto isCubeOpen = me->IsUIOpened(UI_CUBE);

if (!isStashOpen && !isInventoryOpen && !isCubeOpen)
{
return;
}

const auto cursorItem = me->GetCursorItem();
if (cursorItem == 0)
{
return;
}

const auto mousePositionGame = screen->GetMousePosition();
const auto screenDimensions = screen->GetScreenSize();
const auto isOnRightSideOfScreen = mousePositionGame.x > (screenDimensions.cx / 2);

if (isOnRightSideOfScreen)
{
if (isStashOpen)
{
me->DropCursorItemToStorage(STORAGE_STASH);
}
else if (isCubeOpen)
{
me->DropCursorItemToStorage(STORAGE_CUBE);
}
else
{
me->DropCursorItemToGround();
}
}
else
{
me->DropCursorItemToStorage(STORAGE_INVENTORY);
}
}


BOOL EXPORT OnGameJoin()
{
server->SendKey(189);

return TRUE;
}

BOOL EXPORT OnClientStart()
{
if (!GetModuleHandle("d2maphack.dll"))
{
server->HookD2WndProc(g_hModule, ClientWndProc);
}
else
{
return FALSE;
}

return TRUE;
}

void ReadConfig()
{
isRightClickItemTransfer = GetPrivateProfileInt("Main", "RightClickItemTransfer", 1, CONFIG_FILE);
}

VOID EXPORT OnGameJoin(THISGAMESTRUCT* thisgame)
{
ReadConfig();
}

MODULECOMMANDSTRUCT ModuleCommands[]=
{
{
"help",
OnGameCommandHelp,
"helpÿc0 List commands available in this module.\n"
"<command> helpÿc0 Shows detailed help for <command> in this module."
},
{NULL}
};
125 changes: 125 additions & 0 deletions D2Hackit/Modules/QualityOfLife/QualityOfLife.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<Diablo2Path Condition="'$(Diablo2Path)' == '' ">
C:\Program Files (x86)\Diablo II
</Diablo2Path>
</PropertyGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EA69AB6D-FFC2-4CB7-83C8-5D43CDAFF036}</ProjectGuid>
<RootNamespace>QualityOfLife</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.d2h</TargetExt>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.d2h</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>qol</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;QualityOfLife_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>xcopy /Y Resources $(SolutionDir)\..\$(Configuration)\
xcopy /Y $(TargetPath) $(SolutionDir)\..\$(Configuration)\
xcopy /Y $(TargetPath) "$(Diablo2Path)\plugin\"
xcopy /Y $(TargetDir)$(TargetName).pdb "$(Diablo2Path)\plugin\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;QualityOfLife_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>xcopy /Y Resources $(SolutionDir)\..\$(Configuration)\
xcopy /Y $(TargetPath) $(SolutionDir)\..\$(Configuration)\</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="QualityOfLife.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\QualityOfLife.ini" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
27 changes: 27 additions & 0 deletions D2Hackit/Modules/QualityOfLife/QualityOfLife.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{FFC737F1-C7A5-4376-A066-2A32DF52A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{9399FF80-89BD-4b04-88EB-6F5FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-Fc08-8B7A-83BB1FFAAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="QualityOfLife.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Resources\QualityOfLife.ini">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions D2Hackit/Modules/QualityOfLife/Resources/QualityOfLife.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Main]
RightClickItemTransfer=1

0 comments on commit ce67ffc

Please sign in to comment.