Модификатор-LUA, действующий от модификаторов DataDriven

Илья

Друзья CG
25 Сен 2015
2,348
41
Тебе же говорят, что ты неправильно его вызываешь. Ты проверил: заходит ли компилятор в него? Вызываются ли его методы, как я советовал?


Кастера так вызывать следует:
local caster = self:GetCaster()

А накладывать модификатор так:
caster:AddNewModifier( caster, self, "modifier_item_arcane_armlet_active_tick", {duration = -1})
 
Последнее редактирование модератором:

EnDronist

Продвинутый
28 Апр 2016
231
0
Проект
Защитники Изобилия | Defenders of Abundance
Тебе же говорят, что ты неправильно его вызываешь. Ты проверил: заходит ли компилятор в него? Вызываются ли его методы, как я советовал?


Кастера так вызывать следует:
local caster = self:GetCaster()

А накладывать модификатор так:
caster:AddNewModifier( caster, self, "modifier_item_arcane_armlet_active_tick", {duration = -1})
Код:
[ W VScript       ]: Script Runtime Error: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:90: attempt to index global 'self' (a nil value)
[ W VScript       ]: stack traceback:
[ W VScript       ]: 	...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:90: in function 'modifier_item_arcane_armlet_active_tick'
[ W VScript       ]: 	...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:47: in function <...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:45>
90-ая строчка - function modifier_item_arcane_armlet_active_tick(params)
47-ая строчка - modifier_item_arcane_armlet_active_tick(params) --вызов
 
Последнее редактирование модератором:

CryDeS

Друзья CG
14 Июл 2015
1,210
11
[quote author=I_GRIN_I link=topic=922.msg4553#msg4553 date=1464415570]
Илья, просто вот, это рабочие строки:
Код:
  LinkLuaModifier( "modifier_stun",      'modifiers/modifier_stun',       LUA_MODIFIER_MOTION_NONE )
  LinkLuaModifier( "modifier_stop",      'modifiers/modifier_stop',       LUA_MODIFIER_MOTION_NONE )
  LinkLuaModifier( "modifier_medical_tractate",  'modifiers/modifier_medical_tractate',  LUA_MODIFIER_MOTION_NONE )
  LinkLuaModifier( "modifier_boss_power",     'modifiers/modifier_boss_power',    LUA_MODIFIER_MOTION_NONE )
  LinkLuaModifier( "modifier_yarik",      'modifiers/modifier_yarik',     LUA_MODIFIER_MOTION_NONE )
  LinkLuaModifier( "modifier_grin",      'modifiers/modifier_grin',       LUA_MODIFIER_MOTION_NONE )
  LinkLuaModifier( "modifier_crydes",      'modifiers/modifier_crydes',     LUA_MODIFIER_MOTION_NONE )
  LinkLuaModifier( "modifier_godmode",     'modifiers/modifier_godmode',     LUA_MODIFIER_MOTION_NONE )
[/quote]
Кхм кхм.
[quote author=EnDronist link=topic=922.msg4575#msg4575 date=1464493715]
Код:
[ W VScript       ]: Script Runtime Error: ...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:90: attempt to index global 'self' (a nil value)
[ W VScript       ]: stack traceback:
[ W VScript       ]: 	...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:90: in function 'modifier_item_arcane_armlet_active_tick'
[ W VScript       ]: 	...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:47: in function <...dons\test1\scripts\vscripts\items\item_arcane_armlet.lua:45>
90-ая строчка - function modifier_item_arcane_armlet_active_tick(params)
47-ая строчка - modifier_item_arcane_armlet_active_tick(params) --вызов
[/quote]
Скинь весь код, будь добр. И код датадривена тоже.
 
Последнее редактирование модератором:

EnDronist

Продвинутый
28 Апр 2016
231
0
Проект
Защитники Изобилия | Defenders of Abundance
Кхм кхм. Скинь весь код, будь добр. И код датадривена тоже.
item_arcane_armlet.lua
Код:
LinkLuaModifier( "modifier_item_arcane_armlet_active_tick", "modifier_item_arcane_armlet_active_tick", LUA_MODIFIER_MOTION_NONE )

function swap_to_item(keys, ItemName)
	for i=0, 5, 1 do --Fill all empty slots in the player's inventory with "dummy" items.
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item == nil then
			keys.caster:AddItem(CreateItem("item_dummy_datadriven", keys.caster, keys.caster))
		end
	end
	
	keys.caster:RemoveItem(keys.ability)
	keys.caster:AddItem(CreateItem(ItemName, keys.caster, keys.caster)) --This should be put into the same slot that the removed item was in.

	for i=0, 5, 1 do --Remove all dummy items from the player's inventory.
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item ~= nil then
			if current_item:GetName() == "item_dummy_datadriven" then
				keys.caster:RemoveItem(current_item)
			end
		end
	end
end


function item_arcane_armlet_on_spell_start(keys)	--Replace all "on" armlets with "off" ones.
	swap_to_item(keys, "item_arcane_armlet_active")
end


function item_arcane_armlet_active_on_spell_start(keys)	--Replace all "on" armlets with "off" ones.
	swap_to_item(keys, "item_arcane_armlet")
end


function modifier_item_arcane_armlet_active_on_interval_think_damage(keys)
	local new_mp = keys.caster:GetMana() - (keys.UnholyManaDrainPerSecond * keys.UnholyManaDrainInterval) - (keys.caster:GetMaxMana() * keys.UnholyManaDrainProcentPerSecond * keys.UnholyManaDrainInterval / 100)

	if new_mp < 0 then --Armlet cannot kill the caster from its HP drain.
		new_mp = 0
	end
	keys.caster:SetMana(new_mp)
end


function modifier_item_arcane_armlet_active_apply_tick_intellect_on_interval_think(keys)
	if keys.ability.ArmletTicksActive == nil or keys.ability.ArmletTicksActive < keys.UnholyTicksToFullEffect then
		modifier_item_arcane_armlet_active_tick(params)

		--Update the stored amount of active Armlet ticks.
		if keys.ability.ArmletTicksActive == nil then
			keys.ability.ArmletTicksActive = 1
		else
			keys.ability.ArmletTicksActive = keys.ability.ArmletTicksActive + 1
		end
		
		--Increase the caster's current health by the same amount that their maximum health was increased by.
		local currentMP = keys.caster:GetMana()
		local maxMP = keys.caster:GetMaxMana()
		local mana_bonus_interval_ratio = (keys.UnholyBonusIntellect / keys.UnholyTicksToFullEffect) * 12
		
		local amount_to_heal = ((currentMP + mana_bonus_interval_ratio) / (maxMP + mana_bonus_interval_ratio)) * maxMP - currentMP
		
		keys.caster:SetMana(currentMP + amount_to_heal)
	end
end


function item_arcane_armlet_active_on_unequip(keys)
	if keys.ability.ArmletTicksActive ~= nil then
		
		for i=1, keys.ability.ArmletTicksActive, 1 do
			keys.caster:RemoveModifierByName("modifier_item_arcane_armlet_active_tick")
		end
		for i=1, keys.ability.ArmletTicksActive, 1 do
			local currentMP = keys.caster:GetMana()
			local maxMP = keys.caster:GetMaxMana()
			local mana_bonus_interval_ratio = (keys.UnholyBonusIntellect / keys.UnholyTicksToFullEffect) * 12
			local amount_to_damage = ((currentMP + mana_bonus_interval_ratio) / (maxMP + mana_bonus_interval_ratio)) * maxMP - currentMP
			local new_mp = currentMP - amount_to_damage
			if new_mp < 0 then
				new_mp = 0
			end
			keys.caster:SetMana(new_mp)
		end
		keys.ability.ArmletTicksActive = nil
	end
end
--HandleABILITY
function modifier_item_arcane_armlet_active_tick(params)
	local caster = self:GetCaster()
	caster:AddNewModifier( caster, self, "modifier_item_arcane_armlet_active_tick", {duration = -1})
	--self:AddNewModifier(self.caster, self.caster, "modifier_item_arcane_armlet_active_tick", {duration = -1})
end
modifier_item_arcane_armlet_active_tick.lua
Код:
modifier_item_arcane_armlet_active_tick = class({})

function modifier_item_arcane_armlet_active_tick:IsHidden()
	return false
end

function modifier_item_arcane_armlet_active_tick:GetTexture()
  return "omniknight_repel"
end

function modifier_item_arcane_armlet_active_tick:DeclareFunctions()
	local funcs = {
		MODIFIER_PROPERTY_STATS_INTELLECT_BONUS ,
		MODIFIER_PROPERTY_SPELL_AMPLIFY_PERCENTAGE ,
	}
	return funcs
end

function modifier_item_arcane_armlet_active_tick:GetModifierBonusStats_Intellect() 
	return 2.22
end

function modifier_item_arcane_armlet_active_tick:GetModifierSpellAmplify_Percentage() 
	return 2.78 
end
npc_items_custom.txt
Код:
	//=================================================================================================================
	// Recipe: Arcane Armlet
	//=================================================================================================================
	"item_recipe_arcane_armlet"
	{
		// General
		//-------------------------------------------------------------------------------------------------------------
		"BaseClass"						"item_datadriven"
		"ID"							"15100"														// unique ID number for this item. Do not change this once established or it will invalidate collected stats.
		"Model"							"models/props_gameplay/recipe.vmdl"
		
		// Item Info
		//-------------------------------------------------------------------------------------------------------------
		"ItemCost"						"400"	
		"ItemShopTags"					""
		
		// Recipe
		//-------------------------------------------------------------------------------------------------------------
		"ItemRecipe"					"1"
		"ItemResult"					"item_arcane_armlet"
		"ItemRequirements"
		{
			"01"						"item_helm_of_iron_will;item_energy_booster;item_null_talisman;item_robe"
		}
	}

	//=================================================================================================================
	// Arcane Armlet
	//=================================================================================================================

"item_arcane_armlet" //The inactive version of Armlet.
{
	// General
	//-------------------------------------------------------------------------------------------------------------
	"BaseClass"						"item_datadriven"
	"ID"							"15101" //Valve's version of this item uses the ID "151".
	"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL"
	"Model"							"models/props_gameplay/red_box.vmdl" 
	"Effect"						"particles/generic_gameplay/dropped_item.vpcf"
	"AbilityTextureName"			"item_armlet"
	
	// Stats		
	//-------------------------------------------------------------------------------------------------------------
	"AbilityCastPoint"				"0.0"
	"AbilityCooldown"				"0"
	"AbilityManaCost"				"0"
	
	// Item Info
	//-------------------------------------------------------------------------------------------------------------
	"ItemCost"						"2400"
	"ItemShopTags"					"damage;attack_speed;armor;regen_health;hard_to_tag"
	"ItemQuality"					"epic"
	"ItemAliases"					"armlet of mordiggian;arcane;arcane armlet"
	"ItemDeclarations"				"DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_IN_SPEECH | DECLARE_PURCHASES_TO_SPECTATORS"
	
	"AbilitySpecial"
	{
		"01"
		{
			"var_type"							"FIELD_INTEGER"
			"bonus_health_regen"				"7"
		}
		"02"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_damage"					"3"
		}
		"03"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_armor"					"5"
		}
		"04"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_strength"				"3"
		}
		"05"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_agility"					"3"
		}
		"06"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_intellect"				"12"
		}
		"07"
		{
			"var_type"						"FIELD_INTEGER"
			"unholy_bonus_cast_radius"			"125"
		}
		"08"
		{
			"var_type"						"FIELD_INTEGER"
			"unholy_bonus_intellect"			"25"
		}
	}
	
	"OnSpellStart" //Switch to the active version of Armlet.
	{
		"RunScript"
		{
			"ScriptFile"				"items/item_arcane_armlet.lua"
			"Function"				"item_arcane_armlet_on_spell_start"
		}
		
		"FireSound"
		{
			"EffectName"				"DOTA_Item.Armlet.Activate"
			"Target"				"CASTER"
		}
	}
	
	"Modifiers"
	{
		"modifier_item_arcane_armlet"
		{
			"Passive"			"1"
			"IsHidden"			"1"
			"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
			
			"Properties"
			{
				"MODIFIER_PROPERTY_HEALTH_REGEN_CONSTANT"		"%bonus_health_regen"
				"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE"		"%bonus_damage"
				"MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS"		"%bonus_armor"
				"MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"		"%bonus_strength"
				"MODIFIER_PROPERTY_STATS_AGILITY_BONUS"			"%bonus_agility"
				"MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"		"%bonus_intellect"
			}
		}
	}
}


"item_arcane_armlet_active" //The active version of Armlet.
{
	// General
	//-------------------------------------------------------------------------------------------------------------
	"BaseClass"						"item_datadriven"
	"ID"							"15102" //Valve's version of this item uses the ID "151".
	"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL"
	"Model"							"models/props_gameplay/red_box.vmdl" 
	"Effect"						"particles/generic_gameplay/dropped_item.vpcf"
	"AbilityTextureName"			"item_armlet_active"

	// Stats		
	//-------------------------------------------------------------------------------------------------------------
	"AbilityCastPoint"				"0.0"
	"AbilityCooldown"				"0"
	"AbilityManaCost"				"0"
		
	// Item Info
	//-------------------------------------------------------------------------------------------------------------
	"ItemCost"						"2400"
	"ItemShopTags"					"damage;attack_speed;armor;regen_health;hard_to_tag"
	"ItemQuality"					"epic"
	"ItemAliases"					"armlet of mordiggian"
	"ItemDeclarations"				"DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_IN_SPEECH | DECLARE_PURCHASES_TO_SPECTATORS"
	
	"ItemPurchasable"				"0"
		
	"AbilitySpecial"
	{
		"01"
		{
			"var_type"							"FIELD_INTEGER"
			"bonus_health_regen"				"7"
		}
		"02"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_damage"					"3"
		}
		"03"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_armor"					"5"
		}
		"04"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_strength"				"3"
		}
		"05"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_agility"					"3"
		}
		"06"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_intellect"				"12"
		}
		"07"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_bonus_cast_radius"			"125"
		}
		"08"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_bonus_intellect"			"25" //The ratio of %unholy_bonus_strength to %unholy_ticks_to_full_effect is currently hardcoded in modifier_item_armlet_active_datadriven_tick for technical reasons.
		}
		"09"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_mana_drain_per_second"			"25"
		}
		"10"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_mana_drain_percent_per_second"		"2"
		}
		"11"
		{
			"var_type"							"FIELD_FLOAT"
			"unholy_mana_drain_interval"			"0.1"
		}
		"12"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_ticks_to_full_effect"			"9" //The ratio of %unholy_bonus_strength to %unholy_ticks_to_full_effect is currently hardcoded in modifier_item_armlet_active_datadriven_tick for technical reasons.
		}
		"13"
		{
			"var_type"							"FIELD_FLOAT"
			"unholy_tick_interval"				"0.1" //This is the interval at which the caster will gain Strength immediately after Armlet is toggled on.
		}
	}
	
	"OnSpellStart" //Switch to the inactive version of Armlet.
	{
		"RunScript"
		{
			"ScriptFile"				"items/item_arcane_armlet.lua"
			"Function"				"item_arcane_armlet_active_on_spell_start"
		}
		
		"FireSound"
		{
			"EffectName"				"DOTA_Item.Armlet.DeActivate"
			"Target"				"CASTER"
		}
	}
	
	"OnUnequip"
	{		
		"RunScript"
		{
			"ScriptFile"				"items/item_arcane_armlet.lua"
			"Function"				"item_arcane_armlet_active_on_unequip"
			"UnholyTicksToFullEffect"		"%unholy_ticks_to_full_effect"
			"UnholyBonusIntellect"			"%unholy_bonus_intellect"
		}
	}

	"Modifiers"
	{
		"modifier_item_arcane_armlet_active"
		{
			"Passive"			"1"
			"IsHidden"			"1"
			"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
			
			"EffectName"			"particles/items_fx/armlet.vpcf"
			"EffectAttachType"		"follow_origin"
			
			"Properties"
			{
				"MODIFIER_PROPERTY_HEALTH_REGEN_CONSTANT"		"%bonus_health_regen"
				"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE"		"%bonus_damage"
				"MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS"		"%bonus_armor"
				"MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"		"%bonus_strength"
				"MODIFIER_PROPERTY_STATS_AGILITY_BONUS"			"%bonus_agility"
				"MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"		"%bonus_intellect"
			}
			
			"ThinkInterval" 		"%unholy_mana_drain_interval"
			"OnIntervalThink" //Damage the caster while Armlet is toggled on.
			{
				"RunScript"
				{
					"ScriptFile"					"items/item_arcane_armlet.lua"
					"Function"						"modifier_item_arcane_armlet_active_on_interval_think_damage"
					"UnholyManaDrainPerSecond"		"%unholy_mana_drain_per_second"
					"UnholyManaDrainProcentPerSecond"	"%unholy_mana_drain_percent_per_second"
					"UnholyManaDrainInterval"		"%unholy_mana_drain_interval"
				}
			}
		}

		"modifier_item_arcane_armlet_active_apply_tick_intellect"
		{
			"Passive"			"1"
			"IsHidden"			"1"
			"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
			
			"Properties"
			{
				"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE"		"%unholy_bonus_damage"
				"MODIFIER_PROPERTY_ATTACKSPEED_BONUS_CONSTANT"	"%unholy_bonus_attack_speed"
			}
			
			"ThinkInterval" 		"%unholy_tick_interval"
			"OnIntervalThink"
			{
				"RunScript"
				{
					"ScriptFile"					"items/item_arcane_armlet.lua"
					"Function"						"modifier_item_arcane_armlet_active_apply_tick_intellect_on_interval_think"
					"UnholyTicksToFullEffect"		"%unholy_ticks_to_full_effect"
					"UnholyBonusIntellect"			"%unholy_bonus_intellect"
				}
			}
		}

		//"modifier_item_arcane_armlet_active_tick"
		//{
		//	"Passive"			"0"
		//	"IsHidden"			"0"
		//	"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
		//	
		//	"Properties"
		//	{
		//		"MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"		"3.57" //This value is %unholy_bonus_intellect / %unholy_ticks_to_full_effect and is hardcoded here for technical reasons.
		//	}
		//}
	}
}
 
Последнее редактирование модератором:

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
У тебя что то слишком длинно называются:
Код:
[ W VScript     ]: 	...a_addons\example\scripts\vscripts\item_arcane_armlet.lua:47: in function <...a_addons\example\scripts\vscripts\item_arcane_armlet.lua:45>
[ W VScript     ]: Message count limit of 10 hit. Subsequent duplicate messages will be squelched.
Но это не вся ошибка.
 
Последнее редактирование модератором:

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
УРА, Я КОМУ ТО ПОМОГУ!
Код:
LinkLuaModifier( "modifier_item_arcane_armlet_active_tick", "modifier_item_arcane_armlet_active_tick", LUA_MODIFIER_MOTION_NONE )

function swap_to_item(keys, ItemName)
	for i=0, 5, 1 do --Fill all empty slots in the player's inventory with "dummy" items.
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item == nil then
			keys.caster:AddItem(CreateItem("item_dummy_datadriven", keys.caster, keys.caster))
		end
	end
	
	keys.caster:RemoveItem(keys.ability)
	keys.caster:AddItem(CreateItem(ItemName, keys.caster, keys.caster)) --This should be put into the same slot that the removed item was in.

	for i=0, 5, 1 do --Remove all dummy items from the player's inventory.
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item ~= nil then
			if current_item:GetName() == "item_dummy_datadriven" then
				keys.caster:RemoveItem(current_item)
			end
		end
	end
end


function on_spell_start(keys)	--Replace all "on" armlets with "off" ones.
	swap_to_item(keys, "item_arcane_armlet_active")
end


function active_on_spell_start(keys)	--Replace all "on" armlets with "off" ones.
	swap_to_item(keys, "item_arcane_armlet")
end


function on_interval_think_damage(keys)
	local new_mp = keys.caster:GetMana() - (keys.UnholyManaDrainPerSecond * keys.UnholyManaDrainInterval) - (keys.caster:GetMaxMana() * keys.UnholyManaDrainProcentPerSecond * keys.UnholyManaDrainInterval / 100)

	if new_mp < 0 then --Armlet cannot kill the caster from its HP drain.
		new_mp = 0
	end
	keys.caster:SetMana(new_mp)
end


