diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset index 6e0e13d4..1d67df8a 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d593d68d5b9a9fc58b1b7ecc44936b84e361aaa1762ab04c5924e36bfd45bee9 -size 61494 +oid sha256:7cfd791337f79a964dbfef919494665648f1ce39168d4f28cd122e2018c4b694 +size 61741 diff --git a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Reload.uasset b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Reload.uasset index 5ed3f2f9..803128c2 100644 --- a/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Reload.uasset +++ b/EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Reload.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85ff514d76166f7c202ee64b678abe6314dcc24d3d662883b53edb7608ea2bfe -size 1647 +oid sha256:eab7ab2c34f8fe941f0964ebe97c974bbcd4bf68ad27a0f489a65b6cc2c6ddb2 +size 1643 diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 7e024eb4..4a1bd405 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -256,11 +256,11 @@ void AEndlessVendettaCharacter::EquipSecondary() //Calls the fire function in the baseWeaponClass void AEndlessVendettaCharacter::FireCaller() { - if (IsValid(PrimaryWeapon)) + if (IsValid(PrimaryWeapon) && !bIsReloading) { PrimaryWeapon->Fire(); } - if (IsValid(SecondaryWeapon)) + if (IsValid(SecondaryWeapon) && !bIsReloading) { SecondaryWeapon->Fire(); } @@ -330,11 +330,13 @@ void AEndlessVendettaCharacter::GunReload() { if (IsValid(PrimaryWeapon)) { - PrimaryWeapon->WeaponReload(); + PrimaryWeapon->ReloadTimer(); + bIsReloading = true; } if (IsValid(SecondaryWeapon)) { - SecondaryWeapon->WeaponReload(); + SecondaryWeapon->ReloadTimer(); + bIsReloading = true; } } diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index 346213ab..ece80c9f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -91,6 +91,7 @@ protected: public: int Money = 2000; + bool bIsReloading = false; /** Look Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp index d20c1ae8..c053413b 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp @@ -54,6 +54,7 @@ void ABaseWeaponClass::BeginPlay() UE_LOG(LogTemp, Display, TEXT("crnnt ammo: %d"), MagazineSize); } + // Called every frame void ABaseWeaponClass::Tick(float DeltaTime) { @@ -63,7 +64,6 @@ void ABaseWeaponClass::Tick(float DeltaTime) { ApplyRecoil(DeltaTime); } - UE_LOG(LogTemp, Display, TEXT("currnt pitch: %f"), currentPitch); if (currentPitch < 0 && bStopShooting) { float increment = currentPitch * DeltaTime * 8; @@ -213,12 +213,19 @@ void ABaseWeaponClass::WeaponScopedFire() } } +void ABaseWeaponClass::ReloadTimer() +{ + GetWorldTimerManager().SetTimer(reloadTimerHandle, this, &ABaseWeaponClass::WeaponReload, TimeToReload, false); + GLog->Log("ReloadTimer Activated"); +} + void ABaseWeaponClass::WeaponReload() { - if(MagazineSize > currentAmmoCount) + if(MagazineSize >= currentAmmoCount) { UE_LOG(LogTemp, Display, TEXT("Weapon Reloading: mag size: %d"), MagazineSize); currentAmmoCount = MagazineSize; + endlessVendettaChar->bIsReloading = false; } } diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 00541047..82e7c1bd 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -41,10 +41,12 @@ protected: float recoilResultPitch = 0; float recoilResultYaw = 0; + + public: // Called every frame virtual void Tick(float DeltaTime) override; - + void ReloadTimer(); UPROPERTY(EditAnywhere) FName WeaponName; @@ -57,6 +59,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite) int MagazineSize; + UPROPERTY(EditAnywhere) + float TimeToReload = 3.f; + //how many bullets until the recoil stops going up UPROPERTY(EditAnywhere) int howMnyShotsTillRclStop; @@ -95,6 +100,7 @@ public: APlayerController* playerControllerRef; FTimerHandle timerHandle; + FTimerHandle reloadTimerHandle; bool bFirstBulletShot = false;