// Rewrite of the Chaos Knight Reality Rift ability
// Author: Pizzalol
// Date: December 30, 2015
// Version: 6.86
// Type: Datadriven
//
// ----- FILE REQUIREMENTS -----
// Script files:
// scripts/vscripts/heroes/hero_chaos_knight/reality_rift.lua
"reality_rift_datadriven"
{
	// General
	//-------------------------------------------------------------------------------------------------------------
	"BaseClass"				"ability_datadriven"
	"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_UNIT_TARGET"
	"AbilityUnitTargetTeam"			"DOTA_UNIT_TARGET_TEAM_ENEMY"
	"AbilityUnitTargetType"			"DOTA_UNIT_TARGET_HERO | DOTA_UNIT_TARGET_BASIC"
	"SpellImmunityType"				"SPELL_IMMUNITY_ENEMIES_NO"
	"FightRecapLevel"				"1"
	"AbilityTextureName"			"chaos_knight_reality_rift"

	// Precache
	//-------------------------------------------------------------------------------------------------------------
	"precache"
	{
		"soundfile"		"soundevents/game_sounds_heroes/game_sounds_chaos_knight.vsndevts"
		"particle"		"particles/units/heroes/hero_chaos_knight/chaos_knight_reality_rift.vpcf"
		"particle"		"particles/units/heroes/hero_chaos_knight/chaos_knight_reality_rift_buff.vpcf"
	}
	
	// Casting
	//-------------------------------------------------------------------------------------------------------------
	"AbilityCastRange"				"550 600 650 700"
	"AbilityCastPoint"				"0.4 0.4 0.4 0.4"

	// Time		
	//-------------------------------------------------------------------------------------------------------------
	"AbilityCooldown"				"24 18 12 6"


	// Cost
	//-------------------------------------------------------------------------------------------------------------
	"AbilityManaCost"				"50 50 50 50"
	
	// Special
	//-------------------------------------------------------------------------------------------------------------
	"AbilitySpecial"
	{
		"01"
		{
			"var_type"					"FIELD_INTEGER"
			"cast_range"				"550 600 650 700"
		}
		"02"
		{
			"var_type"					"FIELD_INTEGER"
			"bonus_damage"				"60 100 140 180"
		}
		"03"
		{
			"var_type"					"FIELD_FLOAT"
			"bonus_duration"			"1.2"
		}
		// Extra
		"04"
		{
			"var_type"					"FIELD_FLOAT"
			"illusion_search_radius"	"1375"
		}
		"05"
		{
			"var_type"					"FIELD_FLOAT"
			"min_range"					"0.3"
		}
		"06"
		{
			"var_type"					"FIELD_FLOAT"
			"max_range"					"0.8"
		}
	}

	"OnAbilityPhaseStart"
	{
		"FireSound"
		{
			"EffectName"	"Hero_ChaosKnight.RealityRift"
			"Target" 		"CASTER"
		}

		"RunScript"
		{
			"ScriptFile"	"heroes/hero_chaos_knight/reality_rift.lua"
			"Function"		"RealityRiftPosition"
			"reality_rift_particle"	"particles/units/heroes/hero_chaos_knight/chaos_knight_reality_rift.vpcf"
		}
	}

	"OnSpellStart"
	{
		"FireSound"
		{
			"EffectName"	"Hero_ChaosKnight.RealityRift.Target"
			"Target" 		"TARGET"
		}

		"ApplyModifier"
		{
			"ModifierName"	"modifier_reality_rift_datadriven"
			"Target" 		"CASTER"
			"Duration"		"%bonus_duration"
		}

		"RunScript"
		{
			"ScriptFile"	"heroes/hero_chaos_knight/reality_rift.lua"
			"Function"		"RealityRift"
			"bonus_modifier"	"modifier_reality_rift_datadriven"
		}
	}

	"Modifiers"
	{
		"modifier_reality_rift_datadriven"
		{
			"IsBuff"		"1"
	
			"EffectName"		"particles/units/heroes/hero_chaos_knight/chaos_knight_reality_rift_buff.vpcf"
			"EffectAttachType"	"attach_attack"

			"OnAttackLanded"
			// "%attack_damage" is set to the damage value before mitigation
			{
				"RemoveModifier"
				{
					"ModifierName"	"modifier_reality_rift_datadriven"
					"Target" 		"ATTACKER"
				}
			}
	
			"Properties"
			{
				"MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE" "%bonus_damage"
			}
		}
	}
}