UE5 GAS Base

GAS Base

Preface

  • There are many bugs in 4.27, such as the issue with GA’s Trigger Source.
  • Version used: 5.2.1. Please note that there are differences between GAS versions. The difference between 4.27 and 5.2.1 is very big.
  • This article is intended to describe the detailed panels of GE/GA/GC and can be used as a reference. It is not an introductory tutorial.
  • Most of them have been tested personally and the accuracy can be guaranteed (the content in the reference link may be wrong, I have made a second correction)
  • I really want to complain about some articles. I just follow the comments (GAS’s comments are also a mess) and explain them for granted. If I don’t try it myself, I will mislead readers.

Gameplay Ability

1. Tag

  1. Ability Tags : The tags of this GA.
  2. Cancel Abilities with Tag : When activating this GA, interrupt other GAs with the selected tag.
  3. Block Abilities with Tag : When activating the GA, prevent the activation of the GA with the selected tag (already activated ones will not be interrupted).
  4. Activation Owned Tags : When activating the GA, assign the selected GA to ASC.
  5. Activation Required Tags : Tags required by ASC when activating GA.
  6. Activation Blocked Tags : When activating GA, ASC cannot have tags.
  7. Source Required Tags : Tags required by Source when GA is activated.

    It's not immediately obvious how the system views "Source Tags" since it's not explained anywhere, but you can use the GameplayEvents attribute to carry a payload to activate the skill. GameplayEvent can pass a structure containing an InstigatorTags , which can be used for Source Required and Source Blocked Tag detection. When the payload contains all specified tags, the skill is allowed to be activated.

  8. Source Blocked Tags : When activating GA, Source cannot have tags.
  9. Target Required Tags : Tags required by Target when GA is activated.

    The same rules, except that TargetTags in the Payload structure are used here . InstigatorTags should be populated with descriptive tags for the skill owner and triggerer (usually the Character class), and then TargetTags should be populated with information about the skill's target. The code does not force you to fill in the Tag container in the GameplayEvent data. You can adjust it however you want. This is true.

  10. Target Blocked Tags : When activating GA, Target cannot have tags.

2. Input

  • Replicate Input Directly: Set to true, the Client will always synchronize the input press (Press) and release (Release) events to the Server. Epic does not recommend using this option and recommends using AbiliyTask Wait Input ReleaseandWait Input Press

trigger event:

/** Direct Input state replication. These will be called if bReplicateInputDirectly is true on the ability and is generally not a good thing to use. (Instead, prefer to use Generic Replicated Events). */
UFUNCTION(Server, reliable, WithValidation)
void UAbilitySystemComponent::ServerSetInputPressed(FGameplayAbilitySpecHandle AbilityHandle);

UFUNCTION(Server, reliable, WithValidation)
void UAbilitySystemComponent::ServerSetInputReleased(FGameplayAbilitySpecHandle AbilityHandle);

3. Advanced

  • Replication Policy : Do not use this option. The name is misleading and you don't need it. The GameplayAbilitySpecdefault is to synchronize from the server to the owning client. As mentioned above, GameplayAbility will not run on Simulated Proxy , which Use AbilityTask and GameplayCue to sync or RPC visual changes to a Simulated Proxy . Epic's Dave Ratti has indicated a desire to remove this option in the future.
  • Instancing Policy : The instantiation policy of a GameplayAbility determines whether and how a GameplayAbility is instantiated when it is activated.
    • Non-Instanced : GameplayAbility operates its ClassDefaultObject, no instance is created.
      • Best performance, but cannot store state, cannot have dynamic variables and AbilityTask
    • Instanced Per Execution : Every time a GameplayAbility is activated, a new GameplayAbility instance is created, and the same type of GA will be executed repeatedly.
      • Poor performance by default.
    • Instanced Per Actor : Each ASC can only have one GameplayAbility instance that is reused between activations (when the GA of the first Activate has not ended, repeated GA will be ignored)
      • The most commonly used strategy, instance GA will not be destroyed easily
  • Server Respects Remote Ability Cancellation : If the Client's GameplayAbility is canceled by the player or completed naturally, its Server version will be forced to end regardless of whether it is completed. Vice versa
  • Retrigger Instanced Ability : It only works when the Instancing Policy is Instanced Per Actor . If it is true and the first Activate GA has not ended, the repeated GA will End (not Cancel) the executing GA and then re-Activate.
  • Net Execution Policy : GameplayAbility's network execution policy (Net Execution Policy) determines who should run the GameplayAbility in what order
    • Local Only : GA only runs on the owning client. This is useful for abilities that only need to make local visual changes. Single player games should use Server Only.
    • Local Predicted : GA is first activated on the owning client, and then on the server. The server version will correct all inaccuracies predicted by the client.
    • Server Only : GA only runs on the server side. Passive GameplayAbility is generally Server Only. Single player games should use this option.
    • Server Initiated : GA is first activated on the server, and then on the owning client.
  • Net Security Policy : A GameplayAbility's network security policy determines where on the network an Ability should be executed. It provides protection for clients that attempt to execute a restricted Ability.
    • ClientOrServer : No security requirements. The client or server can freely trigger the execution and termination of the Ability.
    • ServerOnlyExecution : The client's execution of the Ability request will be ignored by the server, but the client can still request the server to cancel or end the Ability.
    • ServerOnlyTermination : The client's cancellation or end of the Ability request will be ignored by the server, but the client can still request to execute the Ability.
    • ServerOnly : The server controls the execution and termination of the Ability, and any requests from the client will be ignored.

4. Costs

Internal judgment logic:CurrentValue + CostValue < 0.f

Notice:

  • Cost must be submitted explicitly CommitAbilityafter calling it. If you do not commit but the one-time Cost causes CurrentValue<0.f, the skill will still not be released.
  • Use CurrentValue to judge. In theory, it can be used whether GE sets Period or not.

5. Triggers

Triggers Source:

  • Gameplay Event : GA is called once when the Owner receives a Gameplay Event with a Tag (not a GE of Gameplay Effect!). At this time, the Owner will not have the corresponding Tag.
  • Owned Tag Added : GA is called once when the Owner obtains the corresponding Tag. If the Tag is lost, GA will not be removed. It can be called in other ways later.
  • Owned Tag Present : GA is called once when the Owner obtains the corresponding Tag. If the Tag is lost, Remove GA will be performed. If the execution of GA is not completed, it will be Cancel.

6. Cooldowns

Precautions:

  • GE's GrantedTags can only work after setting the Tag.
  • In essence, it is restricted by Tag. After adding the corresponding Tag to ASC through other methods, GA cannot be released. Cooldowns GE just confirmed GA’s Cooldown Tag

Gameplay Effect

1. GameplayEffect

Use Curve Table : Query the Curve Table according to the GE Level to get the corresponding value. If there is a multiplier, it will be multiplied by it. GE Level = 0 is equivalent to 1

Magnitude Calculation Type:

  • Scalable Float : Specify a floating point number
  • Attribute Based : capture Attribute and then perform operations
    • Calculation RulesCoefficient * (PreMultiplyAdditiveValue + AttributeToCapture) + PostMultiplyAdditiveValue = Magnitude
    • Backing Attribute:
      • Attribute Source : Target or Source, the actor and issuer of GE
      • Snapshot : Snapshotting means capturing the Attribute when the GameplayEffectSpec is created, while No Snapshotting means capturing the Attribute when the GameplayEffectSpec is applied.
    • Attribute Curve: Use the captured Attribute value to query the Curve, and then put it into the formula calculation instead of using it directly.
    • Attribute Calculation Type:
      • Attribute Magnitude: Capture the CurrentValue of Attribute
      • Attribute Base Value: Capture the BaseValue of Attribute
      • Attribute Bonus Magnitude: Capture Attribute's CurrentValue-BaseValue
    • Source Tag Filter: The source code comments are as follows

      Filter to use on source tags; If specified, only modifiers applied with all of these tags will factor into the calculation

      • The actual test does not work. Observing the source code logic does not seem to use this parameter to actually have any impact on the Magnitude value (maybe it is a reserved parameter? I will add it after I study it clearly)
    • Target Tag Filter:

      Filter to use on target tags; If specified, only modifiers applied with all of these tags will factor into the calculation

  • Custom Calculation Class : GameplayModMagnitudeCalculation Class, the custom operation returns the value as Magnitude. Please refer to Custom Calculation Class
    // 重载函数
    virtual float CalculateBaseMagnitude_Implementation(const FGameplayEffectSpec& Spec) const override;
    
    • After getting the return value, you can further modify it in GE and calculate the rules.Coefficient * (PreMultiplyAdditiveValue + ReturnMagnitude) + PostMultiplyAdditiveValue = Magnitude
    • Final Lookup Curve : Use the Magnitude calculated by the above formula to query the Curve as the final Magnitude
  • Set by Caller : Get Magnitude from Caller
    • ASC->MakeOutgoingSpc->AssignSetByCallerMagnitude
