227 lines
9.0 KiB
Lua
227 lines
9.0 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 modifier_sandking_burrowstrike_burrow
|
|
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
|
|
--- Burrowstrike по образцу dota1x6-free: линейный снаряд для попаданий + модификатор «под землёй»
|
|
-- со станом кастера до телепорта на точку (без HorizontalMotionController).
|
|
____exports.sandking_burrowstrike_custom = __TS__Class()
|
|
local sandking_burrowstrike_custom = ____exports.sandking_burrowstrike_custom
|
|
sandking_burrowstrike_custom.name = "sandking_burrowstrike_custom"
|
|
sandking_burrowstrike_custom.____file_path = "scripts/vscripts/abilities/heroes/sand_king/sandking_burrowstrike_custom.lua"
|
|
__TS__ClassExtends(sandking_burrowstrike_custom, BaseAbility)
|
|
function sandking_burrowstrike_custom.prototype.Precache(self, context)
|
|
PrecacheResource("particle", "particles/units/heroes/hero_sandking/sandking_burrowstrike.vpcf", context)
|
|
PrecacheResource("particle", "particles/econ/items/sand_king/king_of_egypt/king_of_egypt_burrowstrike_rocks.vpcf", context)
|
|
PrecacheResource("soundfile", "soundevents/game_sounds_heroes/game_sounds_sandking.vsndevts", context)
|
|
end
|
|
function sandking_burrowstrike_custom.prototype.GetBehavior(self)
|
|
return bit.bor(DOTA_ABILITY_BEHAVIOR_POINT, DOTA_ABILITY_BEHAVIOR_ROOT_DISABLES)
|
|
end
|
|
function sandking_burrowstrike_custom.prototype.GetCastRange(self, _location, _target)
|
|
if not IsServer() then
|
|
return self:GetSpecialValueFor("AbilityCastRange") + self:GetCaster():GetCastRangeBonus()
|
|
end
|
|
return 99999
|
|
end
|
|
function sandking_burrowstrike_custom.prototype.GetBurrowEndPosition(self, caster)
|
|
local origin = caster:GetAbsOrigin()
|
|
local point = self:GetCursorPosition()
|
|
if (point - origin):Length2D() < 1 then
|
|
point = origin + caster:GetForwardVector() * 10
|
|
end
|
|
local dir = point - origin
|
|
local maxDist = self:GetSpecialValueFor("AbilityCastRange") + caster:GetCastRangeBonus()
|
|
if dir:Length2D() >= maxDist then
|
|
dir = dir:Normalized()
|
|
dir.z = 0
|
|
point = GetGroundPosition(origin + dir * maxDist, caster)
|
|
end
|
|
dir = point - origin
|
|
local distance = dir:Length2D()
|
|
local flatDir = distance < 1 and caster:GetForwardVector() or dir:Normalized()
|
|
local endFlat = GetGroundPosition(
|
|
origin + flatDir * math.min(distance, maxDist),
|
|
caster
|
|
)
|
|
return endFlat, flatDir, math.min(distance, maxDist)
|
|
end
|
|
function sandking_burrowstrike_custom.prototype.OnSpellStart(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local caster = self:GetCaster()
|
|
if not caster:IsAlive() then
|
|
return
|
|
end
|
|
local point, dir, distance = self:GetBurrowEndPosition(caster)
|
|
caster:FaceTowards(point)
|
|
caster:SetForwardVector(dir)
|
|
local speed = math.max(
|
|
1,
|
|
self:GetSpecialValueFor("burrow_speed")
|
|
)
|
|
local width = self:GetSpecialValueFor("burrow_width")
|
|
local animTime = math.max(
|
|
0.12,
|
|
self:GetSpecialValueFor("burrow_anim_time")
|
|
)
|
|
local delay = distance / speed
|
|
local burrowModDuration = math.max(delay, animTime)
|
|
ProjectileManager:CreateLinearProjectile({
|
|
Ability = self,
|
|
vSpawnOrigin = caster:GetAbsOrigin(),
|
|
fStartRadius = width,
|
|
fEndRadius = width,
|
|
vVelocity = dir * speed,
|
|
fDistance = distance,
|
|
Source = caster,
|
|
iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_ENEMY,
|
|
iUnitTargetType = bit.bor(DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_BASIC),
|
|
iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES,
|
|
bProvidesVision = true,
|
|
iVisionTeamNumber = caster:GetTeamNumber(),
|
|
iVisionRadius = width
|
|
})
|
|
ProjectileManager:ProjectileDodge(caster)
|
|
caster:AddNewModifier(caster, self, modifier_sandking_burrowstrike_burrow.name, {
|
|
duration = burrowModDuration + 0.02,
|
|
delay = delay,
|
|
pos_x = point.x,
|
|
pos_y = point.y,
|
|
pos_z = point.z
|
|
})
|
|
self:PlayBurrowFx(
|
|
caster:GetAbsOrigin(),
|
|
point
|
|
)
|
|
end
|
|
function sandking_burrowstrike_custom.prototype.OnProjectileHit(self, target, _location)
|
|
if not IsServer() or not target then
|
|
return false
|
|
end
|
|
local caster = self:GetCaster()
|
|
local stunDur = self:GetSpecialValueFor("stun_duration")
|
|
target:AddNewModifier(
|
|
caster,
|
|
self,
|
|
"modifier_stunned",
|
|
{duration = stunDur * (1 - target:GetStatusResistance())}
|
|
)
|
|
local baseDamage = self:GetAbilityDamage()
|
|
local hpPct = self:GetSpecialValueFor("burrow_bonus_damage_max_hp_pct") / 100
|
|
local bonusFromHp = caster:GetMaxHealth() * hpPct
|
|
ApplyDamage({
|
|
victim = target,
|
|
attacker = caster,
|
|
damage = baseDamage + bonusFromHp,
|
|
damage_type = DAMAGE_TYPE_MAGICAL,
|
|
ability = self
|
|
})
|
|
local finale = caster:FindAbilityByName("sandking_caustic_finale_custom")
|
|
if finale and not finale:IsNull() then
|
|
finale:ApplyPoisonFromHit(target)
|
|
end
|
|
return false
|
|
end
|
|
function sandking_burrowstrike_custom.prototype.PlayBurrowFx(self, origin, target)
|
|
local caster = self:GetCaster()
|
|
local fx = ParticleManager:CreateParticle("particles/units/heroes/hero_sandking/sandking_burrowstrike.vpcf", PATTACH_WORLDORIGIN, caster)
|
|
ParticleManager:SetParticleControl(fx, 0, origin)
|
|
ParticleManager:SetParticleControl(fx, 1, target)
|
|
ParticleManager:ReleaseParticleIndex(fx)
|
|
EmitSoundOnLocationWithCaster(target, "SandKing.BurrowStrike", caster)
|
|
end
|
|
sandking_burrowstrike_custom = __TS__Decorate(
|
|
sandking_burrowstrike_custom,
|
|
sandking_burrowstrike_custom,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "sandking_burrowstrike_custom"}
|
|
)
|
|
____exports.sandking_burrowstrike_custom = sandking_burrowstrike_custom
|
|
modifier_sandking_burrowstrike_burrow = __TS__Class()
|
|
modifier_sandking_burrowstrike_burrow.name = "modifier_sandking_burrowstrike_burrow"
|
|
modifier_sandking_burrowstrike_burrow.____file_path = "scripts/vscripts/abilities/heroes/sand_king/sandking_burrowstrike_custom.lua"
|
|
__TS__ClassExtends(modifier_sandking_burrowstrike_burrow, BaseModifier)
|
|
function modifier_sandking_burrowstrike_burrow.prototype.____constructor(self, ...)
|
|
BaseModifier.prototype.____constructor(self, ...)
|
|
self.delay = 0
|
|
self.teleportPoint = Vector(0, 0, 0)
|
|
self.ended = false
|
|
end
|
|
function modifier_sandking_burrowstrike_burrow.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_sandking_burrowstrike_burrow.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_sandking_burrowstrike_burrow.prototype.CheckState(self)
|
|
return {[MODIFIER_STATE_STUNNED] = true}
|
|
end
|
|
function modifier_sandking_burrowstrike_burrow.prototype.OnCreated(self, params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
self.delay = params.delay or 0
|
|
local zx = params.pos_x or parent:GetAbsOrigin().x
|
|
local zy = params.pos_y or parent:GetAbsOrigin().y
|
|
local zz = params.pos_z or parent:GetAbsOrigin().z
|
|
self.teleportPoint = GetGroundPosition(
|
|
Vector(zx, zy, zz),
|
|
parent
|
|
)
|
|
parent:StartGesture(ACT_DOTA_CAST_ABILITY_1)
|
|
local thinkDelay = math.max(
|
|
0.03,
|
|
self.delay - FrameTime()
|
|
)
|
|
self:StartIntervalThink(thinkDelay)
|
|
end
|
|
function modifier_sandking_burrowstrike_burrow.prototype.OnDestroy(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:teleportFinish()
|
|
end
|
|
function modifier_sandking_burrowstrike_burrow.prototype.OnIntervalThink(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:teleportFinish()
|
|
end
|
|
function modifier_sandking_burrowstrike_burrow.prototype.teleportFinish(self)
|
|
if not IsServer() or self.ended then
|
|
return
|
|
end
|
|
self.ended = true
|
|
self:StartIntervalThink(-1)
|
|
local parent = self:GetParent()
|
|
parent:FadeGesture(ACT_DOTA_CAST_ABILITY_1)
|
|
parent:StartGesture(ACT_DOTA_OVERRIDE_ABILITY_1)
|
|
FindClearSpaceForUnit(parent, self.teleportPoint, true)
|
|
local ability = self:GetAbility()
|
|
local width = ability and ability:GetSpecialValueFor("burrow_width") or 150
|
|
local fx = ParticleManager:CreateParticle("particles/econ/items/sand_king/king_of_egypt/king_of_egypt_burrowstrike_rocks.vpcf", PATTACH_WORLDORIGIN, nil)
|
|
ParticleManager:SetParticleControl(fx, 0, self.teleportPoint)
|
|
ParticleManager:SetParticleControl(
|
|
fx,
|
|
1,
|
|
Vector(width, width, 1)
|
|
)
|
|
ParticleManager:ReleaseParticleIndex(fx)
|
|
end
|
|
modifier_sandking_burrowstrike_burrow = __TS__Decorate(
|
|
modifier_sandking_burrowstrike_burrow,
|
|
modifier_sandking_burrowstrike_burrow,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_sandking_burrowstrike_burrow"}
|
|
)
|
|
return ____exports
|