From 3f052ef1dab49e25cb6ad577aed6faf215d9d2d1 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 8 Sep 2022 15:49:53 +0200 Subject: [PATCH] #GROUP * changes from Dev #UNIT * changes from Dev --- Moose Development/Moose/Wrapper/Group.lua | 113 +++++++++++++++------- Moose Development/Moose/Wrapper/Unit.lua | 17 +++- 2 files changed, 92 insertions(+), 38 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index ebb8d9228..d3495fac7 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -187,6 +187,7 @@ GROUPTEMPLATE.Takeoff = { -- @field #string GROUND_APC Infantry carriers, in particular Amoured Personell Carrier. This can be used to transport other assets. -- @field #string GROUND_TRUCK Unarmed ground vehicles, which has the DCS "Truck" attribute. -- @field #string GROUND_INFANTRY Ground infantry assets. +-- @field #string GROUND_IFV Ground Infantry Fighting Vehicle. -- @field #string GROUND_ARTILLERY Artillery assets. -- @field #string GROUND_TANK Tanks (modern or old). -- @field #string GROUND_TRAIN Trains. Not that trains are **not** yet properly implemented in DCS and cannot be used currently. @@ -530,26 +531,32 @@ function GROUP:HasAttribute(attribute, all) -- Get all units of the group. local _units=self:GetUnits() - local _allhave=true - local _onehas=false + if _units then - for _,_unit in pairs(_units) do - local _unit=_unit --Wrapper.Unit#UNIT - if _unit then - local _hastit=_unit:HasAttribute(attribute) - if _hastit==true then - _onehas=true - else - _allhave=false - end - end + local _allhave=true + local _onehas=false + + for _,_unit in pairs(_units) do + local _unit=_unit --Wrapper.Unit#UNIT + if _unit then + local _hastit=_unit:HasAttribute(attribute) + if _hastit==true then + _onehas=true + else + _allhave=false + end + end + end + + if all==true then + return _allhave + else + return _onehas + end + end - if all==true then - return _allhave - else - return _onehas - end + return nil end --- Returns the maximum speed of the group. @@ -568,12 +575,15 @@ function GROUP:GetSpeedMax() for _,unit in pairs(Units) do local unit=unit --Wrapper.Unit#UNIT + local speed=unit:GetSpeedMax() - if speedmax==0 then - speedmax=speed - elseif speed 0 then + narti=narti+Nammo + end + elseif Category==Weapon.Category.ROCKET then -- Add up all rockets. @@ -778,7 +785,7 @@ function UNIT:GetAmmunition() -- Total amount of ammunition. nammo=nshells+nrockets+nmissiles+nbombs - return nammo, nshells, nrockets, nbombs, nmissiles + return nammo, nshells, nrockets, nbombs, nmissiles, narti end --- Returns the unit sensors. @@ -830,7 +837,7 @@ function UNIT:HasSEAD() local HasSEAD = false if UnitSEADAttributes["RADAR_BAND1_FOR_ARM"] and UnitSEADAttributes["RADAR_BAND1_FOR_ARM"] == true or UnitSEADAttributes["RADAR_BAND2_FOR_ARM"] and UnitSEADAttributes["RADAR_BAND2_FOR_ARM"] == true or - UnitSEADAttributes["Optical Tracker"] and UnitSEADAttributes["Optical Tracker"] == true + UnitSEADAttributes["Optical Tracker"] and UnitSEADAttributes["Optical Tracker"] == true then HasSEAD = true end @@ -1068,7 +1075,7 @@ function UNIT:GetThreatLevel() if Descriptor then local Attributes = Descriptor.attributes - + if self:IsGround() then local ThreatLevels = {