diff --git a/Content/ParagonLtBelica/Characters/Heroes/Belica/Meshes/Belica_Skeleton.uasset b/Content/ParagonLtBelica/Characters/Heroes/Belica/Meshes/Belica_Skeleton.uasset index c8569e68..77db39d9 100644 --- a/Content/ParagonLtBelica/Characters/Heroes/Belica/Meshes/Belica_Skeleton.uasset +++ b/Content/ParagonLtBelica/Characters/Heroes/Belica/Meshes/Belica_Skeleton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1eef477e95d489f91b812bbe537dc038a7dc5c472b42bbf0d1070918badaae4b -size 68215 +oid sha256:7f87879dc624d40dbf58e0589b560f1157ffca98cf9d8cf509a51297c3a8e877 +size 67726 diff --git a/Content/ParagonLtBelica/Characters/Heroes/Belica/Skins/Biohazard/Meshes/Belica_Biohazard.uasset b/Content/ParagonLtBelica/Characters/Heroes/Belica/Skins/Biohazard/Meshes/Belica_Biohazard.uasset index f039bf09..250dac39 100644 --- a/Content/ParagonLtBelica/Characters/Heroes/Belica/Skins/Biohazard/Meshes/Belica_Biohazard.uasset +++ b/Content/ParagonLtBelica/Characters/Heroes/Belica/Skins/Biohazard/Meshes/Belica_Biohazard.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aed6e0160154c7df92cc58bec9a7b05ac93fbc258b4fdf9eb123f72ab98bea3f -size 14586592 +oid sha256:9e3f5be5be53585c2d937504cdf748179e4cf5c9c2867b8dea8e3b574cc769e4 +size 15756466 diff --git a/Content/_Game/Character/Animations/AimingPose_AR.uasset b/Content/_Game/Character/Animations/AimingPose_AR.uasset new file mode 100644 index 00000000..c71b16b8 --- /dev/null +++ b/Content/_Game/Character/Animations/AimingPose_AR.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36ac65e3e43097df07a08f449c550e83163a1bd25dcce04603912cc19567a1fa +size 270483 diff --git a/Content/_Game/Character/Animations/Retargeted/AimingPose_Pistol.uasset b/Content/_Game/Character/Animations/Retargeted/AimingPose_Pistol.uasset new file mode 100644 index 00000000..a70c475e --- /dev/null +++ b/Content/_Game/Character/Animations/Retargeted/AimingPose_Pistol.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7392e52a09d53572d0184d4d1053b0b851b93fb69d0c119e545df9967db3a603 +size 632788 diff --git a/Content/_Game/Character/ShooterAnimBP.uasset b/Content/_Game/Character/ShooterAnimBP.uasset index 2979e5fb..96db16af 100644 --- a/Content/_Game/Character/ShooterAnimBP.uasset +++ b/Content/_Game/Character/ShooterAnimBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9aeedd3c740fa2bed569f30db0cf8b1f5f10de47b4b4fc431b6ddd8b0b474e9e -size 1459302 +oid sha256:8c220daaab81eefd4f056215d775c0fdcc02722f1e037174f0016396f74ff561 +size 1530302 diff --git a/Content/_Game/Character/ShooterCharacterBP.uasset b/Content/_Game/Character/ShooterCharacterBP.uasset index a5e8febb..4a2afc6d 100644 --- a/Content/_Game/Character/ShooterCharacterBP.uasset +++ b/Content/_Game/Character/ShooterCharacterBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6a9a0d944472f9b96778caf4c49acf9a93fe9bbb98511efcbe3bbba220af1df6 -size 44856 +oid sha256:c7501fe4d452f8ef25a46dd291d3219fc14030a5e0559c7e3d9e5f3915191a92 +size 44096 diff --git a/Content/_Game/Curves/SlideDisplacementCurve.uasset b/Content/_Game/Curves/SlideDisplacementCurve.uasset new file mode 100644 index 00000000..b5ab01cc --- /dev/null +++ b/Content/_Game/Curves/SlideDisplacementCurve.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6104c21800c260f87c3cf0c43c1358c050260cc403c3804e9f35c8a2886cebb7 +size 4015 diff --git a/Content/_Game/DataTable/WeaponDataTable.uasset b/Content/_Game/DataTable/WeaponDataTable.uasset index cdb25ff6..6e7ecc35 100644 --- a/Content/_Game/DataTable/WeaponDataTable.uasset +++ b/Content/_Game/DataTable/WeaponDataTable.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9969b550cbde0d09105f9144faa61bb71f04cbe13b9e2fd0bacd89391dac4628 -size 10381 +oid sha256:5a0680d3e1f57dd7bf8fb0485a61ebed4a32a8707a429e51ed838ba82cf05107 +size 10824 diff --git a/Content/_Game/Maps/DefaultMap.umap b/Content/_Game/Maps/DefaultMap.umap index c9e337d4..bd35d8b5 100644 --- a/Content/_Game/Maps/DefaultMap.umap +++ b/Content/_Game/Maps/DefaultMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1cd26d29daf54188a81c99974168cb6a534a20dbe5d7c0a1016f3d495a0ef438 -size 126263 +oid sha256:1c3a29a1294c34e6b464b483a768ed4179274ba51d6c8fb94fe2858f74e2afe3 +size 125632 diff --git a/Content/_Game/Materials/PistolMaterials/F_Pistol_Glow_Material.uasset b/Content/_Game/Materials/PistolMaterials/F_Pistol_Glow_Material.uasset new file mode 100644 index 00000000..c7238deb --- /dev/null +++ b/Content/_Game/Materials/PistolMaterials/F_Pistol_Glow_Material.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4601e5c0707832194125a16b071b5e8a1d1e5e7b481af1d90a3f9fe37a799239 +size 21622 diff --git a/Content/_Game/Materials/PistolMaterials/M_Pistol_Mat.uasset b/Content/_Game/Materials/PistolMaterials/M_Pistol_Mat.uasset new file mode 100644 index 00000000..21f6cb82 --- /dev/null +++ b/Content/_Game/Materials/PistolMaterials/M_Pistol_Mat.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16f03b664633b2bcdd4107c7ef2bdda8cc8d796f475f3a23712e2300a2fa7aa8 +size 36467 diff --git a/Content/_Game/Materials/PistolMaterials/M_Pistol_Mat_Inst.uasset b/Content/_Game/Materials/PistolMaterials/M_Pistol_Mat_Inst.uasset new file mode 100644 index 00000000..09283f03 --- /dev/null +++ b/Content/_Game/Materials/PistolMaterials/M_Pistol_Mat_Inst.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1512227a14dba44aee252621805c2601b8580c0c488d37f91610c82a4afe488f +size 19559 diff --git a/Content/_Game/Weapons/BaseWeapon/BaseWeaponBP.uasset b/Content/_Game/Weapons/BaseWeapon/BaseWeaponBP.uasset index 2875c1ac..e1fde56e 100644 --- a/Content/_Game/Weapons/BaseWeapon/BaseWeaponBP.uasset +++ b/Content/_Game/Weapons/BaseWeapon/BaseWeaponBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76bd3acaa29378bf4bea3970e9cf03d7d5045e7081af1748fc27cdcf56f1ffe5 -size 53767 +oid sha256:eeb0ce59ac5573fa8dc700ca8f2494b1e3d5750bdf55cfb34344db12177b009a +size 53833 diff --git a/Content/_Game/Weapons/BaseWeapon/PistolAnimBP.uasset b/Content/_Game/Weapons/BaseWeapon/PistolAnimBP.uasset new file mode 100644 index 00000000..a5a32258 --- /dev/null +++ b/Content/_Game/Weapons/BaseWeapon/PistolAnimBP.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3d7951a942204a0bedc6be4735b1b9765e3a0a8c32128fbc5129f8bf50a6617 +size 141031 diff --git a/Source/Shooter/ShooterCharacter.cpp b/Source/Shooter/ShooterCharacter.cpp index 60c80fa4..c83d58c7 100644 --- a/Source/Shooter/ShooterCharacter.cpp +++ b/Source/Shooter/ShooterCharacter.cpp @@ -288,7 +288,7 @@ void AShooterCharacter::LookUp(float Value) void AShooterCharacter::AimingButtonPressed() { bAimingButtonPressed = true; - if (CombatState != ECombatState::ECS_Reloading) + if (CombatState != ECombatState::ECS_Reloading && CombatState != ECombatState::ECS_Equipping) { Aim(); } @@ -420,6 +420,11 @@ void AShooterCharacter::ExchangeInventoryItems(int32 CurrentItemIndex, int32 New || (CombatState != ECombatState::ECS_Unoccupied && CombatState != ECombatState::ECS_Equipping)) return; + if (bAiming) + { + StopAiming(); + } + auto OldEquippedWeapon = EquippedWeapon; auto NewWeapon = Cast(Inventory[NewItemIndex]); @@ -572,6 +577,12 @@ void AShooterCharacter::FireWeapon() EquippedWeapon->DecrementAmmo(); StartCrosshairBulletFire(); StartFireTimer(); + + if (EquippedWeapon->GetWeaponType() == EWeaponType::EWT_Pistol) + { + // Start moving slide timer + EquippedWeapon->StartSlideTimer(); + } } void AShooterCharacter::StartFireTimer() @@ -585,10 +596,13 @@ void AShooterCharacter::StartFireTimer() void AShooterCharacter::AutoFireReset() { + if (!EquippedWeapon) return; + CombatState = ECombatState::ECS_Unoccupied; + if (WeaponHasAmmo()) { - if (bFireButtonPressed) + if (bFireButtonPressed && EquippedWeapon->GetAutomatic()) { FireWeapon(); } @@ -1046,15 +1060,10 @@ void AShooterCharacter::ReloadWeapon() void AShooterCharacter::FinishReloading() { - CombatState = ECombatState::ECS_Unoccupied; - - if (bAimingButtonPressed) - { - Aim(); - } - if (!EquippedWeapon) return; + CombatState = ECombatState::ECS_Unoccupied; + if (const auto AmmoType { EquippedWeapon->GetAmmoType() }; AmmoMap.Contains(AmmoType)) { int32 CarriedAmmo = AmmoMap[AmmoType]; @@ -1075,11 +1084,37 @@ void AShooterCharacter::FinishReloading() AmmoMap.Add(AmmoType, CarriedAmmo); } } + + if (bAimingButtonPressed) + { + Aim(); + } + + if (WeaponHasAmmo()) + { + if (bFireButtonPressed && EquippedWeapon->GetAutomatic()) + { + FireWeapon(); + } + } } void AShooterCharacter::FinishEquipping() { CombatState = ECombatState::ECS_Unoccupied; + + if (bAimingButtonPressed) + { + Aim(); + } + + if (WeaponHasAmmo()) + { + if (bFireButtonPressed && EquippedWeapon->GetAutomatic()) + { + FireWeapon(); + } + } } bool AShooterCharacter::CarryingAmmo() @@ -1123,6 +1158,7 @@ void AShooterCharacter::CrouchButtonPressed() { bCrouching = !bCrouching; } + if (bCrouching) { GetCharacterMovement()->MaxWalkSpeed = CrouchMovementSpeed; diff --git a/Source/Shooter/Weapon.cpp b/Source/Shooter/Weapon.cpp index 2d327bbd..17a22a2a 100644 --- a/Source/Shooter/Weapon.cpp +++ b/Source/Shooter/Weapon.cpp @@ -11,7 +11,13 @@ AWeapon::AWeapon() : WeaponType(EWeaponType::EWT_SubmachineGun), AmmoType(EAmmoType::EAT_9mm), ReloadMontageSection(FName(TEXT("Reload SMG"))), - ClipBoneName(TEXT("smg_clip")) + ClipBoneName(TEXT("smg_clip")), + SlideDisplacement(0.f), + SlideDisplacementTime(0.2f), + bMovingSlide(false), + MaxSlideDisplacement(4.f), + MaxRecoilRotation(20.f), + bAutomatic(true) { PrimaryActorTick.bCanEverTick = true; } @@ -27,6 +33,9 @@ void AWeapon::Tick(float DeltaTime) GetItemMesh()->SetWorldRotation(MeshRotation, false, nullptr, ETeleportType::TeleportPhysics); } + + // Update slide on pistol + UpdateSlideDisplacement(); } void AWeapon::ThrowWeapon() @@ -61,6 +70,12 @@ void AWeapon::DecrementAmmo() --Ammo; } +void AWeapon::StartSlideTimer() +{ + bMovingSlide = true; + GetWorldTimerManager().SetTimer(SlideTimer, this, &AWeapon::FinishMovingSlide, SlideDisplacementTime); +} + void AWeapon::ReloadAmmo(int32 Amount) { checkf(Ammo + Amount <= MagazineCapacity, TEXT("Attempted to reload with more than the magazine capacity!")) @@ -139,6 +154,8 @@ void AWeapon::OnConstruction(const FTransform& Transform) { GetItemMesh()->HideBoneByName(BoneToHide, EPhysBodyOp::PBO_None); } + + bAutomatic = WeaponDataRow->bAutomatic; } if (GetMaterialInstance()) @@ -161,3 +178,19 @@ void AWeapon::BeginPlay() GetItemMesh()->HideBoneByName(BoneToHide, EPhysBodyOp::PBO_None); } } + +void AWeapon::FinishMovingSlide() +{ + bMovingSlide = false; +} + +void AWeapon::UpdateSlideDisplacement() +{ + if (!SlideDisplacementCurve && !bMovingSlide) return; + + const float ElapsedTime{ GetWorldTimerManager().GetTimerElapsed(SlideTimer) }; + const float CurveValue{ SlideDisplacementCurve->GetFloatValue(ElapsedTime) }; + + SlideDisplacement = CurveValue * MaxSlideDisplacement; + RecoilRotation = CurveValue * MaxRecoilRotation; +} diff --git a/Source/Shooter/Weapon.h b/Source/Shooter/Weapon.h index bd17c0e2..7773798a 100644 --- a/Source/Shooter/Weapon.h +++ b/Source/Shooter/Weapon.h @@ -87,6 +87,9 @@ struct FWeaponDataTable : public FTableRowBase UPROPERTY(EditAnywhere, BlueprintReadWrite) FName BoneToHide; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool bAutomatic; }; /** @@ -109,6 +112,9 @@ protected: virtual void BeginPlay() override; + void FinishMovingSlide(); + void UpdateSlideDisplacement(); + private: FTimerHandle ThrowWeaponTimer; float ThrowWeaponTime; @@ -180,6 +186,41 @@ private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = DataTable, meta = (AllowPrivateAccess = "true")) FName BoneToHide; + /** Amount that the slide is pushed back during pistol fire */ + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Pistol, meta = (AllowPrivateAccess = "true")) + float SlideDisplacement; + + /** Curve for the slide displacement */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Pistol, meta = (AllowPrivateAccess = "true")) + UCurveFloat* SlideDisplacementCurve; + + /** Timer handle for updating SlideDisplacement */ + FTimerHandle SlideTimer; + + /** Time for displacing the slide during pistol fire */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Pistol, meta = (AllowPrivateAccess = "true")) + float SlideDisplacementTime; + + /** True when moving the pistol slide */ + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Pistol, meta = (AllowPrivateAccess = "true")) + bool bMovingSlide; + + /** Max distance for the slide on the pistol */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Pistol, meta = (AllowPrivateAccess = "true")) + float MaxSlideDisplacement; + + /** Max rotation for pistol recoil */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Pistol, meta = (AllowPrivateAccess = "true")) + float MaxRecoilRotation; + + /** Amount that the pistol will rotate during pistol fire */ + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Pistol, meta = (AllowPrivateAccess = "true")) + float RecoilRotation; + + /** True for auto gunfire */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon Properties", meta = (AllowPrivateAccess = "true")) + bool bAutomatic; + public: /** Adds an impulse to the weapon */ void ThrowWeapon(); @@ -197,6 +238,9 @@ public: FORCEINLINE float GetAutoFireRate() const { return AutoFireRate; } FORCEINLINE UParticleSystem* GetMuzzleFlash() const { return MuzzleFlash; } FORCEINLINE USoundCue* GetFireSound() const { return FireSound; } + FORCEINLINE bool GetAutomatic() const { return bAutomatic; } + + void StartSlideTimer(); void ReloadAmmo(int32 Amount);