diff --git a/BH/Modules/Item/ItemDisplay.cpp b/BH/Modules/Item/ItemDisplay.cpp index 394ac4cc..f0b3286b 100644 --- a/BH/Modules/Item/ItemDisplay.cpp +++ b/BH/Modules/Item/ItemDisplay.cpp @@ -10,7 +10,9 @@ {"CRES", STAT_COLDRESIST}, \ {"FRES", STAT_FIRERESIST}, \ {"LRES", STAT_LIGHTNINGRESIST}, \ - {"PRES", STAT_POISONRESIST} \ + {"PRES", STAT_POISONRESIST}, \ + {"MINDMG", STAT_MINIMUMDAMAGE}, \ + {"MAXDMG", STAT_MAXIMUMDAMAGE}, \ // All colors here must also be defined in MAP_COLOR_REPLACEMENTS #define COLOR_REPLACEMENTS \ @@ -615,7 +617,7 @@ void Condition::BuildConditions(vector &conditions, string token) { } else if (key.compare(0, 3, "DEF") == 0) { Condition::AddOperand(conditions, new ItemStatCondition(STAT_DEFENSE, 0, operation, value)); } else if (key.compare(0, 6, "MAXDUR") == 0) { - Condition::AddOperand(conditions, new ItemStatCondition(STAT_ENHANCEDMAXDURABILITY, 0, operation, value)); + Condition::AddOperand(conditions, new DurabilityCondition(operation, value)); } else if (key.compare(0, 3, "RES") == 0) { Condition::AddOperand(conditions, new ResistAllCondition(operation, value)); } else if (key.compare(0, 4, "FRES") == 0) { @@ -660,12 +662,16 @@ void Condition::BuildConditions(vector &conditions, string token) { Condition::AddOperand(conditions, new ItemStatCondition(STAT_DEXTERITY, 0, operation, value)); } else if (key.compare(0, 3, "FRW") == 0) { Condition::AddOperand(conditions, new ItemStatCondition(STAT_FASTERRUNWALK, 0, operation, value)); + } else if (key.compare(0, 6, "MINDMG") == 0) { + Condition::AddOperand(conditions, new ItemStatCondition(STAT_MINIMUMDAMAGE, 0, operation, value)); } else if (key.compare(0, 6, "MAXDMG") == 0) { Condition::AddOperand(conditions, new ItemStatCondition(STAT_MAXIMUMDAMAGE, 0, operation, value)); } else if (key.compare(0, 2, "AR") == 0) { Condition::AddOperand(conditions, new ItemStatCondition(STAT_ATTACKRATING, 0, operation, value)); } else if (key.compare(0, 3, "DTM") == 0) { Condition::AddOperand(conditions, new ItemStatCondition(STAT_DAMAGETOMANA, 0, operation, value)); + } else if (key.compare(0, 4, "MAEK") == 0) { + Condition::AddOperand(conditions, new ItemStatCondition(STAT_MANAAFTEREACHKILL, 0, operation, value)); } else if (key.compare(0, 7, "REPLIFE") == 0) { Condition::AddOperand(conditions, new ItemStatCondition(STAT_REPLENISHLIFE, 0, operation, value)); } else if (key.compare(0, 8, "REPQUANT") == 0) { @@ -1051,6 +1057,31 @@ bool EDCondition::EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Co return IntegerCompare(value, operation, targetED); } +bool DurabilityCondition::EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2) { + // Pulled from JSUnit.cpp in d2bs + DWORD value = 0; + Stat aStatList[256] = { NULL }; + StatList* pStatList = D2COMMON_GetStatList(uInfo->item, NULL, 0x40); + if (pStatList) { + DWORD dwStats = D2COMMON_CopyStatList(pStatList, (Stat*)aStatList, 256); + for (UINT i = 0; i < dwStats; i++) { + if (aStatList[i].wStatIndex == STAT_ENHANCEDMAXDURABILITY && aStatList[i].wSubIndex == 0) { + value += aStatList[i].dwStatValue; + } + } + } + return IntegerCompare(value, operation, targetDurability); +} +bool DurabilityCondition::EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2) { + DWORD value = 0; + for (vector::iterator prop = info->properties.begin(); prop < info->properties.end(); prop++) { + if (prop->stat == STAT_ENHANCEDMAXDURABILITY) { + value += prop->value; + } + } + return IntegerCompare(value, operation, targetDurability); +} + bool FoolsCondition::EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2) { // 1 = MAX DMG / level // 2 = AR / level diff --git a/BH/Modules/Item/ItemDisplay.h b/BH/Modules/Item/ItemDisplay.h index e0ded247..dc356f91 100644 --- a/BH/Modules/Item/ItemDisplay.h +++ b/BH/Modules/Item/ItemDisplay.h @@ -353,6 +353,17 @@ class EDCondition : public Condition bool EvaluateED(unsigned int flags); }; +class DurabilityCondition : public Condition +{ +public: + DurabilityCondition(BYTE op, unsigned int target) : operation(op), targetDurability(target) { conditionType = CT_Operand; }; +private: + BYTE operation; + unsigned int targetDurability; + bool EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2); + bool EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2); +}; + class FoolsCondition : public Condition { public: diff --git a/Release/BH.dll b/Release/BH.dll index e15a2595..7635691e 100644 Binary files a/Release/BH.dll and b/Release/BH.dll differ