Files
Dota-Zombie-Invasion/scripts/vscripts/abilities/heroes/grimstroke/grimstroke_phantoms_embrace_custom.lua
T
2026-05-29 15:11:31 +07:00

317 lines
12 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 BaseModifierMotionHorizontal = ____dota_ts_adapter.BaseModifierMotionHorizontal
local registerAbility = ____dota_ts_adapter.registerAbility
local registerModifier = ____dota_ts_adapter.registerModifier
____exports.grimstroke_phantoms_embrace_custom = __TS__Class()
local grimstroke_phantoms_embrace_custom = ____exports.grimstroke_phantoms_embrace_custom
grimstroke_phantoms_embrace_custom.name = "grimstroke_phantoms_embrace_custom"
grimstroke_phantoms_embrace_custom.____file_path = "scripts/vscripts/abilities/heroes/grimstroke/grimstroke_phantoms_embrace_custom.lua"
__TS__ClassExtends(grimstroke_phantoms_embrace_custom, BaseAbility)
function grimstroke_phantoms_embrace_custom.prototype.____constructor(self, ...)
BaseAbility.prototype.____constructor(self, ...)
self.returned = false
end
function grimstroke_phantoms_embrace_custom.prototype.OnSpellStart(self)
local target = self:GetCursorTarget()
if not target then
return
end
local caster = self:GetCaster()
local spawnPos = caster:GetOrigin() + caster:GetForwardVector() * 150
self.returned = false
local phantom = CreateUnitByName(
"npc_dota_grimstroke_ink_creature",
spawnPos,
true,
nil,
nil,
caster:GetTeamNumber()
)
phantom:AddNewModifier(
caster,
self,
____exports.modifier_grimstroke_phantoms_embrace_custom_thinker.name,
{target = target:entindex()}
)
local effectCast = ParticleManager:CreateParticle("particles/units/heroes/hero_grimstroke/grimstroke_cast_phantom.vpcf", PATTACH_ABSORIGIN_FOLLOW, caster)
ParticleManager:ReleaseParticleIndex(effectCast)
self:SetActivated(false)
EmitSoundOn("Hero_Grimstroke.InkCreature.Cast", caster)
end
function grimstroke_phantoms_embrace_custom.prototype.OnProjectileHit(self, _target)
local caster = self:GetCaster()
self:EndCooldown()
self:SetActivated(true)
self.returned = true
Timers:CreateTimer(
self:GetSpecialValueFor("return_time_free"),
function()
self.returned = false
return nil
end
)
EmitSoundOn("Hero_Grimstroke.InkCreature.Returned", caster)
end
grimstroke_phantoms_embrace_custom = __TS__Decorate(
grimstroke_phantoms_embrace_custom,
grimstroke_phantoms_embrace_custom,
{registerAbility(nil)},
{kind = "class", name = "grimstroke_phantoms_embrace_custom"}
)
____exports.grimstroke_phantoms_embrace_custom = grimstroke_phantoms_embrace_custom
____exports.modifier_grimstroke_phantoms_embrace_custom_thinker = __TS__Class()
local modifier_grimstroke_phantoms_embrace_custom_thinker = ____exports.modifier_grimstroke_phantoms_embrace_custom_thinker
modifier_grimstroke_phantoms_embrace_custom_thinker.name = "modifier_grimstroke_phantoms_embrace_custom_thinker"
modifier_grimstroke_phantoms_embrace_custom_thinker.____file_path = "scripts/vscripts/abilities/heroes/grimstroke/grimstroke_phantoms_embrace_custom.lua"
__TS__ClassExtends(modifier_grimstroke_phantoms_embrace_custom_thinker, BaseModifierMotionHorizontal)
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.____constructor(self, ...)
BaseModifierMotionHorizontal.prototype.____constructor(self, ...)
self.latchOffset = 80
self.latchDuration = 0
self.speed = 0
self.tick = 0
self.latching = false
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.OnCreated(self, params)
if IsClient() then
return
end
local ability = self:GetAbility()
self.target = EntIndexToHScript(params.target)
self.speed = ability:GetSpecialValueFor("speed")
self.latchDuration = ability:GetSpecialValueFor("latch_duration")
self.tick = ability:GetSpecialValueFor("tick")
if not self:ApplyHorizontalMotionController() then
self:Destroy()
end
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.OnDestroy(self)
if IsClient() then
return
end
local parent = self:GetParent()
parent:InterruptMotionControllers(true)
self.target:RemoveModifierByName(____exports.modifier_grimstroke_phantoms_embrace_custom_debuff.name)
local effectCast = ParticleManager:CreateParticle("particles/units/heroes/hero_grimstroke/grimstroke_phantom_death.vpcf", PATTACH_ABSORIGIN_FOLLOW, parent)
ParticleManager:ReleaseParticleIndex(effectCast)
EmitSoundOn("Hero_Grimstroke.InkCreature.Death", parent)
if not self.latching then
local ____opt_0 = self:GetAbility()
if ____opt_0 ~= nil then
____opt_0:SetActivated(true)
end
end
parent:ForceKill(false)
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.CheckState(self)
return {[MODIFIER_STATE_INVULNERABLE] = true, [MODIFIER_STATE_NO_HEALTH_BAR] = true}
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_OVERRIDE_ANIMATION}
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.GetOverrideAnimation(self)
local ____table_latching_2
if self.latching then
____table_latching_2 = ACT_DOTA_CAPTURE
else
____table_latching_2 = ACT_DOTA_RUN
end
return ____table_latching_2
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.UpdateHorizontalMotion(self, me, dt)
if self.latching then
self:latch(me, dt)
return
end
if (self.target:GetOrigin() - self:GetParent():GetOrigin()):Length2D() < self.latchOffset then
self:setLatching()
return
end
self:charge(me, dt)
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.OnHorizontalMotionInterrupted(self)
if IsServer() then
self:Destroy()
end
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.charge(self, _me, dt)
local parent = self:GetParent()
local point = parent:GetOrigin()
local targetPoint = self.target:GetOrigin()
local direction = targetPoint - point
direction.z = 0
local target = point + direction:Normalized() * (self.speed * dt)
parent:SetOrigin(target)
parent:FaceTowards(targetPoint)
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.latch(self, _me, _dt)
local parent = self:GetParent()
local target = self.target:GetOrigin() + self.target:GetForwardVector() * self.latchOffset
parent:SetOrigin(target)
parent:FaceTowards(self.target:GetOrigin())
end
function modifier_grimstroke_phantoms_embrace_custom_thinker.prototype.setLatching(self)
if not self.target:IsAlive() then
self:Destroy()
return
end
self.latching = true
self:SetStackCount(1)
self:SetDuration(self.latchDuration, false)
____exports.modifier_grimstroke_phantoms_embrace_custom_debuff:apply(
self.target,
self:GetCaster(),
self:GetAbility(),
{phantom = self:GetParent():entindex()}
)
EmitSoundOn(
"Hero_Grimstroke.InkCreature.Attach",
self:GetParent()
)
end
modifier_grimstroke_phantoms_embrace_custom_thinker = __TS__Decorate(
modifier_grimstroke_phantoms_embrace_custom_thinker,
modifier_grimstroke_phantoms_embrace_custom_thinker,
{registerModifier(nil)},
{kind = "class", name = "modifier_grimstroke_phantoms_embrace_custom_thinker"}
)
____exports.modifier_grimstroke_phantoms_embrace_custom_thinker = modifier_grimstroke_phantoms_embrace_custom_thinker
____exports.modifier_grimstroke_phantoms_embrace_custom_debuff = __TS__Class()
local modifier_grimstroke_phantoms_embrace_custom_debuff = ____exports.modifier_grimstroke_phantoms_embrace_custom_debuff
modifier_grimstroke_phantoms_embrace_custom_debuff.name = "modifier_grimstroke_phantoms_embrace_custom_debuff"
modifier_grimstroke_phantoms_embrace_custom_debuff.____file_path = "scripts/vscripts/abilities/heroes/grimstroke/grimstroke_phantoms_embrace_custom.lua"
__TS__ClassExtends(modifier_grimstroke_phantoms_embrace_custom_debuff, BaseModifier)
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.____constructor(self, ...)
BaseModifier.prototype.____constructor(self, ...)
self.tick = 0
self.damage = 0
self.radiusFind = 0
self.damageIncoming = 0
end
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.IsPurgable(self)
return false
end
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.RemoveOnDeath(self)
return true
end
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_INCOMING_DAMAGE_PERCENTAGE}
end
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.GetModifierIncomingDamage_Percentage(self, event)
if event.target == self:GetParent() and event.attacker == self:GetCaster() then
return self.damageIncoming
end
return 0
end
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.OnCreated(self, params)
local ability = self:GetAbility()
self.tick = ability:GetSpecialValueFor("tick")
self.damage = ability:GetSpecialValueFor("damage")
self.radiusFind = ability:GetSpecialValueFor("radius_find")
self.damageIncoming = ability:GetSpecialValueFor("damage_incoming")
if IsClient() then
return
end
self.phantom = EntIndexToHScript(params.phantom)
local parent = self:GetParent()
local effectCast = ParticleManager:CreateParticle("particles/units/heroes/hero_grimstroke/grimstroke_phantom_ambient.vpcf", PATTACH_ABSORIGIN_FOLLOW, parent)
ParticleManager:SetParticleControlEnt(
effectCast,
0,
parent,
PATTACH_POINT_FOLLOW,
"attach_hitloc",
Vector(0, 0, 0),
true
)
self:AddParticle(
effectCast,
false,
false,
-1,
false,
false
)
EmitSoundOn("Hero_Grimstroke.InkCreature.Spawn", parent)
self:StartIntervalThink(self.tick)
end
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.OnDestroy(self)
if IsClient() then
return
end
local parent = self:GetParent()
local ability = self:GetAbility()
self.phantom:ForceKill(false)
if parent:IsAlive() then
ability:SetActivated(true)
return
end
local caster = self:GetCaster()
local enemy = FindUnitsInRadius(
caster:GetTeamNumber(),
parent:GetOrigin(),
nil,
self.radiusFind,
DOTA_UNIT_TARGET_TEAM_ENEMY,
bit.bor(DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_BASIC),
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_CLOSEST,
false
)[1]
if enemy then
UTIL_Remove(self.phantom)
local spawnPos = parent:GetOrigin() + parent:GetForwardVector() * 150
local phantom = CreateUnitByName(
"npc_dota_grimstroke_ink_creature",
spawnPos,
true,
nil,
nil,
caster:GetTeamNumber()
)
phantom:AddNewModifier(
caster,
ability,
____exports.modifier_grimstroke_phantoms_embrace_custom_thinker.name,
{target = enemy:entindex()}
)
return
end
ProjectileManager:CreateTrackingProjectile({
Target = caster,
Source = parent,
Ability = ability,
EffectName = "particles/units/heroes/hero_grimstroke/grimstroke_phantom_return.vpcf",
iMoveSpeed = ability:GetSpecialValueFor("speed"),
bDodgeable = true
})
end
function modifier_grimstroke_phantoms_embrace_custom_debuff.prototype.OnIntervalThink(self)
if IsClient() then
return
end
local ability = self:GetAbility()
ApplyDamage({
victim = self:GetParent(),
attacker = self:GetCaster(),
damage = self.damage * self.tick,
damage_type = ability:GetAbilityDamageType(),
ability = ability
})
end
modifier_grimstroke_phantoms_embrace_custom_debuff = __TS__Decorate(
modifier_grimstroke_phantoms_embrace_custom_debuff,
modifier_grimstroke_phantoms_embrace_custom_debuff,
{registerModifier(nil)},
{kind = "class", name = "modifier_grimstroke_phantoms_embrace_custom_debuff"}
)
____exports.modifier_grimstroke_phantoms_embrace_custom_debuff = modifier_grimstroke_phantoms_embrace_custom_debuff
return ____exports