Merge remote-tracking branch 'origin/Shotgun-weapon-creation' into dev
This commit is contained in:
		
						commit
						9688c71a31
					
				
							
								
								
									
										
											BIN
										
									
								
								EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Shotguns/BP_BaseShotgun.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Snipers/BaseSniper.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/Snipers/BaseSniper.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								EndlessVendetta/Content/FirstPerson/Blueprints/BaseWeapons/WBP_AmmoCount.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/5/1H/2QRFI3J5JT02V2G1QP4P99.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/5/1H/2QRFI3J5JT02V2G1QP4P99.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/7/VS/TBSU6BHEHN191N9FG8A6XN.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								EndlessVendetta/Content/__ExternalActors__/FirstPerson/Maps/GunMechanicTester/7/VS/TBSU6BHEHN191N9FG8A6XN.uasset
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -10,6 +10,7 @@
 | 
				
			|||||||
#include "AI/EnemyCharacter.h"
 | 
					#include "AI/EnemyCharacter.h"
 | 
				
			||||||
#include "GameFramework/CharacterMovementComponent.h"
 | 
					#include "GameFramework/CharacterMovementComponent.h"
 | 
				
			||||||
#include "Kismet/GameplayStatics.h"
 | 
					#include "Kismet/GameplayStatics.h"
 | 
				
			||||||
 | 
					#include "GameFramework/MovementComponent.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//////////////////////////////////////////////////////////////////////////
 | 
					//////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
@ -71,6 +72,16 @@ void AEndlessVendettaCharacter::Tick(float DeltaTime)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	WeaponPickUpSystem();
 | 
						WeaponPickUpSystem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						MoveGroundSpeed = Cast<UMovementComponent>(GetComponentByClass(UMovementComponent::StaticClass()))->Velocity.Size();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (MoveGroundSpeed > 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							bIsPlayerMoving = true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (MoveGroundSpeed <= 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							bIsPlayerMoving = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AEndlessVendettaCharacter::WeaponPickUpSystem()
 | 
					void AEndlessVendettaCharacter::WeaponPickUpSystem()
 | 
				
			||||||
 | 
				
			|||||||
@ -94,6 +94,10 @@ public:
 | 
				
			|||||||
	AGadgetManager* GadgetManager;
 | 
						AGadgetManager* GadgetManager;
 | 
				
			||||||
	bool bIsReloading = false;
 | 
						bool bIsReloading = false;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						bool bIsPlayerMoving = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						double MoveGroundSpeed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Look Input Action */
 | 
						/** Look Input Action */
 | 
				
			||||||
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
 | 
						UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
 | 
				
			||||||
	class UInputAction* LookAction;
 | 
						class UInputAction* LookAction;
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@
 | 
				
			|||||||
#include "Components/ArrowComponent.h"
 | 
					#include "Components/ArrowComponent.h"
 | 
				
			||||||
#include "Kismet/KismetMathLibrary.h"
 | 
					#include "Kismet/KismetMathLibrary.h"
 | 
				
			||||||
#include "EndlessVendetta/InteractionInterface.h"
 | 
					#include "EndlessVendetta/InteractionInterface.h"
 | 
				
			||||||
 | 
					#include "Engine/EngineTypes.h"
 | 
				
			||||||
#include "BaseWeaponClass.generated.h"
 | 
					#include "BaseWeaponClass.generated.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AEndlessVendettaCharacter;
 | 
					class AEndlessVendettaCharacter;
 | 
				
			||||||
@ -25,7 +26,7 @@ protected:
 | 
				
			|||||||
	// Called when the game starts or when spawned
 | 
						// Called when the game starts or when spawned
 | 
				
			||||||
	virtual void BeginPlay() override;
 | 
						virtual void BeginPlay() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void ApplyRecoil(float DeltaTime);
 | 
						virtual void ApplyRecoil(float DeltaTime);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	void GenerateRecoilVector();
 | 
						void GenerateRecoilVector();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -55,6 +56,10 @@ public:
 | 
				
			|||||||
	virtual void Tick(float DeltaTime) override;
 | 
						virtual void Tick(float DeltaTime) override;
 | 
				
			||||||
	void ReloadTimer();
 | 
						void ReloadTimer();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						float currentPitch;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						UPROPERTY(EditAnywhere)
 | 
				
			||||||
 | 
						float BulletDistance;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
 | 
						UPROPERTY(EditAnywhere, BlueprintReadWrite)
 | 
				
			||||||
	FString WeaponName;
 | 
						FString WeaponName;
 | 
				
			||||||
@ -159,7 +164,7 @@ public:
 | 
				
			|||||||
	//UFUNCTION(BlueprintCallable, Category = "Weapons")
 | 
						//UFUNCTION(BlueprintCallable, Category = "Weapons")
 | 
				
			||||||
	//void RecoilVerticalLimit(FHitResult Outhit);
 | 
						//void RecoilVerticalLimit(FHitResult Outhit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	UPROPERTY(EditAnywhere)
 | 
						UPROPERTY(VisibleAnywhere)
 | 
				
			||||||
	int bulletCountShoot; //Gets how many bullets shot per
 | 
						int bulletCountShoot; //Gets how many bullets shot per
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void Interact() override;
 | 
						void Interact() override;
 | 
				
			||||||
@ -177,14 +182,10 @@ protected:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	UPROPERTY(EditAnywhere)
 | 
					 | 
				
			||||||
	float BulletDistance;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	float originalMagnitude;
 | 
						float originalMagnitude;
 | 
				
			||||||
	float originalMaxAngleLeft;
 | 
						float originalMaxAngleLeft;
 | 
				
			||||||
	float originalMaxAngleRight;
 | 
						float originalMaxAngleRight;
 | 
				
			||||||
	float originalMinMultiplier;
 | 
						float originalMinMultiplier;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	float currentPitch;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -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();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -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<AAICharacter>(outHit.GetActor())) return;
 | 
				
			||||||
 | 
								Cast<AAICharacter>(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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -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();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user