Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Order of Battle Generator

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Order of Battle Generator Page: [1]
Login
Message << Older Topic   Newer Topic >>
Order of Battle Generator - 12/19/2021 2:24:19 PM   
SeaQueen


Posts: 1451
Joined: 4/14/2007
From: Washington D.C.
Status: offline
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)
Post #: 1
RE: Order of Battle Generator - 12/19/2021 2:59:33 PM   
BDukes

 

Posts: 1695
Joined: 12/27/2017
Status: offline
Well, that's a nerdy thing to do.

Bravo!

_____________________________

Don't call it a comeback...

(in reply to SeaQueen)
Post #: 2
RE: Order of Battle Generator - 12/19/2021 8:05:43 PM   
SeaQueen


Posts: 1451
Joined: 4/14/2007
From: Washington D.C.
Status: offline
quote:

ORIGINAL: BDukes

Well, that's a nerdy thing to do.

Bravo!


LOL!

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

(in reply to BDukes)
Post #: 3
RE: Order of Battle Generator - 12/19/2021 8:59:44 PM   
BDukes

 

Posts: 1695
Joined: 12/27/2017
Status: offline
Yes

_____________________________

Don't call it a comeback...

(in reply to SeaQueen)
Post #: 4
RE: Order of Battle Generator - 12/22/2021 5:54:38 AM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline
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.

(in reply to BDukes)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Order of Battle Generator Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.984