Here is a unit with a series of entities that are attached / offset from the parent unit. Each entity has its own intel range that displays for the player at a roughly 45 degree angle from the point of origin. Stopping at what is exactly the units max weapon range.
As the unit moves so do the attached entities. Effectively i can apply this to any intel type that's needed. Creating a cone of intel rather than a circle. (Which is more realistic)
Script snippet (or it didn't happen)
CreateIntelEntity = function(self, bone, intel, radius)
if not self.IntelEntity then
self.IntelEntity = {}
end
if not self:BeenDestroyed() and radius > 0 then
local counter = 1
while counter <= radius do
local angle = math.ceil(counter / 3.14)
if counter + angle < radius then
ent = import('/lua/sim/Entity.lua').Entity({Owner = self,})
table.insert(self.IntelEntity, ent)
self.Trash:Add(ent)
ent:AttachBoneTo( -1, self, bone or 0 )
local pos = self:CalculateWorldPositionFromRelative({0, 0, counter})
ent:SetParentOffset(Vector(0,0, counter))
ent:SetVizToFocusPlayer('Always')
ent:SetVizToAllies('Always')
ent:SetVizToNeutrals('Never')
ent:SetVizToEnemies('Never')
ent:InitIntel(self.MyArmy, intel, angle)
ent:EnableIntel(intel)
end
counter = counter + 1
end
end
end,
Currently I'm calling this from the units OnCreate to facilitate easier testing.
OnStopBeingBuilt = function(self,builder,layer)
TAirUnit.OnStopBeingBuilt(self,builder,layer)
--Start advanced radar
self:ForkThread(self.CreateIntelEntity,'MuzzleFront', 'Vision', 45)
end,
This could be applied to every "radar" unit in the game including units that have rotating radar antenna.s Thus allowing the intel entities to sweep an area just like a real radar! Eventually, once i unravel the mystery that is the FAF intel system, I will make a mod using this ability as well as something similar for sonar as well.
Enjoy!
Resin