parent
91779abbb7
commit
08002c3777
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -110,7 +110,7 @@ void ABaseDualWeapon::OnHit_OffhandWeapon(FHitResult HitResult)
|
||||||
if(pActor)
|
if(pActor)
|
||||||
{
|
{
|
||||||
if(pActor->Execute_CanReceiveDamage(HitResult.GetActor()))
|
if(pActor->Execute_CanReceiveDamage(HitResult.GetActor()))
|
||||||
UGameplayStatics::ApplyPointDamage(HitResult.GetActor(), GetDamage(), GetOwner()->GetActorForwardVector(), HitResult, GetInstigatorController(), this, TSubclassOf<UDamageType>(UDamageType::StaticClass()));
|
UGameplayStatics::ApplyPointDamage(HitResult.GetActor(), GetDamage(), GetOwner()->GetActorForwardVector(), HitResult, GetInstigatorController(), this, DamageTypeClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ void ABaseDualWeapon::OnHit_RightFoot(FHitResult HitResult)
|
||||||
if(pActor)
|
if(pActor)
|
||||||
{
|
{
|
||||||
if(pActor->Execute_CanReceiveDamage(HitResult.GetActor()))
|
if(pActor->Execute_CanReceiveDamage(HitResult.GetActor()))
|
||||||
UGameplayStatics::ApplyPointDamage(HitResult.GetActor(), GetDamage(), GetOwner()->GetActorForwardVector(), HitResult, GetInstigatorController(), this, TSubclassOf<UDamageType>(UDamageType::StaticClass()));
|
UGameplayStatics::ApplyPointDamage(HitResult.GetActor(), GetDamage(), GetOwner()->GetActorForwardVector(), HitResult, GetInstigatorController(), this, DamageTypeClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include "Components/CombatComponent.h"
|
#include "Components/CombatComponent.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
#include "Components/CollisionComponent.h"
|
#include "Components/CollisionComponent.h"
|
||||||
|
#include "DamageType/AttackDamageType.h"
|
||||||
#include "Interface/CombatInterface.h"
|
#include "Interface/CombatInterface.h"
|
||||||
#include "Definitions/CombatGameplayTags.h"
|
#include "Definitions/CombatGameplayTags.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
@ -22,6 +23,8 @@ ABaseWeapon::ABaseWeapon()
|
||||||
CollisionComponent->SetCollisionObjectTypes(InputCollisionObjectTypes);
|
CollisionComponent->SetCollisionObjectTypes(InputCollisionObjectTypes);
|
||||||
CollisionComponent->SetDrawDebugType(EDrawDebugTrace::None);
|
CollisionComponent->SetDrawDebugType(EDrawDebugTrace::None);
|
||||||
|
|
||||||
|
DamageTypeClass = UAttackDamageType::StaticClass();
|
||||||
|
|
||||||
//Stats
|
//Stats
|
||||||
Damage = 20.f;
|
Damage = 20.f;
|
||||||
if(!FCombatGameplayTags::Get().Character_Action_Attack_LightAttack.IsValid())
|
if(!FCombatGameplayTags::Get().Character_Action_Attack_LightAttack.IsValid())
|
||||||
|
|
@ -74,7 +77,7 @@ void ABaseWeapon::OnHit(FHitResult hitResult)
|
||||||
if (pActor)
|
if (pActor)
|
||||||
{
|
{
|
||||||
if (pActor->Execute_CanReceiveDamage(hitResult.GetActor()))
|
if (pActor->Execute_CanReceiveDamage(hitResult.GetActor()))
|
||||||
UGameplayStatics::ApplyPointDamage(hitResult.GetActor(), GetDamage(), GetOwner()->GetActorForwardVector(), hitResult, GetInstigatorController(), this, TSubclassOf<UDamageType>(UDamageType::StaticClass()));
|
UGameplayStatics::ApplyPointDamage(hitResult.GetActor(), GetDamage(), GetOwner()->GetActorForwardVector(), hitResult, GetInstigatorController(), this, DamageTypeClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ protected:
|
||||||
FName HandSocketName;
|
FName HandSocketName;
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
|
||||||
ECombatType CombatType;
|
ECombatType CombatType;
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Initialization")
|
||||||
|
TSubclassOf<UDamageType> DamageTypeClass;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components")
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components")
|
||||||
TObjectPtr<class UCombatComponent> CombatComponent;
|
TObjectPtr<class UCombatComponent> CombatComponent;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#include "Engine/DamageEvents.h"
|
#include "Engine/DamageEvents.h"
|
||||||
#include "NiagaraFunctionLibrary.h"
|
#include "NiagaraFunctionLibrary.h"
|
||||||
#include "NiagaraComponent.h"
|
#include "NiagaraComponent.h"
|
||||||
|
#include "DamageType/AttackDamageType.h"
|
||||||
#include "Kismet/KismetSystemLibrary.h"
|
#include "Kismet/KismetSystemLibrary.h"
|
||||||
#include "Kismet/KismetMathLibrary.h"
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
|
@ -90,7 +91,6 @@ ACombatCharacter::ACombatCharacter()
|
||||||
SprintSpeed = 700.f;
|
SprintSpeed = 700.f;
|
||||||
|
|
||||||
ChargeAttackTime = 0.18f;
|
ChargeAttackTime = 0.18f;
|
||||||
Health = 100.f;
|
|
||||||
PelvisBoneName = TEXT("pelvis");
|
PelvisBoneName = TEXT("pelvis");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,26 +123,26 @@ float ACombatCharacter::TakeDamage(float Damage, FDamageEvent const& DamageEvent
|
||||||
{
|
{
|
||||||
float fDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);
|
float fDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);
|
||||||
|
|
||||||
|
UAttackDamageType* damageTypeClass = Cast<UAttackDamageType>(DamageEvent.DamageTypeClass->GetDefaultObject());
|
||||||
|
if(!IsValid(damageTypeClass))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (DamageEvent.IsOfType(FPointDamageEvent::ClassID))
|
if (DamageEvent.IsOfType(FPointDamageEvent::ClassID))
|
||||||
{
|
{
|
||||||
const FPointDamageEvent* PointDamageEvent = static_cast<const FPointDamageEvent*>(&DamageEvent);
|
const FPointDamageEvent* PointDamageEvent = static_cast<const FPointDamageEvent*>(&DamageEvent);
|
||||||
|
|
||||||
|
//스텟 관련 처리
|
||||||
StatsComponent->TakeDamageOnStat(Damage);
|
StatsComponent->TakeDamageOnStat(Damage);
|
||||||
|
|
||||||
//Play Sound
|
//앞에서 맞았는지 뒤에서 맞았는지 판별
|
||||||
UGameplayStatics::PlaySoundAtLocation(this, HitSound, PointDamageEvent->HitInfo.Location);
|
bHitFront = UKismetMathLibrary::InRange_FloatFloat(this->GetDotProductTo(EventInstigator->GetPawn()), -0.1f, 1.f);
|
||||||
|
LastHitInfo = PointDamageEvent->HitInfo;
|
||||||
//Hit Effect
|
|
||||||
//UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), HitEmitter, PointDamageEvent->HitInfo.Location);
|
//play sound, effect
|
||||||
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), HitEmitter, PointDamageEvent->HitInfo.Location);
|
ApplyImpactEffect(damageTypeClass->DamageType);
|
||||||
|
|
||||||
if (CanReceiveHitReaction())
|
if (CanReceiveHitReaction())
|
||||||
{
|
ApplyHitReaction(damageTypeClass->DamageType);
|
||||||
StateManagerComponent->SetCurrentState(FCombatGameplayTags::Get().Character_State_Disable);
|
|
||||||
|
|
||||||
//Play Animation
|
|
||||||
PlayAnimMontage(HitMontage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fDamage;
|
return fDamage;
|
||||||
}
|
}
|
||||||
|
|
@ -615,6 +615,33 @@ void ACombatCharacter::SprintStaminaCost()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACombatCharacter::ApplyHitReaction(EDamageType InDamageType)
|
||||||
|
{
|
||||||
|
switch (InDamageType)
|
||||||
|
{
|
||||||
|
case EDamageType::None:
|
||||||
|
PerformHitStun();
|
||||||
|
break;
|
||||||
|
case EDamageType::MeleeDamage:
|
||||||
|
PerformHitStun();
|
||||||
|
break;
|
||||||
|
case EDamageType::KnockdownDamage:
|
||||||
|
PerformKnockdown();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACombatCharacter::ApplyImpactEffect(EDamageType InDamageType)
|
||||||
|
{
|
||||||
|
//Play Sound
|
||||||
|
UGameplayStatics::PlaySoundAtLocation(this, HitSound, LastHitInfo.Location);
|
||||||
|
|
||||||
|
//Hit Effect
|
||||||
|
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), HitEmitter, LastHitInfo.Location);
|
||||||
|
}
|
||||||
|
|
||||||
void ACombatCharacter::PerformAttack(FGameplayTag attackType, int32 attackIndex)
|
void ACombatCharacter::PerformAttack(FGameplayTag attackType, int32 attackIndex)
|
||||||
{
|
{
|
||||||
ABaseWeapon* CurrentWeapon = CombatComponent->GetMainWeapon();
|
ABaseWeapon* CurrentWeapon = CombatComponent->GetMainWeapon();
|
||||||
|
|
@ -725,6 +752,38 @@ void ACombatCharacter::PerformDeath()
|
||||||
}), 4.f, false); // 4초 후에 object 삭제
|
}), 4.f, false); // 4초 후에 object 삭제
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ACombatCharacter::PerformHitStun()
|
||||||
|
{
|
||||||
|
UAnimMontage* hitMontage = nullptr;
|
||||||
|
if(bHitFront)
|
||||||
|
hitMontage = HitStunFrontMontage;
|
||||||
|
else
|
||||||
|
hitMontage = HitStunBackMontage;
|
||||||
|
|
||||||
|
if(!IsValid(hitMontage))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
StateManagerComponent->SetCurrentState(FCombatGameplayTags::Get().Character_State_Disable);
|
||||||
|
PlayAnimMontage(hitMontage);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ACombatCharacter::PerformKnockdown()
|
||||||
|
{
|
||||||
|
UAnimMontage* hitMontage = nullptr;
|
||||||
|
if(bHitFront)
|
||||||
|
hitMontage = KnockdownFrontMontage;
|
||||||
|
else
|
||||||
|
hitMontage = KnockdownBackMontage;
|
||||||
|
|
||||||
|
if(!IsValid(hitMontage))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
StateManagerComponent->SetCurrentState(FCombatGameplayTags::Get().Character_State_Disable);
|
||||||
|
PlayAnimMontage(hitMontage);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ACombatCharacter::CanPerformToggleCombat()
|
bool ACombatCharacter::CanPerformToggleCombat()
|
||||||
{
|
{
|
||||||
bool ReturnValue = true;
|
bool ReturnValue = true;
|
||||||
|
|
|
||||||
|
|
@ -145,14 +145,18 @@ private:
|
||||||
bool ResetChargeAttack();
|
bool ResetChargeAttack();
|
||||||
void DisableSprint();
|
void DisableSprint();
|
||||||
void SprintStaminaCost();
|
void SprintStaminaCost();
|
||||||
|
void ApplyHitReaction(EDamageType InDamageType);
|
||||||
|
void ApplyImpactEffect(EDamageType InDamageType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PerformAttack(FGameplayTag attackType, int32 attackIndex);
|
void PerformAttack(FGameplayTag attackType, int32 attackIndex);
|
||||||
void PerformDodge();
|
void PerformDodge();
|
||||||
bool PerformAction(FGameplayTag characterState, FGameplayTag characterAction, int32 montageIndex);
|
bool PerformAction(FGameplayTag characterState, FGameplayTag characterAction, int32 montageIndex);
|
||||||
void PerformDeath();
|
void PerformDeath();
|
||||||
|
bool PerformHitStun();
|
||||||
|
bool PerformKnockdown();
|
||||||
|
|
||||||
protected:
|
protected: //Check Func
|
||||||
bool CanPerformToggleCombat();
|
bool CanPerformToggleCombat();
|
||||||
bool CanPerformAttack();
|
bool CanPerformAttack();
|
||||||
bool CanPerformDodge();
|
bool CanPerformDodge();
|
||||||
|
|
@ -164,13 +168,10 @@ protected:
|
||||||
public:
|
public:
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
||||||
TObjectPtr<class UCombatComponent> CombatComponent;
|
TObjectPtr<class UCombatComponent> CombatComponent;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
||||||
TObjectPtr<UStateManagerComponent> StateManagerComponent;
|
TObjectPtr<UStateManagerComponent> StateManagerComponent;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
||||||
TObjectPtr<UStatsComponent> StatsComponent;
|
TObjectPtr<UStatsComponent> StatsComponent;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true"))
|
||||||
TObjectPtr<UTargetingComponent> TargetingComponent;
|
TObjectPtr<UTargetingComponent> TargetingComponent;
|
||||||
|
|
||||||
|
|
@ -179,30 +180,28 @@ public:
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
||||||
FName PelvisBoneName;
|
FName PelvisBoneName;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
|
||||||
TObjectPtr<UAnimMontage> HitMontage;
|
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
||||||
TObjectPtr<class USoundBase> HitSound;
|
TObjectPtr<class USoundBase> HitSound;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Hit", meta = (AllowPrivateAccess = "true"))
|
||||||
TObjectPtr<class UNiagaraSystem> HitEmitter;
|
TObjectPtr<class UNiagaraSystem> HitEmitter;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
||||||
EMovementSpeedMode MovementSpeedMode;
|
EMovementSpeedMode MovementSpeedMode;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
||||||
float WalkingSpeed;
|
float WalkingSpeed;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
||||||
float JoggingSpeed;
|
float JoggingSpeed;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MovementSpeed", meta = (AllowPrivateAccess = "true"))
|
||||||
float SprintSpeed;
|
float SprintSpeed;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
||||||
float Health;
|
TObjectPtr<UAnimMontage> HitStunFrontMontage;
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
||||||
|
TObjectPtr<UAnimMontage> HitStunBackMontage;
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
||||||
|
TObjectPtr<UAnimMontage> KnockdownFrontMontage;
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true"))
|
||||||
|
TObjectPtr<UAnimMontage> KnockdownBackMontage;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FTimerHandle StaminaTimerHandle;
|
FTimerHandle StaminaTimerHandle;
|
||||||
|
|
@ -212,5 +211,6 @@ private:
|
||||||
float AttackHeldTime;
|
float AttackHeldTime;
|
||||||
bool bAttackCharged;
|
bool bAttackCharged;
|
||||||
bool bCanMove = true;
|
bool bCanMove = true;
|
||||||
|
bool bHitFront;
|
||||||
|
FHitResult LastHitInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "AttackDamageType.h"
|
||||||
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Definitions/GameEnums.h"
|
||||||
|
#include "GameFramework/DamageType.h"
|
||||||
|
#include "AttackDamageType.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 다른 DamageType 을 처리하고 싶으면 해당 Class 를 상속해서 EDamageType를 다르게 처리할 것
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class D1_API UAttackDamageType : public UDamageType
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
EDamageType DamageType = EDamageType::MeleeDamage;
|
||||||
|
};
|
||||||
|
|
@ -29,3 +29,10 @@ enum class ECollisionPart : uint8
|
||||||
RightFoot UMETA(DisplayName = "RightFoot"),
|
RightFoot UMETA(DisplayName = "RightFoot"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UENUM(BlueprintType)
|
||||||
|
enum class EDamageType : uint8
|
||||||
|
{
|
||||||
|
None UMETA(DisplayName = "None"),
|
||||||
|
MeleeDamage UMETA(DisplayName = "MeleeDamage"),
|
||||||
|
KnockdownDamage UMETA(DisplayName = "KnockdownDamage"),
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue