How-To: Grant an Ability Set

Goal: bundle abilities, gameplay effects, and attribute sets into one UCrimsonAbilitySet data asset, grant it to an ability system component, and revoke it later - including across plugins with no dependency on CrimsonAbilitySystem.

Prerequisites
An actor with a UAbilitySystemComponent (the GAS plugin is enabled). Granting must run on the server.

1. Create and fill the ability set

Content Browser -> right-click -> Miscellaneous -> Data Asset, choose `CrimsonAbilitySet` as the class. Open it and populate three arrays: Granted Gameplay Abilities (each with an ability class, level, and input tag), Granted Gameplay Effects, and Granted Attributes (with optional per-attribute base-value overrides).

Screenshot pendingImages/CrimsonCommon/howto-abilityset-create.png
A CrimsonAbilitySet with Granted Gameplay Abilities / Effects / Attributes filled in.
Verify
The asset saves with at least one entry. Attribute overrides apply at grant time - set MaxHealth before Health so the cap is read first.

2. Grant it (you hold the ASC)

If you already have the UAbilitySystemComponent, grant directly and keep the returned handles so you can revoke the exact same grant later.

Screenshot pendingImages/CrimsonCommon/howto-abilityset-grant.png
Behind Has Authority: Give To Ability System (ASC, Source Object) -> store the returned Granted Handles.
Verify
The abilities appear on the ASC (check Abilities in the GAS debugger, or showdebug abilitysystem).

3. Grant it across a plugin boundary

When the granting plugin must not depend on CrimsonAbilitySystem (e.g. CrimsonEquipment granting a weapon's abilities), don't reach for the ASC yourself. Cast the owner to ICrimsonAbilitySystemOwner and let it grant on its own component.

cpp
// In CrimsonEquipment - zero #include from CrimsonAbilitySystem:
if (ICrimsonAbilitySystemOwner* Owner = Cast<ICrimsonAbilitySystemOwner>(OwnerActor))
{
FCrimsonAbilitySet_GrantedHandles Handles;
Owner->GrantAbilitySet(AbilitySet, /*SourceObject*/ ItemInstance, &Handles);
GrantedHandlesByItem.Add(ItemInstance, Handles);
}
Why this works
ICrimsonAbilitySystemOwner is the bridge interface (see Concept: Decoupling Patterns). UCrimsonAbilitySystemComponent in CrimsonAbilitySystem implements it; the equipment plugin only knows the interface. Note it has no GetAbilitySystemComponent() - the implementer owns its ASC and grants on it directly.

4. Revoke it

Pass the stored handles back to remove everything the grant added - also server-only.

Call Revoke Ability Set (UCrimsonAbilitySetStatics) with the stored Granted Handles and the ASC. The handle set is cleared after removal so it can't be revoked twice.

Verify
The granted abilities/effects/attribute sets are gone from the ASC after the call, and clients reflect the removal.

See also

  • Concept: Decoupling Patterns - the interface-bridge pattern in full
  • API Reference - UCrimsonAbilitySet, FCrimsonAbilitySet_GrantedHandles, ICrimsonAbilitySystemOwner