From 44a3930eaa14e7594fc2e59e4e9bcd3432a857fc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 9 Jan 2024 16:24:16 +0800 Subject: [PATCH] 1 --- server/gameserver/ability.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/server/gameserver/ability.cc b/server/gameserver/ability.cc index b77e3b62..d65adca4 100644 --- a/server/gameserver/ability.cc +++ b/server/gameserver/ability.cc @@ -248,11 +248,16 @@ void Ability::RecalcAttrAddition(int attr_id) list_head* pos = nullptr; list_head* next = nullptr; float new_val = 0.0f; + bool inited = false; list_for_each_safe(pos, next, head) { AttrAddition* e = list_entry(pos, AttrAddition, entry); if (IsMulCalc(attr_id)) { + if (!inited) { + new_val = 1; + inited = true; + } new_val *= 1 + e->value; } else { new_val += e->value; @@ -283,11 +288,16 @@ void Ability::RecalcAttrRuduce(int attr_id) list_head* pos = nullptr; list_head* next = nullptr; float new_val = 0.0f; + bool inited = false; list_for_each_safe(pos, next, head) { AttrAddition* e = list_entry(pos, AttrAddition, entry); if (IsMulCalc(attr_id)) { + if (!inited) { + new_val = 1; + inited = true; + } new_val *= 1 + e->value; } else { new_val += e->value; @@ -470,13 +480,13 @@ float Ability::GetAttr(int attr_id) } if (IsMulCalc(attr_id)) { if (IsValidHumanAttr(attr_id)) { - val = std::get<0>(attr_add_[attr_id]) * - std::get<0>(attr_dec_[attr_id]); + val = (HasAddAttr(attr_id) ? std::get<0>(attr_add_[attr_id]) : 1) * + (HasDecAttr(attr_id) ? std::get<0>(attr_dec_[attr_id]) : 1); } else if (IsValidHumanVirtualAttr(attr_id)) { - val = std::get<0>(vattr_add_[attr_id - kHVAT_Begin]) * - std::get<0>(vattr_dec_[attr_id - kHVAT_Begin]); + val = (HasAddAttr(attr_id) ? std::get<0>(vattr_add_[attr_id - kHVAT_Begin]) : 1) * + (HasDecAttr(attr_id) ? std::get<0>(vattr_dec_[attr_id - kHVAT_Begin]) : 1); } - val = 1.0f - val; + val = val - 1.0f; } else { if (IsValidHumanAttr(attr_id)) { val = std::get<0>(attr_add_[attr_id]) +