This commit is contained in:
aozhiwei 2024-01-09 15:28:42 +08:00
parent bbbffd3c3b
commit a8b9b8284e

View File

@ -33,6 +33,40 @@ struct AttrAddition : public std::enable_shared_from_this<AttrAddition>
}; };
static bool IsMulCalc(int attr_id)
{
switch (attr_id) {
case kNHAT_pHealthRateIn:
case kNHAT_vHealthRateIn:
case kNHAT_pAttackRateIn:
case kNHAT_vAttackRateIn:
case kNHAT_pDefendRateIn:
case kNHAT_pBlockRateIn:
case kNHAT_pCritRateIn:
case kNHAT_vSpeedRateIn:
case kNHAT_vHaste:
case kNHAT_vDrain:
case kNHAT_vTenacity:
case kNHAT_vDamageTakenRateIn:
case kNHAT_vDamageDealtRateIn:
case kNHAT_vNormalDamageTakenRateIn:
case kNHAT_vNormalDamageDealtRateIn:
case kNHAT_vSkillDamageTakenRateIn:
case kNHAT_vSkillDamageDealtRateIn:
case kNHAT_vHealthGainRateIn:
case kNHAT_vHealDealtRateIn:
{
return true;
}
break;
default:
{
return false;
}
break;
}
}
Ability::Ability(CreatureWeakPtr owner) Ability::Ability(CreatureWeakPtr owner)
{ {
for (auto& tuple : attr_add_) { for (auto& tuple : attr_add_) {
@ -218,7 +252,11 @@ void Ability::RecalcAttrAddition(int attr_id)
AttrAddition* e = list_entry(pos, AttrAddition* e = list_entry(pos,
AttrAddition, AttrAddition,
entry); entry);
new_val += e->value; if (IsMulCalc(attr_id)) {
new_val *= 1 + e->value;
} else {
new_val += e->value;
}
} }
if (IsValidHumanAttr(attr_id)) { if (IsValidHumanAttr(attr_id)) {
std::get<0>(attr_add_[attr_id]) = new_val; std::get<0>(attr_add_[attr_id]) = new_val;
@ -244,35 +282,15 @@ void Ability::RecalcAttrRuduce(int attr_id)
} }
list_head* pos = nullptr; list_head* pos = nullptr;
list_head* next = nullptr; list_head* next = nullptr;
bool inited = false;
float new_val = 0.0f; float new_val = 0.0f;
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);
switch (attr_id) { if (IsMulCalc(attr_id)) {
/* new_val *= 1 + e->value;
case kHAT_Speed: } else {
{ new_val += e->value;
new_val = std::max(new_val, e->value);
}
break;
*/
case kHVAT_Dmg:
{
if (inited) {
new_val *= 1.0f - e->value;
} else {
new_val = 1.0f - e->value;
inited = true;
}
}
break;
default:
{
new_val += e->value;
}
break;
} }
} }
if (IsValidHumanAttr(attr_id)) { if (IsValidHumanAttr(attr_id)) {