Skip to content

Instantly share code, notes, and snippets.

@abner-math
Last active November 14, 2023 21:00
Show Gist options
  • Save abner-math/0f3ae072e18ce6b365202e46960265e3 to your computer and use it in GitHub Desktop.
Save abner-math/0f3ae072e18ce6b365202e46960265e3 to your computer and use it in GitHub Desktop.
Sasuke Amaterasu
--[[
Author: PicoleDeLimao
Date: 11.14.2023
Implement Sasuke Amaterasu ability
]]
function SpellStart(event)
local caster = event.caster
local ability = event.ability
local target = event.target_points[1]
local duration = ability:GetLevelSpecialValueFor("duration", ability:GetLevel() - 1)
local damagePerInt = ability:GetLevelSpecialValueFor("damage_per_int", ability:GetLevel() - 1) / duration / 10
local dummy = Units:CreateDummy(caster, target, duration)
dummy:EmitSound("Hero_Sasuke.AmaterasuCast")
local affectedEnemies = {}
local affectedEnemiesParticles = {}
AmaterasuCreate(dummy, affectedEnemies, affectedEnemiesParticles)
Timers:CreateTimer(0.1, function()
if duration > 0 then
duration = duration - 0.1
for _, unit in pairs(affectedEnemies) do
if Units:IsValidAlive(unit) then
Units:Damage(caster, unit, damagePerInt * caster:GetIntellect(), "katon", ability:GetAbilityDamageType())
local newUnits = FindUnitsInRadius(caster:GetTeamNumber(), unit:GetAbsOrigin(), nil, 220.0, DOTA_UNIT_TARGET_TEAM_BOTH, DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC, DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES, FIND_ANY_ORDER, false)
for _, newUnit in pairs(newUnits) do
if Units:IsValidAlive(newUnit) and newUnit ~= caster then
AmaterasuCreate(newUnit, affectedEnemies, affectedEnemiesParticles)
end
end
else
AmaterasuFinish(unit, affectedEnemies, affectedEnemiesParticles)
end
end
return 0.1
else
for k, unit in pairs(affectedEnemies) do
AmaterasuFinish(unit, affectedEnemies, affectedEnemiesParticles)
end
end
end)
end
function AmaterasuCreate(unit, affectedEnemies, affectedEnemiesParticles)
if TableContains(affectedEnemies, unit:GetEntityIndex()) then
return
end
local index = unit:GetEntityIndex()
table.insert(affectedEnemies, index, unit)
local particle = ParticleManager:CreateParticle("particles/heroes/sasuke/amaterasu/sasuke_amaterasu.vpcf", PATTACH_ABSORIGIN_FOLLOW, unit)
table.insert(affectedEnemiesParticles, index, particle)
Particles:Attach(particle, unit, "attach_hitloc")
end
function AmaterasuFinish(unit, affectedEnemies, affectedEnemiesParticles)
if unit == nil or not IsValidEntity(unit) then
return
end
local index = unit:GetEntityIndex()
ParticleManager:DestroyParticle(affectedEnemiesParticles[index], false)
table.remove(affectedEnemies, index)
table.remove(affectedEnemiesParticles, index)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment