Targets Under Targets
Posted: Fri Nov 10, 2023 10:24 pm
Sometimes facilities are buried. Sometimes facilities are buried UNDER other facilities. For example, one might bury a C3 bunker underneath a SATCOM facility. It might or might not be desirable to strike the surface target, but regardless, you care enough about the thing underneath that it's worth the trouble of digging through the thing on top of it to get to the thing underneath it. How might one represent this in CMO using a combination of LUA and triggers? It's actually not very difficult.
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})