Applying Data Driven Modifiers from script

From Valve Developer Community
Jump to navigation Jump to search
Wikipedia - Letter.png
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
Icon-callout-underlinked.png
This article needs more links to other pages (since January 2024). You can help improve navigation by adding links to related documentation, such as entities or tools.
Icon-callout-orphan.png
This article is an orphan, meaning that few or no articles link to it (since January 2024). You can help by adding links to this article from other relevant articles.

It's possible to freely apply custom data-driven modifiers from VScript using the following function.

CDOTA_Item_DataDriven

Function Signature Description
ApplyDataDrivenModifier void ApplyDataDrivenModifier(handle source, handle target, string modifier_name, handle modifierArgs)

Hopefully you've noticed this function belongs to objects of the Item type. It's used along with a data-driven item definition containing your data-driven modifiers.

	"item_modifier_master"
	{
		"ID"							"1010"

		// General
		//-------------------------------------------------------------------------------------------------------------
		"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IMMEDIATE"
		"BaseClass"						"item_datadriven"

		// Stats
		//-------------------------------------------------------------------------------------------------------------
		"AbilityCastRange"				"100"
		"AbilityCastPoint"				"0.0"
		
		// Item Info
		//-------------------------------------------------------------------------------------------------------------

		"Modifiers"
		{
			"modifier_custom"
			{
				"TextureName" "item_greater_salve"
				"EffectName" "particles/items_fx/healing_flask.vpcf"
				"EffectAttachType" "follow_origin"

				"Properties"
				{
					"MODIFIER_PROPERTY_ATTACKSPEED_BONUS_CONSTANT" "100"
			
		
				}
			}
		}
}

And the script:

local ModMaster = CreateItem("item_modifier_master", nil, nil) 
ModMaster:ApplyDataDrivenModifier(unit, unit, "modifier_custom", {duration = 3})
Wikipedia - Letter.png
This article has not been added to any content categories. Please help out by adding categories.
January 2024