134 lines
4.6 KiB
Lua
134 lines
4.6 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_arc = __TS__Class()
|
|
local modifier_general_arc = ____exports.modifier_general_arc
|
|
modifier_general_arc.name = "modifier_general_arc"
|
|
modifier_general_arc.____file_path = "scripts/vscripts/abilities/modifiers/modifier_general_arc.lua"
|
|
__TS__ClassExtends(modifier_general_arc, BaseModifierMotionBoth)
|
|
function modifier_general_arc.prototype.____constructor(self, ...)
|
|
BaseModifierMotionBoth.prototype.____constructor(self, ...)
|
|
self.direction = Vector(0, 0, 0)
|
|
self.interrupted = false
|
|
self.duration = 0
|
|
self.distance = 0
|
|
self.speed = 0
|
|
self.height = 0
|
|
self.const1 = 0
|
|
self.const2 = 0
|
|
self.isFlail = false
|
|
end
|
|
function modifier_general_arc.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_general_arc.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_general_arc.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
function modifier_general_arc.prototype.OnCreated(self, params)
|
|
if IsClient() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
local origin = parent:GetOrigin()
|
|
if not not params.isFlail then
|
|
self:SetStackCount(1)
|
|
end
|
|
if not not params.x then
|
|
local targetOrigin = Vector(params.x, params.y, 0)
|
|
local dir = targetOrigin - origin
|
|
dir = dir:Normalized()
|
|
self.direction = dir
|
|
self.distance = (targetOrigin - origin):Length()
|
|
else
|
|
self.direction = parent:GetForwardVector()
|
|
self.distance = params.distance
|
|
end
|
|
self.duration = params.duration
|
|
self.height = params.height
|
|
self.speed = self.distance / self.duration
|
|
if self:ApplyHorizontalMotionController() == false or self:ApplyVerticalMotionController() == false then
|
|
self:Destroy()
|
|
return
|
|
end
|
|
local posEnd = origin + self.direction * self.distance
|
|
local heightStart = GetGroundHeight(origin, parent)
|
|
local heightEnd = GetGroundHeight(posEnd, parent)
|
|
local tempmin = heightStart
|
|
local tempmax = heightEnd
|
|
if tempmin > tempmax then
|
|
tempmin = tempmax
|
|
tempmax = tempmin
|
|
end
|
|
local delta = (tempmax - tempmin) * 2 / 3
|
|
local heightMax = tempmin + delta + self.height
|
|
heightEnd = heightEnd - heightStart
|
|
heightMax = heightMax - heightStart
|
|
if heightMax < heightEnd then
|
|
heightMax = heightEnd + 0.01
|
|
end
|
|
if heightMax <= 0 then
|
|
heightMax = 0.01
|
|
end
|
|
local durationEnd = (1 + math.sqrt(1 - heightEnd / heightMax)) / 2
|
|
self.const1 = 4 * heightMax * durationEnd / self.duration
|
|
self.const2 = 4 * heightMax * durationEnd * durationEnd / (self.duration * self.duration)
|
|
end
|
|
function modifier_general_arc.prototype.OnDestroy(self)
|
|
if IsClient() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
parent:RemoveHorizontalMotionController(self)
|
|
parent:RemoveVerticalMotionController(self)
|
|
end
|
|
function modifier_general_arc.prototype.GetVerticalSpeed(self, time)
|
|
return self.const1 - 2 * self.const2 * time
|
|
end
|
|
function modifier_general_arc.prototype.UpdateHorizontalMotion(self, me, dt)
|
|
local pos = me:GetOrigin() + self.direction * self.speed * dt
|
|
me:SetOrigin(pos)
|
|
end
|
|
function modifier_general_arc.prototype.UpdateVerticalMotion(self, me, dt)
|
|
local pos = me:GetOrigin()
|
|
local time = self:GetElapsedTime()
|
|
local height = pos.z
|
|
local speed = self:GetVerticalSpeed(time)
|
|
pos.z = height + speed * dt
|
|
me:SetOrigin(pos)
|
|
end
|
|
function modifier_general_arc.prototype.OnHorizontalMotionInterrupted(self)
|
|
self.interrupted = true
|
|
end
|
|
function modifier_general_arc.prototype.OnVerticalMotionInterrupted(self)
|
|
self:Destroy()
|
|
end
|
|
function modifier_general_arc.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_OVERRIDE_ANIMATION}
|
|
end
|
|
function modifier_general_arc.prototype.CheckState(self)
|
|
return {[MODIFIER_STATE_STUNNED] = true}
|
|
end
|
|
function modifier_general_arc.prototype.GetOverrideAnimation(self)
|
|
if self:GetStackCount() == 1 then
|
|
return ACT_DOTA_FLAIL
|
|
else
|
|
return ACT_DOTA_OVERRIDE_ABILITY_2
|
|
end
|
|
end
|
|
modifier_general_arc = __TS__Decorate(
|
|
modifier_general_arc,
|
|
modifier_general_arc,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_general_arc"}
|
|
)
|
|
____exports.modifier_general_arc = modifier_general_arc
|
|
return ____exports
|