1
0
Fork 0

Haybale damage reduction implementation (#5277)

* Haybale damage reduction impl

* Update Pawn.cpp
This commit is contained in:
Rorkh 2021-08-04 11:58:54 +03:00 committed by GitHub
parent c6de5e9bc5
commit 383867b6b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -423,20 +423,27 @@ void cPawn::HandleFalling(void)
Damage = static_cast<int>(static_cast<float>(Damage) * 0.33);
}
TakeDamage(dtFalling, nullptr, Damage, static_cast<float>(Damage), 0);
// Fall particles:
if (const auto Below = POS_TOINT.addedY(-1); Below.y >= 0)
{
const auto BlockBelow = GetWorld()->GetBlock(Below);
if (BlockBelow == E_BLOCK_HAY_BALE)
{
Damage = std::clamp(static_cast<int>(static_cast<float>(Damage) * 0.2), 1, 20);
}
GetWorld()->BroadcastParticleEffect(
"blockdust",
GetPosition(),
{ 0, 0, 0 },
(Damage - 1.f) * ((0.3f - 0.1f) / (15.f - 1.f)) + 0.1f, // Map damage (1 - 15) to particle speed (0.1 - 0.3)
static_cast<int>((Damage - 1.f) * ((50.f - 20.f) / (15.f - 1.f)) + 20.f), // Map damage (1 - 15) to particle quantity (20 - 50)
{ { GetWorld()->GetBlock(Below), 0 } }
{ { BlockBelow, 0 } }
);
}
TakeDamage(dtFalling, nullptr, Damage, static_cast<float>(Damage), 0);
}
m_bTouchGround = true;