Order of Battle Generator (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


SeaQueen -> Order of Battle Generator (12/19/2021 2:24:19 PM)

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)




BDukes -> RE: Order of Battle Generator (12/19/2021 2:59:33 PM)

Well, that's a nerdy thing to do.[;)]

Bravo![:)]




SeaQueen -> RE: Order of Battle Generator (12/19/2021 8:05:43 PM)

quote:

ORIGINAL: BDukes

Well, that's a nerdy thing to do.[;)]

Bravo![:)]


LOL!

N.B. I used recursion. Do I get extra nerd points?




BDukes -> RE: Order of Battle Generator (12/19/2021 8:59:44 PM)

Yes[:)]




KnightHawk75 -> RE: Order of Battle Generator (12/22/2021 5:54:38 AM)

I posted some quickbattle generating code awhile back you may be able to leverage or lift ideas from, granted it didn't do diamond shape placements, but did do formation generation (was ship oriented).
https://www.matrixgames.com/forums/tm.asp?m=4933469.

Traveling atm, so I probably will not be much help.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.625