diff --git a/D2Hackit/Modules/autoReroll/AutoReroll.cpp b/D2Hackit/Modules/autoReroll/AutoReroll.cpp index a5054aa..1ce95a2 100644 --- a/D2Hackit/Modules/autoReroll/AutoReroll.cpp +++ b/D2Hackit/Modules/autoReroll/AutoReroll.cpp @@ -9,6 +9,11 @@ #undef min #undef max +std::vector gemsInInventory; +std::unordered_set goodPrefix; +std::unordered_set goodSuffix; +std::unordered_set goodStats; + std::unordered_set gemItemCodes; std::unordered_set gemCanItemCodes; std::unordered_set canOpenerItemCodes; @@ -105,9 +110,16 @@ bool AutoReroll::Init(bool useChat) return false; } + if(!ReadAffixConfig(".\\plugin\\goodStats_ar.txt", goodStats)) + { + return false; + } + minPrefix = GetPrivateProfileInt("AutoReroll", "PrefixCount", 2, CONFIG_PATH); minSuffix = GetPrivateProfileInt("AutoReroll", "SuffixCount", 0, CONFIG_PATH); numGemsToUse = GetPrivateProfileInt("AutoReroll", "GemCount", 2, CONFIG_PATH); + requirePerfectStats = GetPrivateProfileInt("AutoReroll", "RequirePerfectStats", 0, CONFIG_PATH) != 0; + perfectionPercentage = GetPrivateProfileInt("AutoReroll", "PerfectionPercentage", 100, CONFIG_PATH); char buff[128]; if (GetPrivateProfileStringA("AutoReroll", "CustomExtractorItemCode", "", buff, sizeof(buff), CONFIG_PATH) > 0) @@ -348,8 +360,28 @@ bool AutoReroll::IsPerfectProperty(GAMEUNIT& itemUnit, UnitAny* unit, const D2Pr return true; } + auto minimumValue = std::min(property.nMin, property.nMax); + auto maximumValue = std::max(property.nMin, property.nMax); + + if (maximumValue == minimumValue) + { + return true; + } + + bool isPerfect = false; for (int propertyTxtIndex = 0; propertyTxtIndex < sizeof(propertyTxt->wStat) / sizeof(propertyTxt->wStat[0]); ++propertyTxtIndex) { + if (propertyTxt->wStat[propertyTxtIndex] < 0) + { + break; + } + + if (!requirePerfectStats && goodStats.find(propertyTxt->wStat[propertyTxtIndex]) == goodStats.end()) + { + // We don't care about this stat since we're only looking for specific stats to be perfect + continue; + } + auto statTxt = server->GetItemStatCostTxtRecord(propertyTxt->wStat[propertyTxtIndex]); if (statTxt == nullptr) { @@ -357,9 +389,6 @@ bool AutoReroll::IsPerfectProperty(GAMEUNIT& itemUnit, UnitAny* unit, const D2Pr return true; } - auto minimumValue = std::min(property.nMin, property.nMax); - auto maximumValue = std::max(property.nMin, property.nMax); - std::string propertyName = server->GetPropertyName(property.nProperty); switch (propertyTxt->nFunc[propertyTxtIndex]) { @@ -369,35 +398,32 @@ bool AutoReroll::IsPerfectProperty(GAMEUNIT& itemUnit, UnitAny* unit, const D2Pr auto actualValue = (int32_t)server->GetUnitStat(&itemUnit, propertyTxt->wStat[propertyTxtIndex]); actualValue >>= statTxt->nValShift; - if (actualValue < maximumValue && actualValue >= minimumValue) + auto percentPerfect = (int)(100.0 * (actualValue - minimumValue)) / (maximumValue - minimumValue); + if (percentPerfect < perfectionPercentage) { return false; } - - return true; } case 21: // +class skills { auto actualValue = server->GetUnitStatBonus(unit, propertyTxt->wStat[propertyTxtIndex], propertyTxt->wVal[propertyTxtIndex]); actualValue >>= statTxt->nValShift; - if (actualValue < maximumValue && actualValue >= minimumValue) + auto percentPerfect = (int)(100.0 * (actualValue - minimumValue)) / (maximumValue - minimumValue); + if (percentPerfect < perfectionPercentage) { return false; } - - return true; } case 22: // oskills { auto actualValue = server->GetUnitStatBonus(unit, propertyTxt->wStat[propertyTxtIndex], property.nLayer); - if (actualValue < maximumValue && actualValue >= minimumValue) + auto percentPerfect = (int)(100.0 * (actualValue - minimumValue)) / (maximumValue - minimumValue); + if (percentPerfect < perfectionPercentage) { return false; } - - return true; } } } diff --git a/D2Hackit/Modules/autoReroll/AutoReroll.h b/D2Hackit/Modules/autoReroll/AutoReroll.h index 47c088d..dc9a05d 100644 --- a/D2Hackit/Modules/autoReroll/AutoReroll.h +++ b/D2Hackit/Modules/autoReroll/AutoReroll.h @@ -40,7 +40,6 @@ class AutoReroll bool Init(bool useChat); void OnItemToCube(const ITEM &item); - void OnItemFromCube(DWORD itemID); void OnItemFromInventory(DWORD itemID); bool OnEmptyCubeMessage(const std::string_view &message); bool OnAutoExtractorMessage(const std::string_view &message); @@ -48,7 +47,6 @@ class AutoReroll void Abort(); private: - void StartStocking(); bool CheckRerolledItem(const ITEM &item); bool IsPerfectProperty(GAMEUNIT& itemUnit, UnitAny* unit, const D2PropertyStrc& property, D2DataTablesStrc* dataTables); @@ -59,7 +57,6 @@ class AutoReroll void ExtractMoreGems(); void MoveGemCanAndOpenerToCube(); void MoveNextGemToCube(); - void FinishedEmptyCube(); bool ReadAffixConfig(const std::string &configPath, std::unordered_set &readTo); @@ -69,11 +66,10 @@ class AutoReroll int minPrefix; int minSuffix; int numGemsToUse; + bool requirePerfectStats; + int perfectionPercentage; DWORD itemToRerollID; int currentGemIndex; - std::vector gemsInInventory; - std::unordered_set goodPrefix; - std::unordered_set goodSuffix; States currentState; GemCanStuff gemCanAndOpener; diff --git a/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj b/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj index e7a2eb5..d403e64 100644 --- a/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj +++ b/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj @@ -124,6 +124,9 @@ xcopy /Y $(TargetPath) $(SolutionDir)\Publish_$(Configuration)\ + + + diff --git a/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj.filters b/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj.filters index 8fae3ec..33b10b8 100644 --- a/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj.filters +++ b/D2Hackit/Modules/autoReroll/AutoReroll.vcxproj.filters @@ -38,4 +38,9 @@ Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/D2Hackit/Modules/autoReroll/Resources/autoreroll.ini b/D2Hackit/Modules/autoReroll/Resources/autoreroll.ini index 23fce7e..14302f1 100644 --- a/D2Hackit/Modules/autoReroll/Resources/autoreroll.ini +++ b/D2Hackit/Modules/autoReroll/Resources/autoreroll.ini @@ -11,3 +11,5 @@ GemCount = 2 ;CustomExtractorItemCode = key ;CustomGemItemCode = 6gk ;CustomGemCanItemCode = kk0 +;RequirePerfectStats = +;PerfectionPercentage = 100 diff --git a/D2Hackit/Modules/autoReroll/goodStats_ar.txt b/D2Hackit/Modules/autoReroll/goodStats_ar.txt new file mode 100644 index 0000000..2732eb0 --- /dev/null +++ b/D2Hackit/Modules/autoReroll/goodStats_ar.txt @@ -0,0 +1,7 @@ +437 passive_mag_pierce +335 passive_cold_pierce +429 passive_cold_mastery_multi +331 passive_cold_mastery +127 item_allskills +37 magicresist +85 item_addexperience