2022-11-14 15:53:50 +00:00
|
|
|
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
|
|
|
2022-11-14 17:42:26 +00:00
|
|
|
#include "EatableItems.h"
|
2022-11-14 15:53:50 +00:00
|
|
|
|
2022-11-15 00:04:46 +00:00
|
|
|
#include "the_twilight_abyss/BaseItems/InventoryComponent.h"
|
2022-11-14 16:52:57 +00:00
|
|
|
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
2023-02-23 17:48:20 +00:00
|
|
|
#include "the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h"
|
2022-11-14 16:52:57 +00:00
|
|
|
|
2022-11-14 15:53:50 +00:00
|
|
|
|
2022-11-15 00:04:46 +00:00
|
|
|
UEatableItems::UEatableItems()
|
|
|
|
{
|
2023-05-11 04:59:49 +00:00
|
|
|
static ConstructorHelpers::FClassFinder<UStatusEffect> StrengthBuffClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_StrengthBuff"));
|
|
|
|
StrengthBuffStatusEffect = StrengthBuffClassFinder.Class;
|
2022-11-15 00:04:46 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 17:42:26 +00:00
|
|
|
void UEatableItems::Use(ATempCharacter* Character)
|
2022-11-14 15:53:50 +00:00
|
|
|
{
|
2023-02-27 03:46:06 +00:00
|
|
|
if (Character)
|
2022-11-14 16:52:57 +00:00
|
|
|
{
|
2023-02-27 03:46:06 +00:00
|
|
|
if (isHealingItem)
|
2022-11-23 00:56:33 +00:00
|
|
|
{
|
2023-02-04 17:56:25 +00:00
|
|
|
if (Character->Health < 100)
|
|
|
|
{
|
2023-05-12 12:51:08 +00:00
|
|
|
Character->Health = FMath::Clamp(Character->Health + 20, 0, 100);
|
2023-02-27 03:46:06 +00:00
|
|
|
Character->Inventory->RemoveItem(this);
|
2023-05-21 14:19:18 +00:00
|
|
|
return;
|
2023-02-04 17:56:25 +00:00
|
|
|
}
|
|
|
|
else if (Character->Health >= 100)
|
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Display, TEXT("Health is full"));
|
2023-03-28 02:43:31 +00:00
|
|
|
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Health is full"));
|
2023-05-21 14:19:18 +00:00
|
|
|
return;
|
2023-02-04 17:56:25 +00:00
|
|
|
}
|
2022-11-23 00:56:33 +00:00
|
|
|
}
|
2023-02-27 03:46:06 +00:00
|
|
|
|
|
|
|
if (isDamageBuffItem)
|
2022-11-23 00:56:33 +00:00
|
|
|
{
|
2023-05-11 04:59:49 +00:00
|
|
|
UStatusSystem* StatusSystem = Character->FindComponentByClass<UStatusSystem>();
|
|
|
|
StatusSystem->AddStatusEffect(NewObject<UStatusEffect>(Character, StrengthBuffStatusEffect));
|
2022-11-23 00:56:33 +00:00
|
|
|
UE_LOG(LogTemp, Display, TEXT("Damage Buffed"));
|
2023-01-12 13:56:30 +00:00
|
|
|
Character->Inventory->RemoveItem(this);
|
2023-05-21 14:19:18 +00:00
|
|
|
return;
|
2022-11-15 00:04:46 +00:00
|
|
|
}
|
2023-02-07 00:11:00 +00:00
|
|
|
|
2023-03-13 17:00:08 +00:00
|
|
|
if (isProbertiumType)
|
2023-02-07 00:11:00 +00:00
|
|
|
{
|
2023-02-20 14:49:05 +00:00
|
|
|
TurnBaseCombat = GetWorld()->GetGameState<ATurnBaseCombatV2>();
|
2023-05-14 20:34:08 +00:00
|
|
|
if (TurnBaseCombat->ProbertiumResource < 20)
|
2023-02-19 15:29:16 +00:00
|
|
|
{
|
2023-03-13 17:00:08 +00:00
|
|
|
UE_LOG(LogTemp, Warning, TEXT("Probertium eaten"));
|
2023-05-14 20:34:08 +00:00
|
|
|
TurnBaseCombat->ProbertiumResource = FMath::Clamp(TurnBaseCombat->ProbertiumResource + 2, 0, 20);
|
2023-03-13 17:06:10 +00:00
|
|
|
Character->Inventory->RemoveItem(this);
|
2023-02-19 15:29:16 +00:00
|
|
|
}
|
2023-05-21 14:19:18 +00:00
|
|
|
return;
|
2023-03-13 17:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isEisType)
|
|
|
|
{
|
|
|
|
TurnBaseCombat = GetWorld()->GetGameState<ATurnBaseCombatV2>();
|
2023-05-14 20:34:08 +00:00
|
|
|
if (TurnBaseCombat->EisResource < 20)
|
2023-02-19 15:29:16 +00:00
|
|
|
{
|
2023-03-13 17:00:08 +00:00
|
|
|
UE_LOG(LogTemp, Warning, TEXT("Eis eaten"));
|
2023-05-14 20:34:08 +00:00
|
|
|
TurnBaseCombat->EisResource = FMath::Clamp(TurnBaseCombat->EisResource + 2, 0, 20);
|
2023-03-13 17:06:10 +00:00
|
|
|
Character->Inventory->RemoveItem(this);
|
2023-02-19 15:29:16 +00:00
|
|
|
}
|
2023-05-21 14:19:18 +00:00
|
|
|
return;
|
2023-02-07 00:11:00 +00:00
|
|
|
}
|
2023-05-12 12:51:08 +00:00
|
|
|
|
2023-03-13 17:00:08 +00:00
|
|
|
if (isAzosType)
|
|
|
|
{
|
|
|
|
TurnBaseCombat = GetWorld()->GetGameState<ATurnBaseCombatV2>();
|
2023-05-14 20:34:08 +00:00
|
|
|
if (TurnBaseCombat->AzosResource < 20)
|
2023-03-13 17:00:08 +00:00
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("Azos eaten"));
|
2023-05-14 20:34:08 +00:00
|
|
|
TurnBaseCombat->AzosResource = FMath::Clamp(TurnBaseCombat->AzosResource + 2, 0, 20);
|
2023-03-13 17:06:10 +00:00
|
|
|
Character->Inventory->RemoveItem(this);
|
2023-03-13 17:00:08 +00:00
|
|
|
}
|
2023-05-21 14:19:18 +00:00
|
|
|
return;
|
2023-03-13 17:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isIroquoidType)
|
|
|
|
{
|
|
|
|
TurnBaseCombat = GetWorld()->GetGameState<ATurnBaseCombatV2>();
|
2023-05-14 20:34:08 +00:00
|
|
|
if (TurnBaseCombat->IroquoidResource < 20)
|
2023-03-13 17:00:08 +00:00
|
|
|
{
|
|
|
|
UE_LOG(LogTemp, Warning, TEXT("Iroq eaten"));
|
2023-05-14 20:34:08 +00:00
|
|
|
TurnBaseCombat->IroquoidResource = FMath::Clamp(TurnBaseCombat->IroquoidResource + 3, 0, 20);
|
2023-03-13 17:06:10 +00:00
|
|
|
Character->Inventory->RemoveItem(this);
|
2023-03-13 17:00:08 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-14 16:52:57 +00:00
|
|
|
}
|
2022-11-23 00:56:33 +00:00
|
|
|
}
|