Setting unit proficiency help

Take command of air and naval assets from post-WW2 to the near future in tactical and operational scale, complete with historical and hypothetical scenarios and an integrated scenario editor.

Moderator: MOD_Command

Post Reply
Knightpawn
Posts: 332
Joined: Mon Dec 02, 2024 12:28 pm

Setting unit proficiency help

Post by Knightpawn »

Apologies if there is an obvious answer to this question:

How can I adjust the unit proficiency to multiple units sitting on a base? If I select them all from the "Aircraft Ops" menu, doing Unit Orders - Senario Editor - Set unit proficiency does not have any effect. And from the OOB window I cannot select more than one unit each time. Do I have to do it one by one? Is there a more quick way?
Dimitris
Posts: 15390
Joined: Sun Jul 31, 2005 10:29 am
Contact:

Re: Setting unit proficiency help

Post by Dimitris »

Scripting?
Knightpawn
Posts: 332
Joined: Mon Dec 02, 2024 12:28 pm

Re: Setting unit proficiency help

Post by Knightpawn »

Dimitris wrote: Thu Oct 30, 2025 6:44 pm Scripting?
There are some gen-x guys like us that are 100% coding-illiterate and we are looking to find a select-all , open drop down menu and select a parameter. Show some mercy :-)
Kushan04
Posts: 1177
Joined: Tue Jun 28, 2005 9:27 pm
Location: USA
Contact:

Re: Setting unit proficiency help

Post by Kushan04 »

Do you want to set all units on a side to the same proficiency? You can do that via the Side menu.

If you want to randomize proficiency for all units on a side, you can use these functions.

Code: Select all

function RandomizeUnitProficiency(unitGUID, chanceNovice, chanceCadet, chanceRegular, chanceVeteran, chanceAce)
	local chance = math.random(1,100)
	local proficiency

	if chance <= chanceNovice then 
		proficiency = 0 -- Novice
	elseif chance <= chanceCadet then 
		proficiency = 1 -- Cadet
	elseif chance <= chanceRegular then 
		proficiency = 2 -- Regular
	elseif chance <= chanceVeteran then 
		proficiency = 3 -- Veteran
	else 
		proficiency = 4 -- Ace
	end

	ScenEdit_SetUnit({guid=unitGUID, proficiency=proficiency})
end

function RandomizeUnitProficiency_BySide(side, chanceNovice, chanceCadet, chanceRegular, chanceVeteran, chanceAce)
	local sideUnits = VP_GetSide({side=side}).units
	for k,v in ipairs(sideUnits) do
		local unit = ScenEdit_GetUnit({guid=v.guid})
		if unit and unit.type ~= 'Group' then
			RandomizeUnitProficiency(unit.guid, chanceNovice, chanceCadet, chanceRegular, chanceVeteran, chanceAce)
		end
	end
end

RandomizeUnitProficiency_BySide('Blue', 20, 50, 80, 90, 100)
1) Run both of the function RandomizeUnitProficiency functions in the Lua console or when the scenario is loaded.
2) Run this but with your side name and whatever chance values you want. "RandomizeUnitProficiency_BySide('Blue', 20, 50, 80, 90, 100)". In this example there's a 20% chance units will be Novice, 30% chance they'll be set to Cadet, 30% Regular, 10% for Veteran and Ace.
Mark352
Posts: 52
Joined: Thu Jul 25, 2024 2:35 pm

Re: Setting unit proficiency help

Post by Mark352 »

This script worked for a group of 12 aircraft. In the example code groups of four are each set to a different proficiency. I"m not much of coder so I use AI, primarily CoPilot, to help. The AI doesn't always get it right but, along with Command Lua Docs it helps me to learn what can be done with Lua in CMO. I couldn't resist looking into this because I haven't played with unit proficiency much. Learn something new in CMO everyday.

Code: Select all

local sideName = "Blue"

-- Define proficiency tiers
local function setProficiency(unitName, proficiency)
    local unit = ScenEdit_GetUnit({name = unitName, side = sideName})
    if unit then
        ScenEdit_SetUnit({guid = unit.guid, proficiency = proficiency})
        print("Set " .. unitName .. " to " .. proficiency)
    else
        print("Unit not found: " .. unitName)
    end
end

-- Hawk #1 to #4 → Regular
for i = 1, 4 do
    setProficiency("Hawk #" .. i, "Regular")
end

-- Hawk #5 to #8 → Veteran
for i = 5, 8 do
    setProficiency("Hawk #" .. i, "Veteran")
end

-- Hawk #9 to #12 → Ace
for i = 9, 12 do
    setProficiency("Hawk #" .. i, "Ace")
end
TyphoonFr
Posts: 179
Joined: Thu Nov 23, 2017 4:27 pm
Location: FRA
Contact:

Re: Setting unit proficiency help

Post by TyphoonFr »

For a base, I was perfectly happy with just that until now, but I see there are some cool features.

Code: Select all

local ab = ScenEdit_GetUnit({name='BAN de Landivisiau', guid='J7POY9-0HMUDSQ3UL3TH'}) 

for i=1, #(ab.hostedUnits['Aircraft']), 1 do

local hu = ScenEdit_GetUnit({name=ab.hostedUnits['Aircraft'][i]})

su = ScenEdit_SetUnit({name=hu.guid, proficiency = math.random(0,4) }) 

end
Christophe

To all English teachers of the forum, sorry if English is not my mother language.
Knightpawn
Posts: 332
Joined: Mon Dec 02, 2024 12:28 pm

Re: Setting unit proficiency help

Post by Knightpawn »

Thank you all
Post Reply

Return to “Command: Modern Operations series”