Skip to content

Commit

Permalink
Fixed D2PropertiesTxt.wStat (uint16 -> int16)
Browse files Browse the repository at this point in the history
Fixed autoreroll so it actually checks more than the first stat of a property
Removed stats from .pick lvl and moved them to .pick stats
.pick stats dumps all the stat info (affix id, prop id, stat id)
  • Loading branch information
nooperation committed Feb 3, 2024
1 parent f3f4e46 commit 0106f16
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 84 deletions.
2 changes: 1 addition & 1 deletion D2Hackit/Includes/DataTbls/ItemsTbls.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ struct D2PropertiesTxt
uint16_t wVal[7]; //0x0A
uint8_t nFunc[7]; //0x18
uint8_t pad0x1F; //0x1F
uint16_t wStat[7]; //0x20
int16_t wStat[7]; //0x20
};

// sgptDataTable and inlined structs
Expand Down
72 changes: 39 additions & 33 deletions D2Hackit/Modules/autoReroll/AutoReroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,51 +348,57 @@ bool AutoReroll::IsPerfectProperty(GAMEUNIT& itemUnit, UnitAny* unit, const D2Pr
return true;
}

auto statTxt = server->GetItemStatCostTxtRecord(propertyTxt->wStat[0]);
if (statTxt == nullptr)
for (int propertyTxtIndex = 0; propertyTxtIndex < sizeof(propertyTxt->wStat) / sizeof(propertyTxt->wStat[0]); ++propertyTxtIndex)
{
server->GameStringf("Invalid propertyTxt stat %d", propertyTxt->wStat[0]);
return true;
}
auto statTxt = server->GetItemStatCostTxtRecord(propertyTxt->wStat[propertyTxtIndex]);
if (statTxt == nullptr)
{
server->GameStringf("Invalid propertyTxt stat %d", propertyTxt->wStat[propertyTxtIndex]);
return true;
}

auto minimumValue = std::min(property.nMin, property.nMax);
auto maximumValue = std::max(property.nMin, property.nMax);
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[0])
{
case 8:
case 1:
std::string propertyName = server->GetPropertyName(property.nProperty);
switch (propertyTxt->nFunc[propertyTxtIndex])
{
auto actualValue = (int32_t)server->GetUnitStat(&itemUnit, propertyTxt->wStat[0]);
actualValue >>= statTxt->nValShift;
case 8:
case 1:
{
auto actualValue = (int32_t)server->GetUnitStat(&itemUnit, propertyTxt->wStat[propertyTxtIndex]);
actualValue >>= statTxt->nValShift;

if (actualValue < maximumValue && actualValue >= minimumValue) {
return false;
if (actualValue < maximumValue && actualValue >= minimumValue)
{
return false;
}

return true;
}
case 21: // +class skills
{
auto actualValue = server->GetUnitStatBonus(unit, propertyTxt->wStat[propertyTxtIndex], propertyTxt->wVal[propertyTxtIndex]);
actualValue >>= statTxt->nValShift;

return true;
}
case 21: // +class skills
{
auto actualValue = server->GetUnitStatBonus(unit, propertyTxt->wStat[0], propertyTxt->wVal[0]);
actualValue >>= statTxt->nValShift;
if (actualValue < maximumValue && actualValue >= minimumValue)
{
return false;
}

if (actualValue < maximumValue && actualValue >= minimumValue) {
return false;
return true;
}
case 22: // oskills
{
auto actualValue = server->GetUnitStatBonus(unit, propertyTxt->wStat[propertyTxtIndex], property.nLayer);

return true;
}
case 22: // oskills
{
auto actualValue = server->GetUnitStatBonus(unit, propertyTxt->wStat[0], property.nLayer);
if (actualValue < maximumValue && actualValue >= minimumValue)
{
return false;
}

if (actualValue < maximumValue && actualValue >= minimumValue) {
return false;
return true;
}

return true;
}
}

Expand Down
Loading

0 comments on commit 0106f16

Please sign in to comment.