When I get some order of battle data, I want to be able to quickly and automatically generate it. I'm writing some code (work in progress) that will allow me to do that. Things I'm having trouble figuring out how to do algorithmically include naming the units and their subordinates in a way that makes sense, and I'd like to arrange things on the map in a nice pyramid instead of what I'm doing now. I'd appreciate any suggestions.
mobilecpdbid = 3163
sa10dbid = 1487
sa20dbid = 399
sa21dbid = 1937
bigbirdDdbid = 2443
bigbirdCdbid = 439
bigbirdBdbid = 1626
sa21rgt = {lvl="rgt", unitname="SA-21 Rgt", equipmentname="SA-21 Bn", equipment = {mobilecpdbid, bigbirdDdbid, sa21dbid, sa21dbid, sa21dbid}, subordinates={}}
sa20rgt = {lvl="rgt", unitname="SA-20 Rgt", equipmentname="SA-20 Bn", equipment = {mobilecpdbid, bigbirdCdbid, sa20dbid, sa20dbid, sa20dbid}, subordinates={}}
sa10rgt = {lvl="rgt", unitname="SA-10 Rgt", equipmentname="SA-10 Bn", equipment = {mobilecpdbid, bigbirdBdbid, sa10dbid, sa10dbid, sa10dbid}, subordinates={}}
airdefensebgd = {lvl="bgd", unitname="Air Defense Brigade",equipment={mobilecpdbid}, subordinates={sa21rgt, sa20rgt, sa10rgt}}
neboRLMSdbid = 1848
neboRLMDdbid = 1847
neboRLMMdbid = 1846
rezonansNdbid = 3319
protivnikGEdbid = 2257
radiotechnicalcpy1 = {lvl="cpy", unitname="Radiotechnical Cpy", equipmentname="Nebo Radar", equipment={mobilecpdbid, neboRLMSdbid, neboRLMDdbid, neboRLMMdbid}, subordinates={}}
radiotechnicalcpy2 = {lvl="cpy", unitname="Radiotechnical Cpy", equipmentname="Rezonans Radar", equipment={mobilecpdbid, rezonansNdbid, rezonansNdbid}, subordinates={}}
radiotechnicalcpy3 = {lvl="cpy", unitname="Radiotechnical Cpy", equipmentname="Protivnik Radar", equipment={mobilecpdbid, protivnikGEdbid, protivnikGEdbid}, subordinates={}}
radiotechnicalbn1 = {lvl="bn", unitname="Radiotechnical Bn", equipmentname="Radiotechnical Bn CP", equipment={mobilecpdbid}, subordinates={radiotechnicalcpy1, radiotechnicalcpy1}}
radiotechnicalbn2 = {lvl="bn", unitname="Radiotechnical Bn", equipmentname="Radiotechnical Bn CP", equipment={mobilecpdbid}, subordinates={radiotechnicalcpy2, radiotechnicalcpy2}}
radiotechnicalbn3 = {lvl="bn", unitname="Radiotechnical Bn", equipmentname="Radiotechnical Bn CP", equipment={mobilecpdbid}, subordinates={radiotechnicalcpy3, radiotechnicalcpy3}}
radiotechnicalrgt1 = {lvl="rgt", unitname="Radiotechnical Rgt", equipmentname="Radiotechnical Rgt CP", equipment={mobilecpdbid}, subordinates={radiotechnicalbn1, radiotechnicalbn1, radiotechnicalbn1}}
radiotechnicalrgt2 = {lvl="rgt", unitname="Radiotechnical Rgt", equipmentname="Radiotechnical Rgt CP", equipment={mobilecpdbid}, subordinates={radiotechnicalbn2, radiotechnicalbn2, radiotechnicalbn2}}
radiotechnicalrgt3 = {lvl="rgt", unitname="Radiotechnical Rgt", equipmentname="Radiotechnical Rgt CP", equipment={mobilecpdbid}, subordinates={radiotechnicalbn3, radiotechnicalbn3, radiotechnicalbn3}}
radiotechnicalbgd = {lvl="bgd", unitname="Radiotechnical Bgd", equipmentname="Radiotechnical Bgd CP", equipment={mobilecpdbid}, subordinates={radiotechnicalrgt1, radiotechnicalrgt2, radiotechnicalrgt3}}
airdefensedivision = {lvl="div", unitname="Air Defence Division", equipmentname="Air Defense Division CP", equipment={mobilecpdbid}, subordinates={radiotechnicalbgd, airdefensebgd}}
rp = ScenEdit_GetReferencePoints({side="RUS", area={"Start Here"}})
rp = rp[1]
startposition = {latitude=rp.latitude, longitude=rp.longitude}
function placeequipment(parentname, equipmentname, equipment, position)
for i, item in ipairs(equipment) do
namestr = equipmentname.."_"..parentname.."_"..i
ScenEdit_AddUnit({side="RUS", type="Facility", unitname=namestr, dbid=item, latitude=position.latitude, longitude=position.longitude})
position=World_GetPointFromBearing({latitude=tostring(position.latitude), longitude=tostring(position.longitude), distance=5, bearing=90})
end
end
function descendEchelon(formation, position)
if(formation.subordinates ~= {}) then
for s, sub in ipairs(formation.subordinates) do
position = World_GetPointFromBearing({latitude=tostring(position.latitude), longitude=tostring(position.longitude), distance=5, bearing=180});
descendEchelon(sub, position)
end
end
placeequipment(formation.unitname, formation.equipmentname, formation.equipment, position)
--print(formation.lvl)
--print(position)
return true
end
descendEchelon(airdefensedivision, startposition )
--placeequipment(sa21rgt.equipment, startposition)