GKLSampleAbilities.h
Click a line number to link it. Shift-click to select a range.
| 1 | // Copyright (c) 2026 Reignance Studios. MIT License, see LICENSE. |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include "CoreMinimal.h" |
| 6 | #include "ActiveGameplayEffectHandle.h" |
| 7 | #include "GKLGameplayAbility.h" |
| 8 | #include "GKLSampleAbilities.generated.h" |
| 9 | |
| 10 | /* |
| 11 | * Five samples, each showing one multiplayer pattern. Subclass them in Blueprint to tune numbers. |
| 12 | * |
| 13 | * Jump LocalPredicted, stamina cost, movement already predicted by the CharacterMovementComponent |
| 14 | * Heal LocalPredicted, mana cost + cooldown, effect on self predicted with the activation's key |
| 15 | * Strike LocalPredicted cost/cooldown, damage applied by the server only |
| 16 | * Regen ServerOnly passive, starts when granted, infinite periodic effect |
| 17 | * Death ServerOnly, triggered by Event.Death from the AttributeSet |
| 18 | */ |
| 19 | |
| 20 | /** Ability.Jump: 10 stamina. */ |
| 21 | UCLASS() |
| 22 | class GASKITLITE_API UGKLAbility_Jump : public UGKLGameplayAbility |
| 23 | { |
| 24 | GENERATED_BODY() |
| 25 | |
| 26 | public: |
| 27 | UGKLAbility_Jump(); |
| 28 | |
| 29 | virtual bool CanActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 30 | const FGameplayTagContainer* SourceTags = nullptr, const FGameplayTagContainer* TargetTags = nullptr, |
| 31 | FGameplayTagContainer* OptionalRelevantTags = nullptr) const override; |
| 32 | virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 33 | const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override; |
| 34 | }; |
| 35 | |
| 36 | /** Ability.Heal: 25 mana, 6 s cooldown, +30 health. */ |
| 37 | UCLASS() |
| 38 | class GASKITLITE_API UGKLAbility_Heal : public UGKLGameplayAbility |
| 39 | { |
| 40 | GENERATED_BODY() |
| 41 | |
| 42 | public: |
| 43 | UGKLAbility_Heal(); |
| 44 | |
| 45 | virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 46 | const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override; |
| 47 | |
| 48 | protected: |
| 49 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Heal") |
| 50 | float HealAmount = 30.f; |
| 51 | }; |
| 52 | |
| 53 | /** Ability.Strike: 15 stamina, 0.8 s cooldown, 20 damage to every ASC in a sphere in front of the avatar. */ |
| 54 | UCLASS() |
| 55 | class GASKITLITE_API UGKLAbility_Strike : public UGKLGameplayAbility |
| 56 | { |
| 57 | GENERATED_BODY() |
| 58 | |
| 59 | public: |
| 60 | UGKLAbility_Strike(); |
| 61 | |
| 62 | virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 63 | const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override; |
| 64 | |
| 65 | protected: |
| 66 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Strike") |
| 67 | float DamageAmount = 20.f; |
| 68 | |
| 69 | /** Distance from the avatar to the sphere centre, in cm. */ |
| 70 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Strike") |
| 71 | float Range = 150.f; |
| 72 | |
| 73 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Strike") |
| 74 | float Radius = 80.f; |
| 75 | }; |
| 76 | |
| 77 | /** Ability.Passive.Regen: +10 stamina and +2 mana per second while alive. */ |
| 78 | UCLASS() |
| 79 | class GASKITLITE_API UGKLAbility_Regen : public UGKLGameplayAbility |
| 80 | { |
| 81 | GENERATED_BODY() |
| 82 | |
| 83 | public: |
| 84 | UGKLAbility_Regen(); |
| 85 | |
| 86 | virtual void OnGiveAbility(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override; |
| 87 | virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 88 | const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override; |
| 89 | virtual void EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 90 | const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility, bool bWasCancelled) override; |
| 91 | |
| 92 | private: |
| 93 | FActiveGameplayEffectHandle RegenHandle; |
| 94 | }; |
| 95 | |
| 96 | /** Ability.Death: cancels other abilities, adds State.Dead, tells the character. */ |
| 97 | UCLASS() |
| 98 | class GASKITLITE_API UGKLAbility_Death : public UGKLGameplayAbility |
| 99 | { |
| 100 | GENERATED_BODY() |
| 101 | |
| 102 | public: |
| 103 | UGKLAbility_Death(); |
| 104 | |
| 105 | virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 106 | const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override; |
| 107 | }; |