diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index f4db7e47..b6dcb8c3 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -155,4 +155,5 @@ ManualIPAddress= +PropertyRedirects=(OldName="/Script/D1.CombatPlayerCharacter.EquippedItems",NewName="/Script/D1.CombatPlayerCharacter.StartingEquipments") +PropertyRedirects=(OldName="/Script/D1.BaseConsumable.NumberOfUses",NewName="/Script/D1.BaseConsumable.CurrentNumberOfUses") +PropertyRedirects=(OldName="/Script/D1.BaseConsumable.NumberOfUses",NewName="/Script/D1.BaseConsumable.CurrentNumberOfUses") ++PropertyRedirects=(OldName="/Script/D1.BaseConsumable.Value",NewName="/Script/D1.BaseConsumable.ModificationValue") diff --git a/Content/CombatSystem/Blueprints/Actor/BP_HealthPotion.uasset b/Content/CombatSystem/Blueprints/Actor/BP_HealthPotion.uasset index acf89d3a..967b16d4 100644 Binary files a/Content/CombatSystem/Blueprints/Actor/BP_HealthPotion.uasset and b/Content/CombatSystem/Blueprints/Actor/BP_HealthPotion.uasset differ diff --git a/Content/CombatSystem/Blueprints/Animnotifies/ConsumeItem_AN.uasset b/Content/CombatSystem/Blueprints/Animnotifies/ConsumeItem_AN.uasset new file mode 100644 index 00000000..2c09bd9b Binary files /dev/null and b/Content/CombatSystem/Blueprints/Animnotifies/ConsumeItem_AN.uasset differ diff --git a/Content/ParagonKwang/Animations/Potion/DrinkingPotion_Anim1_Montage.uasset b/Content/ParagonKwang/Animations/Potion/DrinkingPotion_Anim1_Montage.uasset index b9bc3b1b..91fdfab9 100644 Binary files a/Content/ParagonKwang/Animations/Potion/DrinkingPotion_Anim1_Montage.uasset and b/Content/ParagonKwang/Animations/Potion/DrinkingPotion_Anim1_Montage.uasset differ diff --git a/Source/D1/Actor/BaseConsumable.cpp b/Source/D1/Actor/BaseConsumable.cpp index 8791305c..558ed18d 100644 --- a/Source/D1/Actor/BaseConsumable.cpp +++ b/Source/D1/Actor/BaseConsumable.cpp @@ -3,6 +3,7 @@ #include "Actor/BaseConsumable.h" +#include "Components/StatsComponent.h" #include "Interface/CombatInterface.h" ABaseConsumable::ABaseConsumable() @@ -15,7 +16,7 @@ ABaseConsumable::ABaseConsumable() OwnedGameplayTags.AddTag(FCombatGameplayTags::Get().Item_Consumable_Potion); } -void ABaseConsumable::UseItem() +void ABaseConsumable::PerformItemAction() { if(CurrentNumberOfUses <= 0) return; @@ -25,9 +26,15 @@ void ABaseConsumable::UseItem() return; ActionObjects->PerformCustomAction(FCombatGameplayTags::Get().Character_Action_Attack_UseItem, FCombatGameplayTags::Get().Character_State_GeneralActionState, UseItemMontage); - CurrentNumberOfUses--; +} +void ABaseConsumable::ConsumeItem() +{ + CurrentNumberOfUses--; OnConsumeUpdated.Broadcast(GetNumberOfConsumable()); + + if (UStatsComponent* StatComponent = GetOwner()->GetComponentByClass()) + StatComponent->ModifyCurrentStatValue(StatType, ModificationValue, ShouldRegenerate); } int32 ABaseConsumable::GetNumberOfConsumable() diff --git a/Source/D1/Actor/BaseConsumable.h b/Source/D1/Actor/BaseConsumable.h index 506cce1d..0efe3040 100644 --- a/Source/D1/Actor/BaseConsumable.h +++ b/Source/D1/Actor/BaseConsumable.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "Actor/BaseEquippable.h" +#include "Components/StatsComponent.h" #include "BaseConsumable.generated.h" /** @@ -18,8 +19,11 @@ class D1_API ABaseConsumable : public ABaseEquippable public: ABaseConsumable(); public: - virtual void UseItem() override; - + virtual void PerformItemAction() override; +public: + UFUNCTION(BlueprintCallable) + void ConsumeItem(); + public: int32 GetNumberOfConsumable(); @@ -29,8 +33,15 @@ private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true")) TObjectPtr UseItemMontage; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true")) + //Blueprint에서 입력 + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Stat Modification", meta = (AllowPrivateAccess = "true")) int32 CurrentNumberOfUses; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Montage", meta = (AllowPrivateAccess = "true")) + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Stat Modification", meta = (AllowPrivateAccess = "true")) int32 MaxNumberOfUses; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Stat Modification", meta = (AllowPrivateAccess = "true")) + EStats StatType; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Stat Modification", meta = (AllowPrivateAccess = "true")) + float ModificationValue; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Consumable Stat Modification", meta = (AllowPrivateAccess = "true")) + bool ShouldRegenerate; }; diff --git a/Source/D1/Actor/BaseEquippable.cpp b/Source/D1/Actor/BaseEquippable.cpp index 8786a0ac..27edc24a 100644 --- a/Source/D1/Actor/BaseEquippable.cpp +++ b/Source/D1/Actor/BaseEquippable.cpp @@ -61,7 +61,7 @@ bool ABaseEquippable::GetIsEquipped() return bIsEquipped; } -void ABaseEquippable::UseItem() +void ABaseEquippable::PerformItemAction() { } diff --git a/Source/D1/Actor/BaseEquippable.h b/Source/D1/Actor/BaseEquippable.h index 67fd15a8..250acfce 100644 --- a/Source/D1/Actor/BaseEquippable.h +++ b/Source/D1/Actor/BaseEquippable.h @@ -24,7 +24,7 @@ public: virtual void OnUnequipped(); virtual void SetIsEquipped(bool IsEquipped); virtual bool GetIsEquipped(); - virtual void UseItem(); + virtual void PerformItemAction(); protected: // Inherited via IGameplayTagAssetInterface diff --git a/Source/D1/CombatPlayerCharacter.cpp b/Source/D1/CombatPlayerCharacter.cpp index beee2e61..ab1d9a7f 100644 --- a/Source/D1/CombatPlayerCharacter.cpp +++ b/Source/D1/CombatPlayerCharacter.cpp @@ -411,7 +411,7 @@ bool ACombatPlayerCharacter::UseItemByTag(FGameplayTag ItemTag) continue; if(TagItem->HasMatchingGameplayTag(ItemTag)) { - Item->UseItem(); + Item->PerformItemAction(); return true; } } @@ -1098,4 +1098,20 @@ bool ACombatPlayerCharacter::WasHitBlocked() return false; } +ABaseEquippable* ACombatPlayerCharacter::GetEquippedItemByTag(FGameplayTag itemTag) +{ + for (auto Item : EquippedItems) + { + if(IsValid(Item)) + { + IGameplayTagAssetInterface* TagItem = Cast(Item); + if(!TagItem) + continue; + if(TagItem->HasMatchingGameplayTag(itemTag)) + return Item; + } + } + return nullptr; +} + diff --git a/Source/D1/CombatPlayerCharacter.h b/Source/D1/CombatPlayerCharacter.h index ca5e911d..d8698556 100644 --- a/Source/D1/CombatPlayerCharacter.h +++ b/Source/D1/CombatPlayerCharacter.h @@ -15,7 +15,6 @@ #include "Definitions/GameEnums.h" #include "CombatPlayerCharacter.generated.h" - class UInputMappingContext; class UInputAction; @@ -205,6 +204,9 @@ protected: //Check Func FGameplayTag GetDesiredAttackType(); bool WasHitBlocked(); + UFUNCTION(BlueprintCallable) + class ABaseEquippable* GetEquippedItemByTag(FGameplayTag itemTag); + public: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Components", meta=(AllowPrivateAccess="true")) TObjectPtr CombatComponent; diff --git a/Source/D1/Components/StatsComponent.cpp b/Source/D1/Components/StatsComponent.cpp index 963c1c95..6baa1cdb 100644 --- a/Source/D1/Components/StatsComponent.cpp +++ b/Source/D1/Components/StatsComponent.cpp @@ -58,7 +58,7 @@ void UStatsComponent::ModifyCurrentStatValue(EStats stat, float value, bool bSho return; float currentValue = GetCurrentStatValue(stat) + value; - currentValue = FMath::Clamp(currentValue, 0.f, currentValue); + currentValue = FMath::Clamp(currentValue, 0.f, GetMaxStatValue(stat)); SetCurrentStatValue(stat, currentValue); if (bShouldRegenerate)