will this snippet work for making a unit stand upside down?
GroupFindCenterLoc
not ratedGiven a unit group, finds the center, like the center of gravity.
function GroupFindCenterXEnum takes nothing returns nothing
set bj_randomSubGroupChance = bj_randomSubGroupChance + GetUnitX(GetEnumUnit())
set bj_randomSubGroupTotal = bj_randomSubGroupTotal + 1
endfunction
function GroupFindCenterYEnum takes nothing returns nothing
set bj_randomSubGroupChance = bj_randomSubGroupChance + GetUnitY(GetEnumUnit())
set bj_randomSubGroupTotal = bj_randomSubGroupTotal + 1
endfunction
function GroupFindCenterLoc takes group whichGroup returns location
local real oldReal = bj_randomSubGroupChance
local integer oldInt = bj_randomSubGroupTotal
local real x
local real y
//Determine average x
if (whichGroup == null) or (FirstOfGroup(whichGroup) == null) then
return null
endif
set bj_randomSubGroupChance = 0.0
set bj_randomSubGroupTotal = 0
call ForGroup(whichGroup, function GroupFindCenterXEnum)
set x = bj_randomSubGroupChance / (bj_randomSubGroupTotal)
//Determine average y
set bj_randomSubGroupChance = 0.0
set bj_randomSubGroupTotal = 0
call ForGroup(whichGroup, function GroupFindCenterYEnum)
set y = bj_randomSubGroupChance / (bj_randomSubGroupTotal)
set bj_randomSubGroupChance = oldReal
set bj_randomSubGroupTotal = oldInt
return Location(x,y)
endfunction