Files
2HUCardTDGame/game/scripts/vscripts/abilities/abilitymokou.lua
2021-11-10 08:48:00 -05:00

107 lines
4.6 KiB
Lua
Executable File

function OnMokou01AttackLanded(keys)
local caster = EntIndexToHScript(keys.caster_entindex)
local target = keys.target
if caster.thtd_mokou_01_crit_chance == nil then
caster.thtd_mokou_01_crit_chance = keys.base_chance
end
if caster.thtd_mokou_01_crit_chance < keys.max_chance then
caster.thtd_mokou_01_crit_chance = math.min(keys.max_chance, caster.thtd_mokou_01_crit_chance + keys.bonus_chance)
end
local modifier = caster:FindModifierByName("passive_mokou_01_crit")
if modifier ~= nil then
modifier:SetStackCount(caster.thtd_mokou_01_crit_chance)
modifier:SetDuration(keys.duration_time,false)
else
local modifier = keys.ability:ApplyDataDrivenModifier(caster, caster, "passive_mokou_01_crit", {Duration = keys.duration_time})
modifier:SetStackCount(caster.thtd_mokou_01_crit_chance)
end
local base_crit = caster:GetAbilityValue("thtd_mokou_02", "base_crit")
local max_crit = caster:GetAbilityValue("thtd_mokou_02", "max_crit")
if caster.thtd_mokou_01_crit_damage == nil then
caster.thtd_mokou_01_crit_damage = base_crit
end
if RollPercentage(caster.thtd_mokou_01_crit_chance) then
caster.thtd_mokou_01_crit_damage = math.min(max_crit, caster.thtd_mokou_01_crit_damage * base_crit)
local radius = keys.range
if caster:HasModifier("modifier_mokou_03_buff") then
radius = radius + caster:GetAbilityValue("thtd_mokou_03", "bonus_range")
end
local targets = THTD_FindUnitsInRadius(caster,target:GetOrigin(),radius)
local damage = caster:THTD_GetAttack() * caster.thtd_mokou_01_crit_damage
SendOverheadEventMessage(caster:GetPlayerOwner(), OVERHEAD_ALERT_DAMAGE, caster, caster.thtd_mokou_01_crit_damage, caster:GetPlayerOwner())
for k,v in pairs(targets) do
local DamageTable_aoe = {
ability = keys.ability,
victim = v,
attacker = caster,
damage = damage,
damage_type = keys.ability:GetAbilityDamageType(),
damage_flags = DOTA_DAMAGE_FLAG_NONE
}
UnitDamageTarget(DamageTable_aoe)
end
if caster:HasModifier("modifier_mokou_03_buff") then
local effectIndex = ParticleManager:CreateParticle("particles/heroes/mouko/ability_mokou_01_boom.vpcf", PATTACH_CUSTOMORIGIN, nil)
ParticleManager:SetParticleControl(effectIndex, 0, target:GetOrigin())
ParticleManager:SetParticleControl(effectIndex, 1, target:GetOrigin())
ParticleManager:SetParticleControl(effectIndex, 3, target:GetOrigin())
ParticleManager:DestroyParticleSystem(effectIndex,false)
caster:EmitSound("Hero_OgreMagi.Fireblast.Target")
else
local effectIndex = ParticleManager:CreateParticle("particles/thd2/heroes/mouko/ability_mokou_02_boom.vpcf", PATTACH_CUSTOMORIGIN, nil)
ParticleManager:SetParticleControl(effectIndex, 0, target:GetOrigin()+Vector(0,0,64))
ParticleManager:SetParticleControl(effectIndex, 1, Vector(1,1,1))
ParticleManager:DestroyParticleSystem(effectIndex,false)
caster:EmitSound("Hero_OgreMagi.Fireblast.Target")
end
else
caster.thtd_mokou_01_crit_damage = base_crit
end
local modifier = caster:FindModifierByName("modifier_mokou_crit_buff")
if modifier ~= nil then
modifier:SetStackCount(caster.thtd_mokou_01_crit_damage)
else
local modifier = keys.ability:ApplyDataDrivenModifier(caster, caster, "modifier_mokou_crit_buff", nil)
modifier:SetStackCount(caster.thtd_mokou_01_crit_damage)
end
end
function OnMokou01Remove(keys)
local caster = EntIndexToHScript(keys.caster_entindex)
caster.thtd_mokou_01_crit_chance = keys.base_chance
caster.thtd_mokou_01_crit_damage = caster:GetAbilityValue("thtd_mokou_02", "base_crit")
local modifier = caster:FindModifierByName("modifier_mokou_crit_buff")
if modifier ~= nil then
modifier:SetStackCount(caster.thtd_mokou_01_crit_damage)
else
local modifier = keys.ability:ApplyDataDrivenModifier(caster, caster, "modifier_mokou_crit_buff", nil)
modifier:SetStackCount(caster.thtd_mokou_01_crit_damage)
end
end
function OnMokou03SpellStart(keys)
local caster = EntIndexToHScript(keys.caster_entindex)
local effectIndex = ParticleManager:CreateParticle("particles/thd2/heroes/mouko/ability_mokou_04_wing.vpcf", PATTACH_CUSTOMORIGIN, caster)
ParticleManager:SetParticleControlEnt(effectIndex , 0, caster, 5, "follow_origin", Vector(0,0,0), true)
ParticleManager:DestroyParticleSystemTime(effectIndex,keys.duration_time)
keys.ability:ApplyDataDrivenModifier(caster,caster,"modifier_mokou_03_buff", {duration = keys.duration_time})
end
function OnCreatedMokou03Buff(keys)
keys.target:THTD_AddBaseAttack(keys.bonus_attack, "thtd_mokou_03_bonus")
end
function OnDestroyMokou03Buff(keys)
keys.target:THTD_AddBaseAttack("thtd_mokou_03_bonus")
end