mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-17 09:15: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:
@@ -706,3 +706,15 @@ TEST_F(DestroyableTest, DeadSmashableIsNotStunned) {
|
||||
const auto sent = PacketTestUtils::Capture([&] { destroyableComponent->Smash(LWOOBJID_EMPTY); });
|
||||
EXPECT_TRUE(GameMessageTestUtils::SentGameMessages<GameMessages::SetStunned>(sent).empty());
|
||||
}
|
||||
|
||||
// The client's AddDamageReduction / RemoveDamageReduction: two buffs add up, ending one leaves the other's
|
||||
TEST_F(DestroyableTest, DamageReductionsAddUp) {
|
||||
destroyableComponent->SetDamageReduction(0);
|
||||
destroyableComponent->AddDamageReduction(2);
|
||||
destroyableComponent->AddDamageReduction(3);
|
||||
EXPECT_EQ(destroyableComponent->GetDamageReduction(), 5);
|
||||
destroyableComponent->RemoveDamageReduction(2);
|
||||
EXPECT_EQ(destroyableComponent->GetDamageReduction(), 3);
|
||||
destroyableComponent->RemoveDamageReduction(10);
|
||||
EXPECT_EQ(destroyableComponent->GetDamageReduction(), 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user