function active_apply_tick_intellect(keys)
	if keys.ability.ArmletTicksActive == nil or keys.ability.ArmletTicksActive < keys.UnholyTicksToFullEffect then
		active_tick(keys)

		--Update the stored amount of active Armlet ticks.
		if keys.ability.ArmletTicksActive == nil then
			keys.ability.ArmletTicksActive = 1
		else
			keys.ability.ArmletTicksActive = keys.ability.ArmletTicksActive + 1
		end
		
		--Increase the caster's current health by the same amount that their maximum health was increased by.
		local currentMP = keys.caster:GetMana()
		local maxMP = keys.caster:GetMaxMana()
		local mana_bonus_interval_ratio = (keys.UnholyBonusIntellect / keys.UnholyTicksToFullEffect) * 12
		
		local amount_to_heal = ((currentMP + mana_bonus_interval_ratio) / (maxMP + mana_bonus_interval_ratio)) * maxMP - currentMP
		
		keys.caster:SetMana(currentMP + amount_to_heal)
	end
end


function active_on_unequip(keys)
	if keys.ability.ArmletTicksActive ~= nil then
		
		for i=1, keys.ability.ArmletTicksActive, 1 do
			keys.caster:RemoveModifierByName("modifier_item_arcane_armlet_active_tick")
		end
		for i=1, keys.ability.ArmletTicksActive, 1 do
			local currentMP = keys.caster:GetMana()
			local maxMP = keys.caster:GetMaxMana()
			local mana_bonus_interval_ratio = (keys.UnholyBonusIntellect / keys.UnholyTicksToFullEffect) * 12
			local amount_to_damage = ((currentMP + mana_bonus_interval_ratio) / (maxMP + mana_bonus_interval_ratio)) * maxMP - currentMP
			local new_mp = currentMP - amount_to_damage
			if new_mp < 0 then
				new_mp = 0
			end
			keys.caster:SetMana(new_mp)
		end
		keys.ability.ArmletTicksActive = nil
	end
end
--HandleABILITY
function active_tick(keys)
	local caster = keys.caster
	caster:AddNewModifier( caster, nil, "modifier_item_arcane_armlet_active_tick", {duration = -1})
end

Код:
"DOTAAbilities"
{
	//=================================================================================================================
	// Recipe: Arcane Armlet
	//=================================================================================================================
	"item_recipe_arcane_armlet"
	{
		// General
		//-------------------------------------------------------------------------------------------------------------
		"BaseClass"						"item_datadriven"
		"ID"							"15100"														// unique ID number for this item. Do not change this once established or it will invalidate collected stats.
		"Model"							"models/props_gameplay/recipe.vmdl"
		
		// Item Info
		//-------------------------------------------------------------------------------------------------------------
		"ItemCost"						"400"	
		"ItemShopTags"					""
		
		// Recipe
		//-------------------------------------------------------------------------------------------------------------
		"ItemRecipe"					"1"
		"ItemResult"					"item_arcane_armlet"
		"ItemRequirements"
		{
			"01"						"item_helm_of_iron_will;item_energy_booster;item_null_talisman;item_robe"
		}
	}

	//=================================================================================================================
	// Arcane Armlet
	//=================================================================================================================

"item_arcane_armlet" //The inactive version of Armlet.
{
	// General
	//-------------------------------------------------------------------------------------------------------------
	"BaseClass"						"item_datadriven"
	"ID"							"15101" //Valve's version of this item uses the ID "151".
	"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL"
	"Model"							"models/props_gameplay/red_box.vmdl" 
	"Effect"						"particles/generic_gameplay/dropped_item.vpcf"
	"AbilityTextureName"			"item_armlet"
	
	// Stats		
	//-------------------------------------------------------------------------------------------------------------
	"AbilityCastPoint"				"0.0"
	"AbilityCooldown"				"0"
	"AbilityManaCost"				"0"
	
	// Item Info
	//-------------------------------------------------------------------------------------------------------------
	"ItemCost"						"2400"
	"ItemShopTags"					"damage;attack_speed;armor;regen_health;hard_to_tag"
	"ItemQuality"					"epic"
	"ItemAliases"					"armlet of mordiggian;arcane;arcane armlet"
	"ItemDeclarations"				"DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_IN_SPEECH | DECLARE_PURCHASES_TO_SPECTATORS"
	
	"AbilitySpecial"
	{
		"01"
		{
			"var_type"							"FIELD_INTEGER"
			"bonus_health_regen"				"7"
		}
		"02"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_damage"					"3"
		}
		"03"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_armor"					"5"
		}
		"04"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_strength"				"3"
		}
		"05"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_agility"					"3"
		}
		"06"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_intellect"				"12"
		}
		"07"
		{
			"var_type"						"FIELD_INTEGER"
			"unholy_bonus_cast_radius"			"125"
		}
		"08"
		{
			"var_type"						"FIELD_INTEGER"
			"unholy_bonus_intellect"			"25"
		}
	}
	
	"OnSpellStart" //Switch to the active version of Armlet.
	{
		"RunScript"
		{
			"ScriptFile"				"item_arcane_armlet.lua"
			"Function"					"on_spell_start"
		}
		
		"FireSound"
		{
			"EffectName"				"DOTA_Item.Armlet.Activate"
			"Target"					"CASTER"
		}
	}
	
	"Modifiers"
	{
		"modifier_item_arcane_armlet"
		{
			"Passive"			"1"
			"IsHidden"			"1"
			"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
			
			"Properties"
			{
				"MODIFIER_PROPERTY_HEALTH_REGEN_CONSTANT"		"%bonus_health_regen"
				"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE"		"%bonus_damage"
				"MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS"		"%bonus_armor"
				"MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"		"%bonus_strength"
				"MODIFIER_PROPERTY_STATS_AGILITY_BONUS"			"%bonus_agility"
				"MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"		"%bonus_intellect"
			}
		}
	}
}


