Skip to content

Commit

Permalink
Added Hoyt filter changes (whitelists, more filtering options for jew…
Browse files Browse the repository at this point in the history
…els)
  • Loading branch information
nooperation committed Sep 19, 2022
1 parent 6793904 commit 634bd69
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 5 deletions.
52 changes: 48 additions & 4 deletions D2Hackit/Modules/filter/ItemFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ bool ItemFilter::LoadItems()
{
return false;
}

if(!LoadItemMap(".\\plugin\\filterUniqueWhitelist.txt", allowedItemsUnique))
{
return false;
}
if(!LoadItemMap(".\\plugin\\filterSetWhitelist.txt", allowedItemsSet))
{
return false;
}
//filterTown = GetPrivateProfileInt("Filter", "FilterTown", 1, FILTER_SETTINGS_PATH);

showUnique = GetPrivateProfileInt("WeaponArmor", "Unique", 1, FILTER_SETTINGS_PATH) == TRUE;
Expand All @@ -50,6 +57,9 @@ bool ItemFilter::LoadItems()
showMagicCharms = GetPrivateProfileInt("Charms", "MagicCharms", 1, FILTER_SETTINGS_PATH) == TRUE;
showRareCharms = GetPrivateProfileInt("Charms", "RareCharms", 1, FILTER_SETTINGS_PATH) == TRUE;

showMagicJewels = GetPrivateProfileInt("Jewels", "MagicJewels", 1, FILTER_SETTINGS_PATH) == TRUE;
showRareJewels = GetPrivateProfileInt("Jewels", "RareJewels", 1, FILTER_SETTINGS_PATH) == TRUE;

minGoldAmount = GetPrivateProfileInt("Misc", "MinGoldAmount", 0, FILTER_SETTINGS_PATH);
return true;
}
Expand Down Expand Up @@ -82,6 +92,12 @@ bool ItemFilter::OnItemFind(ITEM &item)
if(IsAllowed(item.szItemCode))
return true;

if(item.iQuality == ITEM_LEVEL_UNIQUE && allowedItemsUnique.find(item.szItemCode) != allowedItemsUnique.end())
return true;

if(item.iQuality == ITEM_LEVEL_SET && allowedItemsSet.find(item.szItemCode) != allowedItemsSet.end())
return true;

if(IsFiltered(item.szItemCode))
return false;

Expand Down Expand Up @@ -115,6 +131,16 @@ bool ItemFilter::OnItemFind(ITEM &item)

return true;
}

if (IsJewel(item.szItemCode))
{
if (!showMagicJewels && item.iQuality == ITEM_LEVEL_MAGIC)
return false;
if (!showRareJewels && item.iQuality == ITEM_LEVEL_RARE)
return false;

return true;
}

if(server->IsWeapon(item.szItemCode) || server->IsArmor(item.szItemCode))
{
Expand All @@ -127,7 +153,7 @@ bool ItemFilter::OnItemFind(ITEM &item)
if(showEthSoc && item.iEthereal && item.iSocketed)
return true;

if(!showUnique && item.iQuality == ITEM_LEVEL_UNIQUE)
if(!showUnique && item.iQuality == ITEM_LEVEL_UNIQUE)
return false;

if(!showRare && item.iQuality == ITEM_LEVEL_RARE)
Expand Down Expand Up @@ -217,8 +243,7 @@ bool ItemFilter::IsGoodItemCode(char *itemCode)
return true;
}

if(strcmp(itemCode, "jew") == 0 ||
strcmp(itemCode, "xu0") == 0 ||
if(strcmp(itemCode, "xu0") == 0 ||
strcmp(itemCode, "s51") == 0 ||
strcmp(itemCode, "s01") == 0 ||
strcmp(itemCode, "t51") == 0 ||
Expand Down Expand Up @@ -252,6 +277,16 @@ bool ItemFilter::IsCharm(char *itemCode)
return false;
}

bool ItemFilter::IsJewel(char* itemCode)
{
if (strcmp(itemCode, "jew") == 0)
{
return true;
}

return false;
}

bool ItemFilter::IsRareSpecial(char *itemCode)
{
// Unique boss parts
Expand Down Expand Up @@ -291,6 +326,15 @@ bool ItemFilter::IsRareSpecial(char *itemCode)
return true;
}

if(strcmp(itemCode, "sbs") == 0 ||
strcmp(itemCode, "srj") == 0 ||
strcmp(itemCode, "sbk") == 0 ||
strcmp(itemCode, "toa") == 0 ||
strcmp(itemCode, "zz0") == 0)
{
return true;
}

return false;
}

