Space Plunder
Loading...
Searching...
No Matches
CustomAICharacter.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
13//#include "Perception/AIPerceptionListenerInterface.h"
14#include "CustomAICharacter.generated.h"
15
16
17UCLASS()
18class CUSTOMALS_API ACustomAICharacter : public ACustomCharacterBase, public IAIActionsInterface,
19 public IStealthInterface, public IHitMarkerInterface, public ICompanionInterface //, public IAIPerceptionListenerInterface
20{
21 GENERATED_BODY()
22
23public:
24 ACustomAICharacter(const FObjectInitializer& ObjectInitializer);
25
26 //~ AI Actions, for Behaviors and Tasks ~//
27 UFUNCTION(BlueprintCallable, Category = "AI Actions")
28 virtual float Reload() override;
29 UFUNCTION(BlueprintCallable, Category="AI Actions")
30 virtual void Aim(const bool bStartAiming = true) override;
31 UFUNCTION(BlueprintCallable, Category="AI Actions")
32 virtual void CrouchAction(const bool bCrouch = true) override;
33 UFUNCTION(BlueprintCallable, Category="AI Actions")
34 virtual void ShootAction(const bool bStartShooting = true) override;
35 UFUNCTION(BlueprintCallable, Category="AI Actions")
36 virtual void ShootAtTargetAction(const bool bStartShooting = true, const FVector& TargetLocation = FVector::ZeroVector) override;
37 UFUNCTION(BlueprintCallable, Category="AI Actions")
38 virtual bool CheckAmmo(bool& bNeedToReload) const override;
39 virtual bool GetHasWeapon() const override;
40 virtual uint8 GetWeaponFireMode() const override;
41 virtual float GetWeaponFireRate() const override;
42
43 UFUNCTION(BlueprintCallable, Category="AI Actions")
44 virtual void UpdateMovementSpeed(const EAIMovementSpeed MovementSpeed = EAIMovementSpeed::Running, const EAIMovementType MovementType = EAIMovementType::Normal) override;
45 UFUNCTION(BlueprintCallable, Category="AI Actions")
46 virtual bool PickupObject(const AActor* TargetObject) override;
47 UFUNCTION(BlueprintCallable, Category="AI Actions")
48 virtual float MeleeAttack() override;
49 UFUNCTION(BlueprintCallable, Category="AI Actions")
50 virtual float PlayAnimationMontage(UAnimMontage* Montage, const float PlayRate = 1.0f, const float InTimeToStartMontageAt = 0.0f, const bool bStopAllMontages = true) override;
51 UFUNCTION(BlueprintCallable, Category="AI Actions")
52 virtual FVector PredictLocation(AActor* TargetActor) override;
53 UFUNCTION(BlueprintCallable, Category = "AI Actions")
54 virtual TArray<AActor*> GetHostileActors() const override;
55 // UFUNCTION(BlueprintCallable, Category = "AI Actions")
56 // virtual TArray<FHostileActorInfo> GetHostileActorsInfo() const override;
57 UFUNCTION(BlueprintCallable, Category = "AI Actions")
58 virtual TArray<AActor*> GetPerceivedObjects(TArray<EAIStimuliType> Filters) const override;
59 UFUNCTION(BlueprintCallable, Category = "AI Actions")
60 virtual AActor* GetBestHostileActor() const override;
61 UFUNCTION(BlueprintCallable, Category = "AI Actions")
62 virtual float GetMaxHealth() const override;
63 UFUNCTION(BlueprintCallable, Category="AI Actions")
64 virtual FVector GetLastKnownLocation(AActor* TargetActor, const TArray<EAISense>& Senses) override;
65
66 //~ AI Actions, for Behaviors and Tasks ~//
67
68 UFUNCTION(BlueprintCallable, Category = "AI Actions")
69 class UAITraitsComponent* GetTraitsComponent() const{return CharacterTraitsComponent;};
70 UFUNCTION(BlueprintCallable, Category = "AI Actions")
71 virtual void SetCanSprint(const bool CanSprint){bCanSprint = CanSprint;};
72
73
74 //~ Companion Interface ~//
75 UFUNCTION(BlueprintCallable, Category="Companions")
76 virtual void SetMaster(AActor* MasterActor) override;
77 UFUNCTION(BlueprintCallable, Category="Companions")
78 virtual void Follow() override;
79 UFUNCTION(BlueprintCallable, Category="Companions")
80 virtual void Pickup(AActor* TargetActor) override;
81 UFUNCTION(BlueprintCallable, Category="Companions")
82 virtual void Interact(AActor* TargetActor) override;
83 UFUNCTION(BlueprintCallable, Category="Companions")
84 virtual void StartCombat(AActor* TargetEnemy) override;
85 UFUNCTION(BlueprintCallable, Category="Companions")
86 virtual void Wait(const FVector& TargetLocation) override;
87 UFUNCTION(BlueprintCallable, Category="Companions")
88 virtual void GrabObject() override;
89 UFUNCTION(BlueprintCallable, Category="Companions")
90 virtual void AskToCrouch(const bool bValue) override;
91 UFUNCTION(BlueprintCallable, Category="Companions")
92 virtual FCompanionData GetCompanionData(const bool bValue) override;
93 // UFUNCTION(BlueprintCallable, Category="Companions")
94 // virtual void Attack() override;
95 UFUNCTION(BlueprintCallable, Category="Companions")
96 virtual bool GetIsReadyToCommand() const override;
97 //~ Companion Interface ~//
98
99
100 // //- Base Interface //
101 // virtual bool GetCharacterSkills(FCharacterBaseSkills& Traits) override;
102
103 // virtual int32 GetStrength() const override;
104 // virtual int32 GetPerception() const override;
105 // virtual int32 GetEndurance() const override;
106 // virtual int32 GetCharisma() const override;
107 // virtual int32 GetIntelligence() const override;
108 // virtual int32 GetAgility() const override;
109 // virtual int32 GetWeaponSkill() const override;
110 // virtual int32 GetStealth() const override;
111 // virtual int32 GetLuck() const override;
112
113
114 //- Stealth Interface //
115 virtual void StealthTakedown(AActor* Attacker, const int32 AnimationIndex) override;
116
117 virtual void CancelStealthTakedown() override;
118
119 virtual void StealthTakedownComplete() override;
120 virtual bool GetCanPerformTakedown(const float Damage) const override;
121 virtual void ShowStealthPrompt(const bool bShow = true) override;
122
123 UFUNCTION(BlueprintImplementableEvent, Category="Stealth")
124 void OnStealthTakedown();
125 UFUNCTION(BlueprintImplementableEvent, Category="Stealth")
126 void OnStealthTakedownComplete();
127 UFUNCTION(BlueprintImplementableEvent, Category="Stealth")
128 void OnStealthTakedownCancelled();
129 //- Stealth Interface //
130
131
132 UFUNCTION(BlueprintCallable, Category="Hit Markers")
133 virtual void HitMarker(const AActor* ActorHit, const float Damage, const UDamageType* DamageType, const FName HitBone, const FVector HitLocation, const bool bKillingHit = false, const bool bInjuredPart = false) override;
134
135protected:
136
137 //@ TODO Move all these to Base Character ? or Multiplayer Defender Character
138 // FStealthData StealthData;
139 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
140 FName StealthTakedownName = "Stealth_Attack_NonLethal_01";
141 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
142 bool bStealthMotionWarp = true;
143 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
144 bool bStealthMotionWarpFromComponent = true;
145 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
146 FName StealthMotionWarpBoneName = FName("root");
147 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
148 bool bStealthMotionWarpFollowComponent = true;
149
150 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
151 float StealthActorDistance = -175.0f;
152 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
153 float StealthActorForward = 65.0f;
154 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
155 float StealthActorZ = 90.0f;
156 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
157 float StealthActorRight = 20.0f;
158
159 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Stealth")
160 AActor* StealthCurrentAttacker = nullptr;
161 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
162 // bool bStealthAttach = false;
163 //- Stealth //
164 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
165 TArray<UAnimMontage*> StealthTakedownAnims;
166 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Stealth")
167 bool bGettingTakedown = false;
168
169 virtual void BeginPlay() override;
170 virtual void SetupComponents(AController* ControllerReference = nullptr, AActor* HUDReference = nullptr, bool bIsLocallyControlled = false) override;
171 virtual void Tick(const float DeltaTime) override;
172 virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
173
174 virtual void SetHandsTied(const bool bValue) override;
175
176 //- Base Interface //
177 virtual FInteractionData GetInteractionData() const override;
178
179
180 //- Interaction Interface //
181 virtual void OnInteract(AActor* Caller, const int32 SelectedInteraction) override;
182 virtual bool OnOverlap(AActor* Caller) override;
183 virtual void StartFocus() override;
184 virtual void EndFocus() override;
185
186 virtual void ReceiveOnInteract_Implementation(AActor* Caller, const EInteractionType InteractionType) override;
187 virtual void ReceiveStartFocus_Implementation(AActor* Caller) override;
188 virtual void ReceiveEndFocus_Implementation(AActor* Caller) override;
189
190 //- Blueprint Calls //
191 // UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Interaction", meta=(DisplayName = "On Interacted With"))
192 // void ReceiveOnInteract(AActor* Caller, const int32 SelectedInteraction);
193 // UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Interaction", meta=(DisplayName = "On Pickup"))
194 // void ReceiveOnPickUp(AActor* Caller);
195 // UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Interaction", meta=(DisplayName = "Start Focus"))
196 // void ReceiveStartFocus();
197 // UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Interaction", meta=(DisplayName = "End Focus"))
198 // void ReceiveEndFocus();
199
200
201 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Companion")
202 class UCompanionComponent* CompanionComponent;
203 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Shooting Component")
204 class UCharacterShootingComponent* CharacterShootingComponent;
205 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "AI Traits")
206 class UAITraitsComponent* CharacterTraitsComponent;
207 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Stealth")
208 class UStealthTakedownCollision* StealthTakedownCollision;
209 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Optimization")
210 class UOptimizationProxyComponent* OptimizationComponent;
211 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Animation")
212 class UMotionWarpingComponent* MotionWarping;
213
214 //- Optimization levels //
215 UFUNCTION()
216 virtual void OptimizationWaveChanged(const EOptimizationWave NewWave);
217 UFUNCTION(BlueprintImplementableEvent, Category="Optimization")
218 void OnOptimizationWaveChanged(const EOptimizationWave NewWave);
219
220
221 UFUNCTION()
222 virtual void AIStateChanged(EAIStateType State);
223
224
225 virtual EFactionType GetCharacterFaction() const override;
226
227 //- ALS Overridden //
228 virtual bool CanSprint() const override{return bCanSprint;};
229 virtual void RagdollStart() override;
230 virtual void RagdollEnd() override;
231
232 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Sprint")
233 bool bCanSprint = true;
234
235
236 virtual void NotifyHit(UPrimitiveComponent* MyComp, AActor* Other, UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;
237
238
239 virtual void FallOver(const float WaitTime) override;
240 virtual void GetUpFromFall() override;
241
242 //- Character Weapons Interface
243 virtual int32 PickupGunEvent(const FWeaponData_T In_WeaponData) override;
244 virtual bool PickupGunCheck(const FWeaponData_T& In_WeaponData) override;
245
246 //- Shooting Component Bind //
247 virtual void WeaponEquipped(const TArray<FWeaponData_T>& Weapons, const int32 CurrentWeaponIndex) override;
248 virtual void WeaponStateChanged(const struct FPlayerWeaponState& PlayerWeaponState) override;
249
250
251 // virtual void AddStartingWeapons() override;
252
253 virtual void OnDeath(AActor* OwningActor, const EDeathType DeathType, AActor* DeathCauser, AController* DeathInstigator) override;
254 virtual void OnDeathReplicated() override;
255
256 virtual void OnInjuredBodyPart(const EBodyPartName InjuredBodyPart, const FVector& HitLocation, const TArray<FBodyPart>& AllBodyParts) override;
257
258 virtual void OnKnockedOut(const UDamageType* DamageType, const float WaitTime) override;
259 virtual void OnWakeUp() override;
260
261 virtual void OnFullDamageHit(AController* InstigatedBy, const float TotalDamage, const UDamageType* DamageType,
262 const FName& HitBone, const FVector& HitLocation, const bool bKillingHit, const bool bInjuredPart) override;
263
264
265 void CheckForObstacle();
266 void JumpOverObstacle();
267 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Jump")
268 bool bShouldCheckForJumps = true;
269 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Jump")
270 bool bShouldCheckForDoors = true;
271
272 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Jump")
273 float JumpCheckFrequency = 1.0f;
274 //- Trace end is Multiplied by Velocity, in case that is near 0, add This
275 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Jump")
276 float VelocityAdditionalOffset = 25.0f;
277 //- when checking to jump, the sphere start at the actor location + this
278 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Jump")
279 float SphereStartOffset = 65.0f;
280 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Jump")
281 float VelocityClampMax = 100.0f;
282 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "AI|Jump")
283 float SphereTraceRadius = 45.0f;
284
285 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Custom ALS|Aim Assist")
286 float AimAssistSize = 160.0f;
287 //- How much does that sphere change when far away, 0.5 = 1/2 size at wave 2, 0.25 at wave 3
288 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Custom ALS|Aim Assist")
289 float AimAssistDistanceMultiplier = 0.5f;
290
291
292
293private:
294
295 UPROPERTY(VisibleAnywhere, Category= "Blackboard")
296 UBlackboardComponent* BlackboardComponent;
297
298 FTimerHandle SetupCompleteDelayTimerHandle;
299
300 FTimerHandle JumpCheckTimerHandle;
301};
EAIMovementSpeed
Definition AIDataTypes.h:84
EAIStateType
Definition AIDataTypes.h:121
EAIMovementType
Definition AIDataTypes.h:93
EFactionType
Definition AIDataTypes.h:103
EInteractionType
Definition BaseData.h:149
EBodyPartName
Definition BaseData.h:133
EDeathType
Definition BaseData.h:53
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
EOptimizationWave
Definition NPC_Optimizator_Types.h:12
Definition CustomAICharacter.h:20
The base class for custom characters in the game. Inherits from various interfaces and provides imple...
Definition CustomCharacterBase.h:31
Definition AIActionsInterface.h:20
Definition CompanionInterface.h:18
Definition HitMarkerInterface.h:16
Definition StealthInterface.h:17
Component responsible for managing the shooting behavior of a character.
Definition StealthTakedownCollision.h:14
Definition HealthData.h:26
Definition CompanionDataTypes.h:27
Definition BaseData.h:420
A struct that represents the state of a player's weapon.
Definition WeaponStructs.h:118
Struct representing data of a weapon that changes.
Definition WeaponStructs.h:861