diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset new file mode 100644 index 00000000..ca208dae --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:329bb4534943e949f235c44d9782f62012b4e728fa4a566615a718a2ae0f1bde +size 124581 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Snipers/BaseSniper.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Snipers/BaseSniper.uasset new file mode 100644 index 00000000..34390329 --- /dev/null +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Snipers/BaseSniper.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c4edd4b9c090f7fd40cb88de61fd3f0a2cf27d5b2e959e8a1189e705df6a9707 +size 125077 diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset index ff0850c9..8506b4d5 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:4aef926e64cc0bd15cd6df6c9683311954a37d3a4576cd79a564efe16ef7920d -size 64353 +oid sha256:12a2bf04dd00e6b7507070952dc3382734b02f049bd6a73a24f066b802071ca6 +size 64438 diff --git a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/5/1H/2QRFI3J5JT02V2G1QP4P99.uasset b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/5/1H/2QRFI3J5JT02V2G1QP4P99.uasset new file mode 100644 index 00000000..39871f58 --- /dev/null +++ b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/5/1H/2QRFI3J5JT02V2G1QP4P99.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56271e75ce388bac1e70abc1085fcf019d41a311ac70ff84ed3f7bbec53aa6ec +size 6426 diff --git a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/6/TX/BTC9S0W28D5I25IOL56715.uasset b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/6/TX/BTC9S0W28D5I25IOL56715.uasset index fa64ab8e..01662c33 100644 --- a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/6/TX/BTC9S0W28D5I25IOL56715.uasset +++ b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/6/TX/BTC9S0W28D5I25IOL56715.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:39162e6e995a0f6846b1a806d1fa532ddc0af51fc910ab83b5c988fc591f91ff -size 4768 +oid sha256:132a3e687f7729d821313a19996f7ec6d6e423a6fc5adb3035cc427c8333d7f3 +size 4742 diff --git a/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/7/VS/TBSU6BHEHN191N9FG8A6XN.uasset b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/7/VS/TBSU6BHEHN191N9FG8A6XN.uasset new file mode 100644 index 00000000..34849915 --- /dev/null +++ b/EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/7/VS/TBSU6BHEHN191N9FG8A6XN.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b166a03dba174d55220b56cde59bb17914ac485c6b2b4055d1c99ad6d6d3da7 +size 6183 diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 3761ba79..3fb9141f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -10,6 +10,7 @@ #include "AI/EnemyCharacter.h" #include "GameFramework/CharacterMovementComponent.h" #include "Kismet/GameplayStatics.h" +#include "GameFramework/MovementComponent.h" ////////////////////////////////////////////////////////////////////////// @@ -70,7 +71,17 @@ void AEndlessVendettaCharacter::Tick(float DeltaTime) Super::Tick(DeltaTime); WeaponPickUpSystem(); - + + MoveGroundSpeed = Cast(GetComponentByClass(UMovementComponent::StaticClass()))->Velocity.Size(); + + if (MoveGroundSpeed > 0) + { + bIsPlayerMoving = true; + } + else if (MoveGroundSpeed <= 0) + { + bIsPlayerMoving = false; + } } void AEndlessVendettaCharacter::WeaponPickUpSystem() diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index 9995a4f5..71be65d9 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -94,6 +94,10 @@ public: AGadgetManager* GadgetManager; bool bIsReloading = false; + bool bIsPlayerMoving = false; + + double MoveGroundSpeed; + /** Look Input Action */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true")) class UInputAction* LookAction; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index 36de56ca..531048b8 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -7,6 +7,7 @@ #include "Components/ArrowComponent.h" #include "Kismet/KismetMathLibrary.h" #include "EndlessVendetta/InteractionInterface.h" +#include "Engine/EngineTypes.h" #include "BaseWeaponClass.generated.h" class AEndlessVendettaCharacter; @@ -25,7 +26,7 @@ protected: // Called when the game starts or when spawned virtual void BeginPlay() override; - void ApplyRecoil(float DeltaTime); + virtual void ApplyRecoil(float DeltaTime); void GenerateRecoilVector(); @@ -54,7 +55,11 @@ public: // Called every frame virtual void Tick(float DeltaTime) override; void ReloadTimer(); - + + float currentPitch; + + UPROPERTY(EditAnywhere) + float BulletDistance; UPROPERTY(EditAnywhere, BlueprintReadWrite) FString WeaponName; @@ -159,7 +164,7 @@ public: //UFUNCTION(BlueprintCallable, Category = "Weapons") //void RecoilVerticalLimit(FHitResult Outhit); - UPROPERTY(EditAnywhere) + UPROPERTY(VisibleAnywhere) int bulletCountShoot; //Gets how many bullets shot per void Interact() override; @@ -177,14 +182,10 @@ protected: private: - UPROPERTY(EditAnywhere) - float BulletDistance; - float originalMagnitude; float originalMaxAngleLeft; float originalMaxAngleRight; float originalMinMultiplier; - float currentPitch; }; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp new file mode 100644 index 00000000..266ae616 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.cpp @@ -0,0 +1,10 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "ShotgunClass.h" + +AShotgunClass::AShotgunClass() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; +} diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h new file mode 100644 index 00000000..8bf23c16 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/ShotgunClass.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BaseWeaponClass.h" +#include "ShotgunClass.generated.h" + +/** + * + */ +UCLASS() +class ENDLESSVENDETTA_API AShotgunClass : public ABaseWeaponClass +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + AShotgunClass(); + +}; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.cpp new file mode 100644 index 00000000..9ace82f6 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.cpp @@ -0,0 +1,94 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "SniperClass.h" +#include "EndlessVendetta/EndlessVendettaCharacter.h" +#include "EndlessVendetta/AI/AICharacter.h" +#include "Engine/DamageEvents.h" +#include "Kismet/GameplayStatics.h" + +// Sets default values +ASniperClass::ASniperClass() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; +} + +// Called when the game starts or when spawned +void ASniperClass::BeginPlay() +{ + Super::BeginPlay(); +} + +// Called every frame +void ASniperClass::Tick(float DeltaTime) +{ + ApplyRecoil(DeltaTime); + recoilMagnitude = 1; + if(endlessVendettaChar->bIsPlayerMoving == false ) + { + recoilResultPitch = 0; + recoilMagnitude = -1; + } + if (currentPitch < 0 && bStopShooting) + { + float increment = currentPitch * DeltaTime * 8; + currentPitch -= increment; + playerInWorld->AddControllerPitchInput(-increment); + } +} + +void ASniperClass::Fire() +{ + if(currentAmmoCount > 0 && !bSingleShotOnly) + { + bSingleShotOnly = true; + //do damage fallof based off distance + traceStart = GunStartArrow->GetComponentLocation(); + traceEnd = traceStart + (GunStartArrow->GetForwardVector() * BulletDistance); + if (GetWorldTimerManager().IsTimerActive(timerHandle)) return; + GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams); + DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Black , false, 0.2f, 0U, 0.2f); + playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1); + currentAmmoCount -= 1; + bulletCountShoot += 1; + bStopShooting = false; + GenerateRecoilVector(); + ApplyRecoil(UGameplayStatics::GetWorldDeltaSeconds(this->GetWorld())); + this->GetWorld()->GetTimerManager().SetTimer(SniperTimerHandle, this, &ASniperClass::StopFire, FireRate, false); + if (outHit.bBlockingHit) + { + UE_LOG(LogTemp, Display, TEXT("Hit: %s"), *outHit.GetActor()->GetName()); + if (!Cast(outHit.GetActor())) return; + Cast(outHit.GetActor())->TakeDamage(WeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); + } + } + else if(currentAmmoCount <= 0) + { + UE_LOG(LogTemp, Display, TEXT("No ammo, Ammo count: %d"), currentAmmoCount); + } +} + +void ASniperClass::ApplyRecoil(float DeltaTime) +{ + if (recoilTime < 0.3) + { + float amplitude = RecoilCurve->GetFloatValue(recoilTime); //get current value of curve in time + recoilTime += DeltaTime; + + playerInWorld->AddControllerPitchInput(GetRecoilPitch(amplitude, recoilTime)); + + currentPitch += GetRecoilPitch(amplitude,recoilTime); + + playerInWorld->AddControllerPitchInput(FMath::RandRange(-5 * DeltaTime, 5* DeltaTime)); + GunStartArrow->AddRelativeRotation(FRotator(-GetRecoilPitch(amplitude, recoilTime), 0, 0)); + playerInWorld->AddControllerYawInput(GetRecoilYaw(amplitude, recoilTime)); + + UpdateSamples(amplitude, recoilTime); + } +} + +void ASniperClass::StopFire() +{ + bSingleShotOnly = false; +} diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.h new file mode 100644 index 00000000..721020b1 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/SniperClass.h @@ -0,0 +1,42 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BaseWeaponClass.h" +#include "SniperClass.generated.h" + +/** + * + */ +UCLASS() +class ENDLESSVENDETTA_API ASniperClass : public ABaseWeaponClass +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + ASniperClass(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + +private: + + bool bSingleShotOnly; + FTimerHandle SniperTimerHandle; + +protected: + + virtual void Fire() override; + + virtual void ApplyRecoil(float DeltaTime) override; + + void StopFire(); + +};