local units = unit:GetAIBrain():GetUnitsAroundPoint(categories.COMMAND + categories.SUBCOMMANDER, unit:GetPosition(), 25, 'Enemy')
for _, instigator in units do
instigator:AdjustHealth(instigator, -30)
end
Statistics: Posted by Franck83 — 20 Mar 2018, 18:33
@speed2 I deleted the line 58, then no error is reported, but no damage happens still. I feel so confused
instigator:AdjustHealth(instigator, - DamageAmount)
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
function OnPopulate()
ScenarioUtils.InitializeArmies()
end
function OnStart(self)
ForkThread(HealthAdjustor)
end
local DAMAGEAREAName
local location
local px, py, pz
local rect
local units
local health
local preAdjHealth
function HealthAdjustor(self)
while true do
for k = 1, 1 do
DAMAGEAREAName = 'DAMAGEAREA_' .. k
location = ScenarioUtils.MarkerToPosition(DAMAGEAREAName)
px, py, pz = unpack(location)
rect = Rect(px-25, pz-25, px+25, pz+25)
units = GetUnitsInRect(rect)
end
for _, instigator in units do
if VDist3(instigator:GetPosition(), location) <= 25 then
health = instigator:GetHealth()
instigator:AdjustHealth(instigator, -30)
end
end
WaitSeconds(10)
end
end
Statistics: Posted by Ghoustaq — 20 Mar 2018, 17:55
instigator:AdjustHealth(instigator, - DamageAmount)
Statistics: Posted by Franck83 — 19 Mar 2018, 23:20
Statistics: Posted by ZLO_RD — 19 Mar 2018, 19:36
Statistics: Posted by Ghoustaq — 19 Mar 2018, 19:16
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
function OnPopulate()
ScenarioUtils.InitializeArmies()
local self = import('/lua/sim/Entity.lua').Entity()
for k = 1, 1 do
local DAMAGEAREAName = 'DAMAGEAREA_' .. k
local location = ScenarioUtils.MarkerToPosition(DAMAGEAREAName)
ForkThread(Damage, self, location)
end
end
Damage = function(instigator, location, target, amount, damageType)
local px, py, pz = unpack(location)
local army = ListArmies()
local amount = 30
local damageAllies = true
local damageSelf = true
local damageType = 'Reclaimed'
local rect = Rect(px-25, pz-25, px+25, pz+25)
local units = GetUnitsInRect(rect) or {}
for _, u in units do
if VDist3(u:GetPosition(), location) <= 25 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:Damage(instigator, u, 30, vector, 'Reclaimed')
end
elseif damageAllies or not IsAlly(army, u:GetArmy()) then
instigator:Damage(instigator, u, 30, 'Reclaimed')
end
end
local reclaim = GetReclaimablesInRect(rect) or {}
for _, r in reclaim do
if IsProp(r) and VDist3(r:GetPosition(), location) <= 25 then
Damage(instigator, location, r, 30, 'Reclaimed')
end
end
-- Get rid of trees
Damage(instigator, location, 25, 1, 'Force', false, false)
end
function OnStart(self)
end
Statistics: Posted by Ghoustaq — 19 Mar 2018, 19:00
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
function OnPopulate()
ScenarioUtils.InitializeArmies()
ScenarioFramework.SetPlayableArea('AREA_1', false)
local oldDamageArea = DamageArea
local self = import('/lua/sim/Entity.lua').Entity()
for k = 1, 1 do
local DAMAGEAREAName = 'DAMAGEAREA_' .. k
local location = ScenarioUtils.MarkerToPosition(DAMAGEAREAName)
ForkThread(Damage, self)
end
end
Damage = function(instigator, target, amount, damageType)
local px, py, pz = unpack(location)
local army = ListArmies()
local rect = Rect(px-radius, pz-radius, px+radius, pz+radius)
local units = GetUnitsInRect(rect) or {}
local amount = 30
local damageAllies = true
local damageSelf = true
local radius = 25
local damageType = 'Reclaimed'
local target = units
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:Damage(instigator, u, 30, vector, 'Reclaimed')
end
elseif damageAllies or not IsAlly(army, u:GetArmy()) then
instigator:Damage(instigator, u, 30, 'Reclaimed')
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, 30, 'Reclaimed')
end
end
-- Get rid of trees
oldDamageArea(instigator, location, radius, 1, 'Reclaimed', false, false)
end
function OnStart(self)
end
Statistics: Posted by speed2 — 18 Mar 2018, 22:49
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
function OnPopulate()
ScenarioUtils.InitializeArmies()
ScenarioFramework.SetPlayableArea('AREA_1', false)
local oldDamageArea = DamageArea
local self = import('/lua/sim/Entity.lua').Entity()
for k = 1, 1 do
local DAMAGEAREAName = 'DAMAGEAREA_' .. k
local location = ScenarioUtils.MarkerToPosition(DAMAGEAREAName)
ForkThread(Damage, self)
end
end
Damage = function(instigator, target, amount, damageType)
local px, py, pz = unpack(location)
local army = ListArmies()
local rect = Rect(px-radius, pz-radius, px+radius, pz+radius)
local units = GetUnitsInRect(rect) or {}
local amount = 30
local damageAllies = true
local damageSelf = true
local radius = 25
local damageType = 'Reclaimed'
local target = units
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:Damage(instigator, u, 30, vector, 'Reclaimed')
end
elseif damageAllies or not IsAlly(army, u:GetArmy()) then
instigator:Damage(instigator, u, 30, 'Reclaimed')
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, 30, 'Reclaimed')
end
end
-- Get rid of trees
oldDamageArea(instigator, location, radius, 1, 'Reclaimed', false, false)
end
function OnStart(self)
end
Statistics: Posted by Ghoustaq — 18 Mar 2018, 20:23