-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathHailTower.lua
96 lines (81 loc) · 3.3 KB
/
HailTower.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
-- Hail (Darkness + Light + Water)
-- This is a long range single target tower.
-- Every X attacks it applies its attack damage to all creeps in its attack range
HailTower = createClass({
tower = nil,
towerClass = "",
constructor = function(self, tower, towerClass)
self.tower = tower
self.towerClass = towerClass or self.towerClass
end
},
{
className = "HailTower"
},
nil)
function HailTower:OnAttack(keys)
local target = keys.target
local caster = keys.caster
self.current_attacks = self.current_attacks + 1
if self.current_attacks >= self.attacks_required then
self.current_attacks = 0
self.tower:EmitSound("Hail.Cast")
local damage = self.tower:GetAverageTrueAttackDamage(target)
local creeps = GetCreepsInArea(self.tower:GetAbsOrigin(), self.findRadius)
for _, creep in pairs(creeps) do
if creep:IsAlive() and creep:entindex() ~= target:entindex() then
local info =
{
Target = creep,
Source = caster,
Ability = keys.ability,
EffectName = "particles/custom/towers/hail/attack.vpcf",
iMoveSpeed = self.tower:GetProjectileSpeed(),
vSourceLoc= caster:GetAbsOrigin(),
bReplaceExisting = false,
flExpireTime = GameRules:GetGameTime() + 10,
}
projectile = ProjectileManager:CreateTrackingProjectile(info)
end
end
end
self.tower:SetModifierStackCount("modifier_storm_passive", self.tower, self.attacks_required - self.current_attacks)
end
function HailTower:OnAttackLanded(keys)
local target = keys.target
local damage = self.tower:GetAverageTrueAttackDamage(target)
local crit = false
if RollPercentage(self.crit_chance) then
damage = damage * self.damageMultiplier
crit = true
end
local damage_done = DamageEntity(target, self.tower, damage)
-- Show popup on critz
if crit and damage_done then
PopupLightDamage(target, math.floor(damage_done))
end
end
function HailTower:OnProjectileHit(keys)
self:OnAttackLanded({target = keys.target})
end
function HailTower:ApplyUpgradeData(data)
if data.current_attacks then
self.current_attacks = data.current_attacks
self.tower:SetModifierStackCount("modifier_storm_passive", self.tower, self.attacks_required - self.current_attacks)
end
end
function HailTower:GetUpgradeData()
return {
current_attacks = self.current_attacks
}
end
function HailTower:OnCreated()
self.ability = AddAbility(self.tower, "hail_tower_storm", self.tower:GetLevel())
self.attacks_required = self.ability:GetLevelSpecialValueFor("attacks_required", self.ability:GetLevel()-1)
self.current_attacks = 0
self.findRadius = self.ability:GetSpecialValueFor("hail_radius") + self.tower:GetHullRadius()
self.tower:SetModifierStackCount("modifier_storm_passive", self.tower, self.attacks_required)
self.crit_chance = self.ability:GetLevelSpecialValueFor("crit_chance", self.ability:GetLevel()-1)
self.damageMultiplier = self.ability:GetSpecialValueFor("damage_mult") / 100
end
RegisterTowerClass(HailTower, HailTower.className)