diff --git a/Content/Character/Allium/Alium_Q.uasset b/Content/Character/Allium/Alium_Q.uasset index 7645293..df6fc39 100644 --- a/Content/Character/Allium/Alium_Q.uasset +++ b/Content/Character/Allium/Alium_Q.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bee994a8695bb93d63eb7b6adfcdd753204e1ed004bd424fbe536e1bf64cae83 -size 176358 +oid sha256:b1db0f5e39e4d320a168f824b5d4200c506214dbce935ef99d4503535ac392b8 +size 175065 diff --git a/Content/Character/Allium/BP_Allium.uasset b/Content/Character/Allium/BP_Allium.uasset index 331691b..77208a8 100644 --- a/Content/Character/Allium/BP_Allium.uasset +++ b/Content/Character/Allium/BP_Allium.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:21694bc7704056ef6c94661e9fbd4eb2cf13fcf7473cb5998ec51f00e45d6466 -size 429216 +oid sha256:4abe4c8244b4d339d5cf5a7780f3624cc0a93b7dea664bf28b9dd54149091ad1 +size 434066 diff --git a/Content/Character/Lb/BP_Lb.uasset b/Content/Character/Lb/BP_Lb.uasset index bddfc6d..ea54857 100644 --- a/Content/Character/Lb/BP_Lb.uasset +++ b/Content/Character/Lb/BP_Lb.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d574e07d53657f28a5f9db3ec5db3fcd1acb2d11517897c491ff81b060883df3 -size 406936 +oid sha256:5f2710dba726be43ec6aa657b78e64c04994f74957e89cb0dfa2b06bec4bf1ea +size 411719 diff --git a/Content/Character/Lb/BaseArrow.uasset b/Content/Character/Lb/BaseArrow.uasset index e429625..63c659c 100644 --- a/Content/Character/Lb/BaseArrow.uasset +++ b/Content/Character/Lb/BaseArrow.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c3acb4ae3753750e1faaf13646b4fcc7614d6f4351c307f8ccb85479dc16ba48 -size 239209 +oid sha256:5757793046b6c9799196b88682251317dc987f7ec724d850a39a47976f200793 +size 275921 diff --git a/Content/Character/Lb/LB_Q_Arrow.uasset b/Content/Character/Lb/LB_Q_Arrow.uasset index b870c67..91dab59 100644 --- a/Content/Character/Lb/LB_Q_Arrow.uasset +++ b/Content/Character/Lb/LB_Q_Arrow.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:093ff28b564e0498cbabc91d27c0157776a060b3fd0f919b47e1f26ac2d13b03 -size 171085 +oid sha256:b9b9ed770c2a0c5abd4c8bb707344a1131d18c831ff391d07f4dd4ed5de7753f +size 200239 diff --git a/Content/Effect/ETC/Hit_Nomal.uasset b/Content/Effect/ETC/Hit_Nomal.uasset index a3d3e40..a193a3c 100644 --- a/Content/Effect/ETC/Hit_Nomal.uasset +++ b/Content/Effect/ETC/Hit_Nomal.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:377e657ed78b7e160b2ef5584f567fd59aafebc13ce03474b7fab674a7daf0f1 -size 23009 +oid sha256:bfa84589c2b268acfda8e0113a8974c1b3f2df9699b5637ead1d7767b6280939 +size 23415 diff --git a/Source/Promether/Private/DamageType/ApDamage.cpp b/Source/Promether/DamageType/APDamage.cpp similarity index 71% rename from Source/Promether/Private/DamageType/ApDamage.cpp rename to Source/Promether/DamageType/APDamage.cpp index 186bc18..7029a18 100644 --- a/Source/Promether/Private/DamageType/ApDamage.cpp +++ b/Source/Promether/DamageType/APDamage.cpp @@ -1,5 +1,5 @@ // Fill out your copyright notice in the Description page of Project Settings. -#include "DamageType/ApDamage.h" +#include "APDamage.h" diff --git a/Source/Promether/Public/DamageType/ApDamage.h b/Source/Promether/DamageType/APDamage.h similarity index 71% rename from Source/Promether/Public/DamageType/ApDamage.h rename to Source/Promether/DamageType/APDamage.h index b8a6718..81ed8f7 100644 --- a/Source/Promether/Public/DamageType/ApDamage.h +++ b/Source/Promether/DamageType/APDamage.h @@ -4,13 +4,13 @@ #include "CoreMinimal.h" #include "GameFramework/DamageType.h" -#include "ApDamage.generated.h" +#include "APDamage.generated.h" /** * */ UCLASS() -class PROMETHER_API UApDamage : public UDamageType +class PROMETHER_API UAPDamage : public UDamageType { GENERATED_BODY() diff --git a/Source/Promether/DamageType/HomingAttack.cpp b/Source/Promether/DamageType/HomingAttack.cpp new file mode 100644 index 0000000..e089a66 --- /dev/null +++ b/Source/Promether/DamageType/HomingAttack.cpp @@ -0,0 +1,47 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "HomingAttack.h" +#include "../PlayerGeneric/DefaultPlayerCharacter.h" +#include "../PlayerGeneric/DefaultPlayerState.h" +#include "Kismet/KismetMathLibrary.h" + +// Sets default values +AHomingAttack::AHomingAttack() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + ProjectileMovement = CreateDefaultSubobject(TEXT("ProjectileMovement")); + ProjectileMovement->InitialSpeed = 0; + ProjectileMovement->MaxSpeed = 1000; + ProjectileMovement->ProjectileGravityScale = 0; + ProjectileMovement->bIsHomingProjectile = true; + ProjectileMovement->HomingAccelerationMagnitude = 10000; + ProjectileMovement->Velocity = { 0, 0, 0 }; + ProjectileMovement->bRotationFollowsVelocity = true; +} + +// Called when the game starts or when spawned +void AHomingAttack::BeginPlay() +{ + Super::BeginPlay(); + + ADefaultPlayerState* State = Cast(GetOwner())->GetPlayerState(); + if (!State) return; + if (!State->GetCurrentAttackTarget()) + { + UE_LOG(LogTemp, Error, TEXT("No Target")); + Destroy(); + return; + } + + Target = State->GetCurrentAttackTarget(); + ProjectileMovement->HomingTargetComponent = Target->GetRootComponent(); +} + +// Called every frame +void AHomingAttack::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); +} + diff --git a/Source/Promether/DamageType/HomingAttack.h b/Source/Promether/DamageType/HomingAttack.h new file mode 100644 index 0000000..eaa9202 --- /dev/null +++ b/Source/Promether/DamageType/HomingAttack.h @@ -0,0 +1,33 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "GameFramework/ProjectileMovementComponent.h" +#include "HomingAttack.generated.h" + +UCLASS() +class PROMETHER_API AHomingAttack : public AActor +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + AHomingAttack(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UProjectileMovementComponent* ProjectileMovement; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + AActor* Target; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + +}; diff --git a/Source/Promether/DefaultAIController.cpp b/Source/Promether/DefaultAIController.cpp new file mode 100644 index 0000000..5f680d8 --- /dev/null +++ b/Source/Promether/DefaultAIController.cpp @@ -0,0 +1,33 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "DefaultAIController.h" +#include "PlayerGeneric/DefaultPlayerState.h" +#include "PlayerGeneric/DefaultPlayerCharacter.h" + +ADefaultAIController::ADefaultAIController() +{ + bWantsPlayerState = true; +} + +void ADefaultAIController::OnPossess(APawn* aPawn) +{ + //debug + FString MyName = aPawn->GetName(); + + ADefaultPlayerState* MyPlayerState = GetPlayerState(); + if (!MyPlayerState) return; + + ADefaultPlayerCharacter* ControlledPawn = Cast(aPawn); + if (!ControlledPawn) return; + + ControlledPawn->SetPlayerState(MyPlayerState); + + TArray DefaultStatsValue; + TArray CooldownDurationValue; + + ControlledPawn->DefaultStats.GenerateValueArray(DefaultStatsValue); + ControlledPawn->CooldownDuration.GenerateValueArray(CooldownDurationValue); + + MyPlayerState->InitPlayerStats(DefaultStatsValue, CooldownDurationValue); +} \ No newline at end of file diff --git a/Source/Promether/DefaultAIController.h b/Source/Promether/DefaultAIController.h new file mode 100644 index 0000000..96b9d01 --- /dev/null +++ b/Source/Promether/DefaultAIController.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "AIController.h" +#include "DefaultAIController.generated.h" + +/** + * + */ +UCLASS() +class PROMETHER_API ADefaultAIController : public AAIController +{ + GENERATED_BODY() + +public: + ADefaultAIController(); + void OnPossess(APawn* aPawn) override; + +}; diff --git a/Source/Promether/GameModeBase/Deathmatch.cpp b/Source/Promether/GameModeBase/Deathmatch.cpp index 987808c..db8175f 100644 --- a/Source/Promether/GameModeBase/Deathmatch.cpp +++ b/Source/Promether/GameModeBase/Deathmatch.cpp @@ -133,7 +133,7 @@ FString ADeathmatch::InitNewPlayer(APlayerController* NewPlayerController, const //DebugPerpose if (Type == CharacterType::Lukriel) { - Type = CharacterType::Riana; + Type = CharacterType::Lb; } if (Team == TeamType::Null) { diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp index 4a10acf..1f472d8 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp +++ b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp @@ -3,8 +3,10 @@ #include "DefaultPlayerCharacter.h" #include "DefaultPlayerState.h" +#include "../DefaultAIController.h" #include "Engine/DamageEvents.h" #include "Kismet/GameplayStatics.h" +#include "Components/CapsuleComponent.h" ADefaultPlayerCharacter::ADefaultPlayerCharacter() { @@ -13,6 +15,9 @@ ADefaultPlayerCharacter::ADefaultPlayerCharacter() SetCanBeDamaged(true); bUseControllerRotationYaw = false; + AIControllerClass = ADefaultAIController::StaticClass(); + AutoPossessAI = EAutoPossessAI::PlacedInWorldOrSpawned; + CameraSpringArm = CreateDefaultSubobject(TEXT("SpringArm")); CameraSpringArm->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, 0.0f), FRotator(-45.0f, 0.0f, 0.0f)); CameraSpringArm->SetAbsolute(false, true, true); @@ -49,11 +54,10 @@ void ADefaultPlayerCharacter::Tick(float DeltaTime) */ } - - void ADefaultPlayerCharacter::Attack_Implementation() { NetMulticast_Attack(); + BP_Attack(); } void ADefaultPlayerCharacter::NetMulticast_Attack_Implementation() @@ -105,10 +109,11 @@ float ADefaultPlayerCharacter::TakeDamage_Implementation(float DamageAmount, str UpdatedHealth = State->Stats[(uint8)EStats::Health] - DamageAmount * APDamageMultiplier; } - if (UpdatedHealth < 0 || UpdatedHealth < 0.1) + if (UpdatedHealth < 0 || UpdatedHealth < 0.1 ) { State->Stats[(uint8)EStats::Health] = 0; - + Server_PerformDead(); + Client_PerformDead(); } else { @@ -116,13 +121,10 @@ float ADefaultPlayerCharacter::TakeDamage_Implementation(float DamageAmount, str } UE_LOG(LogTemp, Warning, TEXT("Current Health : %f"), State->Stats[(uint8)EStats::Health]); - UE_LOG(LogTemp, Warning, TEXT("U Health : %f"), UpdatedHealth); return ReturnValue; } - - void ADefaultPlayerCharacter::Skill1_Implementation() { NetMulticast_Skill1(); @@ -202,3 +204,23 @@ void ADefaultPlayerCharacter::NetMulticast_Skill7_Implementation() { BP_Skill7(); } + +void ADefaultPlayerCharacter::PerformDead() +{ + ADefaultPlayerState* State = GetPlayerState(); + if (!State) return; + + State->SetState(ECharacterState::Dead); + GetCapsuleComponent()->SetGenerateOverlapEvents(false); + GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision); +} + +void ADefaultPlayerCharacter::Server_PerformDead_Implementation() +{ + PerformDead(); +} + +void ADefaultPlayerCharacter::Client_PerformDead_Implementation() +{ + PerformDead(); +} diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h index 0aac52a..a1adc08 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h +++ b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h @@ -22,12 +22,13 @@ public: virtual void Tick(float DeltaTime) override; UFUNCTION(BlueprintCallable, Server, Reliable) - void Attack(); + void Attack(); //Override me UFUNCTION(BlueprintImplementableEvent) - void BP_Attack(); + void BP_Attack(); UFUNCTION(NetMulticast, Reliable) - void NetMulticast_Attack(); + void NetMulticast_Attack(); + UFUNCTION(BlueprintNativeEvent) float TakeDamage( float Damage, struct FDamageEvent const& DamageEvent, @@ -35,7 +36,13 @@ public: AActor* DamageCauser ) override; + void PerformDead(); + UFUNCTION(Client, Reliable) + void Client_PerformDead(); + + UFUNCTION(Server, Reliable) + void Server_PerformDead(); UFUNCTION(BlueprintCallable, Server, Reliable) diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp b/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp index 31f3638..ff46d6a 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp +++ b/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp @@ -105,7 +105,7 @@ void ADefaultPlayerController::Server_SpawnPlayerCamera_Implementation() void ADefaultPlayerController::SetACharacterOutlineColor(ACharacter* Target, bool Visible) { - if (HasAuthority()) return; + if (!Target) return; ADefaultPlayerState* State = Target->GetPlayerState(); if (!State) @@ -330,9 +330,9 @@ void ADefaultPlayerController::Skill3() } void ADefaultPlayerController::Skill4Triggered() -{//ÄðŸÀÓ Ã¼Å© ³Ö±â +{//��Ÿ�� üũ �ֱ� - if (!GetPlayerState()->Stats[(uint8)EStats::charging] == 0)//Â÷Áö°¡ true°¡ ¾Æ´Ò ¶§ + if (!GetPlayerState()->Stats[(uint8)EStats::charging] == 0)//������ true�� �ƴ� �� { if (!GetPlayerState()->Stats[(uint8)EStats::Skillusable] == 0) { GetPlayerState()->SetState(ECharacterState::Idle); @@ -422,48 +422,51 @@ void ADefaultPlayerController::Bomb() void ADefaultPlayerController::ObjectSelect() { + ADefaultPlayerState* State = GetPlayerState(); + if (!State) return; + FHitResult HitResult; TArray> ObjectTypes; - ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_WorldStatic)); ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Pawn)); GetHitResultUnderCursorForObjects(ObjectTypes, true, HitResult); ACharacter* HitObject = Cast(HitResult.GetActor()); - if (!HitObject) return; - UE_LOG(LogTemp, Warning, TEXT("%s"), *HitObject->GetName()); - SetACharacterOutlineColor(HitObject, true); + if (!HitObject) + { + SetACharacterOutlineColor(Cast(State->GetPreviousAttackTarget()), false); + State->SetPreviousAttackTarget(nullptr); + State->SetCurrentAttackTarget(nullptr); + return; + } + + if (State->GetPreviousAttackTarget() != HitResult.GetActor()) + { + SetACharacterOutlineColor(Cast(State->GetPreviousAttackTarget()), false); + + State->SetPreviousAttackTarget(HitResult.GetActor()); + State->SetCurrentAttackTarget(HitResult.GetActor()); + + SetACharacterOutlineColor(HitObject, true); + } + + UE_LOG(LogTemp, Warning, TEXT("%s"), *State->GetCurrentAttackTarget()->GetName()); + + FString Name = HitResult.GetActor()->GetName(); + APlayerState* TargetState = Cast(HitResult.GetActor())->GetPlayerState(); } - void ADefaultPlayerController::Move() { EndAttack(); - FHitResult HitResult; - TArray> ObjectTypes; - ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_WorldStatic)); - ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Pawn)); - - GetHitResultUnderCursorForObjects(ObjectTypes, true, HitResult); - ACharacter* HitCharacter = Cast(HitResult.GetActor()); //¿ÀºêÁ§Æ®¸¦ °¡Á®¿Í HitCharactor¿¡ ÀúÀå<<ÃßÈÄ Àû ij¸¯ÅÍÀ϶§¸¸ ÀúÀåÀ¸·Î º¯°æÇؾßÇÔ - HitTarget = HitResult.GetActor(); - - UE_LOG(LogTemp, Warning, TEXT("%s"), *HitResult.GetActor()->GetName()); - - if (HitResult.GetActor() != GetPawn()) //Áö±ÝÀº HitObject°¡ nullÀÌ ¾Æ´Ò °æ¿ì Attack()À» ½ÇÇàÇÏ´Â ÄÚµåÁö¸¸, HitObject°¡ Àû ij¸¯ÅÍÀÏ ¶§ ½ÇÇàÀ¸·Î º¯°æÇؾßÇÔ + ObjectSelect(); + + if (GetPlayerState()->GetCurrentAttackTarget() != GetPawn() && + Cast(GetPlayerState()->GetCurrentAttackTarget())) { - if (GetPlayerState()->Stats[(uint8)EStats::Attackable] == 1) - return; - if (!HitCharacter) - { - FVector Destination = GetMouseHitLocation(); - GetPlayerState()->SetState(ECharacterState::Moving); - SimpleMoveToLocation(this, Destination); - this->MoveToLocation(Destination); - return; - } - BeginAttack(); //HitObject¸¦ ´ë»óÀ¸·Î BeginAttack ½ÇÇà + if (!GetPlayerState()->Stats[(uint8)EStats::Attackable] == 0) return; + BeginAttack(); } else { @@ -483,8 +486,6 @@ void ADefaultPlayerController::Multicast_SetRotation_Implementation(FVector Mous Location.Z = 0; FRotator NewRotation = (MouseHitLocation - Location).Rotation(); - - // ¸¸¾à XÃàÀ» °íÁ¤ÇÏ°í ½Í´Ù¸é ¾Æ·¡¿Í °°ÀÌ ÇØ´ç °ªÀ» ¼³Á¤ÇÕ´Ï´Ù. NewRotation.Pitch = 0; @@ -517,7 +518,10 @@ void ADefaultPlayerController::Multicast_StopMove_Implementation() FVector ADefaultPlayerController::GetMouseHitLocation() { FHitResult HitResult; - GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, true, HitResult); + TArray> ObjectTypes; + ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_WorldStatic)); + + GetHitResultUnderCursorForObjects(ObjectTypes, true, HitResult); HitResult.Location.Z = 0; //UE_LOG(LogTemp, Warning, TEXT("Client%d MoveTo : (%f, %f)"), GPlayInEditorID, HitResult.Location.X, HitResult.Location.Y); @@ -646,39 +650,36 @@ void ADefaultPlayerController::OnMoveCompleted(FAIRequestID RequestID, const FPa GetPlayerState()->SetState(ECharacterState::Idle); } -FTimerHandle TimerHandle; - void ADefaultPlayerController::BeginAttack() { - GetWorldTimerManager().SetTimer(TimerHandle, this, &ADefaultPlayerController::RepeatedAttack, 0.1f, true); + GetWorldTimerManager().SetTimer(TimerHandle, this, &ADefaultPlayerController::RepeatedAttack, 0.1f, true); } void ADefaultPlayerController::EndAttack() { - GetWorldTimerManager().ClearTimer(TimerHandle); } void ADefaultPlayerController::RepeatedAttack() { - if (!GetPlayerState()->Stats[(uint8)EStats::Attackable] == 0) - return; Attack(); } - - void ADefaultPlayerController::Attack() { - + if (!GetPlayerState()->Stats[(uint8)EStats::Attackable] == 0) + return; + float MinDistance = GetPlayerState()->Stats[(uint8)EStats:: AttackRange]; - FVector Destination = HitTarget->GetActorLocation(); // HitObjectÀÇ À§Ä¡¸¦ ¸ñÀûÁö·Î ¼³Á¤ + + if (!GetPlayerState()->GetCurrentAttackTarget()) return; + + FVector Destination = GetPlayerState()->GetCurrentAttackTarget()->GetActorLocation(); // HitObject�� ��ġ�� �������� ���� if (FVector::Dist(Destination, GetPawn()->GetActorLocation()) <= MinDistance) { if ((GetPlayerState()->CooldownDuration[(uint8)CooldownType::Attack] != 0)) return; - FVector Location = GetPawn()->GetActorLocation(); Location.X = 0; @@ -688,7 +689,6 @@ void ADefaultPlayerController::Attack() Multicast_SetRotation(Destination); Server_SetRotation(Destination); - UE_LOG(LogTemp, Warning, TEXT("Attack")); GetPlayerState()->SetState(ECharacterState::Attack); @@ -698,12 +698,8 @@ void ADefaultPlayerController::Attack() { GetPlayerState()->SetState(ECharacterState::Moving); SimpleMoveToLocation(this, Destination); - - - this->MoveToLocation(Destination); } - SetTarget(); } void ADefaultPlayerController::MoveToLocation_Implementation(FVector Location) diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerController.h b/Source/Promether/PlayerGeneric/DefaultPlayerController.h index eb66315..711ffdd 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerController.h +++ b/Source/Promether/PlayerGeneric/DefaultPlayerController.h @@ -77,9 +77,7 @@ public: UPROPERTY(BlueprintReadWrite) float MouseClickInterval; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "My Actor") - AActor* HitTarget; - + FTimerHandle TimerHandle; private: UPROPERTY(EditAnywhere, Category = "Input") diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp b/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp index 1159af6..5e96ac2 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp +++ b/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp @@ -6,6 +6,8 @@ ADefaultPlayerState::ADefaultPlayerState() CharacterBPRef = nullptr;; Team = TeamType::Null; State = ECharacterState::Idle; + + NetUpdateFrequency = 100.0f; } void ADefaultPlayerState::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const @@ -22,8 +24,10 @@ void ADefaultPlayerState::GetLifetimeReplicatedProps(TArray& DOREPLIFETIME(ADefaultPlayerState, State); DOREPLIFETIME(ADefaultPlayerState, AttackType); - //DOREPLIFETIME(ADefaultPlayerState, StatusEffectObject); DOREPLIFETIME(ADefaultPlayerState, PlayerCamera); + + DOREPLIFETIME(ADefaultPlayerState, CurrentAttackTarget); + DOREPLIFETIME(ADefaultPlayerState, PreviousAttackTarget); } void ADefaultPlayerState::InitPlayerStats_Implementation(const TArray& StatsValue, const TArray& CooldownDurationValue) @@ -33,7 +37,6 @@ void ADefaultPlayerState::InitPlayerStats_Implementation(const TArray& St CooldownDuration.Append(CooldownDurationValue); MaxCooldownDuration.Append(CooldownDurationValue); - for (float Value : StatsValue) { UE_LOG(LogTemp, Warning, TEXT("Values: %f"), Value); @@ -64,3 +67,35 @@ int32 ADefaultPlayerState::GetCharacterLevel() const { return int32(); } + +void ADefaultPlayerState::SetCurrentAttackTarget(AActor* Target) +{ + Server_SetCurrentAttackTarget(Target); + Client_SetCurrentAttackTarget(Target); +} + +void ADefaultPlayerState::Server_SetCurrentAttackTarget_Implementation(AActor* Target) +{ + CurrentAttackTarget = Target; +} + +void ADefaultPlayerState::Client_SetCurrentAttackTarget_Implementation(AActor* Target) +{ + CurrentAttackTarget = Target; +} + +void ADefaultPlayerState::SetPreviousAttackTarget(AActor* Target) +{ + Server_SetPreviousAttackTarget(Target); + Client_SetPreviousAttackTarget(Target); +} + +void ADefaultPlayerState::Server_SetPreviousAttackTarget_Implementation(AActor* Target) +{ + PreviousAttackTarget = Target; +} + +void ADefaultPlayerState::Client_SetPreviousAttackTarget_Implementation(AActor* Target) +{ + PreviousAttackTarget = Target; +} diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerState.h b/Source/Promether/PlayerGeneric/DefaultPlayerState.h index 117cc17..a37ea68 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerState.h +++ b/Source/Promether/PlayerGeneric/DefaultPlayerState.h @@ -62,6 +62,23 @@ public: UFUNCTION(BlueprintCallable) int32 GetCharacterLevel() const; + + UFUNCTION(BlueprintCallable) + AActor* GetCurrentAttackTarget() const { return CurrentAttackTarget; }; + UFUNCTION(BlueprintCallable) + AActor* GetPreviousAttackTarget() const { return PreviousAttackTarget; }; + + void SetCurrentAttackTarget(AActor* Target); + UFUNCTION(Server, Reliable) + void Server_SetCurrentAttackTarget(AActor* Target); + UFUNCTION(Client, Reliable) + void Client_SetCurrentAttackTarget(AActor* Target); + + void SetPreviousAttackTarget(AActor* Target); + UFUNCTION(Server, Reliable) + void Server_SetPreviousAttackTarget(AActor* Target); + UFUNCTION(Client, Reliable) + void Client_SetPreviousAttackTarget(AActor* Target); UPROPERTY(Replicated, Transient, EditAnywhere, BlueprintReadWrite) TArray Stats; @@ -73,6 +90,7 @@ public: UPROPERTY(Replicated, Transient, BlueprintReadWrite) TArray MaxCooldownDuration; + private: UPROPERTY(Replicated, Transient) UClass* CharacterBPRef; @@ -84,9 +102,11 @@ private: UPROPERTY(Replicated, Transient) CooldownType AttackType; - //UPROPERTY(Replicated, Transient) - //TMap StatusEffectObject; - UPROPERTY(Replicated, Transient) AActor* PlayerCamera; + + UPROPERTY(Replicated, Transient) + AActor* CurrentAttackTarget; + UPROPERTY(Replicated, Transient) + AActor* PreviousAttackTarget; }; diff --git a/Source/Promether/PrometherEnum.h b/Source/Promether/PrometherEnum.h index cecbf72..635d330 100644 --- a/Source/Promether/PrometherEnum.h +++ b/Source/Promether/PrometherEnum.h @@ -2,6 +2,7 @@ #include "CoreMinimal.h" #include "DamageType/BaseAttack.h" +#include "DamageType/APDamage.h" UENUM(BlueprintType) enum class CharacterType : uint8