Updated Boss Character to Trigger Animations
This commit is contained in:
parent
f8936a03f7
commit
cef7b1895b
BIN
Content/Animations/Boss/AB_Boss.uasset
(Stored with Git LFS)
BIN
Content/Animations/Boss/AB_Boss.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/BlueprintAI/AI/AIBruh.uasset
(Stored with Git LFS)
BIN
Content/BlueprintAI/AI/AIBruh.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/BlueprintAI/AI/AIBruh_Boss.uasset
(Stored with Git LFS)
BIN
Content/BlueprintAI/AI/AIBruh_Boss.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/Enemy_Test.umap
(Stored with Git LFS)
BIN
Content/Levels/Enemy_Test.umap
(Stored with Git LFS)
Binary file not shown.
@ -24,8 +24,8 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
|
|||||||
HUDWidget = HUDWidgetClass.Class;
|
HUDWidget = HUDWidgetClass.Class;
|
||||||
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns"));
|
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns"));
|
||||||
ThornsStatusEffect = StatusEffectThornsClassFinder.Class;
|
ThornsStatusEffect = StatusEffectThornsClassFinder.Class;
|
||||||
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDOTClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime"));
|
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime"));
|
||||||
DOTStatusEffect = StatusEffectDOTClassFinder.Class;
|
DOTStatusEffect = StatusEffectDotClassFinder.Class;
|
||||||
|
|
||||||
static ConstructorHelpers::FClassFinder<UUserWidget> DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI"));
|
static ConstructorHelpers::FClassFinder<UUserWidget> DeathScreenWidgetClass(TEXT("/Game/Blueprints/Death_UI/Death_UI"));
|
||||||
DeathScreenWidgetSubclass = DeathScreenWidgetClass.Class;
|
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;
|
if (Enemy == nullptr) return;
|
||||||
EnemyActor = Enemy;
|
EnemyActor = Enemy;
|
||||||
@ -48,7 +48,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot)
|
|||||||
bIsInCombat = true;
|
bIsInCombat = true;
|
||||||
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
||||||
Cast<UQuestSystem>(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden);
|
Cast<UQuestSystem>(PlayerActor->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden);
|
||||||
|
|
||||||
//Disable Character Movement
|
//Disable Character Movement
|
||||||
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
||||||
PlayerController->SetIgnoreMoveInput(true);
|
PlayerController->SetIgnoreMoveInput(true);
|
||||||
@ -56,16 +56,41 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot)
|
|||||||
PlayerController->SetInputMode(FInputModeGameAndUI());
|
PlayerController->SetInputMode(FInputModeGameAndUI());
|
||||||
PlayerController->bShowMouseCursor = true;
|
PlayerController->bShowMouseCursor = true;
|
||||||
|
|
||||||
|
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
||||||
|
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(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<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->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<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), Cast<USkeletalMeshComponent>(EnemyActor->FindComponentByClass<USkeletalMeshComponent>())->GetComponentLocation());
|
||||||
|
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
||||||
|
PlayerController->SetControlRotation(LookAtRotation);
|
||||||
|
}
|
||||||
|
|
||||||
FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
|
FVector Direction = Enemy->GetActorLocation() - PlayerActor->GetActorLocation();
|
||||||
Direction.Normalize();
|
Direction.Normalize();
|
||||||
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
FRotator LookAtRotation = FRotationMatrix::MakeFromX(Direction).Rotator();
|
||||||
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), Cast<USkeletalMeshComponent>(EnemyActor->FindComponentByClass<USkeletalMeshComponent>())->GetComponentLocation());
|
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->GetComponentLocation(), EnemyActor->GetActorLocation());
|
||||||
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
LookAtRotation.Pitch = NewRotation.Pitch - PlayerActor->GetActorRotation().Pitch;
|
||||||
PlayerController->SetControlRotation(LookAtRotation);
|
PlayerController->SetControlRotation(LookAtRotation);
|
||||||
|
|
||||||
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
|
if (EnemyBlackboard->GetValueAsBool("IsInCombat")) return;
|
||||||
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
EnemyBlackboard->SetValueAsBool("IsInCombat", true);
|
||||||
FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
|
const FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
|
||||||
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
|
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
|
||||||
EnemyHealth = EnemyHealthPtr;
|
EnemyHealth = EnemyHealthPtr;
|
||||||
|
|
||||||
@ -85,7 +110,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot)
|
|||||||
//DrawDebugPoint(GetWorld(), Enemy->GetActorLocation(), 10, FColor::Red, false, 10);
|
//DrawDebugPoint(GetWorld(), Enemy->GetActorLocation(), 10, FColor::Red, false, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::CombatCheck(bool bWasShot)
|
void ATurnBaseCombatV2::CombatCheck(const bool bWasShot)
|
||||||
{
|
{
|
||||||
const UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
|
const UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
|
||||||
|
|
||||||
@ -99,8 +124,8 @@ void ATurnBaseCombatV2::CombatCheck(bool bWasShot)
|
|||||||
BaseDamageMultiplier = 1.0f;
|
BaseDamageMultiplier = 1.0f;
|
||||||
DamageMultiplierTextBlock->SetText(FText::FromString(""));
|
DamageMultiplierTextBlock->SetText(FText::FromString(""));
|
||||||
|
|
||||||
FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed"));
|
const FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed"));
|
||||||
float* EnemyReactionSpeedPtr = ReactionSpeedProperty->ContainerPtrToValuePtr<float>(EnemyActor);
|
const float* EnemyReactionSpeedPtr = ReactionSpeedProperty->ContainerPtrToValuePtr<float>(EnemyActor);
|
||||||
|
|
||||||
CurrentComboString = "";
|
CurrentComboString = "";
|
||||||
UpdateComboString(CurrentComboString);
|
UpdateComboString(CurrentComboString);
|
||||||
@ -150,6 +175,18 @@ void ATurnBaseCombatV2::EndCombat()
|
|||||||
PlayerController->SetIgnoreLookInput(false);
|
PlayerController->SetIgnoreLookInput(false);
|
||||||
PlayerController->SetInputMode(FInputModeGameOnly());
|
PlayerController->SetInputMode(FInputModeGameOnly());
|
||||||
PlayerController->bShowMouseCursor = false;
|
PlayerController->bShowMouseCursor = false;
|
||||||
|
|
||||||
|
if (IsValid(EnemyActor))
|
||||||
|
{
|
||||||
|
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
||||||
|
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(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()
|
void ATurnBaseCombatV2::BeginPlay()
|
||||||
@ -343,7 +380,7 @@ void ATurnBaseCombatV2::RevertActionPoints()
|
|||||||
UpdateActionPoints();
|
UpdateActionPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::DamagePlayer(int Damage, FString DamageType)
|
void ATurnBaseCombatV2::DamagePlayer(int Damage, const FString& DamageType)
|
||||||
{
|
{
|
||||||
*PlayerHealth -= FMath::Clamp(Damage * BaseDefenseMultiplier, 0, 100);
|
*PlayerHealth -= FMath::Clamp(Damage * BaseDefenseMultiplier, 0, 100);
|
||||||
UpdateProgressBars();
|
UpdateProgressBars();
|
||||||
@ -351,6 +388,15 @@ void ATurnBaseCombatV2::DamagePlayer(int Damage, FString DamageType)
|
|||||||
if (*EnemyHealth <= 0)
|
if (*EnemyHealth <= 0)
|
||||||
{
|
{
|
||||||
EndCombat();
|
EndCombat();
|
||||||
|
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
||||||
|
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);
|
||||||
|
if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
|
||||||
|
{
|
||||||
|
FOutputDeviceNull AR;
|
||||||
|
const FString Command = FString::Printf(TEXT("TriggerDeathAnimation"));
|
||||||
|
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
EnemyActor->Destroy();
|
EnemyActor->Destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -368,18 +414,34 @@ void ATurnBaseCombatV2::DamagePlayer(int Damage, FString DamageType)
|
|||||||
|
|
||||||
const FString Command2 = FString::Printf(TEXT("TriggerAttackAnimation"));
|
const FString Command2 = FString::Printf(TEXT("TriggerAttackAnimation"));
|
||||||
EnemyActor->CallFunctionByNameWithArguments(*Command2, AR, nullptr, true);
|
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);
|
*EnemyHealth -= FMath::Clamp(Damage * BaseDamageMultiplier, 0, 100);
|
||||||
UpdateProgressBars();
|
UpdateProgressBars();
|
||||||
AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage * BaseDamageMultiplier) + " HP by " + DamageType + ".");
|
AddBattleLogMessage("Enemy was damaged for " + FString::FromInt(Damage * BaseDamageMultiplier) + " HP by " + DamageType + ".");
|
||||||
|
|
||||||
|
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
|
||||||
|
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(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
|
//Ends Combat if either the player or enemy is dead
|
||||||
if (*EnemyHealth <= 0)
|
if (*EnemyHealth <= 0)
|
||||||
{
|
{
|
||||||
EndCombat();
|
EndCombat();
|
||||||
|
if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor))
|
||||||
|
{
|
||||||
|
FOutputDeviceNull AR;
|
||||||
|
const FString Command = FString::Printf(TEXT("TriggerDeathAnimation"));
|
||||||
|
EnemyActor->CallFunctionByNameWithArguments(*Command, AR, nullptr, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
EnemyActor->Destroy();
|
EnemyActor->Destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -394,8 +456,8 @@ void ATurnBaseCombatV2::DamageEnemy(int Damage, FString DamageType)
|
|||||||
|
|
||||||
void ATurnBaseCombatV2::UpdateProgressBars() const
|
void ATurnBaseCombatV2::UpdateProgressBars() const
|
||||||
{
|
{
|
||||||
FProperty* MaxHealthProperty = EnemyActor->GetClass()->FindPropertyByName(FName("MaxHealth"));
|
const FProperty* MaxHealthProperty = EnemyActor->GetClass()->FindPropertyByName(FName("MaxHealth"));
|
||||||
int32* EnemyMaxHealthPtr = MaxHealthProperty->ContainerPtrToValuePtr<int32>(EnemyActor);
|
const int32* EnemyMaxHealthPtr = MaxHealthProperty->ContainerPtrToValuePtr<int32>(EnemyActor);
|
||||||
EnemyHealthBar->SetPercent(static_cast<float>(*EnemyHealth) / static_cast<float>(*EnemyMaxHealthPtr));
|
EnemyHealthBar->SetPercent(static_cast<float>(*EnemyHealth) / static_cast<float>(*EnemyMaxHealthPtr));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,12 +466,12 @@ float ATurnBaseCombatV2::CalculateEscapePercentage() const
|
|||||||
return FMath::RandRange(0.1f, 0.9f);
|
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);
|
return ValidCombos.Contains(Combo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ATurnBaseCombatV2::IsSpecialCombo(const FString Combo) const
|
bool ATurnBaseCombatV2::IsSpecialCombo(const FString& Combo) const
|
||||||
{
|
{
|
||||||
return SpecialCombos.Contains(Combo);
|
return SpecialCombos.Contains(Combo);
|
||||||
}
|
}
|
||||||
@ -558,7 +620,7 @@ void ATurnBaseCombatV2::RunButtonOnClick()
|
|||||||
EndCombat();
|
EndCombat();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::UpdateComboString(FString NewCombo) const
|
void ATurnBaseCombatV2::UpdateComboString(const FString& NewCombo) const
|
||||||
{
|
{
|
||||||
CurrentComboTextBlock->SetText(FText::FromString("?"));
|
CurrentComboTextBlock->SetText(FText::FromString("?"));
|
||||||
CurrentComboTextBlock1->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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::AddBattleLogMessage(FString Message)
|
void ATurnBaseCombatV2::AddBattleLogMessage(const FString& Message)
|
||||||
{
|
{
|
||||||
BattleLog.Append(Message + "\n");
|
BattleLog.Append(Message + "\n");
|
||||||
UpdateBattleLog();
|
UpdateBattleLog();
|
||||||
|
@ -111,8 +111,8 @@ public:
|
|||||||
FOnPlayerTurn OnPlayerTurn;
|
FOnPlayerTurn OnPlayerTurn;
|
||||||
FOnEnemyTurn OnEnemyTurn;
|
FOnEnemyTurn OnEnemyTurn;
|
||||||
|
|
||||||
void DamagePlayer(int Damage, FString DamageType = "unknown");
|
void DamagePlayer(int Damage, const FString& DamageType = "unknown");
|
||||||
void DamageEnemy(int Damage, FString DamageType = "unknown");
|
void DamageEnemy(int Damage, const FString& DamageType = "unknown");
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
@ -129,8 +129,8 @@ protected:
|
|||||||
float CalculateEscapePercentage() const;
|
float CalculateEscapePercentage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool IsValidCombo(FString Combo) const;
|
bool IsValidCombo(const FString& Combo) const;
|
||||||
bool IsSpecialCombo(FString Combo) const;
|
bool IsSpecialCombo(const FString& Combo) const;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
APostProcessVolume* PostProcessVolume;
|
APostProcessVolume* PostProcessVolume;
|
||||||
@ -216,10 +216,10 @@ private:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void RunButtonOnClick();
|
void RunButtonOnClick();
|
||||||
|
|
||||||
void UpdateComboString(FString NewCombo) const;
|
void UpdateComboString(const FString& NewCombo) const;
|
||||||
void UpdateActionPoints() const;
|
static void UpdateActionPoints();
|
||||||
|
|
||||||
void AddBattleLogMessage(FString Message);
|
void AddBattleLogMessage(const FString& Message);
|
||||||
void ClearBattleLog();
|
void ClearBattleLog();
|
||||||
void UpdateBattleLog();
|
void UpdateBattleLog();
|
||||||
void UpdateResourceBars() const;
|
void UpdateResourceBars() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user