AbilitySystem.IgnoreCosts

AbilitySystem.IgnoreCosts

#Overview

name: AbilitySystem.IgnoreCosts

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of AbilitySystem.IgnoreCosts is to provide a cheat or debug option to ignore the costs associated with activating Gameplay Abilities in Unreal Engine’s Ability System.

This setting variable is primarily used in the Gameplay Abilities system, which is a part of the GameplayAbilities plugin in Unreal Engine. It’s specifically utilized in the AbilitySystemGlobals class, which manages global settings and functionality for the Ability System.

The value of this variable is set through a console variable (CVar) named “AbilitySystem.IgnoreCosts”. It’s defined using FAutoConsoleVariableRef in the AbilitySystemGlobals.cpp file, which means it can be changed at runtime through the console or configuration files.

This variable interacts directly with the boolean variable bIgnoreAbilitySystemCosts. They share the same value, with the console variable controlling the state of bIgnoreAbilitySystemCosts.

Developers must be aware that this is a cheat variable (ECVF_Cheat flag), meaning it’s intended for testing and debugging purposes, not for regular gameplay. Using this in a shipping game could potentially break game balance and create exploits.

Best practices when using this variable include:

  1. Only use it for testing and debugging purposes.
  2. Ensure it’s disabled in shipping builds.
  3. Be cautious when using it in multiplayer scenarios, as it could lead to desynchronization between server and clients.

Regarding the associated variable bIgnoreAbilitySystemCosts:

The purpose of bIgnoreAbilitySystemCosts is to store the state of whether ability costs should be ignored. It’s the actual boolean variable that the game code checks when determining whether to apply costs for activating abilities.

This variable is used within the AbilitySystemGlobals class, specifically in the ShouldIgnoreCosts() function, which other parts of the Ability System can query to determine if costs should be applied.

The value of this variable is set by the AbilitySystem.IgnoreCosts console variable.

It interacts directly with the AbilitySystem.IgnoreCosts console variable, reflecting its state.

Developers should be aware that this variable is marked as deprecated as of Unreal Engine 5.3. The comment suggests using the bIgnoreAbilitySystemCosts in the AbilitySystemGlobals namespace instead, which is controlled by the new CVarAbilitySystemIgnoreCosts.

Best practices for this variable include:

  1. Update any code referencing this variable to use the new recommended approach in UE 5.3+.
  2. Ensure that any gameplay code that relies on ability costs has fallbacks or safeguards in case this variable is set to true.
  3. Use this variable in conjunction with other debug tools to thoroughly test ability cost mechanics.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/AbilitySystemGlobals.cpp:35

Scope (from outer to inner):

file
namespace    UE::AbilitySystemGlobals

Source code excerpt:


	FAutoConsoleVariableRef CVarAbilitySystemIgnoreCooldowns(TEXT("AbilitySystem.IgnoreCooldowns"), bIgnoreAbilitySystemCooldowns, TEXT("Ignore cooldowns for all Gameplay Abilities."), ECVF_Cheat);
	FAutoConsoleVariableRef CVarAbilitySystemIgnoreCosts(TEXT("AbilitySystem.IgnoreCosts"), bIgnoreAbilitySystemCosts, TEXT("Ignore costs for all Gameplay Abilities."), ECVF_Cheat);
}

UAbilitySystemGlobals::UAbilitySystemGlobals(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
	AbilitySystemGlobalsClassName = FSoftClassPath(TEXT("/Script/GameplayAbilities.AbilitySystemGlobals"));

#Associated Variable and Callsites

This variable is associated with another variable named bIgnoreAbilitySystemCosts. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/AbilitySystemGlobals.cpp:32

Scope (from outer to inner):

file
namespace    UE::AbilitySystemGlobals

Source code excerpt:

{
	bool bIgnoreAbilitySystemCooldowns = false;
	bool bIgnoreAbilitySystemCosts = false;

	FAutoConsoleVariableRef CVarAbilitySystemIgnoreCooldowns(TEXT("AbilitySystem.IgnoreCooldowns"), bIgnoreAbilitySystemCooldowns, TEXT("Ignore cooldowns for all Gameplay Abilities."), ECVF_Cheat);
	FAutoConsoleVariableRef CVarAbilitySystemIgnoreCosts(TEXT("AbilitySystem.IgnoreCosts"), bIgnoreAbilitySystemCosts, TEXT("Ignore costs for all Gameplay Abilities."), ECVF_Cheat);
}

UAbilitySystemGlobals::UAbilitySystemGlobals(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
	AbilitySystemGlobalsClassName = FSoftClassPath(TEXT("/Script/GameplayAbilities.AbilitySystemGlobals"));

#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/AbilitySystemGlobals.cpp:558

Scope (from outer to inner):

file
function     bool UAbilitySystemGlobals::ShouldIgnoreCosts

Source code excerpt:

bool UAbilitySystemGlobals::ShouldIgnoreCosts() const
{
	return UE::AbilitySystemGlobals::bIgnoreAbilitySystemCosts;
}

#if WITH_EDITOR
void UAbilitySystemGlobals::OnPreBeginPIE(const bool bIsSimulatingInEditor)
{
	ResetCachedData();

#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Public/AbilitySystemGlobals.h:327

Scope (from outer to inner):

file
class        class UAbilitySystemGlobals : public UObject

Source code excerpt:

	/** If we should ignore the costs when activating abilities in the ability system. Set with ToggleIgnoreAbilitySystemCosts() */
	UE_DEPRECATED(5.3, "Use bIgnoreAbilitySystemCosts in the AbilitySystemGlobals namespace, controlled by new CVarAbilitySystemIgnoreCosts")
	bool bIgnoreAbilitySystemCosts;
#endif // WITH_ABILITY_CHEATS

	/** Whether the game should allow the usage of gameplay mod evaluation channels or not */
	UPROPERTY(config)
	bool bAllowGameplayModEvaluationChannels;