Bugfix Enemy Always Started First
This commit is contained in:
parent
37268a3dc2
commit
4f336263fb
BIN
Content/BlueprintAI/AI/AIBruh.uasset
(Stored with Git LFS)
BIN
Content/BlueprintAI/AI/AIBruh.uasset
(Stored with Git LFS)
Binary file not shown.
@ -76,7 +76,7 @@ void UHoldToInitCombat::OnClickDown()
|
|||||||
EnemyBlackboard = Cast<AAIController>(TargetEnemy->GetInstigatorController())->GetBlackboardComponent();
|
EnemyBlackboard = Cast<AAIController>(TargetEnemy->GetInstigatorController())->GetBlackboardComponent();
|
||||||
if (!EnemyBlackboard->GetValueAsBool("WasInCombat"))
|
if (!EnemyBlackboard->GetValueAsBool("WasInCombat"))
|
||||||
{
|
{
|
||||||
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy);
|
Cast<ATurnBaseCombatV2>(GetWorld()->GetGameState())->StartCombat(TargetEnemy, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InitCombatWidget->SetVisibility(ESlateVisibility::Hidden);
|
InitCombatWidget->SetVisibility(ESlateVisibility::Hidden);
|
||||||
|
@ -32,7 +32,7 @@ ATurnBaseCombatV2::ATurnBaseCombatV2()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
void ATurnBaseCombatV2::StartCombat(AActor* Enemy, bool bWasShot)
|
||||||
{
|
{
|
||||||
if (Enemy == nullptr) return;
|
if (Enemy == nullptr) return;
|
||||||
EnemyActor = Enemy;
|
EnemyActor = Enemy;
|
||||||
@ -42,7 +42,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
|||||||
EscapePercentageTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString(FString::FromInt(EscapePercentage * 100)), FText::FromString("%")));
|
EscapePercentageTextBlock->SetText(FText::Join(FText::FromString(""), FText::FromString(FString::FromInt(EscapePercentage * 100)), FText::FromString("%")));
|
||||||
bIsInCombat = true;
|
bIsInCombat = true;
|
||||||
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(Enemy->GetInstigatorController())->GetBlackboardComponent();
|
||||||
|
|
||||||
//Disable Character Movement
|
//Disable Character Movement
|
||||||
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
|
||||||
PlayerController->SetIgnoreMoveInput(true);
|
PlayerController->SetIgnoreMoveInput(true);
|
||||||
@ -61,7 +61,7 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
|||||||
FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
|
FProperty* HealthProperty = Enemy->GetClass()->FindPropertyByName(FName("Health"));
|
||||||
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
|
int32* EnemyHealthPtr = HealthProperty->ContainerPtrToValuePtr<int32>(Enemy);
|
||||||
EnemyHealth = EnemyHealthPtr;
|
EnemyHealth = EnemyHealthPtr;
|
||||||
|
|
||||||
if (IsValid(CombatTutorialWidgetInstance) && CombatTutorialWidgetInstance->IsInViewport()) return;
|
if (IsValid(CombatTutorialWidgetInstance) && CombatTutorialWidgetInstance->IsInViewport()) return;
|
||||||
if (!HasSeenTutorial)
|
if (!HasSeenTutorial)
|
||||||
{
|
{
|
||||||
@ -71,11 +71,11 @@ void ATurnBaseCombatV2::StartCombat(AActor* Enemy)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CombatCheck();
|
CombatCheck(bWasShot);
|
||||||
//DrawDebugPoint(GetWorld(), Enemy->GetActorLocation(), 10, FColor::Red, false, 10);
|
//DrawDebugPoint(GetWorld(), Enemy->GetActorLocation(), 10, FColor::Red, false, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::CombatCheck()
|
void ATurnBaseCombatV2::CombatCheck(bool bWasShot)
|
||||||
{
|
{
|
||||||
const UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
|
const UBlackboardComponent* EnemyBlackboard = Cast<AAIController>(EnemyActor->GetInstigatorController())->GetBlackboardComponent();
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ void ATurnBaseCombatV2::CombatCheck()
|
|||||||
EisResource = 10;
|
EisResource = 10;
|
||||||
AzosResource = 10;
|
AzosResource = 10;
|
||||||
IroquoidResource = 10;
|
IroquoidResource = 10;
|
||||||
|
|
||||||
CurrentComboString = "";
|
CurrentComboString = "";
|
||||||
UpdateComboString(CurrentComboString);
|
UpdateComboString(CurrentComboString);
|
||||||
RevertActionPoints();
|
RevertActionPoints();
|
||||||
@ -93,15 +93,18 @@ void ATurnBaseCombatV2::CombatCheck()
|
|||||||
ClearBattleLog();
|
ClearBattleLog();
|
||||||
EnableButtons();
|
EnableButtons();
|
||||||
|
|
||||||
if (EnemyBlackboard->GetValueAsBool("Sight"))
|
FProperty* ReactionSpeedProperty = EnemyActor->GetClass()->FindPropertyByName(FName("ReactionSpeed"));
|
||||||
|
float* EnemyReactionSpeedPtr = ReactionSpeedProperty->ContainerPtrToValuePtr<float>(EnemyActor);
|
||||||
|
if (EnemyBlackboard->GetValueAsBool("Sight") && !bWasShot)
|
||||||
{
|
{
|
||||||
//bEnemyHasExtraTurn = true;
|
//bEnemyHasExtraTurn = true;
|
||||||
SwitchTurn();
|
SwitchTurn();
|
||||||
}
|
}
|
||||||
else
|
else if (Cast<ATempCharacter>(PlayerActor)->ReactionSpeed > *EnemyReactionSpeedPtr && bWasShot)
|
||||||
{
|
{
|
||||||
bPlayerHasExtraTurn = true;
|
bPlayerHasExtraTurn = true;
|
||||||
}
|
}
|
||||||
|
TurnIndicatorTextBlock->SetText(FText::FromString("Player Turn"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATurnBaseCombatV2::EndCombat()
|
void ATurnBaseCombatV2::EndCombat()
|
||||||
|
@ -97,9 +97,9 @@ public:
|
|||||||
FString BattleLog;
|
FString BattleLog;
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void StartCombat(AActor* Enemy);
|
void StartCombat(AActor* Enemy, bool bWasShot = false);
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void CombatCheck();
|
void CombatCheck(bool bWasShot = false);
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void EndCombat();
|
void EndCombat();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user