Code: Select all
-- at scenario start
-- record the position of all the relevant surface level targets
aboveGroundBuilding = 'Z32OYR-0HMUR6J0UQ4E4'
satcomFacility = 'Z32OYR-0HMUU2TRG92A8'
surfaceTargetList = { aboveGroundBuilding, satcomFacility }
surfaceTargetPositionList = {}
function recordSurfaceTargetPosition(targetGuid)
surfaceTargetPosition = {latitude=99999, longitude=99999} -- initialize to somewhere non-physical for easy error detection
if(ScenEdit_GetUnit({guid=targetGuid}) ~= nil) then
surfaceTarget = ScenEdit_GetUnit({guid=targetGuid})
surfaceTargetPosition = {latitude=surfaceTarget.latitude, longitude=surfaceTarget.longitude}
end
return surfaceTargetPosition
end
for i, g in ipairs( surfaceTargetList ) do
surfaceTargetPositionList[g] = recordSurfaceTargetPosition(g)
end
-- on destruction of the surface level facility run this
-- it "exposes" the target underneath the original target
targetPosition = surfaceTargetPositionList[ satcomFacility ]
ScenEdit_AddUnit({side='RED', type='FACILITY', dbid=5, name="C3 Bunker A", latitude=targetPosition.latitude, longitude=targetPosition.longitude})