Updated Combat to Change the Chance to Miss Based on Enemy Type

This commit is contained in:
Philip W 2023-05-11 04:55:41 +01:00
parent 88f73fe5db
commit aa2f1fabcb

View File

@ -734,7 +734,12 @@ void ATurnBaseCombatV2::EnableButtons() const
void ATurnBaseCombatV2::EnemyTurn()
{
if (FMath::RandRange(1, 100) > 30)
int ChanceToMiss;
FProperty* IsBossProperty = FindFieldChecked<FProperty>(EnemyActor->GetClass(), "IsBoss");
const FBoolProperty* IsBossBoolProperty = CastFieldChecked<FBoolProperty>(IsBossProperty);
if (IsBossBoolProperty->GetPropertyValue_InContainer(EnemyActor)) ChanceToMiss = 5;
else ChanceToMiss = 30;
if (FMath::RandRange(1, 100) > ChanceToMiss)
{
const FProperty* EnemyBaseDamageProperty = EnemyActor->GetClass()->FindPropertyByName(FName("BaseDamage"));
const int* EnemyBaseDamageSpeedPtr = EnemyBaseDamageProperty->ContainerPtrToValuePtr<int>(EnemyActor);