restructure
This commit is contained in:
200
game/scripts/vscripts/abilities/abilitystar.lua
Executable file
200
game/scripts/vscripts/abilities/abilitystar.lua
Executable file
@@ -0,0 +1,200 @@
|
||||
function OnStar01SpellStart(keys)
|
||||
local caster = EntIndexToHScript(keys.caster_entindex)
|
||||
local targetPoint = keys.target_points[1]
|
||||
|
||||
local fairyArea = nil
|
||||
local hero = caster:GetOwner()
|
||||
if hero~=nil and hero:IsNull()==false then
|
||||
local fairyList = GetHeroFairyList(hero)
|
||||
for k,v in pairs(fairyList) do
|
||||
if v.star == caster then
|
||||
fairyArea = v
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local isTargetInArea = false
|
||||
if fairyArea ~= nil then
|
||||
local pos1 = fairyArea.sunny:GetAbsOrigin()
|
||||
local pos2 = fairyArea.star:GetAbsOrigin()
|
||||
local pos3 = fairyArea.luna:GetAbsOrigin()
|
||||
isTargetInArea = IsInTriangle(pos1,pos2,pos3,targetPoint)
|
||||
local center, radius = GetCircleCenterAndRadius(pos1,pos2,pos3)
|
||||
local targetsTotal = {}
|
||||
local fairyTargets = THTD_FindUnitsInRadius(caster,center,radius)
|
||||
for _,v in pairs(fairyTargets) do
|
||||
if v~=nil and v:IsNull()==false and v:IsAlive() and IsUnitInFairy(fairyArea,v) then
|
||||
targetsTotal[v:GetEntityIndex()] = v
|
||||
end
|
||||
end
|
||||
for k,v in pairs(targetsTotal) do
|
||||
OnStar01Damage(keys,v:GetOrigin())
|
||||
end
|
||||
end
|
||||
|
||||
if not isTargetInArea then
|
||||
OnStar01Damage(keys,targetPoint)
|
||||
end
|
||||
end
|
||||
|
||||
function OnStar01Damage(keys,targetPoint)
|
||||
local caster = EntIndexToHScript(keys.caster_entindex)
|
||||
local effectIndex = ParticleManager:CreateParticle("particles/heroes/thtd_star/ability_star_01.vpcf", PATTACH_CUSTOMORIGIN, caster)
|
||||
ParticleManager:SetParticleControl(effectIndex, 0, targetPoint)
|
||||
ParticleManager:DestroyParticleSystem(effectIndex,false)
|
||||
|
||||
caster:SetContextThink(DoUniqueString("ability_star_01_delay"),
|
||||
function()
|
||||
if GameRules:IsGamePaused() then return 0.03 end
|
||||
local targets = THTD_FindUnitsInRadius(caster,targetPoint,keys.range)
|
||||
local damage = caster:THTD_GetAbilityPowerDamage(keys.ability)
|
||||
for k,v in pairs(targets) do
|
||||
keys.ability:ApplyDataDrivenModifier(caster, v, "modifier_star_01_slow", {Duration = keys.duration_time})
|
||||
|
||||
local DamageTable = {
|
||||
ability = keys.ability,
|
||||
victim = v,
|
||||
attacker = caster,
|
||||
damage = damage,
|
||||
damage_type = keys.ability:GetAbilityDamageType(),
|
||||
damage_flags = DOTA_DAMAGE_FLAG_NONE
|
||||
}
|
||||
UnitDamageTarget(DamageTable)
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
0.5)
|
||||
end
|
||||
|
||||
function OnStar02SpellStart(keys)
|
||||
local caster = EntIndexToHScript(keys.caster_entindex)
|
||||
local targetPoint = keys.target_points[1]
|
||||
|
||||
local fairyArea = nil
|
||||
local hero = caster:GetOwner()
|
||||
if hero~=nil and hero:IsNull()==false then
|
||||
local fairyList = GetHeroFairyList(hero)
|
||||
for k,v in pairs(fairyList) do
|
||||
if v.star == caster then
|
||||
fairyArea = v
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local isTargetInArea = false
|
||||
if fairyArea ~= nil then
|
||||
local pos1 = fairyArea.sunny:GetAbsOrigin()
|
||||
local pos2 = fairyArea.star:GetAbsOrigin()
|
||||
local pos3 = fairyArea.luna:GetAbsOrigin()
|
||||
|
||||
isTargetInArea = IsInTriangle(pos1,pos2,pos3,targetPoint)
|
||||
|
||||
local center, radius = GetCircleCenterAndRadius(pos1,pos2,pos3)
|
||||
|
||||
local pos10 = GetTwoVectorSub(center, pos1, 2/1)
|
||||
local pos20 = GetTwoVectorSub(center, pos2, 2/1)
|
||||
local pos30 = GetTwoVectorSub(center, pos3, 2/1)
|
||||
local star_points = {}
|
||||
table.insert(star_points, center)
|
||||
table.insert(star_points, pos10)
|
||||
table.insert(star_points, pos20)
|
||||
table.insert(star_points, pos30)
|
||||
table.insert(star_points, GetTwoVectorSub(pos10, pos20, 1/1))
|
||||
table.insert(star_points, GetTwoVectorSub(pos20, pos30, 1/1))
|
||||
table.insert(star_points, GetTwoVectorSub(pos30, pos10, 1/1))
|
||||
|
||||
local time = keys.max_count * 0.2
|
||||
local count = 0
|
||||
caster:SetContextThink(DoUniqueString("ability_star_02_delay"),
|
||||
function()
|
||||
if GameRules:IsGamePaused() then return 0.03 end
|
||||
if time < 0 then return nil end
|
||||
if fairyArea.sunny==nil or fairyArea.sunny:IsNull() or fairyArea.sunny:THTD_IsHidden() then return nil end
|
||||
if fairyArea.star==nil or fairyArea.star:IsNull() or fairyArea.star:THTD_IsHidden() then return nil end
|
||||
if fairyArea.luna==nil or fairyArea.luna:IsNull() or fairyArea.luna:THTD_IsHidden() then return nil end
|
||||
|
||||
for _, pos in pairs(star_points) do
|
||||
local effectIndex = ParticleManager:CreateParticle("particles/heroes/thtd_star/ability_star_01.vpcf", PATTACH_CUSTOMORIGIN, caster)
|
||||
ParticleManager:SetParticleControl(effectIndex, 0, pos)
|
||||
ParticleManager:DestroyParticleSystem(effectIndex,false)
|
||||
end
|
||||
|
||||
if count > 0 and count % 2 == 0 then
|
||||
local targetsTotal = {}
|
||||
local targets = THTD_FindUnitsInRadius(caster,center,radius)
|
||||
for _,v in pairs(targets) do
|
||||
if v~=nil and v:IsNull()==false and v:IsAlive() and IsUnitInFairy(fairyArea,v) then
|
||||
table.insert(targetsTotal, v)
|
||||
end
|
||||
end
|
||||
targets = {}
|
||||
local damage = caster:THTD_GetAbilityPowerDamage(keys.ability) * 2 * (1 + keys.damage_up/100)^count
|
||||
for _, v in pairs(targetsTotal) do
|
||||
local DamageTable = {
|
||||
ability = keys.ability,
|
||||
victim = v,
|
||||
attacker = caster,
|
||||
damage = damage,
|
||||
damage_type = keys.ability:GetAbilityDamageType(),
|
||||
damage_flags = DOTA_DAMAGE_FLAG_NONE
|
||||
}
|
||||
UnitDamageTarget(DamageTable)
|
||||
end
|
||||
end
|
||||
|
||||
count = count + 1
|
||||
time = time - 0.2
|
||||
return 0.2
|
||||
end,
|
||||
0)
|
||||
|
||||
end
|
||||
|
||||
if not isTargetInArea then
|
||||
OnStar02Damage(keys,targetPoint)
|
||||
end
|
||||
end
|
||||
|
||||
function OnStar02Damage(keys,targetPoint)
|
||||
local caster = EntIndexToHScript(keys.caster_entindex)
|
||||
local time = keys.max_count * 0.2
|
||||
local count = 0
|
||||
|
||||
caster:SetContextThink(DoUniqueString("ability_star_02_delay"),
|
||||
function()
|
||||
if GameRules:IsGamePaused() then return 0.03 end
|
||||
if time < 0 then return nil end
|
||||
|
||||
local effectIndex = ParticleManager:CreateParticle("particles/heroes/thtd_star/ability_star_01.vpcf", PATTACH_CUSTOMORIGIN, caster)
|
||||
ParticleManager:SetParticleControl(effectIndex, 0, targetPoint)
|
||||
ParticleManager:DestroyParticleSystem(effectIndex,false)
|
||||
|
||||
if count > 0 and count % 2 == 0 then
|
||||
caster:SetContextThink(DoUniqueString("ability_star_02_delay"),
|
||||
function()
|
||||
local targets = THTD_FindUnitsInRadius(caster,targetPoint,keys.range)
|
||||
local damage = caster:THTD_GetAbilityPowerDamage(keys.ability) * 2 * (1 + keys.damage_up/100)^count
|
||||
for k,v in pairs(targets) do
|
||||
local DamageTable = {
|
||||
ability = keys.ability,
|
||||
victim = v,
|
||||
attacker = caster,
|
||||
damage = damage,
|
||||
damage_type = keys.ability:GetAbilityDamageType(),
|
||||
damage_flags = DOTA_DAMAGE_FLAG_NONE
|
||||
}
|
||||
UnitDamageTarget(DamageTable)
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
0.5)
|
||||
end
|
||||
|
||||
count = count + 1
|
||||
time = time - 0.2
|
||||
return 0.2
|
||||
end,
|
||||
0)
|
||||
end
|
||||
Reference in New Issue
Block a user