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

Skill charges support #33

Merged
merged 1 commit into from
Mar 18, 2020
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: 35 additions & 0 deletions BH/Modules/Item/ItemDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,13 @@ void Condition::BuildConditions(vector<Condition*> &conditions, string token) {
return;
}
Condition::AddOperand(conditions, new ItemStatCondition(STAT_NONCLASSSKILL, num, operation, value));
} else if (key.compare(0, 4, "CHSK") == 0) { // skills granted by charges
int num = -1;
stringstream ss(key.substr(4));
if ((ss >> num).fail() || num < 0 || num > (int)SKILL_MAX) {
return;
}
Condition::AddOperand(conditions, new ChargedCondition(operation, num, value));
} else if (key.compare(0, 4, "CLSK") == 0) {
int num = -1;
stringstream ss(key.substr(4));
Expand Down Expand Up @@ -1145,6 +1152,34 @@ bool DurabilityCondition::EvaluateInternalFromPacket(ItemInfo *info, Condition *
return IntegerCompare(value, operation, targetDurability);
}

bool ChargedCondition::EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2) {
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_CHARGED)
// PrintText(1, "ChargedCondition::EvaluateInternal: Index=%hx, SubIndex=%hx, Value=%x", aStatList[i].wStatIndex, aStatList[i].wSubIndex, aStatList[i].dwStatValue);
if (aStatList[i].wStatIndex == STAT_CHARGED && (aStatList[i].wSubIndex>>6) == skill) { // 10 MSBs of subindex is the skill ID
unsigned int level = aStatList[i].wSubIndex & 0x3F; // 6 LSBs are the skill level
value = (level > value) ? level : value; // use highest level
}
}
}
return IntegerCompare(value, operation, targetLevel);
}
bool ChargedCondition::EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2) {
DWORD num = 0;
for (vector<ItemProperty>::iterator prop = info->properties.begin(); prop < info->properties.end(); prop++) {
if (prop->stat == STAT_CHARGED && prop->skill == skill) {
num = (prop->level > num) ? prop->level : num; // use the highest level charges for the comparison
//PrintText(1, "Found charged skill. skill=%u level=%u", prop->skill, prop->level);
}
}
return IntegerCompare(num, operation, targetLevel);
}

bool FoolsCondition::EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2) {
// 1 = MAX DMG / level
// 2 = AR / level
Expand Down
12 changes: 12 additions & 0 deletions BH/Modules/Item/ItemDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ class DurabilityCondition : public Condition
bool EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2);
};

class ChargedCondition : public Condition
{
public:
ChargedCondition(BYTE op, unsigned int sk, unsigned int target) : operation(op), skill(sk), targetLevel(target) { conditionType = CT_Operand; };
private:
BYTE operation;
unsigned int skill;
unsigned int targetLevel;
bool EvaluateInternal(UnitItemInfo *uInfo, Condition *arg1, Condition *arg2);
bool EvaluateInternalFromPacket(ItemInfo *info, Condition *arg1, Condition *arg2);
};

class FoolsCondition : public Condition
{
public:
Expand Down