{"id":127,"date":"2022-03-16T15:59:56","date_gmt":"2022-03-16T15:59:56","guid":{"rendered":"https:\/\/www.thegames.dev\/?p=127"},"modified":"2022-03-16T16:02:05","modified_gmt":"2022-03-16T16:02:05","slug":"checking-if-gameplay-ability-is-active","status":"publish","type":"post","link":"https:\/\/www.thegames.dev\/?p=127","title":{"rendered":"Checking if Gameplay Ability is Active."},"content":{"rendered":"\n<p>Here some useful functions for your custom Ability System Component to determine if an ability is Active or not.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: Relevant Code:; notranslate\" title=\"Relevant Code:\">\nbool UKaosAbilitySystemComponent::IsAbilityActive(const FGameplayTagContainer* WithTags, const FGameplayTagContainer* WithoutTags, UGameplayAbility* Ignore)\n{\n\tABILITYLIST_SCOPE_LOCK();\n\n\tfor (FGameplayAbilitySpec&amp; Spec : ActivatableAbilities.Items)\n\t{\n\t\tif (!Spec.IsActive() || Spec.Ability == nullptr || Spec.Ability == Ignore)\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bool WithTagPass = (!WithTags || Spec.Ability-&gt;AbilityTags.HasAny(*WithTags));\n\t\tconst bool WithoutTagPass = (!WithoutTags || !Spec.Ability-&gt;AbilityTags.HasAny(*WithoutTags));\n\n\t\tif (WithTagPass &amp;&amp; WithoutTagPass)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nbool UKaosAbilitySystemComponent::IsAbilityActive(const FGameplayAbilitySpecHandle&amp; InHandle)\n{\n\tABILITYLIST_SCOPE_LOCK();\n\tFGameplayAbilitySpec* Spec = FindAbilitySpecFromHandle(InHandle);\n\treturn Spec ? Spec-&gt;IsActive() : false;\n}\n\nbool UKaosAbilitySystemComponent::IsAbilityActive(TSubclassOf&lt;UKaosGameplayAbility&gt; AbilityClass, UObject* SourceObject)\n{\n\tABILITYLIST_SCOPE_LOCK();\n\n\tFGameplayAbilitySpec* Spec;\n\n\tif (SourceObject)\n\t{\n\t\tSpec = FindAbilitySpecByClassAndSource(AbilityClass, SourceObject);\n\t}\n\telse\n\t{\n\t\tSpec = FindAbilitySpecFromClass(AbilityClass);\n\t}\n\n\tif (Spec)\n\t{\n\t\treturn Spec-&gt;IsActive();\n\t}\n\treturn false;\n}\n<\/pre><\/div>\n\n\n<p>This is a very short post, and the functions should make some sense just by reading them.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here some useful functions for your custom Ability System Component to determine if an ability is Active or not. This is a very short post, and the functions should make some sense just by reading them.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2],"tags":[],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-gameplay-ability-system","category-unreal-engine"],"rise-blocks_total_comments":0,"rise-blocks_categories":[{"term_id":4,"name":"Gameplay Ability System","slug":"gameplay-ability-system","term_group":0,"term_taxonomy_id":4,"taxonomy":"category","description":"Unreal Engine's Gameplay Ability System (GAS)","parent":2,"count":16,"filter":"raw","cat_ID":4,"category_count":16,"category_description":"Unreal Engine's Gameplay Ability System (GAS)","cat_name":"Gameplay Ability System","category_nicename":"gameplay-ability-system","category_parent":2},{"term_id":2,"name":"Unreal Engine","slug":"unreal-engine","term_group":0,"term_taxonomy_id":2,"taxonomy":"category","description":"All unreal engine related tutorials, tips and tricks.","parent":0,"count":5,"filter":"raw","cat_ID":2,"category_count":5,"category_description":"All unreal engine related tutorials, tips and tricks.","cat_name":"Unreal Engine","category_nicename":"unreal-engine","category_parent":0}],"rise-blocks_excerpt":"Here some useful functions for your custom Ability System Component to determine if an ability is Active or not. This is a very short post, and the functions should make some sense just by reading them.","_links":{"self":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127"}],"version-history":[{"count":2,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thegames.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}