Fixed player self damaging
Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
parent
7be2b97c3b
commit
b76e0e0b55
@ -132,6 +132,7 @@ ManualIPAddress=
|
||||
+Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.")
|
||||
+Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Bullet")
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Enemy")
|
||||
+EditProfiles=(Name="NoCollision",CustomResponses=((Channel="Bullet",Response=ECR_Ignore)))
|
||||
+EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Bullet",Response=ECR_Overlap)))
|
||||
+EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Bullet",Response=ECR_Ignore)))
|
||||
|
BIN
Content/Legumix/Player/BP_Play.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_Play.uasset
(Stored with Git LFS)
Binary file not shown.
@ -27,6 +27,7 @@ void ULMHealthComponent::RegisterHitBoxes()
|
||||
for (const auto HitBox : HitBoxes)
|
||||
{
|
||||
HitBox->OnHitBoxHit.AddUniqueDynamic(this, &ULMHealthComponent::HitBoxHit);
|
||||
HitBox->SetHealthComponent(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "Player/LMHitBox.h"
|
||||
|
||||
#include "Player/LMBulletInfo.h"
|
||||
#include "Player/LMHealthComponent.h"
|
||||
|
||||
|
||||
ULMHitBox::ULMHitBox()
|
||||
@ -20,6 +21,14 @@ void ULMHitBox::OnHit(const FLMBulletInfo& BulletInfo)
|
||||
OnHitBoxHit.Broadcast(this, TotalDamage);
|
||||
}
|
||||
|
||||
bool ULMHitBox::CanBeHitByTeam(const ETeam Team) const
|
||||
{
|
||||
if (!HealthComponent)
|
||||
return false;
|
||||
|
||||
return HealthComponent->CanBeHurtByTeam(Team);
|
||||
}
|
||||
|
||||
float ULMHitBox::CalculateDamage_Implementation(const float Damage, const float Distance, UCurveFloat* Falloff, const float MaxDistance)
|
||||
{
|
||||
const float Absorption = Damage - FlatDamageAbsorption;
|
||||
|
@ -13,18 +13,11 @@
|
||||
#include "Player/LMHitBox.h"
|
||||
#include "Weapon/LMWeaponManager.h"
|
||||
|
||||
|
||||
ALMPlayer::ALMPlayer()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
// Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
|
||||
// Camera->SetupAttachment(RootComponent);
|
||||
// Camera->bUsePawnControlRotation = true;
|
||||
// Camera->SetRelativeLocation(FVector(20, 0, 90));
|
||||
//
|
||||
// ArmsMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Arms Mesh"));
|
||||
// ArmsMesh->SetupAttachment(Camera);
|
||||
|
||||
SpreadStream = FRandomStream(FMath::Rand());
|
||||
HealthComponent = CreateDefaultSubobject<ULMHealthComponent>(TEXT("HealthComponent"));
|
||||
|
||||
@ -37,7 +30,6 @@ ALMPlayer::ALMPlayer()
|
||||
NextPlayerViewOcclusionPercent = 0.f;
|
||||
PlayerViewOcclusionPercent = 0.f;
|
||||
AlphaLerpForPlayerViewOcclusionPercent = 0.f;
|
||||
|
||||
}
|
||||
|
||||
void ALMPlayer::BeginPlay()
|
||||
@ -159,6 +151,9 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings)
|
||||
|
||||
if (ULMHitBox* HitBox = Cast<ULMHitBox>(OutHit.Component))
|
||||
{
|
||||
if (!HitBox->CanBeHitByTeam(Team))
|
||||
continue;
|
||||
|
||||
HitSomething = true;
|
||||
HitBox->OnHit(Settings);
|
||||
}
|
||||
@ -215,7 +210,6 @@ void ALMPlayer::SetDisplayDamageParameters(float Health, float Damage)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ALMPlayer::SetPlayerViewOcclusionPercent()
|
||||
{
|
||||
AlphaLerpForPlayerViewOcclusionPercent = 0;
|
||||
|
11
Source/LegumeMix/Public/LMTeam.h
Normal file
11
Source/LegumeMix/Public/LMTeam.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class ETeam : uint8
|
||||
{
|
||||
ET_None UMETA(Hidden),
|
||||
ET_Player UMETA(DisplayName = "Player"),
|
||||
ET_Enemy UMETA(DisplayName = "Enemy"),
|
||||
ET_Other UMETA(DisplayName = "Other"),
|
||||
ET_Max UMETA(Hidden),
|
||||
};
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMTeam.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "LMHealthComponent.generated.h"
|
||||
|
||||
@ -75,6 +76,9 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category=Legumix, meta=(Keywords = "Refill, Health"))
|
||||
void FillHealth() { Health = MaxHealth; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category=Legumix, meta=(Keywords = "Team"))
|
||||
bool CanBeHurtByTeam(const ETeam AttackingTeam) const { return Team != AttackingTeam; }
|
||||
|
||||
public:
|
||||
/** Delegate called when this component receives damages. */
|
||||
UPROPERTY(BlueprintAssignable, Category=Legumix)
|
||||
@ -97,6 +101,9 @@ private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0, UIMin=0, UIMax=1000))
|
||||
float MaxHealth = 100.f;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
||||
ETeam Team = ETeam::ET_Enemy;
|
||||
|
||||
/**
|
||||
* A list of all associated LMHitboxes.
|
||||
*/
|
||||
|
@ -4,10 +4,13 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMBulletInfo.h"
|
||||
#include "LMTeam.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "LMHitBox.generated.h"
|
||||
|
||||
|
||||
class ULMHealthComponent;
|
||||
|
||||
UCLASS(Blueprintable, ClassGroup=(Legumix), meta=(BlueprintSpawnableComponent))
|
||||
class LEGUMEMIX_API ULMHitBox : public UCapsuleComponent
|
||||
{
|
||||
@ -18,6 +21,8 @@ class LEGUMEMIX_API ULMHitBox : public UCapsuleComponent
|
||||
public:
|
||||
ULMHitBox();
|
||||
void OnHit(const FLMBulletInfo& BulletInfo);
|
||||
void SetHealthComponent(ULMHealthComponent* NewHealthComponent) { HealthComponent = NewHealthComponent; }
|
||||
bool CanBeHitByTeam(ETeam Team) const;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Legumix)
|
||||
@ -43,4 +48,7 @@ private:
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0.0f, UIMin=0.0f))
|
||||
float FlatDamageAbsorption = 0.f;
|
||||
|
||||
UPROPERTY(Transient)
|
||||
TObjectPtr<ULMHealthComponent> HealthComponent;
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "LMBulletInfo.h"
|
||||
#include "LMTeam.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "LMPlayer.generated.h"
|
||||
@ -173,6 +174,9 @@ private:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = true))
|
||||
float AlphaLerpForPlayerViewOcclusionPercent;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true))
|
||||
ETeam Team = ETeam::ET_Player;
|
||||
|
||||
/**
|
||||
* Actualize all parameters needed to calculate PlayerViewOcclusionPercent
|
||||
*/
|
||||
|
Reference in New Issue
Block a user