Template:Effect: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(Overhauled article to cover more bases)
Line 1: Line 1:
==Usage==
== Usage ==


To use this effect, {{{2}}} turn off SmartEdit mode and add the following keyvalue pair to the entity: <code>effects {{{1}}}</code>.
=== In code ===
 
Inside of the codebase, effects are defined as a bit-based enum and are stored in <code>m_fEffects</code>. This effect can be manipulated with <code>AddEffects( {{PAGENAME}} )</code>, <code>RemoveEffects( {{PAGENAME}} )</code>, and <code>SetEffects( {{PAGENAME}} )</code>. This effect can be obtained with <code>GetEffects() & {{PAGENAME}}</code> or <code>IsEffectActive( {{PAGENAME}} )</code>.
 
=== In scripting ===
 
The functions mentioned above are supported in [[VScript]] starting with {{Game link|Dota 2}}. They can also be found in {{Game link|Garry's Mod}}.
 
=== In a map ===
 
{{#if:{{{mapcfg|}}} | {{{mapcfg}}} |
To use this effect in a map, {{#if:{{{2|}}}|{{{2}}}}} turn off SmartEdit mode and add the following keyvalue pair to the entity: <code>effects {{{1}}}</code>.


{{note|If it is desired to use this with other [[effects enum|effects]], you should add the integer value of each effect to the value.}}
{{note|If it is desired to use this with other [[effects enum|effects]], you should add the integer value of each effect to the value.}}


Remember that you can set the effects value during runtime using an entity's <code>AddOutput</code> input with the input value <code>effects x</code> (x being any summation of effects flags to enable).
You can set the <code>effects</code> keyvalue during runtime using {{ent|AddOutput}} with the input value <code>effects x</code> (x being any summation of effects flags to enable).


{{warning|Using the AddOutput functionality for this, the new value may interfere with an entity's simulation functionality.}}
{{warning|Using <code>AddOutput</code> to change an entity's effects may interfere with an entity's simulation functionality.}}
}}

Revision as of 15:50, 8 May 2020

Usage

In code

Inside of the codebase, effects are defined as a bit-based enum and are stored in m_fEffects. This effect can be manipulated with AddEffects( Effect ), RemoveEffects( Effect ), and SetEffects( Effect ). This effect can be obtained with GetEffects() & Effect or IsEffectActive( Effect ).

In scripting

The functions mentioned above are supported in VScript starting with Dota 2 Dota 2 . They can also be found in Garry's Mod Garry's Mod .

In a map

To use this effect in a map, turn off SmartEdit mode and add the following keyvalue pair to the entity: effects {{{1}}}.

Note.pngNote:If it is desired to use this with other effects, you should add the integer value of each effect to the value.

You can set the effects keyvalue during runtime using AddOutput with the input value effects x (x being any summation of effects flags to enable).

Warning.pngWarning:Using AddOutput to change an entity's effects may interfere with an entity's simulation functionality.