Statistics: Posted by Nono06 — 09 Sep 2014, 15:10
Statistics: Posted by Nono06 — 09 Sep 2014, 00:08
OnGotTarget = function(self, Weapon)
prevUnit.OnGotTarget(self, Weapon)
if self:IsUnitState("Attacking") then
self:SetCanSwitchTarget(false)
end
end,
Statistics: Posted by Nono06 — 08 Sep 2014, 15:50
Nono06 wrote:
The issue I'm seeing is coming from another thread which prevents enemy to be detected.
Is there an easy way to know what was the last order a user gave to a unit? Moving, attacking, repair...
IsUnitState() return the current state but it is not necessarily an order provided by the user and I do not know how to use GetCommandQueue() function correctly.
Statistics: Posted by Sheeo — 08 Sep 2014, 11:57
Statistics: Posted by Nono06 — 08 Sep 2014, 11:17
function GetUnitsInSphere(position, radius)
local x1 = position.x - radius
local y1 = position.y - radius
local z1 = position.z - radius
local x2 = position.x + radius
local y2 = position.y + radius
local z2 = position.z + radius
local UnitsinRec = GetUnitsInRect( Rect(x1, z1, x2, z2) )
if not UnitsinRec then
return false
end
local RetEntities = {}
for k, v in UnitsinRec do
local dist = VDist3(position, v:GetPosition())
if dist <= radius then
table.insert(RetEntities, v)
end
end
return RetEntities
end
function GetEnemyUnitsInSphere(army, position, radius)
local UnitsinRec = GetUnitsInSphere(position, radius)
army = army or GetFocusArmy()
if not UnitsinRec then
return false
end
local RetEntities = {}
if army then
for k, v in UnitsinRec do
local dist = VDist3(position, v:GetPosition())
if IsEnemy(v:GetArmy(), army) and dist <= radius then
table.insert(RetEntities, v)
end
end
end
return RetEntities
end
Statistics: Posted by Nono06 — 04 Sep 2014, 13:52
Statistics: Posted by Sheeo — 04 Sep 2014, 11:55
Statistics: Posted by IceDreamer — 04 Sep 2014, 11:46
local EnemyUnits = GetEnemyUnitsInSphere(self:GetArmy(), self:GetPosition(), 128)
Nono06 wrote:
If the priority unit is a land unit and a bomber is flying above that unit, the GetEnemyUnitsInSphere func is not reporting it unless the plane starts its landing approach.
Nono06 wrote:
I'm not exactly sure how X, Y, Z axis are used in FA but usually Y represents the height and I find strange that it is not used anywhere.
Statistics: Posted by Sheeo — 04 Sep 2014, 11:23
while not self:IsDead() and self:HasGlobalPriority() do
local EnemyUnits = GetEnemyUnitsInSphere(self:GetArmy(), self:GetPosition(), 128)
local GlobalPriority = self:GetGlobalPriority()
if EnemyUnits and table.getn(EnemyUnits) > 0 then
for j,k in EnemyUnits do
if not k:IsPriorityTarget(GlobalPriority, self) then
local distance = GetDistanceBetweenTwoEntities(self, k)
if (distance <= k:GetMaxPriorityRange()) then
k:AddPriorityTarget(GlobalPriority, self)
end
end
end
end
WaitSeconds(1)
end
Statistics: Posted by Nono06 — 04 Sep 2014, 10:44
function GetEnemyUnitsInSphere(unit, position, radius)
local x1 = position.x - radius
local y1 = position.y - radius
local z1 = position.z - radius
local x2 = position.x + radius
local y2 = position.y + radius
local z2 = position.z + radius
local UnitsinRec = GetUnitsInRect( Rect(x1, z1, x2, z2) )
#Check for empty rectangle
if not UnitsinRec then
return UnitsinRec
end
local RadEntities = {}
for k, v in UnitsinRec do
local dist = VDist3(position, v:GetPosition())
if (unit:GetArmy() != v:GetArmy()) and (dist <= radius) then
table.insert(RadEntities, v)
end
end
return RadEntities
end
Statistics: Posted by Sheeo — 04 Sep 2014, 03:15
Statistics: Posted by IceDreamer — 03 Sep 2014, 23:46
Statistics: Posted by Nono06 — 03 Sep 2014, 21:27