235 lines
8.3 KiB
Lua
235 lines
8.3 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
|
|
____exports.ability_star_devour = __TS__Class()
|
|
local ability_star_devour = ____exports.ability_star_devour
|
|
ability_star_devour.name = "ability_star_devour"
|
|
ability_star_devour.____file_path = "scripts/vscripts/abilities/heroes/sargatanas/ability_star_devour.lua"
|
|
__TS__ClassExtends(ability_star_devour, BaseAbility)
|
|
function ability_star_devour.prototype.CastFilterResultTarget(self, target)
|
|
local nResult = UnitFilter(
|
|
target,
|
|
DOTA_UNIT_TARGET_TEAM_ENEMY,
|
|
DOTA_UNIT_TARGET_CREEP,
|
|
bit.bor(
|
|
bit.bor(DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES, DOTA_UNIT_TARGET_FLAG_NOT_ANCIENTS),
|
|
DOTA_UNIT_TARGET_FLAG_NOT_CREEP_HERO
|
|
),
|
|
self:GetCaster():GetTeamNumber()
|
|
)
|
|
if nResult ~= UF_SUCCESS then
|
|
return nResult
|
|
end
|
|
return UF_SUCCESS
|
|
end
|
|
function ability_star_devour.prototype.OnSpellStart(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local caster = self:GetCaster()
|
|
local target = self:GetCursorTarget()
|
|
if not target then
|
|
return
|
|
end
|
|
local duration = self:GetSpecialValueFor("devour_time")
|
|
caster:AddNewModifier(caster, self, ____exports.modifier_star_devour.name, {duration = duration})
|
|
if target:IsNeutralUnitType() and self:GetAutoCastState() and not self:IsStolen() then
|
|
local targetAbilities = {}
|
|
do
|
|
local i = 0
|
|
while i <= 5 do
|
|
local ability = target:GetAbilityByIndex(i)
|
|
if ability then
|
|
targetAbilities[#targetAbilities + 1] = ability:GetAbilityName()
|
|
if #targetAbilities > 1 then
|
|
break
|
|
end
|
|
end
|
|
i = i + 1
|
|
end
|
|
end
|
|
if #targetAbilities > 0 then
|
|
do
|
|
local i = 0
|
|
while i < 2 do
|
|
local empty = "doom_bringer_empty" .. tostring(i + 1)
|
|
local newAbilityName = targetAbilities[i + 1] or empty
|
|
local oldAbility = caster:GetAbilityByIndex(i + (self.addIndex or 0))
|
|
local oldAbilityName = oldAbility and oldAbility:GetAbilityName() or ""
|
|
if newAbilityName ~= oldAbilityName then
|
|
local ability = caster:AddAbility(newAbilityName)
|
|
caster:SwapAbilities(oldAbilityName, newAbilityName, false, true)
|
|
caster:RemoveAbility(oldAbilityName)
|
|
if newAbilityName ~= empty then
|
|
ability:SetLevel(1)
|
|
end
|
|
end
|
|
i = i + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
target:AddNoDraw()
|
|
target:Kill(self, caster)
|
|
local effectCast = ParticleManager:CreateParticle("particles/units/heroes/hero_doom_bringer/doom_bringer_devour.vpcf", PATTACH_ABSORIGIN_FOLLOW, target)
|
|
ParticleManager:SetParticleControlEnt(
|
|
effectCast,
|
|
1,
|
|
caster,
|
|
PATTACH_POINT_FOLLOW,
|
|
"attach_hitloc",
|
|
Vector(0, 0, 0),
|
|
true
|
|
)
|
|
ParticleManager:ReleaseParticleIndex(effectCast)
|
|
EmitSoundOn("Hero_DoomBringer.Devour", caster)
|
|
EmitSoundOn("Hero_DoomBringer.DevourCast", target)
|
|
end
|
|
function ability_star_devour.prototype.OnUpgrade(self)
|
|
if self:GetLevel() == 1 then
|
|
if not self:GetAutoCastState() then
|
|
self:ToggleAutoCast()
|
|
end
|
|
end
|
|
if self.addIndex == nil then
|
|
do
|
|
local i = 0
|
|
while i <= 10 do
|
|
local ability = self:GetCaster():GetAbilityByIndex(i)
|
|
if ability and ability:GetAbilityName() == "doom_bringer_empty1" then
|
|
self.addIndex = i - 1
|
|
break
|
|
end
|
|
i = i + 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
ability_star_devour = __TS__Decorate(
|
|
ability_star_devour,
|
|
ability_star_devour,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "ability_star_devour"}
|
|
)
|
|
____exports.ability_star_devour = ability_star_devour
|
|
____exports.modifier_star_devour = __TS__Class()
|
|
local modifier_star_devour = ____exports.modifier_star_devour
|
|
modifier_star_devour.name = "modifier_star_devour"
|
|
modifier_star_devour.____file_path = "scripts/vscripts/abilities/heroes/sargatanas/ability_star_devour.lua"
|
|
__TS__ClassExtends(modifier_star_devour, BaseModifier)
|
|
function modifier_star_devour.prototype.____constructor(self, ...)
|
|
BaseModifier.prototype.____constructor(self, ...)
|
|
self.bonusGold = 0
|
|
self.bonusRegen = 0
|
|
self.maxStack = 0
|
|
end
|
|
function modifier_star_devour.prototype.CheckState(self)
|
|
return {[MODIFIER_STATE_DISARMED] = true}
|
|
end
|
|
function modifier_star_devour.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_star_devour.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_star_devour.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_star_devour.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_star_devour.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
function modifier_star_devour.prototype.OnCreated(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local ability = self:GetAbility()
|
|
if not ability then
|
|
return
|
|
end
|
|
self.bonusGold = ability:GetSpecialValueFor("bonus_gold")
|
|
self.bonusRegen = ability:GetSpecialValueFor("regen")
|
|
self.maxStack = ability:GetSpecialValueFor("max_stack")
|
|
end
|
|
function modifier_star_devour.prototype.OnDestroy(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
if not parent:IsAlive() then
|
|
return
|
|
end
|
|
local playerId = parent:GetPlayerOwnerID()
|
|
if playerId >= 0 then
|
|
PlayerResource:ModifyGold(playerId, self.bonusGold, false, DOTA_ModifyGold_Unspecified)
|
|
end
|
|
local modifier = parent:FindModifierByName(____exports.modifier_star_devour_stack.name)
|
|
if modifier then
|
|
if modifier:GetStackCount() == self.maxStack then
|
|
modifier:SetStackCount(self.maxStack)
|
|
else
|
|
modifier:IncrementStackCount()
|
|
end
|
|
else
|
|
modifier = parent:AddNewModifier(
|
|
parent,
|
|
self:GetAbility(),
|
|
____exports.modifier_star_devour_stack.name,
|
|
{}
|
|
)
|
|
if modifier then
|
|
modifier:SetStackCount(1)
|
|
end
|
|
end
|
|
end
|
|
function modifier_star_devour.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_HEALTH_REGEN_CONSTANT}
|
|
end
|
|
function modifier_star_devour.prototype.GetModifierConstantHealthRegen(self)
|
|
return self.bonusRegen
|
|
end
|
|
modifier_star_devour = __TS__Decorate(
|
|
modifier_star_devour,
|
|
modifier_star_devour,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_star_devour"}
|
|
)
|
|
____exports.modifier_star_devour = modifier_star_devour
|
|
____exports.modifier_star_devour_stack = __TS__Class()
|
|
local modifier_star_devour_stack = ____exports.modifier_star_devour_stack
|
|
modifier_star_devour_stack.name = "modifier_star_devour_stack"
|
|
modifier_star_devour_stack.____file_path = "scripts/vscripts/abilities/heroes/sargatanas/ability_star_devour.lua"
|
|
__TS__ClassExtends(modifier_star_devour_stack, BaseModifier)
|
|
function modifier_star_devour_stack.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_star_devour_stack.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_star_devour_stack.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_star_devour_stack.prototype.IsBuff(self)
|
|
return true
|
|
end
|
|
function modifier_star_devour_stack.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
modifier_star_devour_stack = __TS__Decorate(
|
|
modifier_star_devour_stack,
|
|
modifier_star_devour_stack,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_star_devour_stack"}
|
|
)
|
|
____exports.modifier_star_devour_stack = modifier_star_devour_stack
|
|
return ____exports
|