188 lines
4.1 KiB
C++
188 lines
4.1 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "WeaponItemClass.h"
|
|
#include "Components/ArrowComponent.h"
|
|
#include "Kismet/KismetMathLibrary.h"
|
|
#include "EndlessVendetta/InteractionInterface.h"
|
|
#include "BaseWeaponClass.generated.h"
|
|
|
|
class AEndlessVendettaCharacter;
|
|
class UCapsuleComponent;
|
|
|
|
UCLASS()
|
|
class ENDLESSVENDETTA_API ABaseWeaponClass : public AActor, public IInteractionInterface
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Sets default values for this actor's properties
|
|
ABaseWeaponClass();
|
|
|
|
protected:
|
|
// Called when the game starts or when spawned
|
|
virtual void BeginPlay() override;
|
|
|
|
void ApplyRecoil(float DeltaTime);
|
|
|
|
void GenerateRecoilVector();
|
|
|
|
void nullSamples();
|
|
|
|
//recoil previous curve
|
|
float recoilCurvez1 = 0;
|
|
|
|
//recoil previous curve time
|
|
float recoilCurvet = 0;
|
|
|
|
float recoilTime = 0;
|
|
|
|
float recoilResultPitch = 0;
|
|
float recoilResultYaw = 0;
|
|
|
|
UFUNCTION(BlueprintImplementableEvent)
|
|
void ShowReloadingWidget();
|
|
|
|
UFUNCTION(BlueprintImplementableEvent)
|
|
void HideReloadingWidget();
|
|
|
|
|
|
|
|
public:
|
|
// Called every frame
|
|
virtual void Tick(float DeltaTime) override;
|
|
void ReloadTimer();
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
FString WeaponName;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
int WeaponDamage;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
FString WeaponDescription;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
float FireRate;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
int MagazineSize;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
float TimeToReload = 3.f;
|
|
|
|
//how many bullets until the recoil stops going up
|
|
UPROPERTY(EditAnywhere)
|
|
int howMnyShotsTillRclStop;
|
|
|
|
UPROPERTY(BlueprintReadWrite)
|
|
int currentAmmoCount;
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
|
UTexture2D* WeaponImage;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
|
float scopedRecoilMag;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
|
float scopedMaxAngleLeft;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
|
float scopedMaxAngleRight;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "ScopedFire")
|
|
float scopedMinMultiplier;
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
|
virtual void Fire();
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
|
virtual void ClickDetectionTimer();
|
|
|
|
virtual void CancelFire();
|
|
|
|
UPROPERTY(VisibleAnywhere)
|
|
ACharacter* playerInWorld;
|
|
|
|
AEndlessVendettaCharacter* endlessVendettaChar;
|
|
|
|
APlayerController* playerControllerRef;
|
|
|
|
FTimerHandle timerHandle;
|
|
FTimerHandle reloadTimerHandle;
|
|
|
|
bool bFirstBulletShot = false;
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
TSubclassOf<UCameraShakeBase> CameraShakeClass;
|
|
|
|
/* How far the gun goes up*/
|
|
UPROPERTY(EditAnywhere, Category = "Recoil")
|
|
float recoilMagnitude;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Recoil")
|
|
float recoilMaxAngleLeft;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Recoil")
|
|
float recoilMaxAngleRight;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Recoil")
|
|
float recoilMinMultiplier;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Recoil")
|
|
class UCurveFloat* RecoilCurve;
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Recoil")
|
|
float GetRecoilPitch(float Amp, float Time);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Recoil")
|
|
float GetRecoilYaw(float Amp, float Time);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Recoil")
|
|
void UpdateSamples(float Amp, float Time);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
|
void WeaponScopedFire();
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
|
void WeaponReload();
|
|
|
|
FHitResult outHit;
|
|
FVector traceStart;
|
|
FVector traceEnd;
|
|
FVector newTraceEnd;
|
|
FCollisionQueryParams collisionParams;
|
|
|
|
//UFUNCTION(BlueprintCallable, Category = "Weapons")
|
|
//void RecoilVerticalLimit(FHitResult Outhit);
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
int bulletCountShoot; //Gets how many bullets shot per
|
|
|
|
void Interact() override;
|
|
|
|
void InteractPrompt() override;
|
|
|
|
UFUNCTION(BlueprintImplementableEvent)
|
|
void WeaponStatsPopUp();
|
|
|
|
protected:
|
|
UArrowComponent* GunStartArrow;
|
|
bool bStopShooting = false;
|
|
|
|
private:
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
float BulletDistance;
|
|
|
|
float originalMagnitude;
|
|
float originalMaxAngleLeft;
|
|
float originalMaxAngleRight;
|
|
float originalMinMultiplier;
|
|
|
|
float currentPitch;
|
|
|
|
};
|