"item_arcane_armlet_active" //The active version of Armlet.
{
	// General
	//-------------------------------------------------------------------------------------------------------------
	"BaseClass"						"item_datadriven"
	"ID"							"15102" //Valve's version of this item uses the ID "151".
	"AbilityBehavior"				"DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL"
	"Model"							"models/props_gameplay/red_box.vmdl" 
	"Effect"						"particles/generic_gameplay/dropped_item.vpcf"
	"AbilityTextureName"			"item_armlet_active"

	// Stats		
	//-------------------------------------------------------------------------------------------------------------
	"AbilityCastPoint"				"0.0"
	"AbilityCooldown"				"0"
	"AbilityManaCost"				"0"
		
	// Item Info
	//-------------------------------------------------------------------------------------------------------------
	"ItemCost"						"2400"
	"ItemShopTags"					"damage;attack_speed;armor;regen_health;hard_to_tag"
	"ItemQuality"					"epic"
	"ItemAliases"					"armlet of mordiggian"
	"ItemDeclarations"				"DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_IN_SPEECH | DECLARE_PURCHASES_TO_SPECTATORS"
	
	"ItemPurchasable"				"0"
		
	"AbilitySpecial"
	{
		"01"
		{
			"var_type"							"FIELD_INTEGER"
			"bonus_health_regen"				"7"
		}
		"02"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_damage"					"3"
		}
		"03"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_armor"					"5"
		}
		"04"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_strength"				"3"
		}
		"05"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_agility"					"3"
		}
		"06"
		{
			"var_type"						"FIELD_INTEGER"
			"bonus_intellect"				"12"
		}
		"07"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_bonus_cast_radius"			"125"
		}
		"08"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_bonus_intellect"			"25" //The ratio of %unholy_bonus_strength to %unholy_ticks_to_full_effect is currently hardcoded in modifier_item_armlet_active_datadriven_tick for technical reasons.
		}
		"09"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_mana_drain_per_second"			"25"
		}
		"10"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_mana_drain_percent_per_second"		"2"
		}
		"11"
		{
			"var_type"							"FIELD_FLOAT"
			"unholy_mana_drain_interval"			"0.1"
		}
		"12"
		{
			"var_type"							"FIELD_INTEGER"
			"unholy_ticks_to_full_effect"			"9" //The ratio of %unholy_bonus_strength to %unholy_ticks_to_full_effect is currently hardcoded in modifier_item_armlet_active_datadriven_tick for technical reasons.
		}
		"13"
		{
			"var_type"							"FIELD_FLOAT"
			"unholy_tick_interval"				"0.1" //This is the interval at which the caster will gain Strength immediately after Armlet is toggled on.
		}
	}
	
	"OnSpellStart" //Switch to the inactive version of Armlet.
	{
		"RunScript"
		{
			"ScriptFile"				"item_arcane_armlet.lua"
			"Function"					"active_on_spell_start"
		}
		
		"FireSound"
		{
			"EffectName"				"DOTA_Item.Armlet.DeActivate"
			"Target"					"CASTER"
		}
	}
	
	"OnUnequip"
	{		
		"RunScript"
		{
			"ScriptFile"					"item_arcane_armlet.lua"
			"Function"						"active_on_unequip"
			"UnholyTicksToFullEffect"		"%unholy_ticks_to_full_effect"
			"UnholyBonusIntellect"			"%unholy_bonus_intellect"
		}
	}

	"Modifiers"
	{
		"modifier_item_arcane_armlet_active"
		{
			"Passive"			"1"
			"IsHidden"			"1"
			"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
			
			"EffectName"			"particles/items_fx/armlet.vpcf"
			"EffectAttachType"		"follow_origin"
			
			"Properties"
			{
				"MODIFIER_PROPERTY_HEALTH_REGEN_CONSTANT"		"%bonus_health_regen"
				"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE"		"%bonus_damage"
				"MODIFIER_PROPERTY_PHYSICAL_ARMOR_BONUS"		"%bonus_armor"
				"MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"		"%bonus_strength"
				"MODIFIER_PROPERTY_STATS_AGILITY_BONUS"			"%bonus_agility"
				"MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"		"%bonus_intellect"
			}
			
			"ThinkInterval" 		"%unholy_mana_drain_interval"
			"OnIntervalThink" //Damage the caster while Armlet is toggled on.
			{
				"RunScript"
				{
					"ScriptFile"						"item_arcane_armlet.lua"
					"Function"							"on_interval_think_damage"
					"UnholyManaDrainPerSecond"			"%unholy_mana_drain_per_second"
					"UnholyManaDrainProcentPerSecond"	"%unholy_mana_drain_percent_per_second"
					"UnholyManaDrainInterval"			"%unholy_mana_drain_interval"
				}
			}
		}

		"modifier_item_arcane_armlet_active_apply_tick_intellect"
		{
			"Passive"			"1"
			"IsHidden"			"1"
			"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
			
			"Properties"
			{
				"MODIFIER_PROPERTY_BASEATTACK_BONUSDAMAGE"		"%unholy_bonus_damage"
				"MODIFIER_PROPERTY_ATTACKSPEED_BONUS_CONSTANT"	"%unholy_bonus_attack_speed"
			}
			
			"ThinkInterval" 		"%unholy_tick_interval"
			"OnIntervalThink"
			{
				"RunScript"
				{
					"ScriptFile"					"item_arcane_armlet.lua"
					"Function"						"active_apply_tick_intellect"
					"UnholyTicksToFullEffect"		"%unholy_ticks_to_full_effect"
					"UnholyBonusIntellect"			"%unholy_bonus_intellect"
				}
			}
		}

		//"modifier_item_arcane_armlet_active_tick"
		//{
		//	"Passive"			"0"
		//	"IsHidden"			"0"
		//	"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
		//	
		//	"Properties"
		//	{
		//		"MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"		"3.57" //This value is %unholy_bonus_intellect / %unholy_ticks_to_full_effect and is hardcoded here for technical reasons.
		//	}
		//}
	}
}
}

В modifier_item_arcane_armlet_active_tick.lua ничего не менял.

OQD2.png

Не забудь путь к скрипту поменять в ДатаДрайвене!!! Я у себя его кидал в vscripts, а не в vscripts/items!!!
 
Последнее редактирование модератором:

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
Но Spell Amplify не работает так, как ты сделал:
OQD4.png
OQD5.png
 

Adam Smith

