SeaQueen
Posts: 1451
Joined: 4/14/2007 From: Washington D.C. Status: offline
|
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"))
< Message edited by SeaQueen -- 1/1/2022 6:39:17 PM >
|