morphling_morph_custom = class({})
function morphling_morph_custom:GetIntrinsicModifierName()
return "modifier_morphling_morph_custom_bonus"
end
function morphling_morph_custom:GetAbilityTextureName()
local caster = self:GetCaster()
if(not caster) then
return self.BaseClass.GetAbilityTextureName()
end
local stacks = caster:GetModifierStackCount(self:GetIntrinsicModifierName(), caster)
if (stacks == 0) then
return "morphling/morph_none"
elseif (stacks == 1) then
return "morphling/morph_agi"
elseif (stacks == 2) then
return "morphling/morph_str"
end
end
function morphling_morph_custom:OnSpellStart()
local caster = self:GetCaster()
local morph_ability = caster:FindAbilityByName("morphling_morph_custom_str")
local morph_modifier = caster:FindModifierByName("modifier_morphling_morph_custom_bonus")
local morph_state = morph_modifier:GetStackCount()
if morph_state == 0 then
morph_modifier:SetStackCount(1)
caster:AddNewModifier( caster, self, "modifier_morphling_morph_custom_agi", nil )
EmitSoundOn("Hero_Morphling.MorphAgility", caster)
elseif morph_state == 1 then
morph_modifier:SetStackCount(2)
caster:AddNewModifier( caster, self, "modifier_morphling_morph_custom_str", nil )
EmitSoundOn("Hero_Morphling.MorphStrengh", caster)
caster:RemoveModifierByName("modifier_morphling_morph_custom_agi")
StopSoundOn("Hero_Morphling.MorphAgility", caster)
elseif morph_state == 2 then
morph_modifier:SetStackCount(0)
caster:RemoveModifierByName("modifier_morphling_morph_custom_str")
StopSoundOn("Hero_Morphling.MorphStrengh", caster)
end
end
--------------------------------------------------------------------------------
modifier_morphling_morph_custom_agi = class({
IsHidden = function(self) return false end,
IsPurgable = function(self) return false end,
})
function modifier_morphling_morph_custom_agi:OnCreated()
if not IsServer() then
return
end
self:OnRefresh()
end
function modifier_morphling_morph_custom_agi:OnRefresh()
local ability = self:GetAbility()
local transfer_speed = ability:GetSpecialValueFor("transfer_speed")
local transfer_speed_pct = ability:GetSpecialValueFor("transfer_speed_pct")
local tick_interval = 0.1
if transfer_speed <= 30 then --because of frame time 0.03
tick_interval = 1/transfer_speed
end
self.transfer_amount = transfer_speed*tick_interval
self.transfer_amount_pct = transfer_speed_pct*tick_interval
self:StartIntervalThink(tick_interval)
end
function modifier_morphling_morph_custom_agi:GetEffectName()
return "particles/units/heroes/hero_morphling/morphling_morph_agi.vpcf"
end
function modifier_morphling_morph_custom_agi:OnIntervalThink()
if not IsServer() then return end
local caster = self:GetCaster()
local ability = self:GetAbility()
local strength = math.floor(caster:GetStrength())
local agility = math.floor(caster:GetAgility())
local atr_sum = strength + agility
local total_transfer = self.transfer_amount + atr_sum*self.transfer_amount_pct/100
if strength < total_transfer and strength > 2 then
total_transfer = strength-1
elseif strength <= 1 then
return
end
caster:ModifyStrength(-total_transfer)
caster:ModifyAgility(total_transfer)
local transfer_health_amount = total_transfer*10
-- ApplyDamage({
-- victim = caster,
-- attacker = caster,
-- damage = transfer_health_amount,
-- damage_type = DAMAGE_TYPE_PURE,
-- damage_flags = DOTA_DAMAGE_FLAG_NO_SPELL_AMPLIFICATION + DOTA_DAMAGE_FLAG_NON_LETHAL + DOTA_DAMAGE_FLAG_NO_SPELL_LIFESTEAL + DOTA_DAMAGE_FLAG_NO_DIRECTOR_EVENT,
-- ability = ability
-- })
end
modifier_morphling_morph_custom_str = class({
IsHidden = function(self) return false end,
IsPurgable = function(self) return false end,
})
function modifier_morphling_morph_custom_str:OnCreated()
if not IsServer() then
return
end
self:OnRefresh()
end
function modifier_morphling_morph_custom_str:OnRefresh()
local ability = self:GetAbility()
local transfer_speed = ability:GetSpecialValueFor("transfer_speed")
local transfer_speed_pct = ability:GetSpecialValueFor("transfer_speed_pct")
local tick_interval = 0.1
if transfer_speed <= 30 then --because of frame time 0.03
tick_interval = 1/transfer_speed
end
self.transfer_amount = transfer_speed*tick_interval
self.transfer_amount_pct = transfer_speed_pct*tick_interval
self:StartIntervalThink(tick_interval)
end
function modifier_morphling_morph_custom_str:GetEffectName()
return "particles/units/heroes/hero_morphling/morphling_morph_str.vpcf"
end
function modifier_morphling_morph_custom_str:OnIntervalThink()
local caster = self:GetCaster()
local ability = self:GetAbility()
local strength = math.floor(caster:GetStrength())
local agility = math.floor(caster:GetAgility())
local atr_sum = strength + agility
local total_transfer = self.transfer_amount + atr_sum*self.transfer_amount_pct/100
if agility < total_transfer and agility > 2 then
total_transfer = agility-1
elseif agility <= 1 then
return
end
caster:ModifyStrength(total_transfer)
caster:ModifyAgility(-total_transfer)
local transfer_health_amount = total_transfer*10
-- caster:Heal(total_transfer*10, ability, DOTA_HEAL_TYPE_HEALING)
end
modifier_morphling_morph_custom_bonus = class({
IsHidden = function(self) return true end,
IsPurgable = function(self) return false end,
DeclareFunctions = function(self) return {
MODIFIER_PROPERTY_STATS_STRENGTH_BONUS,
MODIFIER_PROPERTY_STATS_AGILITY_BONUS,
MODIFIER_PROPERTY_MODEL_SCALE
}end,
})
function modifier_morphling_morph_custom_bonus:OnCreated()
if not IsServer() then
return
end
self:OnRefresh()
end
function modifier_morphling_morph_custom_bonus:OnRefresh()
local ability = self:GetAbility()
self.bonus_attributes = ability:GetSpecialValueFor("bonus_attributes")
self.min_model_scale_pct = ability:GetSpecialValueFor("min_model_scale_pct")
self.max_model_scale_pct = ability:GetSpecialValueFor("max_model_scale_pct")
end
function modifier_morphling_morph_custom_bonus:GetModifierBonusStats_Agility()
return self.bonus_attributes
end
function modifier_morphling_morph_custom_bonus:GetModifierBonusStats_Strength()
return self.bonus_attributes
end
function modifier_morphling_morph_custom_bonus:GetModifierModelScale()
local caster= self:GetCaster()
local strength = caster:GetStrength()-1
local agility = caster:GetAgility()-1
local half_stats = (strength + agility)/2
local strength_weight = (strength-half_stats)/half_stats
if strength_weight > 0 then
value = strength_weight*self.max_model_scale_pct
else
value = (-strength_weight)*self.min_model_scale_pct
end
return value
end
morphling_morph_custom_mega = class(morphling_morph_custom)
LinkLuaModifier( "modifier_morphling_morph_custom_agi", "abilities/heroes/hero_morphling/morph_custom", LUA_MODIFIER_MOTION_NONE, modifier_morphling_morph_custom_agi)
LinkLuaModifier( "modifier_morphling_morph_custom_str", "abilities/heroes/hero_morphling/morph_custom", LUA_MODIFIER_MOTION_NONE, modifier_morphling_morph_custom_str)
LinkLuaModifier( "modifier_morphling_morph_custom_bonus", "abilities/heroes/hero_morphling/morph_custom", LUA_MODIFIER_MOTION_NONE, modifier_morphling_morph_custom_bonus)