Друзья CG
4 Окт 2014
473
2
[quote author=I_GRIN_I link=topic=922.msg4585#msg4585 date=1464514070]
Но Spell Amplify не работает так, как ты сделал:
OQD4.png
OQD5.png
[/quote]
Мой способ тоже не сработал, об котором я вчера говорил
 

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
Adam Smith, GetModifierSpellAmplify_Percentage - может return нужно делать не через эту функцию?
 

Adam Smith

Друзья CG
4 Окт 2014
473
2
[quote author=I_GRIN_I link=topic=922.msg4588#msg4588 date=1464516752]
Adam Smith, GetModifierSpellAmplify_Percentage - может return нужно делать не через эту функцию?
[/quote]
Ща тему создам, тут надо решать всем форумом
 

EnDronist

Продвинутый
28 Апр 2016
231
0
Проект
Защитники Изобилия | Defenders of Abundance
[quote author=I_GRIN_I link=topic=922.msg4585#msg4585 date=1464514070]
Но Spell Amplify не работает так, как ты сделал:
OQD4.png
OQD5.png
[/quote]
Перекинул в vscripts и не робит
paDVXocSsCk.jpg
 

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
EnDronist,
Код:
LinkLuaModifier( "modifier_item_arcane_armlet_active_tick", "modifier_item_arcane_armlet_active_tick", LUA_MODIFIER_MOTION_NONE )
Поменяй на:
Код:
LinkLuaModifier( "modifier_item_arcane_armlet_active_tick", "items/modifier_item_arcane_armlet_active_tick", LUA_MODIFIER_MOTION_NONE )
 
Последнее редактирование модератором:

EnDronist

Продвинутый
28 Апр 2016
231
0
Проект
Защитники Изобилия | Defenders of Abundance
[quote author=I_GRIN_I link=topic=922.msg4604#msg4604 date=1464520153]
EnDronist,
Код:
LinkLuaModifier( "modifier_item_arcane_armlet_active_tick", "modifier_item_arcane_armlet_active_tick", LUA_MODIFIER_MOTION_NONE )
Поменяй на:
Код:
LinkLuaModifier( "modifier_item_arcane_armlet_active_tick", "items/modifier_item_arcane_armlet_active_tick", LUA_MODIFIER_MOTION_NONE )
[/quote]
Та же самая проблема, он не может понять self
 
Последнее редактирование модератором:

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
EnDronist, какой нафиг селф? Я же скинул тебе код. Там нету селфов, тебе не нужны селфы.
 

EnDronist

Продвинутый
28 Апр 2016
231
0
Проект
Защитники Изобилия | Defenders of Abundance
[quote author=I_GRIN_I link=topic=922.msg4626#msg4626 date=1464591578]
EnDronist, какой нафиг селф? Я же скинул тебе код. Там нету селфов, тебе не нужны селфы.
[/quote]
Смотри, такой модификатор стакается:
Код:
		"modifier_item_armlet_active_datadriven_tick"
		{
			"Passive"			"0"
			"IsHidden"			"1"
			"Attributes" 		"MODIFIER_ATTRIBUTE_MULTIPLE"
			
			"Properties"
			{
				"MODIFIER_PROPERTY_STATS_STRENGTH_BONUS"		"3.57" //This value is %unholy_bonus_strength / %unholy_ticks_to_full_effect and is hardcoded here for technical reasons.
			}
		}
А мой tick не стакается, как сделать стакаемый?
Код:
function modifier_item_arcane_armlet_active_tick:OnCreated(params)
	if IsServer() then
		self:SetStackCount( 0 )
		if keys.caster:HasModifier("modifier_item_arcane_armlet_active_tick") then
			self:SetStackCount( 0 ) == self:SetStackCount( 0 ) + 1
		end -- А я, походу, криворукий, либо не понимаю разницы между self и params
	end
end
YY_Udku4jug.jpg
 
Последнее редактирование модератором:

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
EnDronist,
Код:
function modifier_item_arcane_armlet_active_tick:GetAttributes ()
  return MODIFIER_ATTRIBUTE_MULTIPLE
end
 

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
Я себе вот такой армлетик переписал:
Код:
"item_dummy_armlet"
 {
  "ID"              "1252"
  "BaseClass"           "item_datadriven"
  "ItemBaseLevel"         "1"
  "ItemPurchasable"        "0"
 }
 "item_armlet_of_azrael"
 {
  "BaseClass"          "item_datadriven"
  "AbilityTextureName"     "armlet_of_azrael"
  "ID"             "1253"
  "AbilityBehavior"       "DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL"
  "Model"            "models/props_gameplay/red_box.vmdl" 
  "Effect"           "particles/generic_gameplay/dropped_item.vpcf"
  "AbilityCastPoint"      "0.0"
  "AbilityCooldown"       "0"
  "AbilityManaCost"       "100"
  "ItemCost"          "0"
  "ItemShopTags"        "int;damage;attack_speed;mana_pool;regen_mana;hard_to_tag"
  "ItemQuality"         "epic"
  "ItemAliases"         "armlet of azrael"
  "PingOverrideText"      "DOTA_Chat_azrael" 
  "ItemDeclarations"      "DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_IN_SPEECH | DECLARE_PURCHASES_TO_SPECTATORS"
  
  "AbilitySpecial"
  {
   "01"
   {
    "var_type"          "FIELD_INTEGER"
    "bonus_spell_damage"     "1.5"
   }
   "02"
   {
    "var_type"          "FIELD_INTEGER"
    "cd_red"           "5"
   }
   "03"
   {
    "var_type"          "FIELD_INTEGER"
    "bonus_mana"         "300"
   }
   "04"
   {
    "var_type"          "FIELD_INTEGER"
    "bonus_mana_regen"      "200"
   }
   "05"
   {
    "var_type"          "FIELD_INTEGER"
    "unholy_bonus_mana"      "400"
   }
   "06"
   {
    "var_type"          "FIELD_INTEGER"
    "unholy_cd_red"        "10"
   }
   "07"
   {
    "var_type"          "FIELD_INTEGER"
    "unholy_bonus_int"      "25"
   }
   "08"
   {
    "var_type"          "FIELD_INTEGER"
    "unholy_mana_drain"      "100"
   }
   "09"
   {
    "var_type"          "FIELD_FLOAT"
    "toggle_cooldown"       "0.5"
   }
   "10"
   {
    "var_type"          "FIELD_FLOAT"
    "unholy_bonus_spell_damage"  "5.0"
   }
  }
  "OnSpellStart"
  {
   "RunScript"
   {
    "ScriptFile"   "items/item_armlet_of_azrael.lua"
    "Function"    "on_spell_start"
   }
   
   "FireSound"
   {
    "EffectName"    "DOTA_Item.Armlet.Activate"
    "Target"      "CASTER"
   }
  }
  
  "Modifiers"
  {
   "modifier_item_armlet_datadriven"
   {
    "Passive"    "1"
    "IsHidden"   "1"
    "Attributes"  "MODIFIER_ATTRIBUTE_MULTIPLE"
    
    "Properties"
    {
     "MODIFIER_PROPERTY_MANA_REGEN_PERCENTAGE"        "%bonus_mana_regen"
     "MODIFIER_PROPERTY_MANA_BONUS"             "%bonus_mana"
    }
   }
  }
  "OnEquip"
  {
   "RunScript"
   {
    "ScriptFile" "items/item_armlet_of_azrael.lua"
    "Function"  "createmodifier"
   }
  }
  "OnUnequip"
  {
   "RemoveModifier"
   {
    "ModifierName" "modifier_item_armlet_of_azrael"
    "Target"    "CASTER"
   }
   "RemoveModifier"
   {
    "ModifierName"       "modifier_item_unholy_armlet_of_azrael"
    "Target"          "CASTER"
   }
  }
 }
 "item_recipe_armlet_of_azrael"
 {
  "BaseClass"           "item_datadriven"
  "ID"              "1254"
  "Model"             "models/props_gameplay/recipe.vmdl" 
  "Effect"            "particles/generic_gameplay/dropped_item.vpcf" 
  "ItemCost"           "1000"  
  "ItemShopTags"         ""
  "ItemRecipe"          "1"
  "ItemResult"          "item_armlet_of_azrael"
  "ItemRequirements"
  {
   "01"             "item_devotit_core;item_helm_of_int"
  }
 }
 "item_armlet_of_azrael_active"
 {
  "BaseClass"       "item_datadriven"
  "ID"          "1255"
  "AbilityBehavior"    "DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL"
  "Model"         "models/props_gameplay/red_box.vmdl" 
  "Effect"        "particles/generic_gameplay/dropped_item.vpcf"
  "AbilityTextureName"  "armlet_of_azrael_activate"
  "AbilityCastPoint"   "0.0"
  "AbilityCooldown"    "0"
  "AbilityManaCost"    "0"
  "ItemCost"       "0"
  "ItemPurchasable"    "0"
  "ItemShareability"   "ITEM_NOT_SHAREABLE"
  "ItemShopTags"     "int;damage;attack_speed;mana_pool;regen_mana;hard_to_tag"
  "ItemQuality"      "epic"
  "ItemAliases"      "armlet of mordiggian"
  "ItemDeclarations"   "DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_IN_SPEECH | DECLARE_PURCHASES_TO_SPECTATORS"
  
  "ItemPurchasable"    "0"
   
  "AbilitySpecial"
  {
   "01"
   {
    "var_type"            "FIELD_FLOAT"
    "bonus_spell_damage"       "1.5"
   }
   "02"
   {
    "var_type"            "FIELD_INTEGER"
    "cd_red"             "10"
   }
   "03"
   {
    "var_type"            "FIELD_INTEGER"
    "bonus_mana"           "300"
   }
   "04"
   {
    "var_type"            "FIELD_INTEGER"
    "bonus_mana_regen"        "200"
   }
   "05"
   {
    "var_type"            "FIELD_FLOAT"
    "unholy_bonus_spell_damage"    "5.0"
   }
   "06"
   {
    "var_type"            "FIELD_INTEGER"
    "unholy_cd_red"          "20"
   }
   "07"
   {
    "var_type"            "FIELD_INTEGER"
    "unholy_bonus_int"        "100"
   }
   "08"
   {
    "var_type"            "FIELD_INTEGER"
    "unholy_mana_drain"        "100"
   }
   "09"
   {
    "var_type"            "FIELD_FLOAT"
    "unholy_mana_drain_interval"   "0.1"
   }
   "10"
   {
    "var_type"            "FIELD_INTEGER"
    "unholy_ticks_to_full_effect"   "7"
   }
   "11"
   {
    "var_type"            "FIELD_FLOAT"
    "unholy_tick_interval"      "0.1"
   }
   "12"
   {
    "var_type"            "FIELD_INTEGER"
    "unholy_hp_drain"         "50"
   }
  }
  "OnSpellStart"
  {
   "RunScript"
   {
    "ScriptFile"   "items/item_armlet_of_azrael.lua"
    "Function"    "active_on_spell_start"
   }
   "FireSound"
   {
    "EffectName"   "DOTA_Item.Armlet.DeActivate"
    "Target"     "CASTER"
   }
   "RemoveModifier"
   {
    "ModifierName"       "modifier_item_unholy_armlet_of_azrael"
    "Target"          "CASTER"
   }
  }
  "OnUnequip"
  {  
   "RunScript"
   {
    "ScriptFile"        "items/item_armlet_of_azrael.lua"
    "Function"         "on_unequip"
    "UnholyTicksToFullEffect"  "%unholy_ticks_to_full_effect"
    "UnholyBonusInt"      "%unholy_bonus_int"
   }
   "RemoveModifier"
   {
    "ModifierName"       "modifier_item_armlet_of_azrael"
    "Target"          "CASTER"
   }
   "RemoveModifier"
   {
    "ModifierName"       "modifier_item_unholy_armlet_of_azrael"
    "Target"          "CASTER"
   }
  }
  "Modifiers"
  {
   "modifier_item_armlet_active_datadriven"
   {
    "Passive"       "1"
    "IsHidden"      "1"
    "Attributes"     "MODIFIER_ATTRIBUTE_MULTIPLE"
    
    "EffectName"     "particles/items_fx/armlet.vpcf"
    "EffectAttachType"  "follow_origin"
    
    "Properties"
    {
     "MODIFIER_PROPERTY_MANA_REGEN_PERCENTAGE"        "%bonus_mana_regen"
     "MODIFIER_PROPERTY_MANA_BONUS"             "%bonus_mana"
    }
    
    "ThinkInterval"          "%unholy_mana_drain_interval"
    "OnIntervalThink"
    {
     "RunScript"
     {
      "ScriptFile"         "items/item_armlet_of_azrael.lua"
      "Function"          "on_interval_think_mana"
      "UnholyManaDrainPerSecond"  "%unholy_mana_drain"
      "UnholyManaDrainInterval"   "%unholy_mana_drain_interval"
      "UnholyHpDrainPerSecond"   "%unholy_hp_drain"
     }
    }
   }
   "modifier_item_armlet_active_datadriven_apply_tick_strength"
   {
    "Passive"      "1"
    "IsHidden"     "1"
    "Attributes"    "MODIFIER_ATTRIBUTE_MULTIPLE"
    
    "Properties"
    {
     "MODIFIER_PROPERTY_INCOMING_SPELL_DAMAGE_CONSTANT"   "%unholy_bonus_spell_damage"
     "MODIFIER_PROPERTY_COOLDOWN_REDUCTION_CONSTANT"     "%unholy_cd_red"
    }
    
    "ThinkInterval"                  "%unholy_tick_interval"
    "OnIntervalThink"
    {
     "RunScript"
     {
      "ScriptFile"        "items/item_armlet_of_azrael.lua"
      "Function"         "apply_tick_int_on_interval_think"
      "UnholyTicksToFullEffect"  "%unholy_ticks_to_full_effect"
      "UnholyBonusInt"      "%unholy_bonus_int"
     }
    }
    "OnCreated"
    {
     "RunScript"
     {
      "ScriptFile"        "items/item_armlet_of_azrael.lua"
      "Function"         "createactivemodifier"
     }
    }
   }
   "modifier_item_armlet_active_datadriven_tick"
   {
    "Passive"       "0"
    "IsHidden"      "1"
    "Attributes"     "MODIFIER_ATTRIBUTE_MULTIPLE"
    
    "Properties"
    {
     "MODIFIER_PROPERTY_STATS_INTELLECT_BONUS"  "14.29"
    }
   }
  }
  "OnEquip"
  {
   "RunScript"
   {
    "ScriptFile" "items/item_armlet_of_azrael.lua"
    "Function"  "createmodifier"
   }
  }
 }
Код:
LinkLuaModifier("modifier_item_armlet_of_azrael","items/modifier_item_armlet_of_azrael",LUA_MODIFIER_MOTION_NONE)
LinkLuaModifier("modifier_item_unholy_armlet_of_azrael","items/modifier_item_unholy_armlet_of_azrael",LUA_MODIFIER_MOTION_NONE)
function swap_to_item(keys, ItemName)
	for i=0, 5, 1 do
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item == nil then
			keys.caster:AddItem(CreateItem("item_dummy_armlet", keys.caster, keys.caster))
		end
	end
	
	keys.caster:RemoveItem(keys.ability)
	keys.caster:AddItem(CreateItem(ItemName, keys.caster, keys.caster))
	
	for i=0, 5, 1 do
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item ~= nil then
			if current_item:GetName() == "item_dummy_armlet" then
				keys.caster:RemoveItem(current_item)
			end
		end
	end
end


function active_on_spell_start(keys)
	keys.caster:EmitSound("DOTA_Item.Armlet.DeActivate")
	swap_to_item(keys, "item_armlet_of_azrael")
end


function on_spell_start(keys)
	while keys.caster:HasAnyAvailableInventorySpace() do
		keys.caster:AddItem(CreateItem("item_dummy_armlet", keys.caster, keys.caster))
	end
	for i=0, 5, 1 do
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item ~= nil then
			if current_item:GetName() == "item_armlet_of_azrael_active" then
				keys.caster:RemoveItem(current_item)
				keys.caster:AddItem(CreateItem("item_armlet_of_azrael", keys.caster, keys.caster))
			end
		end
	end
	
	for i=0, 5, 1 do
		local current_item = keys.caster:GetItemInSlot(i)
		if current_item ~= nil then
			if current_item:GetName() == "item_dummy_armlet" then
				keys.caster:RemoveItem(current_item)
			end
		end
	end

	keys.caster:EmitSound("DOTA_Item.Armlet.Activate")
	swap_to_item(keys, "item_armlet_of_azrael_active")
end
function on_interval_think_mana(keys)
	local new_mp = keys.caster:GetMana() - (keys.UnholyManaDrainPerSecond * keys.UnholyManaDrainInterval)
	local new_hp = keys.caster:GetHealth() - (keys.UnholyHpDrainPerSecond * keys.UnholyManaDrainInterval)
	
	if new_mp < 0 then
		new_mp = 0
	end

	if new_hp < 1 then
		new_hp = 1
	end

	keys.caster:SetHealth(new_hp)
	keys.caster:SetMana(new_mp)
end
function apply_tick_int_on_interval_think(keys)
	if keys.ability.ArmletTicksActive == nil or keys.ability.ArmletTicksActive < keys.UnholyTicksToFullEffect then
		keys.ability:ApplyDataDrivenModifier(keys.caster, keys.caster, "modifier_item_armlet_active_datadriven_tick", {duration = -1})
		if keys.ability.ArmletTicksActive == nil then
			keys.ability.ArmletTicksActive = 1
		else
			keys.ability.ArmletTicksActive = keys.ability.ArmletTicksActive + 1
		end
		local currentMP = keys.caster:GetMana()
		local maxMP = keys.caster:GetMaxMana()
		local mana_bonus_interval_ratio = (keys.UnholyBonusInt / keys.UnholyTicksToFullEffect) * 12
		
		local amount_to_mana = ((currentMP + mana_bonus_interval_ratio) / (maxMP + mana_bonus_interval_ratio)) * maxMP - currentMP
		
		keys.caster:SetMana(currentMP + amount_to_mana)
	end
end
function on_unequip(keys)
	if keys.ability.ArmletTicksActive ~= nil then
		
		for i=1, keys.ability.ArmletTicksActive, 1 do
			keys.caster:RemoveModifierByName("modifier_item_armlet_active_datadriven_tick")
		end
		for i=1, keys.ability.ArmletTicksActive, 1 do
			local currentMP = keys.caster:GetMana()
			local maxMP = keys.caster:GetMaxMana()
			local mana_bonus_interval_ratio = (keys.UnholyBonusInt / keys.UnholyTicksToFullEffect) * 12
			local amount_to_mana = ((currentMP + mana_bonus_interval_ratio) / (maxMP + mana_bonus_interval_ratio)) * maxMP - currentMP
			local new_mp = currentMP - amount_to_mana
			if new_mp < 0 then
				new_mp = 0
			end
			keys.caster:SetMana(new_mp)
		end
		keys.ability.ArmletTicksActive = nil
	end
end

function createmodifier(keys)
	keys.caster:AddNewModifier(keys.caster,nil,"modifier_item_armlet_of_azrael",{duration = -1})
end

function createactivemodifier(keys)
	keys.caster:AddNewModifier(keys.caster, nil, "modifier_item_unholy_armlet_of_azrael", {duration = -1})
end
Код:
if modifier_item_armlet_of_azrael == nil then
	modifier_item_armlet_of_azrael = class({})
end

function modifier_item_armlet_of_azrael:IsHidden()
	return true
end

function modifier_item_armlet_of_azrael:DeclareFunctions()
	local funcs = {
		MODIFIER_PROPERTY_SPELL_AMPLIFY_PERCENTAGE,
		MODIFIER_PROPERTY_COOLDOWN_PERCENTAGE
	}

	return funcs
end

function modifier_item_armlet_of_azrael:GetModifierSpellAmplify_Percentage( params )
	return math.floor(2)
end

function modifier_item_armlet_of_azrael:GetModifierPercentageCooldown( params )
	return 10
end

function modifier_item_armlet_of_azrael:GetAttributes ()
  return MODIFIER_ATTRIBUTE_IGNORE_INVULNERABLE + MODIFIER_ATTRIBUTE_MULTIPLE
end
Код:
if modifier_item_unholy_armlet_of_azrael == nil then
	modifier_item_unholy_armlet_of_azrael = class({})
end

function modifier_item_unholy_armlet_of_azrael:IsHidden()
	return false
end

function modifier_item_unholy_armlet_of_azrael:GetTexture()
	return "item_armlet_of_azrael"
end

function modifier_item_unholy_armlet_of_azrael:DeclareFunctions()
	local funcs = {
		MODIFIER_PROPERTY_SPELL_AMPLIFY_PERCENTAGE,
		MODIFIER_PROPERTY_COOLDOWN_PERCENTAGE
	}

	return funcs
end

function modifier_item_unholy_armlet_of_azrael:GetModifierSpellAmplify_Percentage( params )
	return math.floor(5)
end

function modifier_item_unholy_armlet_of_azrael:GetModifierPercentageCooldown( params )
	return 20
end

function modifier_item_unholy_armlet_of_azrael:GetAttributes ()
  return MODIFIER_ATTRIBUTE_IGNORE_INVULNERABLE + MODIFIER_ATTRIBUTE_MULTIPLE
end

Жалко, что амплифай демедж не робит.
 
Последнее редактирование модератором:

I_GRIN_I

Друзья CG
15 Мар 2016
1,335
105
[quote author=EnDronist link=topic=922.msg4627#msg4627 date=1464594950]
YY_Udku4jug.jpg

[/quote]

А здесь он ругается на то, что ты класс не определил в начале, нужно в начале модификатора вот так написать:
Код:
if modifier_item_arcane_armlet_active_tick == nil then
	modifier_item_arcane_armlet_active_tick = class({})
end
 

EnDronist

Продвинутый
28 Апр 2016
231
0
Проект
Защитники Изобилия | Defenders of Abundance
[quote author=I_GRIN_I link=topic=922.msg4633#msg4633 date=1464606291]
А здесь он ругается на то, что ты класс не определил в начале, нужно в начале модификатора вот так написать:
Код:
if modifier_item_arcane_armlet_active_tick == nil then
	modifier_item_arcane_armlet_active_tick = class({})
end
[/quote]
А как же
Код:
modifier_item_arcane_armlet_active_tick = class({})
?
 
Реклама: