forked from OpenAngelArena/oaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboss_swiper_swipe.lua
185 lines (147 loc) · 5.83 KB
/
boss_swiper_swipe.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
LinkLuaModifier("modifier_boss_swiper_anti_stun", "abilities/swiper/boss_swiper_swipe.lua", LUA_MODIFIER_MOTION_NONE)
--------------------------------------------------------------------------------
boss_swiper_backswipe_base = class(AbilityBaseClass)
--------------------------------------------------------------------------------
function boss_swiper_backswipe_base:DebugRange(caster, range)
for i=1,8 do
local point = caster:GetAbsOrigin() + (caster:GetForwardVector() * range)--self:PointOnCircle(range, 360 / 16 * i)
DebugDrawSphere(RotatePosition(caster:GetAbsOrigin(), QAngle(0,(360 / 16 * (-i + 0.5)) + 90,0), point), Vector(255,0,0), 255, 32, true, self:GetCastPoint())
end
end
--------------------------------------------------------------------------------
function boss_swiper_backswipe_base:FindUnitsInCone(position, coneDirection, coneLength, coneWidth, teamNumber, teamFilter, typeFilter, flagFilter, order)
local units = FindUnitsInRadius(teamNumber, position, nil, coneLength, teamFilter, typeFilter, flagFilter, order, false)
coneDirection = (coneDirection * Vector(1,1,0)):Normalized()
local output = {}
local cone = math.cos(coneWidth/2)
for _, unit in pairs(units) do
local direction = ((unit:GetAbsOrigin() - position) * Vector(1,1,0)):Normalized()
if direction:Dot(coneDirection) >= cone then
table.insert(output, unit)
end
end
return output
end
--------------------------------------------------------------------------------
function boss_swiper_backswipe_base:PointOnCircle(radius, angle)
local x = radius * math.cos(angle * math.pi / 180)
local y = radius * math.sin(angle * math.pi / 180)
return Vector(x,y,0)
end
--------------------------------------------------------------------------------
function boss_swiper_backswipe_base:GetPlaybackRateOverride()
return 0.375
end
--------------------------------------------------------------------------------
function boss_swiper_backswipe_base:OnAbilityPhaseStart()
if IsServer() then
local caster = self:GetCaster()
local range = self:GetCastRange(caster:GetAbsOrigin(), caster)
local hit = {}
caster:AddNewModifier(caster, self, "modifier_boss_swiper_anti_stun", {duration = self:GetCastPoint()})
Timers:CreateTimer(self:GetCastPoint()/3, function()
local swipe = ParticleManager:CreateParticle(self.particleName, PATTACH_CUSTOMORIGIN, caster)
ParticleManager:SetParticleControl(swipe, 0, caster:GetAbsOrigin() + (caster:GetForwardVector() * 50) + Vector(0,0,100))
ParticleManager:SetParticleControl(swipe, 1, caster:GetAbsOrigin() + (caster:GetForwardVector() * 100) + Vector(0,0,100))
ParticleManager:SetParticleControl(swipe, 2, Vector(0.8,0,0))
ParticleManager:SetParticleControl(swipe, 3, Vector(0.75,0,0))
ParticleManager:ReleaseParticleIndex(swipe)
self:DebugRange(caster, range)
end)
local position2 = caster:GetAbsOrigin() + (caster:GetForwardVector() * range)
local position1 = RotatePosition(caster:GetAbsOrigin(), QAngle(0,45,0), position2)
local position3 = RotatePosition(caster:GetAbsOrigin(), QAngle(0,-45,0), position2)
local forward1 = (position1 - caster:GetAbsOrigin()):Normalized()
local forward3 = (position3 - caster:GetAbsOrigin()):Normalized()
local width = (position2 - position1):Length2D() / 2
local units = {}
table.insert(units, self:FindUnitsInCone(
caster:GetAbsOrigin(),
forward1,
range,
width,
caster:GetTeamNumber(),
DOTA_UNIT_TARGET_TEAM_ENEMY,
DOTA_UNIT_TARGET_ALL,
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_CLOSEST
))
table.insert(units, self:FindUnitsInCone(
caster:GetAbsOrigin(),
caster:GetForwardVector(),
range,
width,
caster:GetTeamNumber(),
DOTA_UNIT_TARGET_TEAM_ENEMY,
DOTA_UNIT_TARGET_ALL,
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_CLOSEST
))
table.insert(units, self:FindUnitsInCone(
caster:GetAbsOrigin(),
forward3,
range,
width,
caster:GetTeamNumber(),
DOTA_UNIT_TARGET_TEAM_ENEMY,
DOTA_UNIT_TARGET_ALL,
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_CLOSEST
))
local function Impact(v)
v:EmitSound("Hero_Juggernaut.BladeDance")
local impact = ParticleManager:CreateParticle("particles/econ/items/pudge/pudge_ti6_immortal/pudge_meathook_witness_impact_ti6.vpcf", PATTACH_POINT_FOLLOW, v)
ParticleManager:ReleaseParticleIndex(impact)
local damageTable = {
victim = v,
attacker = caster,
damage = self:GetSpecialValueFor("damage"),
damage_type = self:GetAbilityDamageType(),
ability = self
}
ApplyDamage(damageTable)
end
local isFront = string.match(self:GetName(), "frontswipe")
local modifier = 0
if isFront then
modifier = 4
end
local delay = self:GetCastPoint() / 3
for k,v in pairs(units) do
Timers:CreateTimer((delay * math.abs(k - modifier) / 2.5) + delay, function ()
for _,target in pairs(units[k]) do
if not hit[target:entindex()] then
hit[target:entindex()] = true
Impact(target)
end
end
end)
end
end
return true
end
--------------------------------------------------------------------------------
function boss_swiper_backswipe_base:OnSpellStart()
if IsServer() then
local caster = self:GetCaster()
local range = self:GetCastRange(caster:GetAbsOrigin(), caster)
end
end
------------------------------------------------------------------------------------
modifier_boss_swiper_anti_stun = class(ModifierBaseClass)
------------------------------------------------------------------------------------
function modifier_boss_swiper_anti_stun:GetPriority()
return MODIFIER_PRIORITY_SUPER_ULTRA
end
------------------------------------------------------------------------------------
function modifier_boss_swiper_anti_stun:IsPurgable()
return false
end
------------------------------------------------------------------------------------
function modifier_boss_swiper_anti_stun:CheckState()
local state =
{
[MODIFIER_STATE_STUNNED] = false
}
return state
end