// Fill out your copyright notice in the Description page of Project Settings. #include "EatableItems.h" #include "the_twilight_abyss/BaseItems/InventoryComponent.h" #include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "the_twilight_abyss/TurnBasedCombatV2/StatusSystem.h" UEatableItems::UEatableItems() { static ConstructorHelpers::FClassFinder StrengthBuffClassFinder(TEXT("/Game/Blueprints/StatusEffects/BP_StrengthBuff")); StrengthBuffStatusEffect = StrengthBuffClassFinder.Class; } void UEatableItems::Use(ATempCharacter* Character) { if (Character) { if (isHealingItem) { if (Character->Health < 100) { Character->Health += 20; Character->Inventory->RemoveItem(this); } else if (Character->Health >= 100) { UE_LOG(LogTemp, Display, TEXT("Health is full")); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Health is full")); } } if (isDamageBuffItem) { UStatusSystem* StatusSystem = Character->FindComponentByClass(); StatusSystem->AddStatusEffect(NewObject(Character, StrengthBuffStatusEffect)); UE_LOG(LogTemp, Display, TEXT("Damage Buffed")); Character->Inventory->RemoveItem(this); } if (isProbertiumType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->ProbertiumResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Probertium eaten")); TurnBaseCombat->ProbertiumResource = FMath::Clamp(TurnBaseCombat->ProbertiumResource + 2, 0, 10); Character->Inventory->RemoveItem(this); } } if (isEisType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->EisResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Eis eaten")); TurnBaseCombat->EisResource = FMath::Clamp(TurnBaseCombat->EisResource + 2, 0, 10); Character->Inventory->RemoveItem(this); } } if (isAzosType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->AzosResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Azos eaten")); TurnBaseCombat->AzosResource = FMath::Clamp(TurnBaseCombat->AzosResource + 2, 0, 10); Character->Inventory->RemoveItem(this); } } if (isIroquoidType) { TurnBaseCombat = GetWorld()->GetGameState(); if (TurnBaseCombat->IroquoidResource < 10) { UE_LOG(LogTemp, Warning, TEXT("Iroq eaten")); TurnBaseCombat->IroquoidResource = FMath::Clamp(TurnBaseCombat->IroquoidResource + 3, 0, 10); Character->Inventory->RemoveItem(this); } } } }