171 lines
6.2 KiB
Lua
171 lines
6.2 KiB
Lua
local ____lualib = require("lualib_bundle")
|
|
local __TS__Class = ____lualib.__TS__Class
|
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
local __TS__Decorate = ____lualib.__TS__Decorate
|
|
local ____exports = {}
|
|
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
|
local BaseAbility = ____dota_ts_adapter.BaseAbility
|
|
local BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerAbility = ____dota_ts_adapter.registerAbility
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
local ____incoming_damage_reduction_combine = require("utils.incoming_damage_reduction_combine")
|
|
local removeIncomingDamageReductionSource = ____incoming_damage_reduction_combine.removeIncomingDamageReductionSource
|
|
local setIncomingDamageReductionSource = ____incoming_damage_reduction_combine.setIncomingDamageReductionSource
|
|
local WAR_FOR_LIFE_INCOMING_SOURCE = "modifier_war_for_life_buff"
|
|
____exports.war_for_life = __TS__Class()
|
|
local war_for_life = ____exports.war_for_life
|
|
war_for_life.name = "war_for_life"
|
|
war_for_life.____file_path = "scripts/vscripts/abilities/heroes/nagash/war_for_life.lua"
|
|
__TS__ClassExtends(war_for_life, BaseAbility)
|
|
function war_for_life.prototype.GetAOERadius(self)
|
|
return self:GetSpecialValueFor("radius")
|
|
end
|
|
function war_for_life.prototype.Precache(self, context)
|
|
PrecacheResource("particle", "particles/units/heroes/hero_skeletonking/wraith_king_reincarnate.vpcf", context)
|
|
PrecacheResource("particle", "particles/econ/items/queen_of_pain/qop_arcana/qop_arcana_wings_ambient.vpcf", context)
|
|
end
|
|
function war_for_life.prototype.OnSpellStart(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local caster = self:GetCaster()
|
|
if not caster then
|
|
return
|
|
end
|
|
local casterTeam = caster:GetTeamNumber()
|
|
local casterPos = caster:GetAbsOrigin()
|
|
local radius = self:GetSpecialValueFor("radius")
|
|
self:GetCaster():AddNewModifier(
|
|
caster,
|
|
self,
|
|
"modifier_war_for_life_buff",
|
|
{duration = self:GetSpecialValueFor("duration")}
|
|
)
|
|
local heroes = HeroList:GetAllHeroes()
|
|
for ____, hero in ipairs(heroes) do
|
|
do
|
|
if not hero or not IsValidEntity(hero) then
|
|
goto __continue7
|
|
end
|
|
if not hero:IsRealHero() then
|
|
goto __continue7
|
|
end
|
|
if hero:GetTeamNumber() ~= casterTeam then
|
|
goto __continue7
|
|
end
|
|
if hero:IsAlive() then
|
|
goto __continue7
|
|
end
|
|
if hero.IsReincarnating and hero:IsReincarnating() then
|
|
goto __continue7
|
|
end
|
|
local heroDeathPos = hero:GetAbsOrigin()
|
|
local distance = (heroDeathPos - casterPos):Length2D()
|
|
if distance > radius then
|
|
goto __continue7
|
|
end
|
|
do
|
|
pcall(function()
|
|
hero:RespawnHero(false, false)
|
|
end)
|
|
end
|
|
local spawnPos = casterPos + RandomVector(150)
|
|
FindClearSpaceForUnit(hero, spawnPos, true)
|
|
local pfx = ParticleManager:CreateParticle("particles/units/heroes/hero_skeletonking/wraith_king_reincarnate.vpcf", PATTACH_ABSORIGIN_FOLLOW, hero)
|
|
ParticleManager:SetParticleControl(
|
|
pfx,
|
|
0,
|
|
hero:GetAbsOrigin()
|
|
)
|
|
ParticleManager:ReleaseParticleIndex(pfx)
|
|
EmitSoundOn("Hero_SkeletonKing.Hellfire_BlastImpact", hero)
|
|
local maxHealth = hero:GetMaxHealth()
|
|
local newHealth = math.max(
|
|
1,
|
|
math.floor(maxHealth * self:GetSpecialValueFor("health_res_pct") / 100)
|
|
)
|
|
hero:SetHealth(newHealth)
|
|
hero:AddNewModifier(
|
|
caster,
|
|
self,
|
|
"modifier_war_for_life_buff",
|
|
{duration = self:GetSpecialValueFor("duration")}
|
|
)
|
|
hero:RemoveModifierByName("modifier_fountain_invulnerability")
|
|
hero:Stop()
|
|
hero:Purge(
|
|
false,
|
|
true,
|
|
false,
|
|
true,
|
|
true
|
|
)
|
|
end
|
|
::__continue7::
|
|
end
|
|
end
|
|
war_for_life = __TS__Decorate(
|
|
war_for_life,
|
|
war_for_life,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "war_for_life"}
|
|
)
|
|
____exports.war_for_life = war_for_life
|
|
____exports.modifier_war_for_life_buff = __TS__Class()
|
|
local modifier_war_for_life_buff = ____exports.modifier_war_for_life_buff
|
|
modifier_war_for_life_buff.name = "modifier_war_for_life_buff"
|
|
modifier_war_for_life_buff.____file_path = "scripts/vscripts/abilities/heroes/nagash/war_for_life.lua"
|
|
__TS__ClassExtends(modifier_war_for_life_buff, BaseModifier)
|
|
function modifier_war_for_life_buff.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_war_for_life_buff.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_war_for_life_buff.prototype.GetEffectName(self)
|
|
return "particles/econ/items/queen_of_pain/qop_arcana/qop_arcana_wings_ambient.vpcf"
|
|
end
|
|
function modifier_war_for_life_buff.prototype.GetEffectAttachType(self)
|
|
return PATTACH_CENTER_FOLLOW
|
|
end
|
|
function modifier_war_for_life_buff.prototype.OnCreated(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
local ability = self:GetAbility()
|
|
if not parent or not ability then
|
|
return
|
|
end
|
|
setIncomingDamageReductionSource(
|
|
nil,
|
|
parent,
|
|
WAR_FOR_LIFE_INCOMING_SOURCE,
|
|
function() return math.max(
|
|
0,
|
|
ability:GetSpecialValueFor("inc_damage_res")
|
|
) end
|
|
)
|
|
end
|
|
function modifier_war_for_life_buff.prototype.OnRefresh(self)
|
|
self:OnCreated()
|
|
end
|
|
function modifier_war_for_life_buff.prototype.OnDestroy(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
removeIncomingDamageReductionSource(
|
|
nil,
|
|
self:GetParent(),
|
|
WAR_FOR_LIFE_INCOMING_SOURCE
|
|
)
|
|
end
|
|
modifier_war_for_life_buff = __TS__Decorate(
|
|
modifier_war_for_life_buff,
|
|
modifier_war_for_life_buff,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_war_for_life_buff"}
|
|
)
|
|
____exports.modifier_war_for_life_buff = modifier_war_for_life_buff
|
|
return ____exports
|