This commit is contained in:
aozhiwei 2024-01-09 16:24:16 +08:00
parent 474ca03650
commit 44a3930eaa

View File

@ -248,11 +248,16 @@ void Ability::RecalcAttrAddition(int attr_id)
list_head* pos = nullptr; list_head* pos = nullptr;
list_head* next = nullptr; list_head* next = nullptr;
float new_val = 0.0f; float new_val = 0.0f;
bool inited = false;
list_for_each_safe(pos, next, head) { list_for_each_safe(pos, next, head) {
AttrAddition* e = list_entry(pos, AttrAddition* e = list_entry(pos,
AttrAddition, AttrAddition,
entry); entry);
if (IsMulCalc(attr_id)) { if (IsMulCalc(attr_id)) {
if (!inited) {
new_val = 1;
inited = true;
}
new_val *= 1 + e->value; new_val *= 1 + e->value;
} else { } else {
new_val += e->value; new_val += e->value;
@ -283,11 +288,16 @@ void Ability::RecalcAttrRuduce(int attr_id)
list_head* pos = nullptr; list_head* pos = nullptr;
list_head* next = nullptr; list_head* next = nullptr;
float new_val = 0.0f; float new_val = 0.0f;
bool inited = false;
list_for_each_safe(pos, next, head) { list_for_each_safe(pos, next, head) {
AttrAddition* e = list_entry(pos, AttrAddition* e = list_entry(pos,
AttrAddition, AttrAddition,
entry); entry);
if (IsMulCalc(attr_id)) { if (IsMulCalc(attr_id)) {
if (!inited) {
new_val = 1;
inited = true;
}
new_val *= 1 + e->value; new_val *= 1 + e->value;
} else { } else {
new_val += e->value; new_val += e->value;
@ -470,13 +480,13 @@ float Ability::GetAttr(int attr_id)
} }
if (IsMulCalc(attr_id)) { if (IsMulCalc(attr_id)) {
if (IsValidHumanAttr(attr_id)) { if (IsValidHumanAttr(attr_id)) {
val = std::get<0>(attr_add_[attr_id]) * val = (HasAddAttr(attr_id) ? std::get<0>(attr_add_[attr_id]) : 1) *
std::get<0>(attr_dec_[attr_id]); (HasDecAttr(attr_id) ? std::get<0>(attr_dec_[attr_id]) : 1);
} else if (IsValidHumanVirtualAttr(attr_id)) { } else if (IsValidHumanVirtualAttr(attr_id)) {
val = std::get<0>(vattr_add_[attr_id - kHVAT_Begin]) * val = (HasAddAttr(attr_id) ? std::get<0>(vattr_add_[attr_id - kHVAT_Begin]) : 1) *
std::get<0>(vattr_dec_[attr_id - kHVAT_Begin]); (HasDecAttr(attr_id) ? std::get<0>(vattr_dec_[attr_id - kHVAT_Begin]) : 1);
} }
val = 1.0f - val; val = val - 1.0f;
} else { } else {
if (IsValidHumanAttr(attr_id)) { if (IsValidHumanAttr(attr_id)) {
val = std::get<0>(attr_add_[attr_id]) + val = std::get<0>(attr_add_[attr_id]) +