From 52e4c37ee59f1305d7cb599d11be330b3ad08f4d Mon Sep 17 00:00:00 2001 From: HappyTanuki Date: Sun, 8 Oct 2023 04:45:12 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC=20+=20s?= =?UTF-8?q?tats=20FName=EA=B5=AC=ED=98=84=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content/Character/Lb/Animation/ABP_Lb.uasset | 4 +- Content/Character/Lb/Animation/R2_Anim.uasset | 4 +- Content/Character/Lb/BP_Lb.uasset | 4 +- Content/Maps/DevMap.umap | 4 +- .../PlayerGeneric/DefaultPlayerCharacter.cpp | 67 ++---- .../PlayerGeneric/DefaultPlayerCharacter.h | 80 +------ .../PlayerGeneric/DefaultPlayerController.cpp | 220 ++++++++++-------- .../PlayerGeneric/DefaultPlayerState.cpp | 48 +--- .../PlayerGeneric/DefaultPlayerState.h | 31 +-- Source/Promether/PrometherEnum.h | 38 +++ 10 files changed, 217 insertions(+), 283 deletions(-) diff --git a/Content/Character/Lb/Animation/ABP_Lb.uasset b/Content/Character/Lb/Animation/ABP_Lb.uasset index 0a42e01..5b4df98 100644 --- a/Content/Character/Lb/Animation/ABP_Lb.uasset +++ b/Content/Character/Lb/Animation/ABP_Lb.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e790215f1968518d97a61ff6d8c56f7d14c3c7d7cb481025827daf3c4b0a90c6 -size 290801 +oid sha256:75517bd7de78a30c9720f3cfe1ce0a924b5c0ff83a1f830aa6b98dd6fd9c5a04 +size 310577 diff --git a/Content/Character/Lb/Animation/R2_Anim.uasset b/Content/Character/Lb/Animation/R2_Anim.uasset index b86911a..8a69d0e 100644 --- a/Content/Character/Lb/Animation/R2_Anim.uasset +++ b/Content/Character/Lb/Animation/R2_Anim.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0c5d110cbc5ae8d4b489b73f7a2b7b955803f0ebc65b45c53054e3777484f8b8 -size 164688 +oid sha256:228c3f0cc7442f470f1f6ecd7ac3e46d058570c339c3ea599db5a9e6e27da282 +size 164747 diff --git a/Content/Character/Lb/BP_Lb.uasset b/Content/Character/Lb/BP_Lb.uasset index e2d5ea3..0dbe4c5 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:44edc4eaf0c0147046acc14266f5165ad830fbb9574d289de136b32cdbc08076 -size 139532 +oid sha256:db33b12578b5bbcc1544836fae0157f4325c361d7d93695a0433d2e36b340805 +size 144292 diff --git a/Content/Maps/DevMap.umap b/Content/Maps/DevMap.umap index 132dd6f..6244900 100644 --- a/Content/Maps/DevMap.umap +++ b/Content/Maps/DevMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:83759f90f993a37a6439fbe14a2bbd7701fee19631dab8a196432ca80a6eef09 -size 181915 +oid sha256:e5d16e9758c041479bd4f6b7e3562a337a11384d9e0dac49b9199c91bc6df50b +size 185559 diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp index 76e1f35..1d393db 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp +++ b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.cpp @@ -25,39 +25,18 @@ ADefaultPlayerCharacter::ADefaultPlayerCharacter() Camera = CreateDefaultSubobject(TEXT("Camera")); Camera->SetupAttachment(CameraSpringArm, USpringArmComponent::SocketName); - Health = 0.0f; - HPRegeneration = 0.0f; - HealAndShieldpower = 0.0f; - Armor = 0.0f; - MagicResistance = 0.0f; - Tenacity = 0.0f; - SlowRisist = 0.0f; - AttackSpeed = 0.0f; - AttackDamage = 0.0f; - AbilityPower = 0.0f; - CriticalStrikeChance = 0.0f; - CriticalStrikeDamage = 0.0f; - ArmorPenetration = 0.0f; - MagicPenetration = 0.0f; - LifeSteal = 0.0f; - PhysicalVamp = 0.0f; - Omnivamp = 0.0f; - AbilityHaste = 0.0f; - Mana = 0.0f; - ManaRegeneration = 0.0f; - Energy = 0.0f; - EnergyRegeneration = 0.0f; - AttackRange = 0.0f; - MovementSpeed = 0.0f; - GoldGeneration = 0.0f; - AttackDamageGrowth = 0.0f; - AttackSpeedGrowth = 0.0f; - ArmorGrowth = 0.0f; - MagicResistanceGrowth = 0.0f; - HealthGrowth = 0.0f; - HealthRegenerationGrowth = 0.0f; - ManaGrowth = 0.0f; - ManaRegenerationGrowth = 0.0f; + const UEnum* CharStateEnum = FindObject(ANY_PACKAGE, TEXT("EStats"), true); + if (!CharStateEnum) + { + UE_LOG(LogTemp, Error, TEXT("EStats Missing")); + return; + } + + for (uint8 i = 0; i < (uint8)EStats::SIZE; i++) + DefaultStats.Add(*CharStateEnum->GetNameByValue((uint8)i).ToString(), 0.0f); + + for (uint8 i = 0; i < (uint8)CooldownType::SIZE; i++) + CooldownDuration.Add((CooldownType)i, 0.0f); } void ADefaultPlayerCharacter::Tick(float DeltaTime) @@ -104,15 +83,15 @@ float ADefaultPlayerCharacter::TakeDamage_Implementation(float DamageAmount, str float ADDamageMultiplier = 0; float APDamageMultiplier = 0; - if (MyState->Stats.Armor >= 0) - ADDamageMultiplier = 100 / (100 + MyState->Stats.Armor); + if (MyState->Stats[(uint8)EStats::Armor] >= 0) + ADDamageMultiplier = 100 / (100 + MyState->Stats[(uint8)EStats::Armor]); else - ADDamageMultiplier = 2 - 100 / (100 - MyState->Stats.Armor); + ADDamageMultiplier = 2 - 100 / (100 - MyState->Stats[(uint8)EStats::Armor]); - if (MyState->Stats.MagicResistance >= 0) - APDamageMultiplier = 100 / (100 + MyState->Stats.MagicResistance); + if (MyState->Stats[(uint8)EStats::MagicResistance] >= 0) + APDamageMultiplier = 100 / (100 + MyState->Stats[(uint8)EStats::MagicResistance]); else - APDamageMultiplier = 2 - 100 / (100 - MyState->Stats.MagicResistance); + APDamageMultiplier = 2 - 100 / (100 - MyState->Stats[(uint8)EStats::MagicResistance]); UE_LOG(LogTemp, Warning, TEXT("%s : ADDamageMultiplier : %f CalculatedDamage : %f"), *DamageCauser->GetName(), ADDamageMultiplier, DamageAmount * ADDamageMultiplier); @@ -120,19 +99,19 @@ float ADefaultPlayerCharacter::TakeDamage_Implementation(float DamageAmount, str if (Cast(DamageEvent.DamageTypeClass->GetDefaultObject())) { - UE_LOG(LogTemp, Warning, TEXT("DamageType : BaseAttack")); + UE_LOG(LogTemp, Warning, TEXT("DamageType : BaseAttack")); - float UpdatedHealth = MyState->Stats.Health - EventInstigatorState->Stats.AttackDamage * ADDamageMultiplier; + float UpdatedHealth = MyState->Stats[(uint8)EStats::Health] - EventInstigatorState->Stats[(uint8)EStats::AttackDamage] * ADDamageMultiplier; if (UpdatedHealth < 0) { - MyState->Stats.Health = 0; + MyState->Stats[(uint8)EStats::Health] = 0; } else { - MyState->Stats.Health = UpdatedHealth; + MyState->Stats[(uint8)EStats::Health] = UpdatedHealth; } - UE_LOG(LogTemp, Warning, TEXT("Current Health : %f"), MyState->Stats.Health); + UE_LOG(LogTemp, Warning, TEXT("Current Health : %f"), MyState->Stats[(uint8)EStats::Health]); } } diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h index f7d5601..406f534 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h +++ b/Source/Promether/PlayerGeneric/DefaultPlayerCharacter.h @@ -89,83 +89,11 @@ public: UFUNCTION(NetMulticast, Reliable) void NetMulticast_Skill7(); - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Defensive") - float Health; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Defensive") - float HPRegeneration; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Defensive") - float HealAndShieldpower; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Defensive") - float Armor; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Defensive") - float MagicResistance; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Defensive") - float Tenacity; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Defensive") - float SlowRisist; - - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float AttackSpeed; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float AttackDamage; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float AbilityPower; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float CriticalStrikeChance; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float CriticalStrikeDamage; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float ArmorPenetration; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float MagicPenetration; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float LifeSteal; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float PhysicalVamp; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Offensive") - float Omnivamp; - - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility|Haste") - float AbilityHaste; - - UPROPERTY(EditAnywhere, Category = "Stats|Utility|Haste") - float CooldownDuration[(uint8)CooldownType::SIZE] = { 0.0f, }; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility|Resource") - float Mana; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility|Resource") - float ManaRegeneration; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility|Resource") - float Energy; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility|Resource") - float EnergyRegeneration; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility") - float AttackRange; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility") - float MovementSpeed; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Utility|Non-Combat") - float GoldGeneration; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float AttackDamageGrowth; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float AttackSpeedGrowth; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float ArmorGrowth; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float MagicResistanceGrowth; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float HealthGrowth; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float HealthRegenerationGrowth; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float ManaGrowth; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats|Increasing Statistics") - float ManaRegenerationGrowth; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats") + TMap DefaultStats; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats") + TMap CooldownDuration; protected: UPROPERTY(EditAnywhere) USpringArmComponent* CameraSpringArm; diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp b/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp index ee3bd3e..5653128 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp +++ b/Source/Promether/PlayerGeneric/DefaultPlayerController.cpp @@ -18,18 +18,23 @@ void ADefaultPlayerController::BeginPlay() { Super::BeginPlay(); - if (ULocalPlayer* LocalPlayer = Cast(Player)) { - if (UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem()) { - if (!PlayerInputMapping.IsNull()) { - InputSystem->AddMappingContext(PlayerInputMapping.LoadSynchronous(), 0); - } - else { - UE_LOG(LogTemp, Error, TEXT("AddMappingContext Failed")); - } - } + ULocalPlayer* LocalPlayer = Cast(Player); + if (!LocalPlayer) return; + UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem(); + if (!InputSystem) return; + ADefaultPlayerCharacter* ControlledPawn = GetPawn(); + if (!ControlledPawn) return; + ADefaultPlayerState* MyPlayerState = GetPlayerState(); + if (!MyPlayerState) return; + if (PlayerInputMapping.IsNull()) + { + UE_LOG(LogTemp, Error, TEXT("AddMappingContext Failed")); + return; } + InputSystem->AddMappingContext(PlayerInputMapping.LoadSynchronous(), 0); this->bShowMouseCursor = true; + //MyPlayerState->InitPlayerStats(ControlledPawn->DefaultStats, ControlledPawn->CooldownDuration); } void ADefaultPlayerController::OnPossess(APawn* aPawn) @@ -39,16 +44,15 @@ void ADefaultPlayerController::OnPossess(APawn* aPawn) Server_SpawnPlayerCamera(); AActor *PlayerCamera = GetPlayerState()->GetPlayerCamera(); - if (PlayerCamera) - { - SetViewTarget(PlayerCamera); - - UE_LOG(LogTemp, Warning, TEXT("SetViewTarget Success : %s"), *GetPlayerState()->GetPlayerCamera()->GetName()); - } - else + if (!PlayerCamera) { UE_LOG(LogTemp, Error, TEXT("GetPlayerCamera Failed.")); + return; } + + SetViewTarget(PlayerCamera); + + UE_LOG(LogTemp, Warning, TEXT("SetViewTarget Success : %s"), *GetPlayerState()->GetPlayerCamera()->GetName()); } void ADefaultPlayerController::OnUnPossess() @@ -66,48 +70,46 @@ void ADefaultPlayerController::Server_SpawnPlayerCamera_Implementation() UE_LOG(LogTemp, Warning, TEXT("SpawnPlayerCamera")); - if (APawn* MyPawn = GetPawn()) + APawn* MyPawn = GetPawn(); + if (!MyPawn) return; + + FTransform SpawnTransform = FTransform(); + + SpawnTransform.SetLocation(MyPawn->GetActorLocation()); + + OutContextPlayerCamera = GetWorld()->SpawnActor(ADefaultPlayerCamera::StaticClass(), SpawnTransform, SpawnInfo); + if (!OutContextPlayerCamera) { - FTransform SpawnTransform = FTransform(); - - SpawnTransform.SetLocation(MyPawn->GetActorLocation()); - - OutContextPlayerCamera = GetWorld()->SpawnActor(ADefaultPlayerCamera::StaticClass(), SpawnTransform, SpawnInfo); - if (OutContextPlayerCamera) - { - GetPlayerState()->SetPlayerCamera(OutContextPlayerCamera); - OutContextPlayerCamera->AttachToActor(GetPawn(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, false)); - - UE_LOG(LogTemp, Warning, TEXT("SetPlayerCamera Success : %s, %d"), *GetPlayerState()->GetPlayerCamera()->GetName(), GetPlayerState()->GetPlayerCamera()); - } - else - { - UE_LOG(LogTemp, Error, TEXT("Camera Spawn Failed.")); - } + UE_LOG(LogTemp, Error, TEXT("Camera Spawn Failed.")); + return; } + + GetPlayerState()->SetPlayerCamera(OutContextPlayerCamera); + OutContextPlayerCamera->AttachToActor(GetPawn(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, false)); + + UE_LOG(LogTemp, Warning, TEXT("SetPlayerCamera Success : %s, %d"), *GetPlayerState()->GetPlayerCamera()->GetName(), GetPlayerState()->GetPlayerCamera()); } void ADefaultPlayerController::SetACharacterOutlineColor(ACharacter* Target, bool Visible) { - if (!HasAuthority()) + if (HasAuthority()) return; + + ADefaultPlayerState* State = Target->GetPlayerState(); + if (!State) { - if (ADefaultPlayerState* State = Target->GetPlayerState()) - { - if (State->GetTeam() == GetPlayerState()->GetTeam()) - { - Target->GetMesh()->SetRenderCustomDepth(Visible); - Target->GetMesh()->CustomDepthStencilValue = 1; - } - else - { - Target->GetMesh()->SetRenderCustomDepth(Visible); - Target->GetMesh()->CustomDepthStencilValue = 2; - } - } - else - { - UE_LOG(LogTemp, Error, TEXT("GetPlayerState Failed")); - } + UE_LOG(LogTemp, Error, TEXT("GetPlayerState Failed")); + return; + } + + if (State->GetTeam() == GetPlayerState()->GetTeam()) + { + Target->GetMesh()->SetRenderCustomDepth(Visible); + Target->GetMesh()->CustomDepthStencilValue = 1; + } + else + { + Target->GetMesh()->SetRenderCustomDepth(Visible); + Target->GetMesh()->CustomDepthStencilValue = 2; } } @@ -215,20 +217,20 @@ void ADefaultPlayerController::SetupInputComponent() { Super::SetupInputComponent(); - if (UEnhancedInputComponent* EnhancedInputComponent = Cast(InputComponent)) - { - EnhancedInputComponent->BindAction(Skill1Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill1); - EnhancedInputComponent->BindAction(Skill2Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill2); - EnhancedInputComponent->BindAction(Skill3Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill3); - EnhancedInputComponent->BindAction(Skill4Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill4Triggered); - EnhancedInputComponent->BindAction(Skill4Action.Get(), ETriggerEvent::Completed, this, &ADefaultPlayerController::Skill4Completed); - EnhancedInputComponent->BindAction(RuneSpell1Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell1); - EnhancedInputComponent->BindAction(RuneSpell2Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell2); - EnhancedInputComponent->BindAction(WardAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Ward); - EnhancedInputComponent->BindAction(BombAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Bomb); - EnhancedInputComponent->BindAction(ObjectSelectAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::ObjectSelect); - EnhancedInputComponent->BindAction(MoveAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Move); - } + UEnhancedInputComponent* EnhancedInputComponent = Cast(InputComponent); + if (!EnhancedInputComponent) return; + + EnhancedInputComponent->BindAction(Skill1Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill1); + EnhancedInputComponent->BindAction(Skill2Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill2); + EnhancedInputComponent->BindAction(Skill3Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill3); + EnhancedInputComponent->BindAction(Skill4Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill4Triggered); + EnhancedInputComponent->BindAction(Skill4Action.Get(), ETriggerEvent::Completed, this, &ADefaultPlayerController::Skill4Completed); + EnhancedInputComponent->BindAction(RuneSpell1Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell1); + EnhancedInputComponent->BindAction(RuneSpell2Action.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::RuneSpell2); + EnhancedInputComponent->BindAction(WardAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Ward); + EnhancedInputComponent->BindAction(BombAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Bomb); + EnhancedInputComponent->BindAction(ObjectSelectAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::ObjectSelect); + EnhancedInputComponent->BindAction(MoveAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Move); } void ADefaultPlayerController::Skill1() @@ -236,6 +238,12 @@ void ADefaultPlayerController::Skill1() //if (!(GetPlayerState()->Stats.Mana >= 100)) // return; + FVector Location = GetPawn()->GetActorLocation(); + Location.Z = 0; + + SimpleMoveToLocation(this, Location); + this->MoveToLocation(Location); + Server_SetRotation(GetMouseHitLocation()); UE_LOG(LogTemp, Warning, TEXT("Skill1")); @@ -245,6 +253,12 @@ void ADefaultPlayerController::Skill1() void ADefaultPlayerController::Skill2() { + FVector Location = GetPawn()->GetActorLocation(); + Location.Z = 0; + + SimpleMoveToLocation(this, Location); + this->MoveToLocation(Location); + Server_SetRotation(GetMouseHitLocation()); UE_LOG(LogTemp, Warning, TEXT("Skill2")); @@ -254,6 +268,12 @@ void ADefaultPlayerController::Skill2() void ADefaultPlayerController::Skill3() { + FVector Location = GetPawn()->GetActorLocation(); + Location.Z = 0; + + SimpleMoveToLocation(this, Location); + this->MoveToLocation(Location); + Server_SetRotation(GetMouseHitLocation()); UE_LOG(LogTemp, Warning, TEXT("Skill3")); @@ -263,6 +283,12 @@ void ADefaultPlayerController::Skill3() void ADefaultPlayerController::Skill4Triggered() { + FVector Location = GetPawn()->GetActorLocation(); + Location.Z = 0; + + SimpleMoveToLocation(this, Location); + this->MoveToLocation(Location); + Server_SetRotation(GetMouseHitLocation()); UE_LOG(LogTemp, Warning, TEXT("Skill4 Triggered")); @@ -272,6 +298,12 @@ void ADefaultPlayerController::Skill4Triggered() void ADefaultPlayerController::Skill4Completed() { + FVector Location = GetPawn()->GetActorLocation(); + Location.Z = 0; + + SimpleMoveToLocation(this, Location); + this->MoveToLocation(Location); + Server_SetRotation(GetMouseHitLocation()); UE_LOG(LogTemp, Warning, TEXT("Skill4 Completed")); @@ -316,11 +348,11 @@ void ADefaultPlayerController::ObjectSelect() GetHitResultUnderCursorForObjects(ObjectTypes, true, HitResult); - if (ACharacter* HitObject = Cast(HitResult.GetActor())) - { - UE_LOG(LogTemp, Warning, TEXT("%s"), *HitObject->GetName()); - SetACharacterOutlineColor(HitObject, true); - } + ACharacter* HitObject = Cast(HitResult.GetActor()); + if (!HitObject) return; + + UE_LOG(LogTemp, Warning, TEXT("%s"), *HitObject->GetName()); + SetACharacterOutlineColor(HitObject, true); } void ADefaultPlayerController::Move() @@ -337,9 +369,6 @@ void ADefaultPlayerController::Multicast_SetRotation_Implementation(FVector Mous FVector Location = GetPawn()->GetActorLocation(); Location.Z = 0; - SimpleMoveToLocation(this, Location); - this->MoveToLocation(Location); - GetPawn()->SetActorRotation((MouseHitLocation - Location).Rotation()); } @@ -367,22 +396,21 @@ FVector ADefaultPlayerController::GetMouseHitLocation() DrawDebugLine(GetWorld(), HitResult.Location, Destination, FColor::Emerald, false, 1, 0, 1); const UWorld* CurrentWorld = GetWorld(); - if (CurrentWorld) - { - FHitResult CollisionCheck; + if (!CurrentWorld) return Destination; - FCollisionQueryParams CollisionParams; - CollisionParams.AddIgnoredActor(GetPawn()); + FHitResult CollisionCheck; - FVector Start = HitResult.Location; - FVector End = Destination; + FCollisionQueryParams CollisionParams; + CollisionParams.AddIgnoredActor(GetPawn()); - if (CurrentWorld->LineTraceSingleByChannel(CollisionCheck, Start, End, ECC_Visibility, CollisionParams)) - { - DrawDebugLine(CurrentWorld, Start, End, FColor::Red, false, 1.5, 0, 2); - Destination = HitResult.Location; - } - } + FVector Start = HitResult.Location; + FVector End = Destination; + + if (!CurrentWorld->LineTraceSingleByChannel(CollisionCheck, Start, End, ECC_Visibility, CollisionParams)) + return Destination; + + DrawDebugLine(CurrentWorld, Start, End, FColor::Red, false, 1.5, 0, 2); + Destination = HitResult.Location; return Destination; } @@ -467,18 +495,18 @@ void ADefaultPlayerController::SimpleMoveToLocation(AController* Controller, con void ADefaultPlayerController::OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult& MovementResult) { - if (MovementResult.IsSuccess()) + if (!MovementResult.IsSuccess()) return; + + if (!GPlayInEditorID) { - if (!GPlayInEditorID) - { - UE_LOG(LogTemp, Warning, TEXT("Server MoveCompleted")); - } - else - { - UE_LOG(LogTemp, Warning, TEXT("Client%d MoveCompleted"), GPlayInEditorID); - } - GetPlayerState()->SetState(ECharacterState::Idle); + UE_LOG(LogTemp, Warning, TEXT("Server MoveCompleted")); } + else + { + UE_LOG(LogTemp, Warning, TEXT("Client%d MoveCompleted"), GPlayInEditorID); + } + + GetPlayerState()->SetState(ECharacterState::Idle); } void ADefaultPlayerController::Attack() diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp b/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp index 365a35f..c7e2448 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp +++ b/Source/Promether/PlayerGeneric/DefaultPlayerState.cpp @@ -26,46 +26,11 @@ void ADefaultPlayerState::GetLifetimeReplicatedProps(TArray& DOREPLIFETIME(ADefaultPlayerState, PlayerCamera); } -void ADefaultPlayerState::InitPlayerStats() +void ADefaultPlayerState::InitPlayerStats_Implementation(const TArray& StatsValue, const TArray& CooldownDurationValue) { - ADefaultPlayerCharacter* Initializer = Cast(CharacterBPRef); - - Stats.Health = Initializer->Health; - Stats.HPRegeneration = Initializer->HPRegeneration; - Stats.HealAndShieldpower = Initializer->HealAndShieldpower; - Stats.Armor = Initializer->Armor; - Stats.MagicResistance = Initializer->MagicResistance; - Stats.Tenacity = Initializer->Tenacity; - Stats.SlowRisist = Initializer->SlowRisist; - Stats.AttackSpeed = Initializer->AttackSpeed; - Stats.AttackDamage = Initializer->AttackDamage; - Stats.AbilityPower = Initializer->AbilityPower; - Stats.CriticalStrikeChance = Initializer->CriticalStrikeChance; - Stats.CriticalStrikeDamage = Initializer->CriticalStrikeDamage; - Stats.ArmorPenetration = Initializer->ArmorPenetration; - Stats.MagicPenetration = Initializer->MagicPenetration; - Stats.LifeSteal = Initializer->LifeSteal; - Stats.PhysicalVamp = Initializer->PhysicalVamp; - Stats.Omnivamp = Initializer->Omnivamp; - Stats.AbilityHaste = Initializer->AbilityHaste; - - SetMultipleCooldownDuration(Initializer->CooldownDuration); - - Stats.Mana = Initializer->Mana; - Stats.ManaRegeneration = Initializer->ManaRegeneration; - Stats.Energy = Initializer->Energy; - Stats.EnergyRegeneration = Initializer->EnergyRegeneration; - Stats.AttackRange = Initializer->AttackRange; - Stats.MovementSpeed = Initializer->MovementSpeed; - Stats.GoldGeneration = Initializer->GoldGeneration; - Stats.AttackDamageGrowth = Initializer->AttackDamageGrowth; - Stats.AttackSpeedGrowth = Initializer->AttackSpeedGrowth; - Stats.ArmorGrowth = Initializer->ArmorGrowth; - Stats.MagicResistanceGrowth = Initializer->MagicResistanceGrowth; - Stats.HealthGrowth = Initializer->HealthGrowth; - Stats.HealthRegenerationGrowth = Initializer->HealthRegenerationGrowth; - Stats.ManaGrowth = Initializer->ManaGrowth; - Stats.ManaRegenerationGrowth = Initializer->ManaRegenerationGrowth; + MaxStats.Append(StatsValue); + Stats.Append(StatsValue); + CooldownDuration.Append(CooldownDurationValue); } void ADefaultPlayerState::NetMulticast_SetAttackType_Implementation(CooldownType Value) @@ -92,8 +57,3 @@ int32 ADefaultPlayerState::GetCharacterLevel() const { return int32(); } - -void ADefaultPlayerState::SetMultipleCooldownDuration(const float* Value) -{ - std::memcpy(&CooldownDuration, Value, sizeof(float) * (uint8)CooldownType::SIZE); -} diff --git a/Source/Promether/PlayerGeneric/DefaultPlayerState.h b/Source/Promether/PlayerGeneric/DefaultPlayerState.h index 7b64d67..d566af0 100644 --- a/Source/Promether/PlayerGeneric/DefaultPlayerState.h +++ b/Source/Promether/PlayerGeneric/DefaultPlayerState.h @@ -21,7 +21,8 @@ public: ADefaultPlayerState(); void GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const override; - void InitPlayerStats(); + UFUNCTION(Server, Reliable) + void InitPlayerStats(const TArray& StatsValue, const TArray& CooldownDurationValue); void SetCharacterBPRef(UClass* Value) { CharacterBPRef = Value; } UClass* GetCharacterBPRef() const { return CharacterBPRef; } @@ -34,10 +35,11 @@ public: void SetPlayerCamera(AActor* Actor) { PlayerCamera = Actor; } AActor* GetPlayerCamera() const { return PlayerCamera; } - UFUNCTION(BlueprintCallable) - void SetCooldownDuration(CooldownType Key, float Value) { CooldownDuration[(uint8)Key] = Value; } - UFUNCTION(BlueprintCallable) - float GetCooldownDuration(CooldownType Key) const { return CooldownDuration[(uint8)Key]; } + //fix later + //UFUNCTION(BlueprintCallable) + //void SetCooldownDuration(CooldownType Key, float Value) { CooldownDuration[(uint8)Key] = Value; } + //UFUNCTION(BlueprintCallable) + //float GetCooldownDuration(CooldownType Key) const { return CooldownDuration[(uint8)Key]; } //Execute on server UFUNCTION(BlueprintCallable, Server, Reliable) @@ -57,14 +59,16 @@ public: UFUNCTION(BlueprintCallable) int32 GetCharacterLevel() const; - - //Should be ONLY executed on server!! - void SetMultipleCooldownDuration(const float* Value) ; - UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite) - FDefaultStats Stats; - UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite) - FDefaultStats MaxStats; + UPROPERTY(Replicated, Transient, EditAnywhere, BlueprintReadWrite) + TArray Stats; + UPROPERTY(Replicated, Transient, EditAnywhere, BlueprintReadWrite) + TArray MaxStats; + + UPROPERTY(Replicated, Transient, BlueprintReadWrite) + TArray CooldownDuration; + UPROPERTY(Replicated, Transient, BlueprintReadWrite) + TArray MaxCooldownDuration; private: UPROPERTY(Replicated, Transient) @@ -72,9 +76,6 @@ private: UPROPERTY(Replicated, Transient) TeamType Team; - UPROPERTY(Replicated, Transient) - float CooldownDuration[(uint8)CooldownType::SIZE] = { 0.0f, }; - UPROPERTY(Replicated, Transient) ECharacterState State; UPROPERTY(Replicated, Transient) diff --git a/Source/Promether/PrometherEnum.h b/Source/Promether/PrometherEnum.h index 1fb193f..a2bdd20 100644 --- a/Source/Promether/PrometherEnum.h +++ b/Source/Promether/PrometherEnum.h @@ -91,3 +91,41 @@ struct FUniqueObjectID int32 RandomUniqueNumber; }; +UENUM(BlueprintType) +enum class EStats : uint8 +{ + Health, + HPRegeneration, + HealAndShieldpower, + Armor, + MagicResistance, + Tenacity, + SlowRisist, + AttackSpeed, + AttackDamage, + AbilityPower, + CriticalStrikeChance, + CriticalStrikeDamage, + ArmorPenetration, + MagicPenetration, + LifeSteal, + PhysicalVamp, + Omnivamp, + AbilityHaste, + Mana, + ManaRegeneration, + Energy, + EnergyRegeneration, + AttackRange, + MovementSpeed, + GoldGeneration, + AttackDamageGrowth, + AttackSpeedGrowth, + ArmorGrowth, + MagicResistanceGrowth, + HealthGrowth, + HealthRegenerationGrowth, + ManaGrowth, + ManaRegenerationGrowth, + SIZE +}; \ No newline at end of file