1.1 Duration Policy
  • Instant : Enable immediately to change the BaseValue of the property. Because it is a transient effect, it should not be used to add GameplayTags.
  • Duration : Has a duration. If there is no Period, the CurrentValue of the attribute is modified. If there is a Period, each execution is equivalent to Instant, and the BaseValue is modified. Gameplay Tags can be added.
    • Duration = -1, the value will not change, equivalent to Infinite;
    • Duration <= 0, the value will gradually decrease over time, but it will not be interrupted and is equivalent to Infinite
    • So please note that when assigning a value to Duration for the first time, it must be >0
  • Infinite : Duration is permanent, but can be removed manually. If there is no Period, the CurrentValue of the attribute is modified. If there is, each execution is equivalent to Instant, and the BaseValue is modified. Gameplay Tags can be added.
1.2 Modifiers
  • Attribute : Attribute to be applied
  • Modifier Op : Modification method
    • Add: Attribute += Magnitude
    • Multiply: Attribute *= Magnitude
    • Divide: Attribute /= Magnitude
    • Override: Attribute = Magnitude
    • Invalid: It should be useless. Selecting this engine will trigger Assert.
  • Source Tags : According to GASDocumentation

    SourceTags and TargetTags can be set for each Modifier. They work the same like the Application Tag requirements of a GameplayEffect

    • But it seems that my actual application does not work on a single Modifier. I don’t know if my operation method is wrong. If I have any doubts here, I will make up for it after I figure it out.
  • Target Tags:
1.3 Executions

GameplayEffectExecutionCalculation Class, please refer to Custom Calculation Class

// 重载函数
virtual void Execute_Implementation(const FGameplayEffectCustomExecutionParameters& ExecutionParams, FGameplayEffectCustomExecutionOutput& OutExecutionOutput) const override;
1.4 Conditional Gameplay Effects

When the GE is successfully applied (note that it is Apply, it can also take effect even if the Ongoing Tag Requirements are not met), additional GE will be generated.

  • Effect Class : Class attached to GE
  • Required Source Tags : The Tags contained in the ASC of the Source are required

2. Period

After Duration and Infinite are set (Period != 0), each trigger is equivalent to Instant and BaseValue will be modified.

  • Execute Periodic Effect on Application: Whether to trigger when t=0, default=true
  • Periodic Inhibition Policy ----------> Relevant to whether it is executed successfully each time ( Ongoing Tag Requirements)
    • Never Reset : The period of time will continue as if the suppression never occurred. (Still trying to execute every time)
    • Reset Period : Reset period. The next execution will occur one full cycle after the inhibition is removed. (will restart SetTimer)
    • Execute and Reset Period: Execute immediately and reset the period. (After suppressing contact, it will be called once immediately, and then SetTimer. SetTimerForNextTick->SetTimer)

The execution of GE Period is implemented through Timer. Ongoing Tag RequirementsIf GE is not satisfied, it will be marked as bIsInhibited = true(this variable will be judged every time it is executed, and it can only be executed if it is false)

Let’s take an example to illustrate the role of Periodic Inhibition Policy.

GE1: Duration = 10s , Period = 1s. Modifiers: Health -= 10, Ongoing Tag Requirements:GE.Test

GE2: Duration = 2.2s, GrantedTags:GE.Test

Initially, ASC does not have Tag: GE.Test, but Apply GE1, obviously GE1 will not work. If GE2 is applied at 2.5s, ASC will get Tag: GE.Test, then trigger the callback FActiveGameplayEffectsContainer::OnOwnerTagChange, and then mark GE1 bIsInhibited = false. 4.7s ASC loses Tag: GE.Test, marked GE1bIsInhibited = true

The situation at this time is as follows:

  • Never ResetbIsInhibited = false : GE is executed as usual in 3.0s, normal execution Health -= 10 is detected ; similar in 4.0s; execution fails in 5.0s
    • Execution time: 3.0s 4.0s
    • EffectHealth -= 20
  • Reset Period : 2.5s bIsInhibited = falsewill be reset at the same time as SetTimermarking. Because of the coverage of Timer (the same Handle, the previous Timer will be invalid when re-set), the originally executed Period will be recalculated, so the next execution time is 3.5s; 4.5 s is executed for the second time, and the execution fails at 5.5s;
    • Execution time: 3.5s 4.5s
    • EffectHealth -= 20
  • Execute and Reset Period: Compared with Reset Period , SetTimerit will be before SetTimerForNextTick. Therefore, it will be executed once more every 2.5 seconds.
    • Execution time: 2.5s 3.5s 4.5s
    • EffectHealth -= 30

3. Application

Set the application probability and conditions of GE.

  • Chance to Apply to Target:概率
  • Application Requirement : GameplayEffectCustomApplicationRequirement class—>overload the CanApplyGameplayEffect function

4. Overflow

  • Overflow Effects : After Stakc overflows, you can choose Apply's GE
  • Deny Overflow Application : Overflowed GE will not affect the refresh of Stack. For example, if Stack Limit Count=2, when the third GE wants to take effect, the quantity limit will not be superimposed, but if Stack Duration Refresh Policy != NerverSet, Duration and Period will be refreshed in the same way.
  • Clear Stack on Overflow : When the Stack overflows, whether the Stack will be cleared. Can only be checked when Deny Overflow Application = true

5. Expiration

This logic only exists when the Duration Policy is not Instant .

  • Premature Expiration Effect Classes : GE applied when interrupting.
  • Routine Expiration Effect Classes : GE of Apply at the normal end

6. Display

  • Require Modifier Success to Trigger Cues : Cue can be triggered only when GE Modifiers or Executions are successfully applied.
  • Suppress Stacking Cues : When multiple GEs exist in the Stack, whether to only respond to the first GE
    • If checked, when multiple GEs exist in the Stack, only the first GE can trigger the GC On Activesum While Activeevent .
  • Gameplay Cues:
    • Magnitude Attribute : Select an Attribute to obtain its modified value and pass it to GC. It can be obtained through Raw Magnitude of GC Parameters.
      • For example, this time GE has modified Health, and the modified value is -10, then Raw Magnitude=-10.
    • Min Level:
      • Use with Max Level to standardize GE Level
      • Calculation rules: (GE Level - Min Level) / (Max Level - Min Level)Clamp 0.f-1.f
      • Available via Normalized Magnitude from GC Parameters
    • Max Level:
  • UIData: GameplayEffectUIData类

The impact of GE’s Duration Policy on GC trigger event types

  • Instant : trigger On Executean event immediately
  • Duration:
    • Has PeriodOn Active : The event will be triggered initially While Active, and then the event will be executed every Period On Execute. The event will be triggered at the end of Duration On Remove. On RemoveEvents will also be executed when GE is Removed or suppressed
    • No Period : The sum event will be triggered at the beginning , On Activeand the event While Activewill be triggered at the end of Duration On Remove. On RemoveEvents will also be executed when GE is Removed or suppressed
  • Infinite : similar to Duration

Precautions:

  • Regarding On Removethe triggering of events, for GC_Actor, it Auto Destroy on Removecan only be executed correctly if it is checked. Otherwise, it can only be triggered by GE for the first time, and it will not be triggered again in the future.
  • Theoretically, the choice of GC type has no impact on the triggering of events, but
    • GC_Static operates directly on ClassDefaultObject (meaning no instance), which is excellent for Instant effects (like hit damage).
    • GC_Actor will generate a new instance when it is added (Added), and because it is instantiated, it can perform operations over time until it is removed (Removed). This is great for looping sounds and particle effects, where It will be removed when the Duration or Infinite GameplayEffect is removed or manually called for removal. It also comes with options to manage how many are allowed to be added at the same time (multiple applications of the same effect only create one by default Example)

7. Tags

  • GameplayEffectAssetTag : Tag identifying GE
    • Combined Tag is the calculation result and cannot be edited. The calculation method is继承的Tag + Added - Removed
  • GrantedTags : GE will assign the tag of the target ASC. It is only applicable to Infinite and Has Duration GE. After the GE expires, the Tag will be removed from the ASC.
    • Combined Tag is the calculation result and cannot be edited. The calculation method is继承的Tag + Added - Removed
    • Instant doesn't work
  • GrantedBlockedAbilityTags : When GE exists, GA with these Tags cannot execute. (Same function as GA’s Block Abilities with Tag)
    • Combined Tag is the calculation result and cannot be edited. The calculation method is继承的Tag + Added - Removed
    • Instant doesn't work
  • Ongoing Tag Requirements : GE execution requires/does not require these tags, and these tags will take effect every time it is executed. on/off, GE can be applied but off and do nothing
    • Instant will work
  • Application Tag Requirements : GE applications require/don’t need these tags. These tags will only be considered the first time the Effect is applied, not every cycle execution. pass/faild
    • Instant will work
  • Removal Tag Requirements : When these tags are/are not owned, GE will be removed. Valid for the duration of GE
    • Instant will work
  • Remove Gameplay Effect Query : A more complex method of Remove GE (the author analyzed the source code and came to the following conclusion, but it did not work during the experiment and could not filter UE5.2.1)
    • Custom Match Delegate BP : A Dynamic Unicast Delegate is exposed to the blueprint for use (but I didn't find how to use it in the blueprint), returns bool
    • Owning Tag Query : Query the corresponding GEGameplayEffectAssetTag + GrantedTags + DynamicGrantedTags
      • DynamicGrantedTags are GrantedTags dynamically added by GE Spec---->ASC->MakeOutgoingSpec->AddGrantedTags
    • Effect Tag Query : Query the corresponding GEGameplayEffectAssetTag + DynamicAssetTags
      • DynamicAssetTags is the AssetTag dynamically added by GE Spec---->ASC->MakeOutgoing Spec->AddAssetTags
    • Source Tag Query : Query the Source Tags corresponding to GE
    • Modifying Attribute : Query the Attribute corresponding to GE modification
    • Effect Source : Query the Source Object corresponding to GE
    • Effect Definition : Query the Class corresponding to GE
  • Remove Gameplay Effects with Tags : When GameplayEffect is successfully applied, if the GE located on the target has any of this tag in its Asset Tags or Granted Tags, it will be removed from the target.
    • Combined Tag is the calculation result and cannot be edited. The calculation method is继承的Tag + Added - Removed
    • It only works when Apply. If the GE with Tag is added after Apply, it cannot be deleted.
    • Instant will work

8. Immunity

During the duration of GE, the GE target is given the ability to be immune to other GEs (see other articles saying it can be immune to GA, but the author has not tested this effect)

  • GrantedApplicationImmunityTags:
    • Require Tags : Other GEs will be immune if they have these Tags (must all have them). You can immunize yourself to ensure that only one GE takes effect at the same time (Statck cannot take effect either)
    • Ignore Tags : No test result (it stands to reason that GE will be immune without these Tags, but it is not true)
  • Granted Application Immunity Query: For more complex GE judgment, see Tag-Remove Gameplay Effect Query explanation (the author also did not successfully experiment with this function)

UAbilitySystemComponent::OnImmunityBlockGameplayEffectDelegateUse this system to provide a delegate when GameplayEffect is blocked by immunity .

9. Stacking

The concept of Stack only exists when the Duration Policy is not Instant .

  • Stacking Type : Stacking on the target or the caster

    For example, assuming the number of layers is 3, if it is by Target mode, then the Debuff released by three enemies on me can only stack three times. If it is by Source mode, then 3 enemies can superimpose 9 layers of Debuff on me.

    If the Effect of each layer is calculated using Modifiers, it is a direct superposition effect. For example, if Modifiers are used to increase the attack power by 3, the first layer will increase the attack power by 3, the second layer will increase the attack power by 6, and the third layer will be Increases attack power by 9, and if you need to change the increased value based on the number of layers, you need to use Executions.

  • Stack Limit Count : Number of layers
  • Stack Duration Refresh Policy : Whether to refresh Duration when applying new GE. By default, Overflow's GE will affect Stack refresh.
  • Stack Period Reset Policy : Whether to refresh the Period when applying a new GE. By default, Overflow's GE will affect Stack refresh.
  • Stack Expiration Policy : What to do when the Duration of a layer of GE expires
    • Clear Entire Stack : Clear all the stacks, such as LOL Conqueror.
    • Remove Single Stack and Refresh Duration : Clear one layer, such as LOL Fatal Rhythm.
    • Refresh Duration : Not cleared, equivalent to an infinite Duration, but you can FActiveGameplayEffectsContainer::OnStackCountChange(FActiveGameplayEffect& ActiveEffect, int32 OldStackCount, int32 NewStackCount)handle the details yourself by calling methods, such as dropping two layers at a time.

Usage details:

  • The method to enable Stack is to set the Stacking Type to other than None.
  • After turning on Stack, the Stack Limit Count is 0 , which means unlimited stacking is possible.
  • If Stack is not enabled, multiple GEs will work at the same time, and their own Durations will be calculated independently without interfering with each other.

10. Granted Abilities

When the Duration Policy is not Instant , the GE trigger will be assigned to the Target GA.

InputID: If you use the old version of input, each operation mapping corresponds to an enumeration value. Enter the corresponding enumeration value to bind the new GA to the input. Operations can refer to Ability and binding input.

Removal Policy:

  • Cancel Ability Immediately : After GE fails, if the Ability is executing, immediately Cancel and Remove the Ability
  • Remove Ability on End : After GE fails, if the Ability is executing, allow it to complete and remove the Ability.
  • Do Nothing : After GE expires, it will neither Remove nor Cancel, which is equivalent to having this Ability permanently.

Gameplay Cue

Introducing some parameters of GC_Actor

  • Auto Destroy on Remove : Whether to perform automatic Destory Recycle after the On Remove event (not destroy the Actor)
    • It is usually checked, otherwise there will be problems with the triggering of the on Remove event (see GE 6.Display).
    • The On Remove event does not destroy the Acotr, it just proceedsSetActorHiddenInGame(true)
  • Auto Destroy Delay : After checking Auto Destroy on Remove , how many seconds will it take for Destory
  • Auto Attach to Owner : Whether the GC follows the Owner. If true, it will move with the Owner. There is a performance loss that needs to be weighed
  • Is Override : Whether this GC will overwrite other GCs. For example, there are two GCs, and the Tags are GC.One.Two and GC.One. If you call GC.One.Two through GE, if the value is false, GC.One.Two and GC.One will be called. If the value is true, only GC.One.Two will be called.
  • Unique Instance Per Instigator : Does this GC add a new Instance for each Instigator? For example, if two Instigators apply GC on the same target, do we create two such GameplayCue Notify Actors or one? If GC is only on the target To play FX or sounds, a unique Instance is not required. If this Notify attaches a beam from the Instigator to the target, it does require a unique Instance per Instigator.
  • Unique Instance Per Source Object : Similar to Unique Instance Per Instigator , except that the target is Source Object .
    • Source Object and Instigator correspond to Parameters
    • By default, GC will only generate one Instance for the same target.
  • Allow Multiple on Active Events : When GC is executing, if a request comes to trigger GC again, will On Activethe event be triggered again?
  • Allow Multiple While Active Events : When GC is executing, if a request comes to trigger GC again, whether While Activethe event will be triggered again
  • Num Preallocated Instances : Pre-allocate memory space for GC Instance

reference

Guess you like

Origin blog.csdn.net/qq_52179126/article/details/131860252