Expand Down
5 changes: 5 additions & 0 deletions D2Hackit/Modules/filter/ItemFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ItemFilter
private:
std::unordered_map<std::string, std::string> filteredItems;
std::unordered_map<std::string, std::string> allowedItems;
std::unordered_map<std::string, std::string> allowedItemsUnique;
std::unordered_map<std::string, std::string> allowedItemsSet;
std::unordered_map<std::string, std::string> weaponArmorItems;
//bool filterTown;
bool showEthSoc;
Expand All @@ -31,6 +33,8 @@ class ItemFilter
bool showRareRingAmulet;
bool showMagicCharms;
bool showRareCharms;
bool showMagicJewels;
bool showRareJewels;
int minGoldAmount;

bool OnItemFind(ITEM &item);
Expand All @@ -41,6 +45,7 @@ class ItemFilter
bool IsGoodItemOther(ITEM &item);
bool IsGoodItemCode(char *itemCode);
bool IsCharm(char *itemCode);
bool IsJewel(char *itemCode);
bool IsRareSpecial(char *itemCode);
bool IsRuneDecalScroll(char *itemCode);
bool IsRingAmulet(char *itemCode);
Expand Down
4 changes: 4 additions & 0 deletions D2Hackit/Modules/filter/Resources/filter.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ RareRingAmulet = 1
MagicCharms = 1
RareCharms = 1

[Jewels]
MagicJewels = 1
RareJewels = 1

[Misc]
MinGoldAmount = 0
6 changes: 5 additions & 1 deletion D2Hackit/Modules/filter/Resources/filterAllow.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Key Key
key Key

srj Slurp Juice
sbs Radamant's Smol Skill Book
zz0 Radiant Aura Stone
sbk Not Ranamants Skill Book
toa Token of Absolution
3 changes: 3 additions & 0 deletions D2Hackit/Modules/filter/Resources/filterSetWhitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
yar Cow King's Steel Hide
ybt Cow King's Steel Hoofs
ydw Cow King's Steel Horns
27 changes: 27 additions & 0 deletions D2Hackit/Modules/filter/Resources/filterUniqueWhitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ytp Archmage Plate
yrb Archmage Robe
0gi Slayer Axe
0ts Whale Hunter
yft Ceremonial Shield
yul Ceremonial Armor
ci3 Diadem
zam Amazonian Pin
sam Sorcerer's Talisman
nam Death's Locket
pam Holy Pendant
bam Totemic Pebble
dam Druidic Necklace
aam Assassin's Choker
3lb Sash
amu Amulet
au9 Amulet
rin Ring
rn9 Ring
jwl Jewel
ore Ore
cx1 Small Charm
cx2 Large Charm
cx3 Grand Charm
cm1 Small Charm
cm2 Large Charm
cm3 Grand Charm
4 changes: 4 additions & 0 deletions D2Hackit/Modules/filter/filter.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ xcopy /Y $(TargetPath) $(SolutionDir)\Publish_$(Configuration)\</Command>
<None Include="Resources\filterAllow.txt" />
<None Include="Resources\filterDeny.txt" />
</ItemGroup>
<ItemGroup>
<Text Include="Resources\filterSetWhitelist.txt" />
<Text Include="Resources\filterUniqueWhitelist.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
8 changes: 8 additions & 0 deletions D2Hackit/Modules/filter/filter.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="Resources\filterSetWhitelist.txt">
<Filter>Resource Files</Filter>
</Text>
<Text Include="Resources\filterUniqueWhitelist.txt">
<Filter>Resource Files</Filter>
</Text>
</ItemGroup>
</Project>

0 comments on commit 634bd69

Please sign in to comment.