Merge branch 'HappyTanuki' into SJW1024

# Conflicts:
#	Content/Character/BP_Folder/DefaultClass.uasset
#	Content/Character/Lb/Animation/ABP_Lb.uasset
#	Content/Character/Lb/Animation/R2_Anim.uasset
#	Content/Maps/DevMap.umap
#	Source/Promether/PlayerGeneric/DefaultPlayerController.cpp
#	Source/Promether/PlayerGeneric/DefaultPlayerController.h
This commit is contained in:
2023-10-10 20:53:38 +09:00
14 changed files with 227 additions and 384 deletions

View File

@@ -24,40 +24,12 @@ ADefaultPlayerCharacter::ADefaultPlayerCharacter()
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(CameraSpringArm, USpringArmComponent::SocketName);
for (uint8 i = 0; i < (uint8)EStats::SIZE; i++)
DefaultStats.Add((EStats)i, 0.0f);
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;
for (uint8 i = 0; i < (uint8)CooldownType::SIZE; i++)
CooldownDuration.Add((CooldownType)i, 0.0f);
}
void ADefaultPlayerCharacter::Tick(float DeltaTime)
@@ -104,15 +76,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 +92,19 @@ float ADefaultPlayerCharacter::TakeDamage_Implementation(float DamageAmount, str
if (Cast<UBaseAttack>(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]);
}
}

View File

@@ -97,121 +97,14 @@ public:
UFUNCTION(NetMulticast, Reliable)
void NetMulticast_Skill7();
float GetHealth() const { return Health; }
float GetHPRegeneration() const { return HPRegeneration; }
float GetHealAndShieldpower() const { return HealAndShieldpower; }
float GetArmor() const { return Armor; }
float GetMagicResistance() const { return MagicResistance; }
float GetTenacity() const { return Tenacity; }
float GetSlowRisist() const { return SlowRisist; }
float GetAttackSpeed() const { return AttackSpeed; }
float GetAttackDamage() const { return AttackDamage; }
float GetAbilityPower() const { return AbilityPower; }
float GetCriticalStrikeChance() const { return CriticalStrikeChance; }
float GetCriticalStrikeDamage() const { return CriticalStrikeDamage; }
float GetArmorPenetration() const { return ArmorPenetration; }
float GetMagicPenetration() const { return MagicPenetration; }
float GetLifeSteal() const { return LifeSteal; }
float GetPhysicalVamp() const { return PhysicalVamp; }
float GetOmnivamp() const { return Omnivamp; }
float GetAbilityHaste() const { return AbilityHaste; }
const float* GetCooldownDuration() const { return CooldownDuration; }
float GetMana() const { return Mana; }
float GetManaRegeneration() const { return ManaRegeneration; }
float GetEnergy() const { return Energy; }
float GetEnergyRegeneration() const { return EnergyRegeneration; }
float GetAttackRange() const { return AttackRange; }
float GetMovementSpeed() const { return MovementSpeed; }
float GetGoldGeneration() const { return GoldGeneration; }
float GetAttackDamageGrowth() const { return AttackDamageGrowth; }
float GetAttackSpeedGrowth() const { return AttackSpeedGrowth; }
float GetArmorGrowth() const { return ArmorGrowth; }
float GetMagicResistanceGrowth() const { return MagicResistanceGrowth; }
float GetHealthGrowth() const { return HealthGrowth; }
float GetHealthRegenerationGrowth() const { return HealthRegenerationGrowth; }
float GetManaGrowth() const { return ManaGrowth; }
float GetManaRegenerationGrowth() const { return ManaRegenerationGrowth; }
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats")
TMap<EStats, float> DefaultStats;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Stats")
TMap<CooldownType, float> CooldownDuration;
protected:
UPROPERTY(EditAnywhere)
USpringArmComponent* CameraSpringArm;
UPROPERTY(EditAnywhere)
UCameraComponent* Camera;
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;
};

View File

