Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ItemDisplay: Fixed MAXDUR. Added MINDMG. #15

Merged
merged 1 commit into from
Jan 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions BH/Modules/Item/ItemDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -615,7 +617,7 @@ void Condition::BuildConditions(vector<Condition*> &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) {
Expand Down Expand Up @@ -660,12 +662,16 @@ void Condition::BuildConditions(vector<Condition*> &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) {
Expand Down Expand Up @@ -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<ItemProperty>::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
Expand Down
11 changes: 11 additions & 0 deletions BH/Modules/Item/ItemDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Binary file modified Release/BH.dll
Binary file not shown.