124 lines
4.6 KiB
Lua
124 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 BaseAbility = ____dota_ts_adapter.BaseAbility
|
|
local registerAbility = ____dota_ts_adapter.registerAbility
|
|
____exports.thief_arrow = __TS__Class()
|
|
local thief_arrow = ____exports.thief_arrow
|
|
thief_arrow.name = "thief_arrow"
|
|
thief_arrow.____file_path = "scripts/vscripts/abilities/creep/thief_arrow.lua"
|
|
__TS__ClassExtends(thief_arrow, BaseAbility)
|
|
function thief_arrow.prototype.Precache(self, context)
|
|
PrecacheResource("soundfile", "sounds/units/heroes/mirana/arrow.vsnd", context)
|
|
PrecacheResource("soundfile", "sounds/units/heroes/mirana/arrow_target.vsnd", context)
|
|
PrecacheResource("particle", "particles/units/heroes/hero_phantom_assassin/phantom_assassin_crit_impact.vpcf", context)
|
|
end
|
|
function thief_arrow.prototype.OnAbilityPhaseStart(self)
|
|
if IsServer() then
|
|
self:GetCaster():StartGestureWithPlaybackRate(ACT_DOTA_ATTACK, 0.5)
|
|
self.preParticle = ParticleManager:CreateParticle(
|
|
"particles/darkmoon_creep_warning.vpcf",
|
|
PATTACH_ABSORIGIN_FOLLOW,
|
|
self:GetCaster()
|
|
)
|
|
ParticleManager:SetParticleControlEnt(
|
|
self.preParticle,
|
|
0,
|
|
self:GetCaster(),
|
|
PATTACH_ABSORIGIN_FOLLOW,
|
|
"",
|
|
self:GetCaster():GetOrigin(),
|
|
true
|
|
)
|
|
ParticleManager:SetParticleControl(
|
|
self.preParticle,
|
|
1,
|
|
Vector(100, 100, 100)
|
|
)
|
|
end
|
|
return true
|
|
end
|
|
function thief_arrow.prototype.OnAbilityPhaseInterrupted(self)
|
|
if IsClient() or not self.preParticle then
|
|
return
|
|
end
|
|
self:GetCaster():FadeGesture(ACT_DOTA_ATTACK)
|
|
ParticleManager:DestroyParticle(self.preParticle, false)
|
|
end
|
|
function thief_arrow.prototype.OnSpellStart(self)
|
|
if self.preParticle then
|
|
ParticleManager:DestroyParticle(self.preParticle, false)
|
|
end
|
|
self:GetCaster():FadeGesture(ACT_DOTA_ATTACK)
|
|
local caster = self:GetCaster()
|
|
local origin = caster:GetOrigin()
|
|
local point = self:GetCursorPosition()
|
|
local projectile_speed = self:GetSpecialValueFor("arrow_speed")
|
|
local projectile_distance = self:GetSpecialValueFor("arrow_range")
|
|
local projectile_start_radius = self:GetSpecialValueFor("arrow_width")
|
|
local projectile_end_radius = self:GetSpecialValueFor("arrow_width")
|
|
local projectile_direction = Vector(point.x - origin.x, point.y - origin.y, 0):Normalized()
|
|
ProjectileManager:CreateLinearProjectile({
|
|
Source = caster,
|
|
Ability = self,
|
|
vSpawnOrigin = caster:GetOrigin(),
|
|
iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_ENEMY,
|
|
iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_NONE,
|
|
iUnitTargetType = bit.bor(DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_BASIC),
|
|
EffectName = "particles/units/heroes/hero_mirana/mirana_spell_arrow.vpcf",
|
|
fDistance = projectile_distance,
|
|
fStartRadius = projectile_start_radius,
|
|
fEndRadius = projectile_end_radius,
|
|
vVelocity = projectile_direction * projectile_speed,
|
|
bHasFrontalCone = false,
|
|
fExpireTime = GameRules:GetGameTime() + 10
|
|
})
|
|
self:EmitSound("Hero_Mirana.ArrowCast")
|
|
end
|
|
function thief_arrow.prototype.OnProjectileHit_ExtraData(self, target, location)
|
|
if not target then
|
|
return
|
|
end
|
|
local effect_cast = ParticleManager:CreateParticle("particles/units/heroes/hero_phantom_assassin/phantom_assassin_crit_impact.vpcf", PATTACH_POINT_FOLLOW, target)
|
|
ParticleManager:SetParticleControlEnt(
|
|
effect_cast,
|
|
0,
|
|
target,
|
|
PATTACH_POINT_FOLLOW,
|
|
"attach_hitloc",
|
|
target:GetOrigin(),
|
|
true
|
|
)
|
|
ParticleManager:SetParticleControl(
|
|
effect_cast,
|
|
1,
|
|
target:GetAbsOrigin()
|
|
)
|
|
ParticleManager:SetParticleControlForward(
|
|
effect_cast,
|
|
1,
|
|
(self:GetCaster():GetOrigin() - target:GetOrigin()):Normalized()
|
|
)
|
|
ParticleManager:ReleaseParticleIndex(effect_cast)
|
|
ApplyDamage({
|
|
victim = target,
|
|
attacker = self:GetCaster(),
|
|
damage = self:GetCaster():GetAttackDamage(),
|
|
damage_type = DAMAGE_TYPE_PHYSICAL,
|
|
ability = self
|
|
})
|
|
EmitSoundOn("Hero_Mirana.ArrowImpact", target)
|
|
return true
|
|
end
|
|
thief_arrow = __TS__Decorate(
|
|
thief_arrow,
|
|
thief_arrow,
|
|
{registerAbility(nil)},
|
|
{kind = "class", name = "thief_arrow"}
|
|
)
|
|
____exports.thief_arrow = thief_arrow
|
|
return ____exports
|