From ae400c39e58c9a0771ad54c73a64c4ebb4eab9ae Mon Sep 17 00:00:00 2001 From: TjgL Date: Thu, 17 Apr 2025 00:10:06 +0200 Subject: [PATCH] Implemented weapon hit sounds (normal + critical) --- Content/Legumix/Player/BP_Play.uasset | 4 ++-- Source/LegumeMix/Private/Player/LMPlayer.cpp | 5 ++++- Source/LegumeMix/Public/Player/LMHitBox.h | 2 ++ Source/LegumeMix/Public/Player/LMPlayer.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index e2c603a..ac052a8 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5c422bf6ba1bc88535fa1d525ee7803921caa85b1a3dc33e41719507e8d30f8 -size 940995 +oid sha256:e16bdedf5af4e17588ed3cee89c2d0ebc84501fcd9493ea9562a60965d253f47 +size 941231 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index f467716..f08b9eb 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -158,6 +158,7 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings) FVector ShotVector; FHitResult OutHit = FHitResult(); bool HitSomething = false; + float HighestDamageModifier = 0.f; OnFire(); @@ -192,6 +193,8 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings) HitSomething = true; HitBox->OnHit(Settings, OutHit); + if (HitBox->GetDamageModifier() > HighestDamageModifier) + HighestDamageModifier = HitBox->GetDamageModifier(); } else { @@ -201,7 +204,7 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings) if (HitSomething) { - OnEnnemyHit(); + OnEnnemyHit(HighestDamageModifier); } } diff --git a/Source/LegumeMix/Public/Player/LMHitBox.h b/Source/LegumeMix/Public/Player/LMHitBox.h index 75186c6..37c73e4 100644 --- a/Source/LegumeMix/Public/Player/LMHitBox.h +++ b/Source/LegumeMix/Public/Player/LMHitBox.h @@ -35,6 +35,8 @@ public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Legumix) float CalculateDamage(float Damage, float Distance, UCurveFloat* Falloff, float MaxDistance); + float GetDamageModifier() const { return DamageModifier; } + public: /** Delegate called when the hitbox is hit. * @param HitBox: The Hitbox that was hit. diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 38eb4db..42ab6b7 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -97,7 +97,7 @@ public: void OnAmmoPickup(); UFUNCTION(BlueprintImplementableEvent) - void OnEnnemyHit(); + void OnEnnemyHit(float DamageModifier); UFUNCTION(BlueprintImplementableEvent, Category=Legumix) void OnFire();