155 lines
5.3 KiB
Lua
155 lines
5.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 BaseModifierMotionBoth = ____dota_ts_adapter.BaseModifierMotionBoth
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
____exports.modifier_general_knockback = __TS__Class()
|
|
local modifier_general_knockback = ____exports.modifier_general_knockback
|
|
modifier_general_knockback.name = "modifier_general_knockback"
|
|
modifier_general_knockback.____file_path = "scripts/vscripts/abilities/modifiers/modifier_general_knockback.lua"
|
|
__TS__ClassExtends(modifier_general_knockback, BaseModifierMotionBoth)
|
|
function modifier_general_knockback.prototype.____constructor(self, ...)
|
|
BaseModifierMotionBoth.prototype.____constructor(self, ...)
|
|
self.distance = 0
|
|
self.height = 0
|
|
self.duration = 0
|
|
self.anim = 0
|
|
self.direction = 0
|
|
self.tree = 0
|
|
self.hVelocity = 0
|
|
self.vVelocity = 0
|
|
self.gravity = 0
|
|
self.stun = false
|
|
self.flail = false
|
|
self.interrupted = false
|
|
end
|
|
function modifier_general_knockback.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_general_knockback.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_general_knockback.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_general_knockback.prototype.OnCreated(self, params)
|
|
if IsServer() then
|
|
self.distance = params.distance or 0
|
|
self.height = params.height or 0
|
|
self.duration = params.duration or 0
|
|
if not not params.direction_x and not not params.direction_y then
|
|
self.direction = Vector(params.direction_x, params.direction_y, 0):Normalized()
|
|
else
|
|
self.direction = -self:GetParent():GetForwardVector()
|
|
end
|
|
self.tree = params.tree_destroy_radius or self:GetParent():GetHullRadius()
|
|
self.stun = not not params.isStun
|
|
self.flail = not not params.isFlail
|
|
if self.duration == 0 then
|
|
return self:Destroy()
|
|
end
|
|
self.parent = self:GetParent()
|
|
self.origin = self.parent:GetOrigin()
|
|
self.hVelocity = self.distance / self.duration
|
|
local half_duration = self.duration / 2
|
|
self.gravity = 2 * self.height / (half_duration * half_duration)
|
|
self.vVelocity = self.gravity * half_duration
|
|
if self.distance > 0 then
|
|
if self:ApplyHorizontalMotionController() == false then
|
|
return self:Destroy()
|
|
end
|
|
end
|
|
if self.height >= 0 then
|
|
if self:ApplyVerticalMotionController() == false then
|
|
return self:Destroy()
|
|
end
|
|
end
|
|
if self.flail then
|
|
self:SetStackCount(1)
|
|
elseif self.stun then
|
|
self:SetStackCount(2)
|
|
end
|
|
else
|
|
self.anim = self:GetStackCount()
|
|
self:SetStackCount(0)
|
|
end
|
|
end
|
|
function modifier_general_knockback.prototype.OnDestroy(self)
|
|
if IsClient() then
|
|
return
|
|
end
|
|
if not self.interrupted then
|
|
if self.tree > 0 then
|
|
GridNav:DestroyTreesAroundPoint(
|
|
self.parent:GetOrigin(),
|
|
self.tree,
|
|
true
|
|
)
|
|
end
|
|
end
|
|
self.parent:InterruptMotionControllers(true)
|
|
end
|
|
function modifier_general_knockback.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_OVERRIDE_ANIMATION}
|
|
end
|
|
function modifier_general_knockback.prototype.GetOverrideAnimation(self)
|
|
if self.anim == 1 then
|
|
return ACT_DOTA_FLAIL
|
|
elseif self.anim == 2 then
|
|
return ACT_DOTA_DISABLED
|
|
end
|
|
return ACT_DOTA_FLAIL
|
|
end
|
|
function modifier_general_knockback.prototype.CheckState(self)
|
|
return {[MODIFIER_STATE_STUNNED] = self.stun}
|
|
end
|
|
function modifier_general_knockback.prototype.UpdateHorizontalMotion(self, me, dt)
|
|
local target = self.direction * self.distance * (dt / self.duration)
|
|
self.parent:SetOrigin(self.parent:GetOrigin() + target)
|
|
end
|
|
function modifier_general_knockback.prototype.UpdateVerticalMotion(self, me, dt)
|
|
local time = dt / self.duration
|
|
self.parent:SetOrigin(self.parent:GetOrigin() + Vector(0, 0, self.vVelocity * dt))
|
|
self.vVelocity = self.vVelocity - self.gravity * dt
|
|
end
|
|
function modifier_general_knockback.prototype.OnHorizontalMotionInterrupted(self)
|
|
if IsClient() then
|
|
return
|
|
end
|
|
self.interrupted = true
|
|
self:Destroy()
|
|
end
|
|
function modifier_general_knockback.prototype.OnVerticalMotionInterrupted(self)
|
|
if IsClient() then
|
|
return
|
|
end
|
|
self.interrupted = true
|
|
self:Destroy()
|
|
end
|
|
function modifier_general_knockback.prototype.GetEffectName(self)
|
|
if IsClient() then
|
|
return ""
|
|
end
|
|
if self.stun then
|
|
return "particles/generic_gameplay/generic_stunned.vpcf"
|
|
end
|
|
return ""
|
|
end
|
|
function modifier_general_knockback.prototype.GetEffectAttachType(self)
|
|
if IsClient() then
|
|
return PATTACH_INVALID
|
|
end
|
|
return PATTACH_OVERHEAD_FOLLOW
|
|
end
|
|
modifier_general_knockback = __TS__Decorate(
|
|
modifier_general_knockback,
|
|
modifier_general_knockback,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_general_knockback"}
|
|
)
|
|
____exports.modifier_general_knockback = modifier_general_knockback
|
|
return ____exports
|