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;
|
||||
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectThornsClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_Thorns"));
|
||||
ThornsStatusEffect = StatusEffectThornsClassFinder.Class;
|
||||
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDOTClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime"));
|
||||
DOTStatusEffect = StatusEffectDOTClassFinder.Class;
|
||||
static ConstructorHelpers::FClassFinder<UStatusEffect> StatusEffectDotClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_DamageOverTime"));
|
||||
DOTStatusEffect = StatusEffectDotClassFinder.Class;
|
||||
|
||||
static ConstructorHelpers::FClassFinder<UUserWidget> 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;
|
||||
@ -56,16 +56,41 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot)
|
||||
PlayerController->SetInputMode(FInputModeGameAndUI());
|
||||
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();
|
||||
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());
|
||||
const FRotator NewRotation = UKismetMathLibrary::FindLookAtRotation(Cast<UCameraComponent>(PlayerActor->FindComponentByClass<UCameraComponent>())->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<int32>(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<AAIController>(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<float>(EnemyActor);
|
||||
const FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed"));
|
||||
const float* EnemyReactionSpeedPtr = ReactionSpeedProperty->ContainerPtrToValuePtr<float>(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<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()
|
||||
@ -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<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();
|
||||
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<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
|
||||
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<int32>(EnemyActor);
|
||||
const FProperty* MaxHealthProperty = EnemyActor->GetClass()->FindPropertyByName(FName("MaxHealth"));
|
||||
const int32* EnemyMaxHealthPtr = MaxHealthProperty->ContainerPtrToValuePtr<int32>(EnemyActor);
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user