@@ -18,17 +18,19 @@ void ADefaultPlayerController::BeginPlay()
{
Super::BeginPlay();
if (ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player)) {
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>()) {
if (!PlayerInputMapping.IsNull()) {
InputSystem->AddMappingContext(PlayerInputMapping.LoadSynchronous(), 0);
}
else {
UE_LOG(LogTemp, Error, TEXT("AddMappingContext Failed"));
}
}
ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player);
if (!LocalPlayer) return;
UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
if (!InputSystem) return;
if (PlayerInputMapping.IsNull())
{
UE_LOG(LogTemp, Error, TEXT("AddMappingContext Failed"));
return;
}
InputSystem->AddMappingContext(PlayerInputMapping.LoadSynchronous(), 0);
this->bShowMouseCursor = true;
}
@@ -39,16 +41,29 @@ void ADefaultPlayerController::OnPossess(APawn* aPawn)
Server_SpawnPlayerCamera();
AActor *PlayerCamera = GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera();
if (PlayerCamera)
{
SetViewTarget(PlayerCamera);
UE_LOG(LogTemp, Warning, TEXT("SetViewTarget Success : %s"), *GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera()->GetName());
}
else
if (!PlayerCamera)
{
UE_LOG(LogTemp, Error, TEXT("GetPlayerCamera Failed."));
return;
}
SetViewTarget(PlayerCamera);
UE_LOG(LogTemp, Warning, TEXT("SetViewTarget Success : %s"), *GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera()->GetName());
ADefaultPlayerCharacter* ControlledPawn = GetPawn<ADefaultPlayerCharacter>();
if (!ControlledPawn) return;
ADefaultPlayerState* MyPlayerState = GetPlayerState<ADefaultPlayerState>();
if (!MyPlayerState) return;
TArray<float> DefaultStatsValue;
TArray<float> CooldownDurationValue;
ControlledPawn->DefaultStats.GenerateValueArray(DefaultStatsValue);
ControlledPawn->CooldownDuration.GenerateValueArray(CooldownDurationValue);
MyPlayerState->InitPlayerStats(DefaultStatsValue, CooldownDurationValue);
}
void ADefaultPlayerController::OnUnPossess()
@@ -66,48 +81,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<AActor>(ADefaultPlayerCamera::StaticClass(), SpawnTransform, SpawnInfo);
if (!OutContextPlayerCamera)
{
FTransform SpawnTransform = FTransform();
SpawnTransform.SetLocation(MyPawn->GetActorLocation());
OutContextPlayerCamera = GetWorld()->SpawnActor<AActor>(ADefaultPlayerCamera::StaticClass(), SpawnTransform, SpawnInfo);
if (OutContextPlayerCamera)
{
GetPlayerState<ADefaultPlayerState>()->SetPlayerCamera(OutContextPlayerCamera);
OutContextPlayerCamera->AttachToActor(GetPawn(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, false));
UE_LOG(LogTemp, Warning, TEXT("SetPlayerCamera Success : %s, %d"), *GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera()->GetName(), GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera());
}
else
{
UE_LOG(LogTemp, Error, TEXT("Camera Spawn Failed."));
}
UE_LOG(LogTemp, Error, TEXT("Camera Spawn Failed."));
return;
}
GetPlayerState<ADefaultPlayerState>()->SetPlayerCamera(OutContextPlayerCamera);
OutContextPlayerCamera->AttachToActor(GetPawn(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, EAttachmentRule::KeepWorld, false));
UE_LOG(LogTemp, Warning, TEXT("SetPlayerCamera Success : %s, %d"), *GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera()->GetName(), GetPlayerState<ADefaultPlayerState>()->GetPlayerCamera());
}
void ADefaultPlayerController::SetACharacterOutlineColor(ACharacter* Target, bool Visible)
{
if (!HasAuthority())
if (HasAuthority()) return;
ADefaultPlayerState* State = Target->GetPlayerState<ADefaultPlayerState>();
if (!State)
{
if (ADefaultPlayerState* State = Target->GetPlayerState<ADefaultPlayerState>())
{
if (State->GetTeam() == GetPlayerState<ADefaultPlayerState>()->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<ADefaultPlayerState> Failed"));
}
UE_LOG(LogTemp, Error, TEXT("GetPlayerState<ADefaultPlayerState> Failed"));
return;
}
if (State->GetTeam() == GetPlayerState<ADefaultPlayerState>()->GetTeam())
{
Target->GetMesh()->SetRenderCustomDepth(Visible);
Target->GetMesh()->CustomDepthStencilValue = 1;
}
else
{
Target->GetMesh()->SetRenderCustomDepth(Visible);
Target->GetMesh()->CustomDepthStencilValue = 2;
}
}
@@ -133,7 +146,6 @@ ADefaultPlayerController::ADefaultPlayerController()
IA_SKILL2(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill2.Skill2'")),
IA_SKILL3(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill3.Skill3'")),
IA_SKILL4(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill4.Skill4'")),
IA_SKILL4_End(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Skill4_End.Skill4_End'")),
IA_RUNESPELL1(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/RuneSpell1.RuneSpell1'")),
IA_RUNESPELL2(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/RuneSpell2.RuneSpell2'")),
IA_WARD(TEXT("/Script/EnhancedInput.InputAction'/Game/InputActions/Ward.Ward'")),
@@ -161,11 +173,6 @@ ADefaultPlayerController::ADefaultPlayerController()
UE_LOG(LogTemp, Error, TEXT("IA_ULTIMATESKILL load failed."));
return;
}
if (!IA_SKILL4_End.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_ULTIMATESKILL load failed."));
return;
}
if (!IA_RUNESPELL1.Succeeded())
{
UE_LOG(LogTemp, Error, TEXT("IA_RUNESPELL1 load failed."));
@@ -202,7 +209,6 @@ ADefaultPlayerController::ADefaultPlayerController()
Skill2Action = IA_SKILL2.Object;
Skill3Action = IA_SKILL3.Object;
Skill4Action = IA_SKILL4.Object;
Skill4_EndAction = IA_SKILL4_End.Object;
RuneSpell1Action = IA_RUNESPELL1.Object;
RuneSpell2Action = IA_RUNESPELL2.Object;
WardAction = IA_WARD.Object;
@@ -222,21 +228,20 @@ void ADefaultPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(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::Skill4);
EnhancedInputComponent->BindAction(Skill4_EndAction.Get(), ETriggerEvent::Triggered, this, &ADefaultPlayerController::Skill4_End);
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::MoveTriggered);
EnhancedInputComponent->BindAction(MoveAction.Get(), ETriggerEvent::Started, this, &ADefaultPlayerController::MoveStarted);
}
UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(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()
@@ -250,7 +255,7 @@ void ADefaultPlayerController::Skill1()
SimpleMoveToLocation(this, Location);
this->MoveToLocation(Location);
GetPawn()->SetActorRotation((GetMouseHitLocation() - Location).Rotation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill1"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
@@ -265,7 +270,7 @@ void ADefaultPlayerController::Skill2()
SimpleMoveToLocation(this, Location);
this->MoveToLocation(Location);
GetPawn()->SetActorRotation((GetMouseHitLocation() - Location).Rotation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill2"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
@@ -280,14 +285,14 @@ void ADefaultPlayerController::Skill3()
SimpleMoveToLocation(this, Location);
this->MoveToLocation(Location);
GetPawn()->SetActorRotation((GetMouseHitLocation() - Location).Rotation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill3"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill3);
}
void ADefaultPlayerController::Skill4()
void ADefaultPlayerController::Skill4Triggered()
{
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
@@ -295,14 +300,14 @@ void ADefaultPlayerController::Skill4()
SimpleMoveToLocation(this, Location);
this->MoveToLocation(Location);
GetPawn()->SetActorRotation((GetMouseHitLocation() - Location).Rotation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill4"));
UE_LOG(LogTemp, Warning, TEXT("Skill4 Triggered"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill4Started);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill4Triggered);
}
void ADefaultPlayerController::Skill4_End()
void ADefaultPlayerController::Skill4Completed()
{
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
@@ -310,9 +315,9 @@ void ADefaultPlayerController::Skill4_End()
SimpleMoveToLocation(this, Location);
this->MoveToLocation(Location);
GetPawn()->SetActorRotation((GetMouseHitLocation() - Location).Rotation());
Server_SetRotation(GetMouseHitLocation());
UE_LOG(LogTemp, Warning, TEXT("Skill4_End"));
UE_LOG(LogTemp, Warning, TEXT("Skill4 Completed"));
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Attack);
GetPlayerState<ADefaultPlayerState>()->SetAttackType(CooldownType::Skill4Comlpleted);
}
@@ -354,21 +359,11 @@ void ADefaultPlayerController::ObjectSelect()
GetHitResultUnderCursorForObjects(ObjectTypes, true, HitResult);
if (ACharacter* HitObject = Cast<ACharacter>(HitResult.GetActor()))
{
UE_LOG(LogTemp, Warning, TEXT("%s"), *HitObject->GetName());
SetACharacterOutlineColor(HitObject, true);
}
}
ACharacter* HitObject = Cast<ACharacter>(HitResult.GetActor());
if (!HitObject) return;
void ADefaultPlayerController::MoveTriggered()
{
Move();
}
void ADefaultPlayerController::MoveStarted()
{
Move();
UE_LOG(LogTemp, Warning, TEXT("%s"), *HitObject->GetName());
SetACharacterOutlineColor(HitObject, true);
}
void ADefaultPlayerController::Move()
@@ -380,13 +375,26 @@ void ADefaultPlayerController::Move()
this->MoveToLocation(Destination);
}
void ADefaultPlayerController::Multicast_SetRotation_Implementation(FVector MouseHitLocation)
{
FVector Location = GetPawn()->GetActorLocation();
Location.Z = 0;
GetPawn()->SetActorRotation((MouseHitLocation - Location).Rotation());
}
void ADefaultPlayerController::Server_SetRotation_Implementation(FVector MouseHitLocation)
{
Multicast_SetRotation(MouseHitLocation);
}
FVector ADefaultPlayerController::GetMouseHitLocation()
{
FHitResult HitResult;
GetHitResultUnderCursor(ECollisionChannel::ECC_Visibility, true, HitResult);
HitResult.Location.Z = 0;
UE_LOG(LogTemp, Warning, TEXT("Client%d MoveTo : (%f, %f)"), GPlayInEditorID, HitResult.Location.X, HitResult.Location.Y);
//UE_LOG(LogTemp, Warning, TEXT("Client%d MoveTo : (%f, %f)"), GPlayInEditorID, HitResult.Location.X, HitResult.Location.Y);
FVector ActorLocation = GetPawn()->GetActorLocation();
ActorLocation.Z = 0;
@@ -399,22 +407,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;
}
@@ -499,18 +506,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<ADefaultPlayerState>()->SetState(ECharacterState::Idle);
UE_LOG(LogTemp, Warning, TEXT("Server MoveCompleted"));
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Client%d MoveCompleted"), GPlayInEditorID);
}
GetPlayerState<ADefaultPlayerState>()->SetState(ECharacterState::Idle);
}
void ADefaultPlayerController::Attack()

View File

@@ -34,20 +34,24 @@ public:
void Skill1();
void Skill2();
void Skill3();
void Skill4();
void Skill4_End();
void Skill4Triggered();
void Skill4Completed();
void RuneSpell1();
void RuneSpell2();
void Ward();
void Bomb();
void ObjectSelect();
void MoveTriggered();
void MoveStarted();
void Move();
UFUNCTION(Server, Reliable)
void MoveToLocation(FVector Location);
UFUNCTION(NetMulticast, Reliable)
void Multicast_SetRotation(FVector MouseHitLocation);
UFUNCTION(Server, Reliable)
void Server_SetRotation(FVector MouseHitLocation);
FVector GetMouseHitLocation();
UFUNCTION(BlueprintCallable, Category = "AI|Navigation")
@@ -72,8 +76,6 @@ private:
TSoftObjectPtr<UInputAction> Skill3Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> Skill4Action;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> Skill4_EndAction;
UPROPERTY(EditAnywhere, Category = "Input")
TSoftObjectPtr<UInputAction> RuneSpell1Action;
UPROPERTY(EditAnywhere, Category = "Input")

View File

@@ -26,46 +26,18 @@ void ADefaultPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>&
DOREPLIFETIME(ADefaultPlayerState, PlayerCamera);
}
void ADefaultPlayerState::InitPlayerStats()
void ADefaultPlayerState::InitPlayerStats_Implementation(const TArray<float>& StatsValue, const TArray<float>& CooldownDurationValue)
{
ADefaultPlayerCharacter* Initializer = Cast<ADefaultPlayerCharacter>(CharacterBPRef);
MaxStats.Append(StatsValue);
Stats.Append(StatsValue);
CooldownDuration.Append(CooldownDurationValue);
MaxCooldownDuration.Append(CooldownDurationValue);
Stats.Health = Initializer->GetHealth();
Stats.HPRegeneration = Initializer->GetHPRegeneration();
Stats.HealAndShieldpower = Initializer->GetHealAndShieldpower();
Stats.Armor = Initializer->GetArmor();
Stats.MagicResistance = Initializer->GetMagicResistance();
Stats.Tenacity = Initializer->GetTenacity();
Stats.SlowRisist = Initializer->GetSlowRisist();
Stats.AttackSpeed = Initializer->GetAttackSpeed();
Stats.AttackDamage = Initializer->GetAttackDamage();
Stats.AbilityPower = Initializer->GetAbilityPower();
Stats.CriticalStrikeChance = Initializer->GetCriticalStrikeChance();
Stats.CriticalStrikeDamage = Initializer->GetCriticalStrikeDamage();
Stats.ArmorPenetration = Initializer->GetArmorPenetration();
Stats.MagicPenetration = Initializer->GetMagicPenetration();
Stats.LifeSteal = Initializer->GetLifeSteal();
Stats.PhysicalVamp = Initializer->GetPhysicalVamp();
Stats.Omnivamp = Initializer->GetOmnivamp();
Stats.AbilityHaste = Initializer->GetAbilityHaste();
SetMultipleCooldownDuration(Initializer->GetCooldownDuration());
Stats.Mana = Initializer->GetMana();
Stats.ManaRegeneration = Initializer->GetManaRegeneration();
Stats.Energy = Initializer->GetEnergy();
Stats.EnergyRegeneration = Initializer->GetEnergyRegeneration();
Stats.AttackRange = Initializer->GetAttackRange();
Stats.MovementSpeed = Initializer->GetMovementSpeed();
Stats.GoldGeneration = Initializer->GetGoldGeneration();
Stats.AttackDamageGrowth = Initializer->GetAttackDamageGrowth();
Stats.AttackSpeedGrowth = Initializer->GetAttackSpeedGrowth();
Stats.ArmorGrowth = Initializer->GetArmorGrowth();
Stats.MagicResistanceGrowth = Initializer->GetMagicResistanceGrowth();
Stats.HealthGrowth = Initializer->GetHealthGrowth();
Stats.HealthRegenerationGrowth = Initializer->GetHealthRegenerationGrowth();
Stats.ManaGrowth = Initializer->GetManaGrowth();
Stats.ManaRegenerationGrowth = Initializer->GetManaRegenerationGrowth();
for (float Value : StatsValue)
{
UE_LOG(LogTemp, Warning, TEXT("Values: %f"), Value);
}
}
void ADefaultPlayerState::NetMulticast_SetAttackType_Implementation(CooldownType Value)
@@ -92,8 +64,3 @@ int32 ADefaultPlayerState::GetCharacterLevel() const
{
return int32();
}
void ADefaultPlayerState::SetMultipleCooldownDuration(const float* Value)
{
std::memcpy(&CooldownDuration, Value, sizeof(float) * (uint8)CooldownType::SIZE);
}

View File

@@ -21,7 +21,8 @@ public:
ADefaultPlayerState();
void GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const override;
void InitPlayerStats();
UFUNCTION(Server, Reliable)
void InitPlayerStats(const TArray<float>& StatsValue, const TArray<float>& 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<float> Stats;
UPROPERTY(Replicated, Transient, EditAnywhere, BlueprintReadWrite)
TArray<float> MaxStats;
UPROPERTY(Replicated, Transient, BlueprintReadWrite)
TArray<float> CooldownDuration;
UPROPERTY(Replicated, Transient, BlueprintReadWrite)
TArray<float> 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)

View File

@@ -1,6 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "PerformSkill.h"
// Add default functionality here for any IPerformSkill functions that are not pure virtual.

View File

@@ -1,28 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "PerformSkill.generated.h"
// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UPerformSkill : public UInterface
{
GENERATED_BODY()
};
/**
*
*/
class PROMETHER_API IPerformSkill
{
GENERATED_BODY()
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
virtual void Skill4Started() = 0;
virtual void Skill4Triggered() = 0;
virtual void Skill4Completed() = 0;
};

View File

@@ -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
};