forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDamageArea.lua
More file actions
30 lines (26 loc) · 1.3 KB
/
DamageArea.lua
File metadata and controls
30 lines (26 loc) · 1.3 KB
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
local oldDamageArea = DamageArea
-- Trying to mimic DamageArea as good as possible, used for nukes to bypass the bubble damage absorbation of shields.
DamageArea = function(instigator, location, radius, damage, type, damageAllies, damageSelf, brain, army)
local rect = Rect(location[1]-radius, location[3]-radius, location[1]+radius, location[3]+radius)
local units = GetUnitsInRect(rect) or {}
for _, u in units do
if VDist3(u:GetPosition(), location) > radius then continue end
if instigator == u then
if damageSelf then
local vector = import('/lua/utilities.lua').GetDirectionVector(location, u:GetPosition())
-- need this ugliness due to Damage() refuse to damage when instigator == u
instigator:OnDamage(instigator, damage, vector, type)
end
elseif damageAllies or not IsAlly(army, u.Army) then
Damage(instigator, location, u, damage, type)
end
end
local reclaim = GetReclaimablesInRect(rect) or {}
for _, r in reclaim do
if IsProp(r) and VDist3(r:GetPosition(), location) <= radius then
Damage(instigator, location, r, damage, type)
end
end
-- Get rid of trees
oldDamageArea(instigator, location, radius, 1, 'Force', false, false)
end