Files
Dota-Zombie-Invasion/scripts/vscripts/abilities/creep/demon_dragon_satyr/grab.lua
T
2026-05-29 15:11:31 +07:00

172 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
____exports.ability_grab = __TS__Class()
local ability_grab = ____exports.ability_grab
ability_grab.name = "ability_grab"
ability_grab.____file_path = "scripts/vscripts/abilities/creep/demon_dragon_satyr/grab.lua"
__TS__ClassExtends(ability_grab, BaseAbility)
function ability_grab.prototype.CancelGrabCast(self)
self:EndChannel(true)
self:EndCooldown()
self:RefundManaCost()
end
function ability_grab.prototype.GetCastRange(self)
return 150
end
function ability_grab.prototype.GetChannelTime(self)
return 4.37
end
function ability_grab.prototype.GetBehavior(self)
return bit.bor(DOTA_ABILITY_BEHAVIOR_POINT, DOTA_ABILITY_BEHAVIOR_CHANNELLED)
end
function ability_grab.prototype.OnSpellStart(self)
if not IsServer() then
return
end
local caster = self:GetCaster()
local point = self:GetCursorPosition()
local direction = (point - caster:GetAbsOrigin()):Normalized()
local units = FindUnitsInLine(
caster:GetTeamNumber(),
caster:GetAbsOrigin(),
caster:GetAbsOrigin() + direction * self:GetCastRange(),
nil,
100,
DOTA_UNIT_TARGET_TEAM_ENEMY,
DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC,
DOTA_UNIT_TARGET_FLAG_NONE
)
if #units == 0 then
self:CancelGrabCast()
return
end
local target = units[1]
if not target then
self:CancelGrabCast()
return
end
target:AddNewModifier(
caster,
self,
"modifier_grab_stunned",
{duration = self:GetChannelTime()}
)
caster:AddNewModifier(
caster,
self,
"modifier_grab_caster",
{duration = self:GetChannelTime()}
)
caster:StartGesture(ACT_DOTA_NIAN_PIN_LOOP)
target:SetParent(caster, "attach_pindown")
target:SetOrigin(caster:GetAbsOrigin())
self.target = target
self.damageTimer = Timers:CreateTimer(
0.33,
function()
if self.target and not self.target:IsNull() and self.target:IsAlive() then
ParticleManager:CreateParticle("particles/econ/items/lifestealer/ls_ti9_immortal/ls_ti9_open_wounds_blood_bulk.vpcf", PATTACH_ABSORIGIN_FOLLOW, self.target)
EmitSoundOn("Hero_Pudge.Dismember", self.target)
ApplyDamage({
victim = self.target,
attacker = caster,
damage = self:GetSpecialValueFor("damage") + self:GetCaster():GetAverageTrueAttackDamage(target) * 3,
damage_type = DAMAGE_TYPE_PURE
})
return 0.33
end
return nil
end
)
end
function ability_grab.prototype.OnChannelFinish(self, interrupted)
if not IsServer() then
return
end
self:GetCaster():RemoveGesture(ACT_DOTA_NIAN_PIN_LOOP)
if self.damageTimer then
Timers:RemoveTimer(self.damageTimer)
self.damageTimer = nil
end
if self.target then
self.target:RemoveModifierByName("modifier_grab_stunned")
self.target:SetParent(nil, "")
self.target:RemoveHorizontalMotionController(self.target)
self.target:RemoveVerticalMotionController(self.target)
self.target:InterruptMotionControllers(true)
local casterPos = self:GetCaster():GetAbsOrigin()
local casterForward = self:GetCaster():GetForwardVector()
local dropPoint = casterPos + casterForward * 100
FindClearSpaceForUnit(self.target, dropPoint, true)
ApplyDamage({
victim = self.target,
attacker = self:GetCaster(),
damage = self:GetSpecialValueFor("damage"),
damage_type = DAMAGE_TYPE_PHYSICAL
})
end
self:GetCaster():RemoveModifierByName("modifier_grab_caster")
self.target = nil
end
ability_grab = __TS__Decorate(
ability_grab,
ability_grab,
{registerAbility(nil)},
{kind = "class", name = "ability_grab"}
)
____exports.ability_grab = ability_grab
____exports.modifier_grab_stunned = __TS__Class()
local modifier_grab_stunned = ____exports.modifier_grab_stunned
modifier_grab_stunned.name = "modifier_grab_stunned"
modifier_grab_stunned.____file_path = "scripts/vscripts/abilities/creep/demon_dragon_satyr/grab.lua"
__TS__ClassExtends(modifier_grab_stunned, BaseModifier)
function modifier_grab_stunned.prototype.IsDebuff(self)
return true
end
function modifier_grab_stunned.prototype.IsStunDebuff(self)
return true
end
function modifier_grab_stunned.prototype.CheckState(self)
return {[MODIFIER_STATE_STUNNED] = true, [MODIFIER_STATE_NO_UNIT_COLLISION] = true}
end
function modifier_grab_stunned.prototype.GetEffectName(self)
return "particles/generic_gameplay/generic_stunned.vpcf"
end
function modifier_grab_stunned.prototype.GetEffectAttachType(self)
return PATTACH_OVERHEAD_FOLLOW
end
modifier_grab_stunned = __TS__Decorate(
modifier_grab_stunned,
modifier_grab_stunned,
{registerModifier(nil)},
{kind = "class", name = "modifier_grab_stunned"}
)
____exports.modifier_grab_stunned = modifier_grab_stunned
____exports.modifier_grab_caster = __TS__Class()
local modifier_grab_caster = ____exports.modifier_grab_caster
modifier_grab_caster.name = "modifier_grab_caster"
modifier_grab_caster.____file_path = "scripts/vscripts/abilities/creep/demon_dragon_satyr/grab.lua"
__TS__ClassExtends(modifier_grab_caster, BaseModifier)
function modifier_grab_caster.prototype.IsHidden(self)
return false
end
function modifier_grab_caster.prototype.CheckState(self)
return {[MODIFIER_STATE_DISARMED] = true, [MODIFIER_STATE_ROOTED] = true}
end
modifier_grab_caster = __TS__Decorate(
modifier_grab_caster,
modifier_grab_caster,
{registerModifier(nil)},
{kind = "class", name = "modifier_grab_caster"}
)
____exports.modifier_grab_caster = modifier_grab_caster
return ____exports