diff --git a/Content/Animations/Boss/AB_Boss.uasset b/Content/Animations/Boss/AB_Boss.uasset index cd2aad1..12de586 100644 --- a/Content/Animations/Boss/AB_Boss.uasset +++ b/Content/Animations/Boss/AB_Boss.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:736e52ebc05ae9c3efe35b7205c9fcab59da9306553d3fe7dccbd6de73697a96 -size 317663 +oid sha256:62ec006f5b165f6752c5cbf4cecb1e13bd4a39bbb07f2de3e6b2d117e625e514 +size 302681 diff --git a/Content/BlueprintAI/AI/AIBruh.uasset b/Content/BlueprintAI/AI/AIBruh.uasset index 9bce8cf..be176e5 100644 --- a/Content/BlueprintAI/AI/AIBruh.uasset +++ b/Content/BlueprintAI/AI/AIBruh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ebee0525ea14664d1a15b9b39e2ef7b8baf14367d89f5c5fc48cac9be9925f03 -size 98827 +oid sha256:f62e04e0c4b999171683839ce55019fcba45f1c1d6218fe1675e2e435ccba460 +size 100073 diff --git a/Content/BlueprintAI/AI/AIBruh_Boss.uasset b/Content/BlueprintAI/AI/AIBruh_Boss.uasset index 6eb92c6..284f3c1 100644 --- a/Content/BlueprintAI/AI/AIBruh_Boss.uasset +++ b/Content/BlueprintAI/AI/AIBruh_Boss.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:062f7e63bdfa15e4746e8be1dcfb77a939b2709a1b6a3e5ecf2e801a2cafb761 -size 97126 +oid sha256:60414b698d8a8a00875b69592bfeb75736ac263c3337a58e27d36cc376ed99f3 +size 143105 diff --git a/Content/Levels/Enemy_Test.umap b/Content/Levels/Enemy_Test.umap index 4c5b352..cb9bcee 100644 --- a/Content/Levels/Enemy_Test.umap +++ b/Content/Levels/Enemy_Test.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:753de9294e7e0b871ed0f04cddc57c4fee9dde06c222b6d7fa64f02f93de358c -size 43316 +oid sha256:aede3e25bfdba2a4612c55a6ff0a7fbe65853fa476d74750c3dd3295f7398d78 +size 45107 diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp index 84ecc68..defe1f4 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.cpp @@ -24,8 +24,8 @@ ATurnBaseCombatV2::ATurnBaseCombatV2() HUDWidget = HUDWidgetClass.Class; static ConstructorHelpers::FClassFinder StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns")); ThornsStatusEffect = StatusEffectThornsClassFinder.Class; - static ConstructorHelpers::FClassFinder StatusEffectDOTClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime")); - DOTStatusEffect = StatusEffectDOTClassFinder.Class; + static ConstructorHelpers::FClassFinder StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime")); + DOTStatusEffect = StatusEffectDotClassFinder.Class; static ConstructorHelpers::FClassFinder DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI")); DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class; @@ -35,7 +35,7 @@ ATurnBaseCombatV2::ATurnBaseCombatV2() } } -void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot) +void ATurnBaseCombatV2::StartCombat(AActor* Enemy, const bool bWasShot) { if (Enemy == nullptr) return; EnemyActor = Enemy; @@ -48,7 +48,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot) bIsInCombat = true; UBlackboardComponent* EnemyBlackboard = Cast(Enemy->GetInstigatorController())->GetBlackboardComponent(); Cast(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden); - + //Disable Character Movement APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerController->SetIgnoreMoveInput(true); @@ -56,16 +56,41 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot) PlayerController->SetInputMode(FInputModeGameAndUI()); PlayerController->bShowMouseCursor = true; + FProperty* IsBossProperty = FindFieldChecked(EnemyActor->GetClass(), "IsBoss"); + const FBoolProperty* IsBossBoolProperty = CastFieldChecked(IsBossProperty); + if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor)) + { + FOutputDeviceNull AR; + const FString Command = FString::Printf(TEXT("TriggerCombatAnimation true")); + EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); + + FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); + Direction.Normalize(); + FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); + const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), EnemyActor->GetActorLocation()); + LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; + PlayerController->SetControlRotation(LookAtRotation); + } + else + { + FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); + Direction.Normalize(); + FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); + const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), Cast(EnemyActor->FindComponentByClass())->GetComponentLocation()); + LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; + PlayerController->SetControlRotation(LookAtRotation); + } + FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation(); Direction.Normalize(); FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator(); - const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), Cast(EnemyActor->FindComponentByClass())->GetComponentLocation()); + const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast(PlayerActor->FindComponentByClass())->GetComponentLocation(), EnemyActor->GetActorLocation()); LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch; PlayerController->SetControlRotation(LookAtRotation); if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return; EnemyBlackboard->SetValueAsBool("IsInCombat", true); - FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health")); + const FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health")); int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr(Enemy); EnemyHealth = EnemyHealthPtr; @@ -85,7 +110,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot) //DrawDebugPoint(GetWorld(), Enemy->GetActorLocation(), 10, FColor::Red, false, 10); } -void ATurnBaseCombatV2::CombatCheck(bool bWasShot) +void ATurnBaseCombatV2::CombatCheck(const bool bWasShot) { const UBlackboardComponent* EnemyBlackboard = Cast(EnemyActor->GetInstigatorController())->GetBlackboardComponent(); @@ -99,8 +124,8 @@ void ATurnBaseCombatV2::CombatCheck(bool bWasShot) BaseDamageMultiplier = 1.0f; DamageMultiplierTextBlock->SetText(FText::FromString("")); - FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed")); - float* EnemyReactionSpeedPtr = ReactionSpeedProperty->ContainerPtrToValuePtr(EnemyActor); + const FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed")); + const float* EnemyReactionSpeedPtr = ReactionSpeedProperty->ContainerPtrToValuePtr(EnemyActor); CurrentComboString = ""; UpdateComboString(CurrentComboString); @@ -150,6 +175,18 @@ void ATurnBaseCombatV2::EndCombat() PlayerController->SetIgnoreLookInput(false); PlayerController->SetInputMode(FInputModeGameOnly()); PlayerController->bShowMouseCursor = false; + + if (IsValid(EnemyActor)) + { + FProperty* IsBossProperty = FindFieldChecked(EnemyActor->GetClass(), "IsBoss"); + const FBoolProperty* IsBossBoolProperty = CastFieldChecked(IsBossProperty); + if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor)) + { + FOutputDeviceNull AR; + const FString Command = FString::Printf(TEXT("TriggerCombatAnimation false")); + EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); + } + } } void ATurnBaseCombatV2::BeginPlay() @@ -343,7 +380,7 @@ void ATurnBaseCombatV2::RevertActionPoints() UpdateActionPoints(); } -void ATurnBaseCombatV2::DamagePlayer(int Damage, FString DamageType) +void ATurnBaseCombatV2::DamagePlayer(int Damage, const FString& DamageType) { *PlayerHealth -= FMath::Clamp(Damage * BaseDefenseMultiplier, 0, 100); UpdateProgressBars(); @@ -351,6 +388,15 @@ void ATurnBaseCombatV2::DamagePlayer(int Damage, FString DamageType) if (*EnemyHealth <= 0) { EndCombat(); + FProperty* IsBossProperty = FindFieldChecked(EnemyActor->GetClass(), "IsBoss"); + const FBoolProperty* IsBossBoolProperty = CastFieldChecked(IsBossProperty); + if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor)) + { + FOutputDeviceNull AR; + const FString Command = FString::Printf(TEXT("TriggerDeathAnimation")); + EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); + return; + } EnemyActor->Destroy(); return; } @@ -368,18 +414,34 @@ void ATurnBaseCombatV2::DamagePlayer(int Damage, FString DamageType) const FString Command2 = FString::Printf(TEXT("TriggerAttackAnimation")); EnemyActor->CallFunctionByNameWithArguments(*Command2, AR, nullptr, true); - //Ends Combat if either the player or enemy is dead } -void ATurnBaseCombatV2::DamageEnemy(int Damage, FString DamageType) +void ATurnBaseCombatV2::DamageEnemy(int Damage, const FString& DamageType) { *EnemyHealth -= FMath::Clamp(Damage * BaseDamageMultiplier, 0, 100); UpdateProgressBars(); AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage * BaseDamageMultiplier) + " HP by " + DamageType + "."); + + FProperty* IsBossProperty = FindFieldChecked(EnemyActor->GetClass(), "IsBoss"); + const FBoolProperty* IsBossBoolProperty = CastFieldChecked(IsBossProperty); + if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor)) + { + FOutputDeviceNull AR; + const FString Command = FString::Printf(TEXT("TriggerDamageAnimation")); + EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); + } + //Ends Combat if either the player or enemy is dead if (*EnemyHealth <= 0) { EndCombat(); + if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor)) + { + FOutputDeviceNull AR; + const FString Command = FString::Printf(TEXT("TriggerDeathAnimation")); + EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true); + return; + } EnemyActor->Destroy(); return; } @@ -394,8 +456,8 @@ void ATurnBaseCombatV2::DamageEnemy(int Damage, FString DamageType) void ATurnBaseCombatV2::UpdateProgressBars() const { - FProperty* MaxHealthProperty = EnemyActor->GetClass()->FindPropertyByName(FName("MaxHealth")); - int32* EnemyMaxHealthPtr = MaxHealthProperty->ContainerPtrToValuePtr(EnemyActor); + const FProperty* MaxHealthProperty = EnemyActor->GetClass()->FindPropertyByName(FName("MaxHealth")); + const int32* EnemyMaxHealthPtr = MaxHealthProperty->ContainerPtrToValuePtr(EnemyActor); EnemyHealthBar->SetPercent(static_cast(*EnemyHealth) / static_cast(*EnemyMaxHealthPtr)); } @@ -404,12 +466,12 @@ float ATurnBaseCombatV2::CalculateEscapePercentage() const return FMath::RandRange(0.1f, 0.9f); } -bool ATurnBaseCombatV2::IsValidCombo(const FString Combo) const +bool ATurnBaseCombatV2::IsValidCombo(const FString& Combo) const { return ValidCombos.Contains(Combo); } -bool ATurnBaseCombatV2::IsSpecialCombo(const FString Combo) const +bool ATurnBaseCombatV2::IsSpecialCombo(const FString& Combo) const { return SpecialCombos.Contains(Combo); } @@ -558,7 +620,7 @@ void ATurnBaseCombatV2::RunButtonOnClick() EndCombat(); } -void ATurnBaseCombatV2::UpdateComboString(FString NewCombo) const +void ATurnBaseCombatV2::UpdateComboString(const FString& NewCombo) const { CurrentComboTextBlock->SetText(FText::FromString("?")); CurrentComboTextBlock1->SetText(FText::FromString("?")); @@ -587,12 +649,12 @@ void ATurnBaseCombatV2::UpdateComboString(FString NewCombo) const } } -void ATurnBaseCombatV2::UpdateActionPoints() const +void ATurnBaseCombatV2::UpdateActionPoints() { return; } -void ATurnBaseCombatV2::AddBattleLogMessage(FString Message) +void ATurnBaseCombatV2::AddBattleLogMessage(const FString& Message) { BattleLog.Append(Message + "\n"); UpdateBattleLog(); diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h index 171070e..b891b7f 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/TurnBaseCombatV2.h @@ -111,8 +111,8 @@ public: FOnPlayerTurn OnPlayerTurn; FOnEnemyTurn OnEnemyTurn; - void DamagePlayer(int Damage, FString DamageType = "unknown"); - void DamageEnemy(int Damage, FString DamageType = "unknown"); + void DamagePlayer(int Damage, const FString& DamageType = "unknown"); + void DamageEnemy(int Damage, const FString& DamageType = "unknown"); protected: virtual void BeginPlay() override; @@ -129,8 +129,8 @@ protected: float CalculateEscapePercentage() const; private: - bool IsValidCombo(FString Combo) const; - bool IsSpecialCombo(FString Combo) const; + bool IsValidCombo(const FString& Combo) const; + bool IsSpecialCombo(const FString& Combo) const; UPROPERTY() APostProcessVolume* PostProcessVolume; @@ -216,10 +216,10 @@ private: UFUNCTION() void RunButtonOnClick(); - void UpdateComboString(FString NewCombo) const; - void UpdateActionPoints() const; + void UpdateComboString(const FString& NewCombo) const; + static void UpdateActionPoints(); - void AddBattleLogMessage(FString Message); + void AddBattleLogMessage(const FString& Message); void ClearBattleLog(); void UpdateBattleLog(); void UpdateResourceBars() const;