34 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Weapon|Debugging")
35 bool bDebuggingMode = false;
36 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
37 bool bInfiniteAmmo = false;
38 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
39 bool bBottomlessClip = false;
40 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
41 float DrawDebugTime = 2.0f;
42 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
43 float DrawDebugColorDarkMultiplier = 0.1f;
44 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
45 float DrawDebugColorLightMultiplier = 2.0f;
46 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
47 float DrawDebugPointSize = 16.0f;
48 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
49 FLinearColor MainTraceColor = FLinearColor(0.9f, 0.1f, 0.1f);
50 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Weapon|Debugging")
51 FLinearColor BlindFireTraceColor = FLinearColor(0.1f, 0.9f, 0.1f);
53 UPROPERTY(EditAnywhere, Category = "Weapon|Trace|Debugging")
54 bool bTraceComplex = false;
55 UPROPERTY(EditAnywhere, Category = "Weapon|Trace|Debugging")
56 bool bReturnPhysicalMaterial = false;
58 UPROPERTY(EditAnywhere, Category = "Weapon|Trace|Debugging")
59 float TraceDistanceTooClose = 0.075f;
61 virtual
void BeginPlay() override;
62 virtual
void SetupWeaponEffects();
64 UFUNCTION(BlueprintCallable, Category="Weapon|Debugging")
65 void LogDebugMessage(const FString& Message, const
bool bError = false) const;
67 UFUNCTION(
Server, Reliable, Category="Weapon")
68 void Server_InitWeapon();
71 virtual
void InitWeapon() override;
73 virtual
void Fire(const FVector
Location, const FRotator Rotation, const AActor* ActorToIgnore, const
float Accuracy) override;
74 virtual
void Reload(const
float ReloadTime) override;
75 virtual
void CancelReload() override;
76 virtual
void SwitchAutoMode() override;
77 virtual
void BlindFireWeapon(const FVector
Location,const FRotator Rotation, const AActor* ActorToIgnore, const
float Accuracy) override;
79 virtual
void AddAttachment(const FString& AttachmentID) override;
80 virtual
void ToggleAttachment(const
EAttachmentType& AttachmentType) override;
82 virtual
void MoveUMG(
bool bIsRightShoulder) override;
83 virtual
void Aiming(
bool bIsAiming) override;
85 virtual
FWeaponData_T GetWeaponData()
const override {
return WeaponData;};
90 virtual FTransform
GetPivotPoint()
const override {
return RecoilPivotPoint->GetRelativeTransform();};
91 virtual FTransform GetAimDownSightSocket()
const override;
92 virtual float GetWeaponFOV()
const override;
94 virtual bool IsClipEmpty()
const override {
return WeaponData.CurrentAmmo <= 0;};
97 virtual void SetWeaponShouldAutoReload(
const bool bValue)
override;
98 virtual void SetWeaponMesh(USkeletalMesh* SkeletalMesh)
override;
99 virtual void SetMuzzleOffset(
const FVector&
Location,
const FRotator& Rotation)
override;
100 virtual void SetRecoilPivotPoint(
const FVector&
Location,
const FRotator& Rotation)
override;
102 virtual void SetWeaponMeshHidden(
const bool bValue)
override;
103 UFUNCTION(NetMulticast, Reliable)
104 void Multicast_SetWeaponMeshHidden(const
bool bValue);
106 virtual
void SetDebuggingStats(const
bool bDebug, const
bool bInfinite, const
bool bBottomless)
override {bDebuggingMode = bDebug; bInfiniteAmmo = bInfinite, bBottomlessClip = bBottomless;};
110 UFUNCTION(BlueprintCallable, Category=
"Weapons")
111 virtual
void ToggleLaser(const
bool bForceOff = false);
115 UFUNCTION(BlueprintImplementableEvent, Category = "Weapon", meta=(DisplayName = "
Fire"))
116 void ReceiveFire(FHitResult
Hit, APawn* InstigatorPawn);
120 UFUNCTION(BlueprintCallable, Category = "Weapon|Attachments")
122 UFUNCTION(BlueprintCallable, Category = "Weapon|Attachments")
124 UFUNCTION(BlueprintCallable, Category = "Weapon|Attachments")
126 UFUNCTION(BlueprintCallable, Category = "Weapon|Attachments")
127 bool RemoveAttachment(const FString AttachmentID, const
EAttachmentType AttachmentType);
128 UFUNCTION(BlueprintCallable, Category = "Weapon|Attachments")
129 void RemoveAllAttachments();
132 bool CanShoot() const;
133 float GetAccuracyMultiplier()
const {
return AccuracyMultiplier;};
136 void ApplyDamageToActor(
const FHitResult&
Hit, FVector ShotDirection,
float Multiplier = 1.0f);
139 UFUNCTION(
Server, Reliable)
140 void ServerFire(const FVector
Location,const FRotator Rotation, const AActor* ActorToIgnore, const
float Accuracy);
141 UFUNCTION(
Server, Reliable, WithValidation)
142 virtual
void ServerShoot();
143 UFUNCTION(
Server, Reliable)
144 void ServerSetReloading(const
bool bReloading);
145 UFUNCTION(
Server, Reliable)
147 UFUNCTION(
Server, Reliable, Category = "Weapons|ADS")
148 virtual
void Server_SetWeaponShouldAutoReload(const
bool bValue);
150 void CalculateBulletSpread(FVector& NewBulletSpread) const;
153 virtual
float CalculateDistanceDamage(const
float Distance) const;
154 virtual FHitResult BlindFireWeaponTrace(const
float Accuracy, const AActor* ActorToIgnore =
nullptr);
155 virtual
bool LineTrace(FHitResult&
Hit, FVector& ShotDirection, const FLinearColor& Color = FLinearColor::Green, const FVector& CustomLineEnd = FVector::ZeroVector) const;
158 UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category="Weapon|Components")
159 UHitscanWeaponComponent* HitscanWeaponComponent;
160 UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category="Weapon|Components")
161 UProjectileWeaponComponent* ProjectileWeaponComponent;
164 FVector TraceLocation;
165 FRotator TraceRotation;
168 const AActor* TraceActorToIgnore;
170 TArray<AActor*> ActorsToIgnore;
175 UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category="Weapon|Weapon Data")
177 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Weapon|
General")
182 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon|Components")
183 USceneComponent* SceneRoot;
184 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon|Components")
185 USkeletalMeshComponent* GunMeshComponent;
186 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon|Components")
187 USceneComponent* Muzzle;
188 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon|Components")
189 USceneComponent* RecoilPivotPoint;
190 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon|Components")
191 TArray<UStaticMeshComponent*> AttachmentComponents;
192 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Weapon|Components")
193 class UWeaponEffectsComponent* WeaponEffects;
196 void OnMeshReplicated();
199 void OnRep_WeaponStats();
201 UPROPERTY(ReplicatedUsing=OnMeshReplicated, VisibleAnywhere, BlueprintReadOnly, Category = "Weapon|Components")
202 USkeletalMesh* WeaponMesh;
204 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="
Projectile")
205 TSubclassOf<class AActor> ProjectileClass;
209 void SetWeaponFireMode();
210 void AddWeaponAttachments();
213 void ShootProjectile();
214 UPROPERTY(ReplicatedUsing=OnRep_WeaponStats, VisibleAnywhere, Category = "Weapon|Status")
218 bool bWeaponEffectsSetup = false;
219 float AccuracyMultiplier = 1.0f;
220 bool bLaserOn = false;
222 bool bIsBeingReloaded;
223 FTimerHandle ReloadTimerHandle;