mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Merge pull request #2308 from shaji-Dev/master
[FIXED] Velocity is taking into account dead units for GROUP
This commit is contained in:
commit
1889df4952
@ -912,15 +912,18 @@ function GROUP:GetVelocityVec3()
|
||||
|
||||
if DCSGroup and DCSGroup:isExist() then
|
||||
local GroupUnits = DCSGroup:getUnits()
|
||||
local GroupCount = #GroupUnits
|
||||
local GroupCount = 0
|
||||
|
||||
local VelocityVec3 = { x = 0, y = 0, z = 0 }
|
||||
|
||||
for _, DCSUnit in pairs( GroupUnits ) do
|
||||
local UnitVelocityVec3 = DCSUnit:getVelocity()
|
||||
VelocityVec3.x = VelocityVec3.x + UnitVelocityVec3.x
|
||||
VelocityVec3.y = VelocityVec3.y + UnitVelocityVec3.y
|
||||
VelocityVec3.z = VelocityVec3.z + UnitVelocityVec3.z
|
||||
if DCSUnit:isExist() and DCSUnit:isActive() then
|
||||
local UnitVelocityVec3 = DCSUnit:getVelocity()
|
||||
VelocityVec3.x = VelocityVec3.x + UnitVelocityVec3.x
|
||||
VelocityVec3.y = VelocityVec3.y + UnitVelocityVec3.y
|
||||
VelocityVec3.z = VelocityVec3.z + UnitVelocityVec3.z
|
||||
GroupCount = GroupCount + 1
|
||||
end
|
||||
end
|
||||
|
||||
VelocityVec3.x = VelocityVec3.x / GroupCount
|
||||
@ -1754,11 +1757,13 @@ function GROUP:GetMaxVelocity()
|
||||
|
||||
for Index, UnitData in pairs( DCSGroup:getUnits() ) do
|
||||
|
||||
local UnitVelocityVec3 = UnitData:getVelocity()
|
||||
local UnitVelocity = math.abs( UnitVelocityVec3.x ) + math.abs( UnitVelocityVec3.y ) + math.abs( UnitVelocityVec3.z )
|
||||
if UnitData:isExist() and UnitData:isActive() then
|
||||
local UnitVelocityVec3 = UnitData:getVelocity()
|
||||
local UnitVelocity = math.abs( UnitVelocityVec3.x ) + math.abs( UnitVelocityVec3.y ) + math.abs( UnitVelocityVec3.z )
|
||||
|
||||
if UnitVelocity > GroupVelocityMax then
|
||||
GroupVelocityMax = UnitVelocity
|
||||
if UnitVelocity > GroupVelocityMax then
|
||||
GroupVelocityMax = UnitVelocity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user