From d221a9ffcc8f55495e392bd8114e9718882f8144 Mon Sep 17 00:00:00 2001 From: Bastien Date: Tue, 18 Mar 2025 20:53:33 +0100 Subject: [PATCH 01/12] Updated Map 003 --- Content/Legumix/Levels/LVL_TEST_003.umap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content/Legumix/Levels/LVL_TEST_003.umap b/Content/Legumix/Levels/LVL_TEST_003.umap index d271378..59601f9 100644 --- a/Content/Legumix/Levels/LVL_TEST_003.umap +++ b/Content/Legumix/Levels/LVL_TEST_003.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:776175740aef7de6ed67facad77057e72ca5c2c18e4c35dfed0b0eb7ad66e789 -size 1590420 +oid sha256:7ecfbc6ba4decc05c638909ed55f16a6761dbd58ea1be1d5784374fe369199ee +size 1517440 From b1f139426db92d1a8390d8a544ec8314d2d9d9b0 Mon Sep 17 00:00:00 2001 From: Emilie Schott <43524962+EmilieSchott@users.noreply.github.com> Date: Fri, 21 Mar 2025 01:38:52 +0100 Subject: [PATCH 02/12] Add Perception to range enemy and rework enemy C++ class --- Content/Legumix/Ennemy/E_EnemyState.uasset | 3 +++ .../Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset | 4 ++-- .../Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset | 4 ++-- .../Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset | 4 ++-- .../RangeEnemy/AI/BB_RangeEnnemy.uasset | 4 ++-- .../RangeEnemy/AI/BT_RangeEnnemy.uasset | 4 ++-- .../AI/Task/BTTask_RangeAttack.uasset | 2 +- .../RangeEnemy/AIC_DistantEnnemy.uasset | 4 ++-- .../Ennemy/RangeEnemy/BP_DistantEnemy.uasset | 4 ++-- Content/Legumix/Levels/LVL_00.umap | 4 ++-- Source/LegumeMix/Private/Enemy/LMEnemy.cpp | 6 ------ Source/LegumeMix/Public/Enemy/LMEnemy.h | 20 +------------------ 12 files changed, 21 insertions(+), 42 deletions(-) create mode 100644 Content/Legumix/Ennemy/E_EnemyState.uasset diff --git a/Content/Legumix/Ennemy/E_EnemyState.uasset b/Content/Legumix/Ennemy/E_EnemyState.uasset new file mode 100644 index 0000000..92e5dec --- /dev/null +++ b/Content/Legumix/Ennemy/E_EnemyState.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a30c0970576d8a12503040f483b0cd3b0f6f9291d7a8c3f2a8cef9e1f432f591 +size 2362 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset index 9e4468f..f23a510 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:17b4954d33d02b19a041ab80cb354e1267c0c48855f938a6f60f5f271a2b97e3 -size 3164 +oid sha256:d48ff45c6df936e3c5c0273bc744097f5af9eb6c49efea349f4c49fa3cc84e22 +size 3753 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset index 0e4831b..93243eb 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6c114a3a67b92085baf4239b13b5cc03915aac21c1487bd1adea82a6e37b380 -size 14596 +oid sha256:3c1d0de944be3a186cd83767fcad2b3c45db7992ee4a7b4c113dd94b6b365da0 +size 14578 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset index d1c5956..5137ae4 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:972f0ab7be3e08dd5b398135218d51de818594c4a7f3a9013f87c6b29ff7dabc -size 163138 +oid sha256:4b99f679157ce353be343093b016d9385ee3f22a716f56c58d3cd9af5ef9fba4 +size 155467 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset index 8882c5b..6abcbb6 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f0c051b120695df59fc210d0228690187e72d7365d2ff14fe648ab82fe069587 -size 4844 +oid sha256:f7c204b2084e9bcf242cf2b1e273dacc89f398ceb7d0d6caea68e55000c7b3d1 +size 4764 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset index 63033a9..a7afc91 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b46ec742714bc4daa369f965a18aa057be790fde68a4a2d1e3e03e76dbe505b4 -size 50360 +oid sha256:784e000a3f2cee6e2eedd3d5385317736f6088a309d833fe56d49f76730139bb +size 63522 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset index a947653..c1f57fb 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40bc19f91521ce13ecebe56a7e7137cf6a2089e29e47932e514a2266657203e2 +oid sha256:8f6f919369ab935dd7dea39fa41bc7b3fe7a436237e8ede1f9ffb09eb9bf977b size 23377 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset index 04ab42c..9618c3a 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e2737c468d3483de2b45e7f606cfd6f84df298a5baa7a788e746d765fbf536b -size 44086 +oid sha256:2af9306765d7314b9ab33dbc6c7f9cd14f191950152a053a28e80f07cefcce25 +size 129982 diff --git a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset index 6e5bb11..777b602 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bf09f7315dd6ed8ccad7ffbfa895e37ca97266338ddb8326455065ce452bad25 -size 295981 +oid sha256:1b858f56f6500db366eee61e78aa75418a3ae6eae6462808bf9b32eda916c367 +size 296635 diff --git a/Content/Legumix/Levels/LVL_00.umap b/Content/Legumix/Levels/LVL_00.umap index 18024d9..87eef1f 100644 --- a/Content/Legumix/Levels/LVL_00.umap +++ b/Content/Legumix/Levels/LVL_00.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fe05af22763868ebb24c4664d26ea4b48f7f71431168c5c00fa125d0ab07bb84 -size 116636 +oid sha256:53601be56a5858e1b76ae01857f3aba8f74c5982a7eacd1aba65eab31908027b +size 128808 diff --git a/Source/LegumeMix/Private/Enemy/LMEnemy.cpp b/Source/LegumeMix/Private/Enemy/LMEnemy.cpp index aadbe70..6d8aaca 100644 --- a/Source/LegumeMix/Private/Enemy/LMEnemy.cpp +++ b/Source/LegumeMix/Private/Enemy/LMEnemy.cpp @@ -5,7 +5,6 @@ ALMEnemy::ALMEnemy() { PrimaryActorTick.bCanEverTick = true; - EnemyState = EEnemyState::EES_Chasing; AttackingRadius = 100.f; AttackingDamage = 0.f; } @@ -22,11 +21,6 @@ void ALMEnemy::Attack(const APawn* TargetedPawn) GEngine->AddOnScreenDebugMessage(1, 2.f, FColor::Cyan, Debug); } -double ALMEnemy::GetDistanceToTarget(const AActor* TargetedActor) -{ - return (TargetedActor->GetActorLocation() - GetActorLocation()).Length(); -} - void ALMEnemy::Tick(float DeltaTime) { Super::Tick(DeltaTime); diff --git a/Source/LegumeMix/Public/Enemy/LMEnemy.h b/Source/LegumeMix/Public/Enemy/LMEnemy.h index 001b14d..c3f8b71 100644 --- a/Source/LegumeMix/Public/Enemy/LMEnemy.h +++ b/Source/LegumeMix/Public/Enemy/LMEnemy.h @@ -6,13 +6,6 @@ #include "GameFramework/Character.h" #include "LMEnemy.generated.h" -UENUM(BlueprintType) -enum class EEnemyState : uint8 -{ - EES_Chasing UMETA(DisplayName = "Chasing"), - EES_Attacking UMETA(DisplayName = "Attacking") -}; - UCLASS() class LEGUMEMIX_API ALMEnemy : public ACharacter { @@ -31,23 +24,12 @@ public: protected: virtual void BeginPlay() override; - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") - EEnemyState EnemyState; - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") double AttackingRadius; UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") float AttackingDamage; - - /** - * Returns the distance between the enemy and a target. - * @param TargetedActor - * @returns the distance - */ - UFUNCTION(BlueprintCallable, Category="Legumix", meta=(ReturnDisplayName="Distance", DefaultToSelf="TargetedActor")) - double GetDistanceToTarget(const AActor* TargetedActor); - + /** * Performs an attack on the targeted pawn * @param TargetedPawn From ac7e9679ffdcc0d399b5fe33b2c4caabf0ffc8c0 Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 21 Mar 2025 10:12:54 +0100 Subject: [PATCH 03/12] Updated master bank --- Content/FMOD/Desktop/Master.bank | 4 ++-- Content/FMOD/Desktop/Master.strings.bank | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Content/FMOD/Desktop/Master.bank b/Content/FMOD/Desktop/Master.bank index a920a9b..94beb94 100644 --- a/Content/FMOD/Desktop/Master.bank +++ b/Content/FMOD/Desktop/Master.bank @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e323b4ba1ca2e71a5ba40a4d2c8fa7aae1887367c135340266247ba246d30b46 -size 57600 +oid sha256:22afc72f4ec868d285549b3d651f29d42437b5c0f4ad4b340e33d9a223e7d5cd +size 63136 diff --git a/Content/FMOD/Desktop/Master.strings.bank b/Content/FMOD/Desktop/Master.strings.bank index 4353e74..ff0ea2c 100644 --- a/Content/FMOD/Desktop/Master.strings.bank +++ b/Content/FMOD/Desktop/Master.strings.bank @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d6822a5a948507cb9a44d7f32dcdffab34b7eac0a2bc26fbc7cac1e53353f73 -size 1210 +oid sha256:7cd99ff23ad00c3c45f268a2865d08a8dbb04636b768cb4281f10f77957350de +size 1330 From 4f8ab3697abdb5aa0ca9628f8dcb890c5fd348c9 Mon Sep 17 00:00:00 2001 From: TjgL Date: Fri, 21 Mar 2025 10:17:07 +0100 Subject: [PATCH 04/12] Implemented item pack effect Signed-off-by: TjgL --- Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp | 12 ++++++++++++ Source/LegumeMix/Private/LMHealthPack.cpp | 10 ++++++++++ Source/LegumeMix/Private/LMItemDrop.cpp | 4 ++++ Source/LegumeMix/Public/Ammo/LMAmmoPack.h | 2 ++ Source/LegumeMix/Public/LMHealthPack.h | 2 ++ Source/LegumeMix/Public/LMItemDrop.h | 11 +++++++++-- 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp b/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp index cfc4560..5986eed 100644 --- a/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp +++ b/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp @@ -3,8 +3,20 @@ #include "Ammo/LMAmmoPack.h" +#include "Player/LMPlayer.h" +#include "Weapon/LMWeaponManager.h" + ALMAmmoPack::ALMAmmoPack() { PrimaryActorTick.bCanEverTick = false; } + +void ALMAmmoPack::ConsumePack(ALMPlayer* Player) +{ + Super::ConsumePack(Player); + + Player->GetWeaponManager()->AddAmmoType(AmmoType, AmmoCount); + OnPackConsumed(); + Despawn(); +} diff --git a/Source/LegumeMix/Private/LMHealthPack.cpp b/Source/LegumeMix/Private/LMHealthPack.cpp index 51b9614..7adcdaa 100644 --- a/Source/LegumeMix/Private/LMHealthPack.cpp +++ b/Source/LegumeMix/Private/LMHealthPack.cpp @@ -3,9 +3,19 @@ #include "LMHealthPack.h" +#include "Player/LMHealthComponent.h" +#include "Player/LMPlayer.h" + ALMHealthPack::ALMHealthPack() { PrimaryActorTick.bCanEverTick = false; } +void ALMHealthPack::ConsumePack(ALMPlayer* Player) +{ + Player->GetHealthComponent()->AddHealth(HealthGain); + OnPackConsumed(); + Despawn(); +} + diff --git a/Source/LegumeMix/Private/LMItemDrop.cpp b/Source/LegumeMix/Private/LMItemDrop.cpp index de74b26..36448f4 100644 --- a/Source/LegumeMix/Private/LMItemDrop.cpp +++ b/Source/LegumeMix/Private/LMItemDrop.cpp @@ -17,6 +17,10 @@ void ALMItemDrop::BeginPlay() GetWorldTimerManager().SetTimer(DespawnHandle, this, &ALMItemDrop::Despawn, TimeBeforeDespawn); } +void ALMItemDrop::ConsumePack(ALMPlayer* Player) +{ +} + void ALMItemDrop::Despawn() { GetWorldTimerManager().ClearTimer(DespawnHandle); diff --git a/Source/LegumeMix/Public/Ammo/LMAmmoPack.h b/Source/LegumeMix/Public/Ammo/LMAmmoPack.h index 71d1d65..835babd 100644 --- a/Source/LegumeMix/Public/Ammo/LMAmmoPack.h +++ b/Source/LegumeMix/Public/Ammo/LMAmmoPack.h @@ -21,4 +21,6 @@ public: public: ALMAmmoPack(); + + virtual void ConsumePack(ALMPlayer* Player) override; }; diff --git a/Source/LegumeMix/Public/LMHealthPack.h b/Source/LegumeMix/Public/LMHealthPack.h index ef6f956..db6a4fd 100644 --- a/Source/LegumeMix/Public/LMHealthPack.h +++ b/Source/LegumeMix/Public/LMHealthPack.h @@ -17,4 +17,6 @@ public: public: ALMHealthPack(); + + virtual void ConsumePack(ALMPlayer* Player) override; }; diff --git a/Source/LegumeMix/Public/LMItemDrop.h b/Source/LegumeMix/Public/LMItemDrop.h index 423c7dd..f11843c 100644 --- a/Source/LegumeMix/Public/LMItemDrop.h +++ b/Source/LegumeMix/Public/LMItemDrop.h @@ -6,6 +6,7 @@ #include "GameFramework/Actor.h" #include "LMItemDrop.generated.h" +class ALMPlayer; class ULMDropData; UCLASS() @@ -17,15 +18,21 @@ protected: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix) float TimeBeforeDespawn = 30.f; + FTimerHandle DespawnHandle; + private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) TObjectPtr StaticMeshComponent; - - FTimerHandle DespawnHandle; public: ALMItemDrop(); virtual void BeginPlay() override; + + UFUNCTION(BlueprintCallable) + virtual void ConsumePack(ALMPlayer* Player); + + UFUNCTION(BlueprintImplementableEvent) + void OnPackConsumed(); protected: UFUNCTION(BlueprintCallable) From e7b1dd194a969d2d733be8b5dadf1124749b7a62 Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 21 Mar 2025 12:09:46 +0100 Subject: [PATCH 05/12] Added SpawnPoint and WaveManager to the Level 003 --- Content/Legumix/Levels/LVL_TEST_003.umap | 4 ++-- Content/Legumix/Spawner/DT_WavePreset.uasset | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Content/Legumix/Levels/LVL_TEST_003.umap b/Content/Legumix/Levels/LVL_TEST_003.umap index 59601f9..92534a9 100644 --- a/Content/Legumix/Levels/LVL_TEST_003.umap +++ b/Content/Legumix/Levels/LVL_TEST_003.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ecfbc6ba4decc05c638909ed55f16a6761dbd58ea1be1d5784374fe369199ee -size 1517440 +oid sha256:a87c333778ad73cd9532eb43b6c8b0a47afa2f353247dd7cf71885e420fae4d3 +size 1417025 diff --git a/Content/Legumix/Spawner/DT_WavePreset.uasset b/Content/Legumix/Spawner/DT_WavePreset.uasset index 98efd95..4685997 100644 --- a/Content/Legumix/Spawner/DT_WavePreset.uasset +++ b/Content/Legumix/Spawner/DT_WavePreset.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a8c14f41d1b2e5c1655d90dbbf4bf5ad091136fc028d831c2791b67dade66f5 -size 3973 +oid sha256:d5ad534f038b5ffb73b2c8a71bb452ca0738b663171f420e20399107859821dc +size 3345 From 13c0dbe486ff3e7049b5b3a4c2c02e17b7c1cfe1 Mon Sep 17 00:00:00 2001 From: TjgL Date: Fri, 21 Mar 2025 12:51:57 +0100 Subject: [PATCH 06/12] Updated drop collision layer Signed-off-by: TjgL --- Config/DefaultEngine.ini | 2 ++ Content/Legumix/Drops/BP_DropRevolver.uasset | 4 ++-- Content/Legumix/Drops/BP_DropShotgun.uasset | 4 ++-- Content/Legumix/Drops/BP_HealthPack.uasset | 4 ++-- Source/LegumeMix/Private/LMItemDrop.cpp | 1 + Source/LegumeMix/Public/LMItemDrop.h | 5 +++++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index aa4856d..a41080a 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -131,9 +131,11 @@ ManualIPAddress= +Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Bullet",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.") +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") +Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap),(Channel="Bullet",Response=ECR_Ignore)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++Profiles=(Name="Drop",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="Drop",CustomResponses=,HelpMessage="Needs description") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Bullet") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Enemy") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Projectile") ++DefaultChannelResponses=(Channel=ECC_GameTraceChannel4,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Drop") +EditProfiles=(Name="NoCollision",CustomResponses=((Channel="Bullet",Response=ECR_Ignore))) +EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Bullet",Response=ECR_Overlap))) +EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Bullet",Response=ECR_Ignore))) diff --git a/Content/Legumix/Drops/BP_DropRevolver.uasset b/Content/Legumix/Drops/BP_DropRevolver.uasset index 74a39c7..a4728c9 100644 --- a/Content/Legumix/Drops/BP_DropRevolver.uasset +++ b/Content/Legumix/Drops/BP_DropRevolver.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e56ca9e4a3f512aefb7d9d1a0914c3f00a7b5ab18d6c32ac6d30e57be7fabd6 -size 34961 +oid sha256:cfee965cd84a5caa4fd913f387ae7c13cd4f541d04c4288a709d64703652b721 +size 35231 diff --git a/Content/Legumix/Drops/BP_DropShotgun.uasset b/Content/Legumix/Drops/BP_DropShotgun.uasset index 0518f37..8da0127 100644 --- a/Content/Legumix/Drops/BP_DropShotgun.uasset +++ b/Content/Legumix/Drops/BP_DropShotgun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c323a5669a06a5314d372d57edcd1638bbb828178a9e7c9b6299d245dc6f3794 -size 35513 +oid sha256:a8ef945ed99c81f382c62241939f189a0f5ea6284817a7e98ef5250533e8a1fd +size 35768 diff --git a/Content/Legumix/Drops/BP_HealthPack.uasset b/Content/Legumix/Drops/BP_HealthPack.uasset index 208c515..103847f 100644 --- a/Content/Legumix/Drops/BP_HealthPack.uasset +++ b/Content/Legumix/Drops/BP_HealthPack.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5e2f39e549b5f598278cb14832e87390b3c05da6d4a7e07daa45e29ed4b6af04 -size 36664 +oid sha256:bd25a277922168a5f19ae9d29e8d606180d5fab78f2a2b089500fe65aa6ba76e +size 36931 diff --git a/Source/LegumeMix/Private/LMItemDrop.cpp b/Source/LegumeMix/Private/LMItemDrop.cpp index 36448f4..af6ac13 100644 --- a/Source/LegumeMix/Private/LMItemDrop.cpp +++ b/Source/LegumeMix/Private/LMItemDrop.cpp @@ -14,6 +14,7 @@ ALMItemDrop::ALMItemDrop() void ALMItemDrop::BeginPlay() { Super::BeginPlay(); + SpawnLocation = GetActorLocation(); GetWorldTimerManager().SetTimer(DespawnHandle, this, &ALMItemDrop::Despawn, TimeBeforeDespawn); } diff --git a/Source/LegumeMix/Public/LMItemDrop.h b/Source/LegumeMix/Public/LMItemDrop.h index f11843c..808a1ae 100644 --- a/Source/LegumeMix/Public/LMItemDrop.h +++ b/Source/LegumeMix/Public/LMItemDrop.h @@ -24,6 +24,9 @@ private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) TObjectPtr StaticMeshComponent; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) + FVector SpawnLocation; + public: ALMItemDrop(); virtual void BeginPlay() override; @@ -34,6 +37,8 @@ public: UFUNCTION(BlueprintImplementableEvent) void OnPackConsumed(); + FVector GetSpawnLocation() { return SpawnLocation; } + protected: UFUNCTION(BlueprintCallable) void Despawn(); From 6f57e266f02560c11a4e6afc12de5cf805eca674 Mon Sep 17 00:00:00 2001 From: Bastien Date: Fri, 21 Mar 2025 12:52:22 +0100 Subject: [PATCH 07/12] Removed MotionBlur from the PostProcess setup method --- Content/Legumix/Player/BP_Play.uasset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index 252f3d7..14f01a0 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:097724fddf62f164c3e438a22511a911db5d1f28cb24e61d53b5cb8c71c2f031 -size 638942 +oid sha256:4571d7448aa5ff7b727a5d3df7a1c2cfc9e86a63bfbe20e8caaa38fbf74cf464 +size 649059 From a7f9137dd56fe90406ac648fd7f0549d22e6bae8 Mon Sep 17 00:00:00 2001 From: TjgL Date: Fri, 21 Mar 2025 12:52:36 +0100 Subject: [PATCH 08/12] Started working on grab range Signed-off-by: TjgL --- .../Legumix/Player/BP_GrabComponent.uasset | 3 ++ Content/Legumix/Player/C_GrabMovement.uasset | 3 ++ .../LegumeMix/Private/Player/LMGrabRange.cpp | 53 +++++++++++++++++++ Source/LegumeMix/Private/Player/LMGrabRange.h | 52 ++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 Content/Legumix/Player/BP_GrabComponent.uasset create mode 100644 Content/Legumix/Player/C_GrabMovement.uasset create mode 100644 Source/LegumeMix/Private/Player/LMGrabRange.cpp create mode 100644 Source/LegumeMix/Private/Player/LMGrabRange.h diff --git a/Content/Legumix/Player/BP_GrabComponent.uasset b/Content/Legumix/Player/BP_GrabComponent.uasset new file mode 100644 index 0000000..3f28caf --- /dev/null +++ b/Content/Legumix/Player/BP_GrabComponent.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94d44c354900a897e9d28ac01a7718cc6287fdbab0adc3c8916a0285692a56d9 +size 79004 diff --git a/Content/Legumix/Player/C_GrabMovement.uasset b/Content/Legumix/Player/C_GrabMovement.uasset new file mode 100644 index 0000000..31268a5 --- /dev/null +++ b/Content/Legumix/Player/C_GrabMovement.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8496ddd779404f4331461e71ede1cf9a4cd96bee35fe3d437fc8d8fb388f37a0 +size 5060 diff --git a/Source/LegumeMix/Private/Player/LMGrabRange.cpp b/Source/LegumeMix/Private/Player/LMGrabRange.cpp new file mode 100644 index 0000000..8dcea6c --- /dev/null +++ b/Source/LegumeMix/Private/Player/LMGrabRange.cpp @@ -0,0 +1,53 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "LMGrabRange.h" + +#include "LMItemDrop.h" +#include "Player/LMPlayer.h" + + +ULMGrabRange::ULMGrabRange() +{ + PrimaryComponentTick.bCanEverTick = true; + +} + +void ULMGrabRange::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + +} + +void ULMGrabRange::OnDropOverlapped_Implementation(ALMItemDrop* ItemDrop) +{ + Drops.AddUnique(ItemDrop); +} + + +void ULMGrabRange::ConsumeDrop(ALMItemDrop* ItemDrop) +{ + ItemDrop->ConsumePack(Player); + +} + +void ULMGrabRange::BeginPlay() +{ + Super::BeginPlay(); + Player = CastChecked(GetOwner()); + OnComponentBeginOverlap.AddUniqueDynamic(this, &ULMGrabRange::OnComponentOverlap); +} + +void ULMGrabRange::OnComponentOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) +{ + if (!bIsEnabled) + return; + + if (ALMItemDrop* ItemDrop = Cast(OtherActor)) + { + OnDropOverlapped(ItemDrop); + } +} + diff --git a/Source/LegumeMix/Private/Player/LMGrabRange.h b/Source/LegumeMix/Private/Player/LMGrabRange.h new file mode 100644 index 0000000..a8237aa --- /dev/null +++ b/Source/LegumeMix/Private/Player/LMGrabRange.h @@ -0,0 +1,52 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/SphereComponent.h" +#include "LMGrabRange.generated.h" + + +class ALMPlayer; +class ALMItemDrop; + +UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +class LEGUMEMIX_API ULMGrabRange : public USphereComponent +{ + GENERATED_BODY() + +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) + bool bIsEnabled = true; + + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) + TArray Drops; + + /** The range at which the drop is consumed. */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0.1f)) + float RangeToGrab = 10.f; + + /** Distance curve from 0-1 to the player. */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true)) + TObjectPtr SpeedAtPosition; + + TObjectPtr Player; + +public: + ULMGrabRange(); + UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Legumix) + void OnDropOverlapped(ALMItemDrop* ItemDrop); + + UFUNCTION(BlueprintCallable, Category=Legumix) + void ConsumeDrop(ALMItemDrop* ItemDrop); + + void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + +protected: + virtual void BeginPlay() override; + +private: + UFUNCTION() + void OnComponentOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, + int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); +}; From 0f7492d6826e62dd5df17ef4794d9e6823482c49 Mon Sep 17 00:00:00 2001 From: Emilie Schott Date: Fri, 21 Mar 2025 12:56:34 +0100 Subject: [PATCH 09/12] Change auto-possess by ai controller at spawn r when placed in world for range enemy --- Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset index 777b602..9b712a0 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b858f56f6500db366eee61e78aa75418a3ae6eae6462808bf9b32eda916c367 -size 296635 +oid sha256:5d9dc5f261c0e8a715031171eb0a022f96fd54d3b84dfc0400b4b6d190dc0f24 +size 296710 From cb59ea1628e524b69f91b4f728cd81ea6d5e63a8 Mon Sep 17 00:00:00 2001 From: TjgL Date: Sat, 22 Mar 2025 22:31:36 +0100 Subject: [PATCH 10/12] Finished implementing item drops Signed-off-by: TjgL --- Config/DefaultEngine.ini | 2 +- Content/Legumix/Drops/BP_DropRevolver.uasset | 4 +- Content/Legumix/Drops/BP_DropShotgun.uasset | 4 +- Content/Legumix/Drops/BP_HealthPack.uasset | 4 +- .../Legumix/Player/BP_GrabComponent.uasset | 4 +- Content/Legumix/Player/BP_Play.uasset | 4 +- Content/Legumix/Player/C_GrabMovement.uasset | 4 +- Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp | 2 +- Source/LegumeMix/Private/LMHealthPack.cpp | 2 + Source/LegumeMix/Private/LMItemDrop.cpp | 40 ++++++++++++++++++- .../LegumeMix/Private/Player/LMGrabRange.cpp | 31 +++++++++----- Source/LegumeMix/Private/Player/LMGrabRange.h | 11 +---- Source/LegumeMix/Private/Player/LMPlayer.cpp | 8 ++++ Source/LegumeMix/Public/LMItemDrop.h | 24 ++++++++++- Source/LegumeMix/Public/Player/LMPlayer.h | 4 ++ 15 files changed, 114 insertions(+), 34 deletions(-) diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index a41080a..df8fa0f 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -131,7 +131,7 @@ ManualIPAddress= +Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Bullet",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.") +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") +Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap),(Channel="Bullet",Response=ECR_Ignore)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") -+Profiles=(Name="Drop",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="Drop",CustomResponses=,HelpMessage="Needs description") ++Profiles=(Name="Drop",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="Drop",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="Bullet",Response=ECR_Ignore),(Channel="Enemy",Response=ECR_Ignore),(Channel="Drop",Response=ECR_Ignore)),HelpMessage="Needs description") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Bullet") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Enemy") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Projectile") diff --git a/Content/Legumix/Drops/BP_DropRevolver.uasset b/Content/Legumix/Drops/BP_DropRevolver.uasset index a4728c9..085476f 100644 --- a/Content/Legumix/Drops/BP_DropRevolver.uasset +++ b/Content/Legumix/Drops/BP_DropRevolver.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cfee965cd84a5caa4fd913f387ae7c13cd4f541d04c4288a709d64703652b721 -size 35231 +oid sha256:c81ae7940fd0d9bfbbd9ab2659f2a0aca7b56c094a00dc57f52ecfa43e8c82aa +size 38220 diff --git a/Content/Legumix/Drops/BP_DropShotgun.uasset b/Content/Legumix/Drops/BP_DropShotgun.uasset index 8da0127..8307c21 100644 --- a/Content/Legumix/Drops/BP_DropShotgun.uasset +++ b/Content/Legumix/Drops/BP_DropShotgun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a8ef945ed99c81f382c62241939f189a0f5ea6284817a7e98ef5250533e8a1fd -size 35768 +oid sha256:58d5e1577f8d3fe8d6e31fa53b2f7f9e6141138dad56b8a7b38dd44cc08ba89f +size 38044 diff --git a/Content/Legumix/Drops/BP_HealthPack.uasset b/Content/Legumix/Drops/BP_HealthPack.uasset index 103847f..2cbe4f6 100644 --- a/Content/Legumix/Drops/BP_HealthPack.uasset +++ b/Content/Legumix/Drops/BP_HealthPack.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd25a277922168a5f19ae9d29e8d606180d5fab78f2a2b089500fe65aa6ba76e -size 36931 +oid sha256:237e35c4b2e5a378032198bb9da95c9f9e43fbe93b3309e593ad0ce151e724d0 +size 38978 diff --git a/Content/Legumix/Player/BP_GrabComponent.uasset b/Content/Legumix/Player/BP_GrabComponent.uasset index 3f28caf..6546214 100644 --- a/Content/Legumix/Player/BP_GrabComponent.uasset +++ b/Content/Legumix/Player/BP_GrabComponent.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94d44c354900a897e9d28ac01a7718cc6287fdbab0adc3c8916a0285692a56d9 -size 79004 +oid sha256:fc4a6166579c377d3c8a2ac96634a5e37d05c2aa325abac959e5ea39f3558d4d +size 9696 diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index 14f01a0..e0b165c 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4571d7448aa5ff7b727a5d3df7a1c2cfc9e86a63bfbe20e8caaa38fbf74cf464 -size 649059 +oid sha256:df786d770dc0106b0d0ba66b32f9fde2483ed489db125481e847c87523c7b467 +size 642697 diff --git a/Content/Legumix/Player/C_GrabMovement.uasset b/Content/Legumix/Player/C_GrabMovement.uasset index 31268a5..9e6ef1d 100644 --- a/Content/Legumix/Player/C_GrabMovement.uasset +++ b/Content/Legumix/Player/C_GrabMovement.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8496ddd779404f4331461e71ede1cf9a4cd96bee35fe3d437fc8d8fb388f37a0 -size 5060 +oid sha256:5683d4d38474f956c5e35a3597c4f1d18766f2d312303cfe8173aacf1557f4be +size 5054 diff --git a/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp b/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp index 5986eed..366a839 100644 --- a/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp +++ b/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp @@ -16,7 +16,7 @@ void ALMAmmoPack::ConsumePack(ALMPlayer* Player) { Super::ConsumePack(Player); - Player->GetWeaponManager()->AddAmmoType(AmmoType, AmmoCount); + Player->AddAmmo(AmmoType, AmmoCount); OnPackConsumed(); Despawn(); } diff --git a/Source/LegumeMix/Private/LMHealthPack.cpp b/Source/LegumeMix/Private/LMHealthPack.cpp index 7adcdaa..833ee14 100644 --- a/Source/LegumeMix/Private/LMHealthPack.cpp +++ b/Source/LegumeMix/Private/LMHealthPack.cpp @@ -14,6 +14,8 @@ ALMHealthPack::ALMHealthPack() void ALMHealthPack::ConsumePack(ALMPlayer* Player) { + Super::ConsumePack(Player); + Player->GetHealthComponent()->AddHealth(HealthGain); OnPackConsumed(); Despawn(); diff --git a/Source/LegumeMix/Private/LMItemDrop.cpp b/Source/LegumeMix/Private/LMItemDrop.cpp index af6ac13..e6ad47e 100644 --- a/Source/LegumeMix/Private/LMItemDrop.cpp +++ b/Source/LegumeMix/Private/LMItemDrop.cpp @@ -3,12 +3,17 @@ #include "LMItemDrop.h" +#include "Kismet/KismetMathLibrary.h" + ALMItemDrop::ALMItemDrop() { PrimaryActorTick.bCanEverTick = true; + Root = CreateDefaultSubobject("Root"); + RootComponent = Root; + StaticMeshComponent = CreateDefaultSubobject("MeshComponent"); - RootComponent = StaticMeshComponent; + StaticMeshComponent->SetupAttachment(RootComponent); } void ALMItemDrop::BeginPlay() @@ -18,8 +23,41 @@ void ALMItemDrop::BeginPlay() GetWorldTimerManager().SetTimer(DespawnHandle, this, &ALMItemDrop::Despawn, TimeBeforeDespawn); } +void ALMItemDrop::SetAttractor(AActor* Target) +{ + Attractor = Target; + GetWorldTimerManager().SetTimer(MoveHandle, this, &ALMItemDrop::DoMovingTowardsTarget, MoveRate, true); + GetWorldTimerManager().ClearTimer(DespawnHandle); +} + +void ALMItemDrop::DoMovingTowardsTarget() +{ + if (MoveTime >= MoveDuration) + { + GetWorldTimerManager().ClearTimer(MoveHandle); + SetActorLocation(Attractor->GetActorLocation()); + return; + } + + const FVector Position = Attractor->GetActorLocation(); + + const float Duration = MoveTime / MoveDuration; + + FString text = FString::Printf(TEXT("Time : %f / %f = %f"), MoveTime, MoveDuration, Duration); + GEngine->AddOnScreenDebugMessage(-15, 1.f, FColor::Red, text); + const float CurvePosition = PositionAtTime->GetFloatValue(Duration); + const FVector NewPosition = UKismetMathLibrary::VLerp(SpawnLocation, Position, CurvePosition); + + MoveTime += MoveRate; + SetActorLocation(NewPosition); +} + void ALMItemDrop::ConsumePack(ALMPlayer* Player) { + if (MoveHandle.IsValid()) + { + GetWorldTimerManager().ClearTimer(MoveHandle); + } } void ALMItemDrop::Despawn() diff --git a/Source/LegumeMix/Private/Player/LMGrabRange.cpp b/Source/LegumeMix/Private/Player/LMGrabRange.cpp index 8dcea6c..0a67c9b 100644 --- a/Source/LegumeMix/Private/Player/LMGrabRange.cpp +++ b/Source/LegumeMix/Private/Player/LMGrabRange.cpp @@ -17,19 +17,32 @@ void ULMGrabRange::TickComponent(float DeltaTime, enum ELevelTick TickType, FAct { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - + if (!bIsEnabled) + return; + + for (int i = Drops.Num() - 1; i >= 0; i--) + { + ALMItemDrop* Item = Drops[i]; + + const FVector ItemPosition = Item->GetActorLocation(); + const FVector Position = GetComponentLocation(); + + const float DistanceLeft = FVector::Dist(ItemPosition, Position); + FString text = FString::Printf(TEXT("Item %s at distance %f"), *Item->GetName(), DistanceLeft); + GEngine->AddOnScreenDebugMessage(i, 1.f, FColor::Cyan, text); + + if (DistanceLeft <= RangeToGrab) + { + Item->ConsumePack(Player); + Drops.Remove(Item); + } + } } -void ULMGrabRange::OnDropOverlapped_Implementation(ALMItemDrop* ItemDrop) +void ULMGrabRange::OnDropOverlapped(ALMItemDrop* ItemDrop) { Drops.AddUnique(ItemDrop); -} - - -void ULMGrabRange::ConsumeDrop(ALMItemDrop* ItemDrop) -{ - ItemDrop->ConsumePack(Player); - + ItemDrop->SetAttractor(Player); } void ULMGrabRange::BeginPlay() diff --git a/Source/LegumeMix/Private/Player/LMGrabRange.h b/Source/LegumeMix/Private/Player/LMGrabRange.h index a8237aa..eeb97e7 100644 --- a/Source/LegumeMix/Private/Player/LMGrabRange.h +++ b/Source/LegumeMix/Private/Player/LMGrabRange.h @@ -26,21 +26,14 @@ private: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0.1f)) float RangeToGrab = 10.f; - /** Distance curve from 0-1 to the player. */ - UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true)) - TObjectPtr SpeedAtPosition; - TObjectPtr Player; public: ULMGrabRange(); - UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Legumix) + UFUNCTION(BlueprintCallable, Category=Legumix) void OnDropOverlapped(ALMItemDrop* ItemDrop); - UFUNCTION(BlueprintCallable, Category=Legumix) - void ConsumeDrop(ALMItemDrop* ItemDrop); - - void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; protected: virtual void BeginPlay() override; diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 10d4bb7..f5b5f86 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -116,6 +116,14 @@ bool ALMPlayer::CanJumpInternal_Implementation() const return JumpIsAllowedInternal(); } +void ALMPlayer::AddAmmo(const EAmmoType Ammo, const int AmmoCount) +{ + if (GetWeaponManager()->AddAmmoType(Ammo, AmmoCount)) + { + OnAmmoPickup(); + } +} + void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) { UE_LOG(LogTemp, Warning, TEXT("Set weapon manager")) diff --git a/Source/LegumeMix/Public/LMItemDrop.h b/Source/LegumeMix/Public/LMItemDrop.h index 808a1ae..1ccb8b7 100644 --- a/Source/LegumeMix/Public/LMItemDrop.h +++ b/Source/LegumeMix/Public/LMItemDrop.h @@ -17,19 +17,41 @@ class LEGUMEMIX_API ALMItemDrop : public AActor protected: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix) float TimeBeforeDespawn = 30.f; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix) + float MoveRate = 0.1f; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix) + float MoveDuration = 1.f; + + /** Distance curve from 0-1 to the player. */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true)) + TObjectPtr PositionAtTime; FTimerHandle DespawnHandle; + FTimerHandle MoveHandle; private: + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) + TObjectPtr Root; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) TObjectPtr StaticMeshComponent; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) FVector SpawnLocation; + UPROPERTY() + TObjectPtr Attractor; + + float MoveTime = 0.f; + public: ALMItemDrop(); virtual void BeginPlay() override; + + void SetAttractor(AActor* Target); + UFUNCTION() + void DoMovingTowardsTarget(); UFUNCTION(BlueprintCallable) virtual void ConsumePack(ALMPlayer* Player); @@ -37,7 +59,7 @@ public: UFUNCTION(BlueprintImplementableEvent) void OnPackConsumed(); - FVector GetSpawnLocation() { return SpawnLocation; } + FVector GetSpawnLocation() const { return SpawnLocation; } protected: UFUNCTION(BlueprintCallable) diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 02e4b55..2183e22 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "LMBulletInfo.h" #include "LMTeam.h" +#include "Ammo/LMAmmoPack.h" #include "Camera/CameraComponent.h" #include "GameFramework/Character.h" #include "LMPlayer.generated.h" @@ -56,6 +57,9 @@ public: virtual bool CanJumpInternal_Implementation() const override; + UFUNCTION(BlueprintCallable) + void AddAmmo(EAmmoType Ammo, int AmmoCount); + protected: // Called when the game starts or when spawned virtual void BeginPlay() override; From c50a120cac74638c8bbe89b85e215e0bc7558abe Mon Sep 17 00:00:00 2001 From: TjgL Date: Sun, 23 Mar 2025 17:43:13 +0100 Subject: [PATCH 11/12] Added simple ammo spawner Signed-off-by: TjgL --- Content/Legumix/Drops/BP_AmmoSpawner.uasset | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Content/Legumix/Drops/BP_AmmoSpawner.uasset diff --git a/Content/Legumix/Drops/BP_AmmoSpawner.uasset b/Content/Legumix/Drops/BP_AmmoSpawner.uasset new file mode 100644 index 0000000..ec42523 --- /dev/null +++ b/Content/Legumix/Drops/BP_AmmoSpawner.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9c6959a952dccce541ac2076d99cd92d5d01db2de6d2bfd4eb0769239e5aedd +size 39528 From e797ecd8dea37c5702ddd966f964ccc84045b215 Mon Sep 17 00:00:00 2001 From: TjgL Date: Fri, 28 Mar 2025 16:32:12 +0100 Subject: [PATCH 12/12] Implemented weapon switch scroll limit Signed-off-by: TjgL --- Content/Legumix/Player/BP_PlayerController.uasset | 4 ++-- .../LegumeMix/Private/Player/LMPlayerController.cpp | 12 ++++++++++++ Source/LegumeMix/Public/Player/LMPlayerController.h | 10 +++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset index 12d2476..6804311 100644 --- a/Content/Legumix/Player/BP_PlayerController.uasset +++ b/Content/Legumix/Player/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc92081abb28b81e9a56e981284c3e7802f559c318716fe4c5d2f2bba749c6e3 -size 22303 +oid sha256:c394e1e698d9ca42975ee6cc67d1d92372e58e2241b97abbcddf40d23f5c718d +size 22358 diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 06e4911..adb0930 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -35,6 +35,7 @@ void ALMPlayerController::SetupInputComponent() Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire); Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll); + Input->BindAction(ScrollAction, ETriggerEvent::Canceled, this, &ALMPlayerController::ScrollEnded); Input->BindAction(PauseAction, ETriggerEvent::Triggered, this, &ALMPlayerController::TogglePause); Input->BindAction(SlideAction, ETriggerEvent::Started, this, &ALMPlayerController::SlideInput); Input->BindAction(SlideAction, ETriggerEvent::Completed, this, &ALMPlayerController::SlideCancel); @@ -73,8 +74,19 @@ void ALMPlayerController::Reload(const FInputActionValue& InputValue) void ALMPlayerController::Scroll(const FInputActionValue& InputValue) { + if (bIsScrolling) + return; + const float ScrollAmount = InputValue.Get(); LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount); + bIsScrolling = true; + GetWorldTimerManager().SetTimer(ScrollTimer, this, &ALMPlayerController::ScrollEnded, SwitchWeaponDelay, false); +} + +void ALMPlayerController::ScrollEnded() +{ + GetWorldTimerManager().ClearTimer(ScrollTimer); + bIsScrolling = false; } void ALMPlayerController::PauseInput(const FInputActionValue& InputValue) diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h index 8497837..bd5f4bf 100644 --- a/Source/LegumeMix/Public/Player/LMPlayerController.h +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -54,7 +54,6 @@ private: UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr LegumixPlayer; - virtual void SetupInputComponent() override; void Move(const FInputActionValue& InputValue); void Jump(const FInputActionValue& InputValue); @@ -68,6 +67,10 @@ private: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0)) float Sensitivity = 1.0f; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, ClampMin = 0.f)) + float SwitchWeaponDelay = 0.1f; + private: UFUNCTION(BlueprintCallable, Category = Legumix) @@ -75,4 +78,9 @@ private: UFUNCTION(BlueprintCallable, Category = Legumix) void OnSettingsChanged(); + + void ScrollEnded(); + + FTimerHandle ScrollTimer; + bool bIsScrolling; };