mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 09:45:28 +00:00
fix(destroyable): damage reductions add up, as the client
The damage reduction behavior set the reduction to its amount and back to 0 when it ended, so a second reduction replaced the first and ending either removed both. The client's behavior sends AddDamageReduction (DamageReductionBehavior::Cast) and the destroyable adds it to the current reduction; removing takes off that amount, never below 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -444,6 +444,14 @@ void DestroyableComponent::SetDamageReduction(int32_t value) {
|
||||
m_DamageReduction = value;
|
||||
}
|
||||
|
||||
void DestroyableComponent::AddDamageReduction(const int32_t value) {
|
||||
SetDamageReduction(std::max(m_DamageReduction + value, 0));
|
||||
}
|
||||
|
||||
void DestroyableComponent::RemoveDamageReduction(const int32_t value) {
|
||||
SetDamageReduction(std::max(m_DamageReduction - value, 0));
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetIsImmune(bool value) {
|
||||
m_DirtyHealth = true;
|
||||
m_ImmuneToBasicAttackCount = value ? 1 : 0;
|
||||
|
||||
@@ -175,6 +175,11 @@ public:
|
||||
*/
|
||||
void SetDamageReduction(int32_t value);
|
||||
|
||||
// The client's AddDamageReduction / RemoveDamageReduction: reductions from several buffs add up, and removing one
|
||||
// takes off only its own amount (never below 0)
|
||||
void AddDamageReduction(int32_t value);
|
||||
void RemoveDamageReduction(int32_t value);
|
||||
|
||||
/**
|
||||
* Returns the current damage reduction value
|
||||
* @return the current damage reduction value
|
||||
|
||||
Reference in New Issue
Block a user