Average Percentage Attrition (Full Version)

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



Message


SeaQueen -> Average Percentage Attrition (1/1/2022 5:32:48 PM)

Lately I've been fascinated by air interdiction. The problem is that unless it's CAS, they're usually hunting for elements of larger operational level units (brigades or divisions) and not individual platoons. Realistic mission objectives might be stated something like, "Draw down the XXth Guards Motor Rifle Brigade to 25%." That presents a problem when you're dropping bombs on the sections, platoons and batteries that make it up. How does one determine that the brigade a given game unit belongs to has been drawn down to the desired level? It can't be just 25% of the units destroyed, because damaging units ought to count too. They're talking about 25% of the total available combat power. I wrote this function to help answer that question. Destroyed units count as 100% attrition, while damaged units count for something less than that. It then averages over all the constituent units you add to the list.

-- Returns the average percentage damage of a given set of units.  Intended to be used for calculating the attrition of larger ground forces.

unitOfInterest = {
-- guids go here
}

function averageAttrition(units, mySide)
    totalDpPercent = 0
    avgDpPercent = 0        
    for u, unt in ipairs(units) do
        if(ScenEdit_GetUnit( { side=mySide, guid=unt } )  ~= nil) then
            unit = ScenEdit_GetUnit( { side=mySide, guid=unt } )        
            print(unit.name.." Damaged: "..unit["damage"].dp_percent)
            totalDpPercent = totalDpPercent + unit["damage"].dp_percent
        else
            totalDpPercent = totalDpPercent + 100
        end        
    end
    avDpPercent = totalDpPercent / (#units)
    return avDpPercent
end

print(averageAttrition(unitOfInterest, "RED"))




Parel803 -> RE: Average Percentage Attrition (1/3/2022 1:40:54 PM)

nice, thx. Gonna test it out.
regards GJ




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1.921875