mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'develop' into FF/OpsDev
This commit is contained in:
commit
be2eda25df
@ -1271,7 +1271,11 @@ end
|
|||||||
-- @param #string ClientName Name of the Client.
|
-- @param #string ClientName Name of the Client.
|
||||||
-- @return #number Coalition ID.
|
-- @return #number Coalition ID.
|
||||||
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
|
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
|
||||||
return self.Templates.ClientsByName[ClientName].CoalitionID
|
if self.Templates.ClientsByName[ClientName] then
|
||||||
|
return self.Templates.ClientsByName[ClientName].CoalitionID
|
||||||
|
end
|
||||||
|
self:E("ERROR: Template does not exist for client "..tostring(ClientName))
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get category ID from client name.
|
--- Get category ID from client name.
|
||||||
@ -1279,7 +1283,11 @@ end
|
|||||||
-- @param #string ClientName Name of the Client.
|
-- @param #string ClientName Name of the Client.
|
||||||
-- @return #number Category ID.
|
-- @return #number Category ID.
|
||||||
function DATABASE:GetCategoryFromClientTemplate( ClientName )
|
function DATABASE:GetCategoryFromClientTemplate( ClientName )
|
||||||
return self.Templates.ClientsByName[ClientName].CategoryID
|
if self.Templates.ClientsByName[ClientName] then
|
||||||
|
return self.Templates.ClientsByName[ClientName].CategoryID
|
||||||
|
end
|
||||||
|
self:E("ERROR: Template does not exist for client "..tostring(ClientName))
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get country ID from client name.
|
--- Get country ID from client name.
|
||||||
@ -1287,7 +1295,11 @@ end
|
|||||||
-- @param #string ClientName Name of the Client.
|
-- @param #string ClientName Name of the Client.
|
||||||
-- @return #number Country ID.
|
-- @return #number Country ID.
|
||||||
function DATABASE:GetCountryFromClientTemplate( ClientName )
|
function DATABASE:GetCountryFromClientTemplate( ClientName )
|
||||||
return self.Templates.ClientsByName[ClientName].CountryID
|
if self.Templates.ClientsByName[ClientName] then
|
||||||
|
return self.Templates.ClientsByName[ClientName].CountryID
|
||||||
|
end
|
||||||
|
self:E("ERROR: Template does not exist for client "..tostring(ClientName))
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Airbase
|
--- Airbase
|
||||||
|
|||||||
@ -2250,7 +2250,7 @@ do -- COORDINATE
|
|||||||
-- local MarkGroup = GROUP:FindByName( "AttackGroup" )
|
-- local MarkGroup = GROUP:FindByName( "AttackGroup" )
|
||||||
-- local MarkID = TargetCoord:MarkToGroup( "This is a target for the attack group", AttackGroup )
|
-- local MarkID = TargetCoord:MarkToGroup( "This is a target for the attack group", AttackGroup )
|
||||||
-- <<< logic >>>
|
-- <<< logic >>>
|
||||||
-- RemoveMark( MarkID ) -- The mark is now removed
|
-- TargetCoord:RemoveMark( MarkID ) -- The mark is now removed
|
||||||
function COORDINATE:RemoveMark( MarkID )
|
function COORDINATE:RemoveMark( MarkID )
|
||||||
trigger.action.removeMark( MarkID )
|
trigger.action.removeMark( MarkID )
|
||||||
end
|
end
|
||||||
@ -2764,7 +2764,10 @@ do -- COORDINATE
|
|||||||
|
|
||||||
local sunrise=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, true, Tdiff)
|
local sunrise=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, true, Tdiff)
|
||||||
local sunset=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, false, Tdiff)
|
local sunset=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, false, Tdiff)
|
||||||
|
|
||||||
|
if sunrise == "N/R" then return false end
|
||||||
|
if sunrise == "N/S" then return true end
|
||||||
|
|
||||||
local time=UTILS.ClockToSeconds(clock)
|
local time=UTILS.ClockToSeconds(clock)
|
||||||
|
|
||||||
-- Check if time is between sunrise and sunset.
|
-- Check if time is between sunrise and sunset.
|
||||||
|
|||||||
@ -4729,8 +4729,11 @@ do -- SET_CLIENT
|
|||||||
local MClientCoalition = false
|
local MClientCoalition = false
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
||||||
|
if ClientCoalitionID==nil and MClient:IsAlive()~=nil then
|
||||||
|
ClientCoalitionID=MClient:GetCoalition()
|
||||||
|
end
|
||||||
self:T3( { "Coalition:", ClientCoalitionID, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
self:T3( { "Coalition:", ClientCoalitionID, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||||
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionID then
|
if self.FilterMeta.Coalitions[CoalitionName] and ClientCoalitionID and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionID then
|
||||||
MClientCoalition = true
|
MClientCoalition = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -4742,8 +4745,11 @@ do -- SET_CLIENT
|
|||||||
local MClientCategory = false
|
local MClientCategory = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
||||||
|
if ClientCategoryID==nil and MClient:IsAlive()~=nil then
|
||||||
|
ClientCategoryID=MClient:GetCategory()
|
||||||
|
end
|
||||||
self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||||
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then
|
if self.FilterMeta.Categories[CategoryName] and ClientCategoryID and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then
|
||||||
MClientCategory = true
|
MClientCategory = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -4767,8 +4773,11 @@ do -- SET_CLIENT
|
|||||||
local MClientCountry = false
|
local MClientCountry = false
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName )
|
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName )
|
||||||
|
if ClientCountryID==nil and MClient:IsAlive()~=nil then
|
||||||
|
ClientCountryID=MClient:GetCountry()
|
||||||
|
end
|
||||||
self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } )
|
self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } )
|
||||||
if country.id[CountryName] and country.id[CountryName] == ClientCountryID then
|
if country.id[CountryName] and ClientCountryID and country.id[CountryName] == ClientCountryID then
|
||||||
MClientCountry = true
|
MClientCountry = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
-- @field #table currentMove Holds the current commanded move, if there is one assigned.
|
-- @field #table currentMove Holds the current commanded move, if there is one assigned.
|
||||||
-- @field #number Nammo0 Initial amount total ammunition (shells+rockets+missiles) of the whole group.
|
-- @field #number Nammo0 Initial amount total ammunition (shells+rockets+missiles) of the whole group.
|
||||||
-- @field #number Nshells0 Initial amount of shells of the whole group.
|
-- @field #number Nshells0 Initial amount of shells of the whole group.
|
||||||
|
-- @field #number Narty0 Initial amount of artillery shells of the whole group.
|
||||||
-- @field #number Nrockets0 Initial amount of rockets of the whole group.
|
-- @field #number Nrockets0 Initial amount of rockets of the whole group.
|
||||||
-- @field #number Nmissiles0 Initial amount of missiles of the whole group.
|
-- @field #number Nmissiles0 Initial amount of missiles of the whole group.
|
||||||
-- @field #number Nukes0 Initial amount of tactical nukes of the whole group. Default is 0.
|
-- @field #number Nukes0 Initial amount of tactical nukes of the whole group. Default is 0.
|
||||||
@ -415,7 +416,7 @@
|
|||||||
-- arty set, battery "Paladin Alpha", rearming place
|
-- arty set, battery "Paladin Alpha", rearming place
|
||||||
--
|
--
|
||||||
-- Setting the rearming group is independent of the position of the mark. Just create one anywhere on the map and type
|
-- Setting the rearming group is independent of the position of the mark. Just create one anywhere on the map and type
|
||||||
-- arty set, battery "Mortar Bravo", rearming group "Ammo Truck M818"
|
-- arty set, battery "Mortar Bravo", rearming group "Ammo Truck M939"
|
||||||
-- Note that the name of the rearming group has to be given in quotation marks and spelt exactly as the group name defined in the mission editor.
|
-- Note that the name of the rearming group has to be given in quotation marks and spelt exactly as the group name defined in the mission editor.
|
||||||
--
|
--
|
||||||
-- ## Transporting
|
-- ## Transporting
|
||||||
@ -453,7 +454,7 @@
|
|||||||
-- -- Creat a new ARTY object from a Paladin group.
|
-- -- Creat a new ARTY object from a Paladin group.
|
||||||
-- paladin=ARTY:New(GROUP:FindByName("Blue Paladin"))
|
-- paladin=ARTY:New(GROUP:FindByName("Blue Paladin"))
|
||||||
--
|
--
|
||||||
-- -- Define a rearming group. This is a Transport M818 truck.
|
-- -- Define a rearming group. This is a Transport M939 truck.
|
||||||
-- paladin:SetRearmingGroup(GROUP:FindByName("Blue Ammo Truck"))
|
-- paladin:SetRearmingGroup(GROUP:FindByName("Blue Ammo Truck"))
|
||||||
--
|
--
|
||||||
-- -- Set the max firing range. A Paladin unit has a range of 20 km.
|
-- -- Set the max firing range. A Paladin unit has a range of 20 km.
|
||||||
@ -694,7 +695,7 @@ ARTY.db={
|
|||||||
|
|
||||||
--- Arty script version.
|
--- Arty script version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
ARTY.version="1.3.0"
|
ARTY.version="1.3.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -707,7 +708,7 @@ ARTY.version="1.3.0"
|
|||||||
-- DONE: Add user defined rearm weapon types.
|
-- DONE: Add user defined rearm weapon types.
|
||||||
-- DONE: Check if target is in range. Maybe this requires a data base with the ranges of all arty units. <solved by user function>
|
-- DONE: Check if target is in range. Maybe this requires a data base with the ranges of all arty units. <solved by user function>
|
||||||
-- DONE: Make ARTY move to rearming position.
|
-- DONE: Make ARTY move to rearming position.
|
||||||
-- DONE: Check that right rearming vehicle is specified. Blue M818, Red Ural-375. Are there more? <user needs to know!>
|
-- DONE: Check that right rearming vehicle is specified. Blue M939, Red Ural-375. Are there more? <user needs to know!>
|
||||||
-- DONE: Check if ARTY group is still alive.
|
-- DONE: Check if ARTY group is still alive.
|
||||||
-- DONE: Handle dead events.
|
-- DONE: Handle dead events.
|
||||||
-- DONE: Abort firing task if no shooting event occured with 5(?) minutes. Something went wrong then. Min/max range for example.
|
-- DONE: Abort firing task if no shooting event occured with 5(?) minutes. Something went wrong then. Min/max range for example.
|
||||||
@ -1532,7 +1533,7 @@ end
|
|||||||
|
|
||||||
--- Assign a group, which is responsible for rearming the ARTY group. If the group is too far away from the ARTY group it will be guided towards the ARTY group.
|
--- Assign a group, which is responsible for rearming the ARTY group. If the group is too far away from the ARTY group it will be guided towards the ARTY group.
|
||||||
-- @param #ARTY self
|
-- @param #ARTY self
|
||||||
-- @param Wrapper.Group#GROUP group Group that is supposed to rearm the ARTY group. For the blue coalition, this is often a unarmed M818 transport whilst for red an unarmed Ural-375 transport can be used.
|
-- @param Wrapper.Group#GROUP group Group that is supposed to rearm the ARTY group. For the blue coalition, this is often a unarmed M939 transport whilst for red an unarmed Ural-375 transport can be used.
|
||||||
-- @return self
|
-- @return self
|
||||||
function ARTY:SetRearmingGroup(group)
|
function ARTY:SetRearmingGroup(group)
|
||||||
self:F({group=group})
|
self:F({group=group})
|
||||||
@ -1887,7 +1888,7 @@ function ARTY:onafterStart(Controllable, From, Event, To)
|
|||||||
MESSAGE:New(text, 5):ToAllIf(self.Debug)
|
MESSAGE:New(text, 5):ToAllIf(self.Debug)
|
||||||
|
|
||||||
-- Get Ammo.
|
-- Get Ammo.
|
||||||
self.Nammo0, self.Nshells0, self.Nrockets0, self.Nmissiles0=self:GetAmmo(self.Debug)
|
self.Nammo0, self.Nshells0, self.Nrockets0, self.Nmissiles0, self.Narty0=self:GetAmmo(self.Debug)
|
||||||
|
|
||||||
-- Init nuclear explosion parameters if they were not set by user.
|
-- Init nuclear explosion parameters if they were not set by user.
|
||||||
if self.nukerange==nil then
|
if self.nukerange==nil then
|
||||||
@ -2093,7 +2094,7 @@ function ARTY:_StatusReport(display)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Get Ammo.
|
-- Get Ammo.
|
||||||
local Nammo, Nshells, Nrockets, Nmissiles=self:GetAmmo()
|
local Nammo, Nshells, Nrockets, Nmissiles, Narty=self:GetAmmo()
|
||||||
local Nnukes=self.Nukes
|
local Nnukes=self.Nukes
|
||||||
local Nillu=self.Nillu
|
local Nillu=self.Nillu
|
||||||
local Nsmoke=self.Nsmoke
|
local Nsmoke=self.Nsmoke
|
||||||
@ -2106,7 +2107,7 @@ function ARTY:_StatusReport(display)
|
|||||||
text=text..string.format("Clock = %s\n", Clock)
|
text=text..string.format("Clock = %s\n", Clock)
|
||||||
text=text..string.format("FSM state = %s\n", self:GetState())
|
text=text..string.format("FSM state = %s\n", self:GetState())
|
||||||
text=text..string.format("Total ammo count = %d\n", Nammo)
|
text=text..string.format("Total ammo count = %d\n", Nammo)
|
||||||
text=text..string.format("Number of shells = %d\n", Nshells)
|
text=text..string.format("Number of shells = %d\n", Narty)
|
||||||
text=text..string.format("Number of rockets = %d\n", Nrockets)
|
text=text..string.format("Number of rockets = %d\n", Nrockets)
|
||||||
text=text..string.format("Number of missiles = %d\n", Nmissiles)
|
text=text..string.format("Number of missiles = %d\n", Nmissiles)
|
||||||
text=text..string.format("Number of nukes = %d\n", Nnukes)
|
text=text..string.format("Number of nukes = %d\n", Nnukes)
|
||||||
@ -2293,7 +2294,7 @@ function ARTY:OnEventShot(EventData)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Get current ammo.
|
-- Get current ammo.
|
||||||
local _nammo,_nshells,_nrockets,_nmissiles=self:GetAmmo()
|
local _nammo,_nshells,_nrockets,_nmissiles,_narty=self:GetAmmo()
|
||||||
|
|
||||||
-- Decrease available nukes because we just fired one.
|
-- Decrease available nukes because we just fired one.
|
||||||
if self.currentTarget.weapontype==ARTY.WeaponType.TacticalNukes then
|
if self.currentTarget.weapontype==ARTY.WeaponType.TacticalNukes then
|
||||||
@ -2323,7 +2324,7 @@ function ARTY:OnEventShot(EventData)
|
|||||||
|
|
||||||
-- Weapon type name for current target.
|
-- Weapon type name for current target.
|
||||||
local _weapontype=self:_WeaponTypeName(self.currentTarget.weapontype)
|
local _weapontype=self:_WeaponTypeName(self.currentTarget.weapontype)
|
||||||
self:T(self.lid..string.format("Group %s ammo: total=%d, shells=%d, rockets=%d, missiles=%d", self.groupname, _nammo, _nshells, _nrockets, _nmissiles))
|
self:T(self.lid..string.format("Group %s ammo: total=%d, shells=%d, rockets=%d, missiles=%d", self.groupname, _nammo, _narty, _nrockets, _nmissiles))
|
||||||
self:T(self.lid..string.format("Group %s uses weapontype %s for current target.", self.groupname, _weapontype))
|
self:T(self.lid..string.format("Group %s uses weapontype %s for current target.", self.groupname, _weapontype))
|
||||||
|
|
||||||
-- Default switches for cease fire and relocation.
|
-- Default switches for cease fire and relocation.
|
||||||
@ -2771,7 +2772,7 @@ function ARTY:onafterStatus(Controllable, From, Event, To)
|
|||||||
self:_EventFromTo("onafterStatus", Event, From, To)
|
self:_EventFromTo("onafterStatus", Event, From, To)
|
||||||
|
|
||||||
-- Get ammo.
|
-- Get ammo.
|
||||||
local nammo, nshells, nrockets, nmissiles=self:GetAmmo()
|
local nammo, nshells, nrockets, nmissiles, narty=self:GetAmmo()
|
||||||
|
|
||||||
-- We have a cargo group ==> check if group was loaded into a carrier.
|
-- We have a cargo group ==> check if group was loaded into a carrier.
|
||||||
if self.iscargo and self.cargogroup then
|
if self.iscargo and self.cargogroup then
|
||||||
@ -2788,7 +2789,7 @@ function ARTY:onafterStatus(Controllable, From, Event, To)
|
|||||||
|
|
||||||
-- FSM state.
|
-- FSM state.
|
||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
self:T(self.lid..string.format("Status %s, Ammo total=%d: shells=%d [smoke=%d, illu=%d, nukes=%d*%.3f kT], rockets=%d, missiles=%d", fsmstate, nammo, nshells, self.Nsmoke, self.Nillu, self.Nukes, self.nukewarhead/1000000, nrockets, nmissiles))
|
self:T(self.lid..string.format("Status %s, Ammo total=%d: shells=%d [smoke=%d, illu=%d, nukes=%d*%.3f kT], rockets=%d, missiles=%d", fsmstate, nammo, narty, self.Nsmoke, self.Nillu, self.Nukes, self.nukewarhead/1000000, nrockets, nmissiles))
|
||||||
|
|
||||||
if self.Controllable and self.Controllable:IsAlive() then
|
if self.Controllable and self.Controllable:IsAlive() then
|
||||||
|
|
||||||
@ -2871,20 +2872,19 @@ function ARTY:onafterStatus(Controllable, From, Event, To)
|
|||||||
if self.currentTarget then
|
if self.currentTarget then
|
||||||
self:CeaseFire(self.currentTarget)
|
self:CeaseFire(self.currentTarget)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Open fire on timed target.
|
if self:is("CombatReady") then
|
||||||
self:OpenFire(_timedTarget)
|
-- Open fire on timed target.
|
||||||
|
self:OpenFire(_timedTarget)
|
||||||
|
end
|
||||||
elseif _normalTarget then
|
elseif _normalTarget then
|
||||||
|
|
||||||
-- Open fire on normal target.
|
if self:is("CombatReady") then
|
||||||
self:OpenFire(_normalTarget)
|
-- Open fire on normal target.
|
||||||
|
self:OpenFire(_normalTarget)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get ammo.
|
|
||||||
--local nammo, nshells, nrockets, nmissiles=self:GetAmmo()
|
|
||||||
|
|
||||||
-- Check if we have a target in the queue for which weapons are still available.
|
-- Check if we have a target in the queue for which weapons are still available.
|
||||||
local gotsome=false
|
local gotsome=false
|
||||||
if #self.targets>0 then
|
if #self.targets>0 then
|
||||||
@ -3045,14 +3045,14 @@ function ARTY:onafterOpenFire(Controllable, From, Event, To, target)
|
|||||||
local range=Controllable:GetCoordinate():Get2DDistance(target.coord)
|
local range=Controllable:GetCoordinate():Get2DDistance(target.coord)
|
||||||
|
|
||||||
-- Get ammo.
|
-- Get ammo.
|
||||||
local Nammo, Nshells, Nrockets, Nmissiles=self:GetAmmo()
|
local Nammo, Nshells, Nrockets, Nmissiles, Narty=self:GetAmmo()
|
||||||
local nfire=Nammo
|
local nfire=Narty
|
||||||
local _type="shots"
|
local _type="shots"
|
||||||
if target.weapontype==ARTY.WeaponType.Auto then
|
if target.weapontype==ARTY.WeaponType.Auto then
|
||||||
nfire=Nammo
|
nfire=Narty
|
||||||
_type="shots"
|
_type="shots"
|
||||||
elseif target.weapontype==ARTY.WeaponType.Cannon then
|
elseif target.weapontype==ARTY.WeaponType.Cannon then
|
||||||
nfire=Nshells
|
nfire=Narty
|
||||||
_type="shells"
|
_type="shells"
|
||||||
elseif target.weapontype==ARTY.WeaponType.TacticalNukes then
|
elseif target.weapontype==ARTY.WeaponType.TacticalNukes then
|
||||||
nfire=self.Nukes
|
nfire=self.Nukes
|
||||||
@ -3337,7 +3337,7 @@ function ARTY:_CheckRearmed()
|
|||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
-- Get current ammo.
|
-- Get current ammo.
|
||||||
local nammo,nshells,nrockets,nmissiles=self:GetAmmo()
|
local nammo,nshells,nrockets,nmissiles,narty=self:GetAmmo()
|
||||||
|
|
||||||
-- Number of units still alive.
|
-- Number of units still alive.
|
||||||
local units=self.Controllable:GetUnits()
|
local units=self.Controllable:GetUnits()
|
||||||
@ -3603,7 +3603,11 @@ function ARTY:_FireAtCoord(coord, radius, nshells, weapontype)
|
|||||||
if weapontype==ARTY.WeaponType.TacticalNukes or weapontype==ARTY.WeaponType.IlluminationShells or weapontype==ARTY.WeaponType.SmokeShells then
|
if weapontype==ARTY.WeaponType.TacticalNukes or weapontype==ARTY.WeaponType.IlluminationShells or weapontype==ARTY.WeaponType.SmokeShells then
|
||||||
weapontype=ARTY.WeaponType.Cannon
|
weapontype=ARTY.WeaponType.Cannon
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if group:HasTask() then
|
||||||
|
group:ClearTasks()
|
||||||
|
end
|
||||||
|
|
||||||
-- Set ROE to weapon free.
|
-- Set ROE to weapon free.
|
||||||
group:OptionROEOpenFire()
|
group:OptionROEOpenFire()
|
||||||
|
|
||||||
@ -3614,7 +3618,7 @@ function ARTY:_FireAtCoord(coord, radius, nshells, weapontype)
|
|||||||
local fire=group:TaskFireAtPoint(vec2, radius, nshells, weapontype)
|
local fire=group:TaskFireAtPoint(vec2, radius, nshells, weapontype)
|
||||||
|
|
||||||
-- Execute task.
|
-- Execute task.
|
||||||
group:SetTask(fire)
|
group:SetTask(fire,1)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set task for attacking a group.
|
--- Set task for attacking a group.
|
||||||
@ -3631,7 +3635,11 @@ function ARTY:_AttackGroup(target)
|
|||||||
if weapontype==ARTY.WeaponType.TacticalNukes or weapontype==ARTY.WeaponType.IlluminationShells or weapontype==ARTY.WeaponType.SmokeShells then
|
if weapontype==ARTY.WeaponType.TacticalNukes or weapontype==ARTY.WeaponType.IlluminationShells or weapontype==ARTY.WeaponType.SmokeShells then
|
||||||
weapontype=ARTY.WeaponType.Cannon
|
weapontype=ARTY.WeaponType.Cannon
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if group:HasTask() then
|
||||||
|
group:ClearTasks()
|
||||||
|
end
|
||||||
|
|
||||||
-- Set ROE to weapon free.
|
-- Set ROE to weapon free.
|
||||||
group:OptionROEOpenFire()
|
group:OptionROEOpenFire()
|
||||||
|
|
||||||
@ -3642,7 +3650,7 @@ function ARTY:_AttackGroup(target)
|
|||||||
local fire=group:TaskAttackGroup(targetgroup, weapontype, AI.Task.WeaponExpend.ONE, 1)
|
local fire=group:TaskAttackGroup(targetgroup, weapontype, AI.Task.WeaponExpend.ONE, 1)
|
||||||
|
|
||||||
-- Execute task.
|
-- Execute task.
|
||||||
group:SetTask(fire)
|
group:SetTask(fire,1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -3915,6 +3923,7 @@ end
|
|||||||
-- @return #number Number of shells the group has left.
|
-- @return #number Number of shells the group has left.
|
||||||
-- @return #number Number of rockets the group has left.
|
-- @return #number Number of rockets the group has left.
|
||||||
-- @return #number Number of missiles the group has left.
|
-- @return #number Number of missiles the group has left.
|
||||||
|
-- @return #number Number of artillery shells the group has left.
|
||||||
function ARTY:GetAmmo(display)
|
function ARTY:GetAmmo(display)
|
||||||
self:F3({display=display})
|
self:F3({display=display})
|
||||||
|
|
||||||
@ -3928,6 +3937,7 @@ function ARTY:GetAmmo(display)
|
|||||||
local nshells=0
|
local nshells=0
|
||||||
local nrockets=0
|
local nrockets=0
|
||||||
local nmissiles=0
|
local nmissiles=0
|
||||||
|
local nartyshells=0
|
||||||
|
|
||||||
-- Get all units.
|
-- Get all units.
|
||||||
local units=self.Controllable:GetUnits()
|
local units=self.Controllable:GetUnits()
|
||||||
@ -4030,7 +4040,8 @@ function ARTY:GetAmmo(display)
|
|||||||
|
|
||||||
-- Add up all shells.
|
-- Add up all shells.
|
||||||
nshells=nshells+Nammo
|
nshells=nshells+Nammo
|
||||||
|
local _,_,_,_,_,shells = unit:GetAmmunition()
|
||||||
|
nartyshells=nartyshells+shells
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
text=text..string.format("- %d shells of type %s\n", Nammo, _weaponName)
|
text=text..string.format("- %d shells of type %s\n", Nammo, _weaponName)
|
||||||
|
|
||||||
@ -4076,7 +4087,7 @@ function ARTY:GetAmmo(display)
|
|||||||
-- Total amount of ammunition.
|
-- Total amount of ammunition.
|
||||||
nammo=nshells+nrockets+nmissiles
|
nammo=nshells+nrockets+nmissiles
|
||||||
|
|
||||||
return nammo, nshells, nrockets, nmissiles
|
return nammo, nshells, nrockets, nmissiles, nartyshells
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a name of a missile category.
|
--- Returns a name of a missile category.
|
||||||
@ -4827,7 +4838,10 @@ function ARTY:_CheckShootingStarted()
|
|||||||
|
|
||||||
-- Check if we waited long enough and no shot was fired.
|
-- Check if we waited long enough and no shot was fired.
|
||||||
--if dt > self.WaitForShotTime and self.Nshots==0 then
|
--if dt > self.WaitForShotTime and self.Nshots==0 then
|
||||||
if dt > self.WaitForShotTime and (self.Nshots==0 or self.currentTarget.nshells >= self.Nshots) then --https://github.com/FlightControl-Master/MOOSE/issues/1356
|
|
||||||
|
self:T(string.format("dt = %d WaitTime = %d | shots = %d TargetShells = %d",dt,self.WaitForShotTime,self.Nshots,self.currentTarget.nshells))
|
||||||
|
|
||||||
|
if (dt > self.WaitForShotTime and self.Nshots==0) or (self.currentTarget.nshells <= self.Nshots) then --https://github.com/FlightControl-Master/MOOSE/issues/1356
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("%s, no shot event after %d seconds. Removing current target %s from list.", self.groupname, self.WaitForShotTime, name))
|
self:T(self.lid..string.format("%s, no shot event after %d seconds. Removing current target %s from list.", self.groupname, self.WaitForShotTime, name))
|
||||||
@ -4889,7 +4903,7 @@ end
|
|||||||
function ARTY:_CheckOutOfAmmo(targets)
|
function ARTY:_CheckOutOfAmmo(targets)
|
||||||
|
|
||||||
-- Get current ammo.
|
-- Get current ammo.
|
||||||
local _nammo,_nshells,_nrockets,_nmissiles=self:GetAmmo()
|
local _nammo,_nshells,_nrockets,_nmissiles,_narty=self:GetAmmo()
|
||||||
|
|
||||||
-- Special weapon type requested ==> Check if corresponding ammo is empty.
|
-- Special weapon type requested ==> Check if corresponding ammo is empty.
|
||||||
local _partlyoutofammo=false
|
local _partlyoutofammo=false
|
||||||
@ -4901,7 +4915,7 @@ function ARTY:_CheckOutOfAmmo(targets)
|
|||||||
self:T(self.lid..string.format("Group %s, auto weapon requested for target %s but all ammo is empty.", self.groupname, Target.name))
|
self:T(self.lid..string.format("Group %s, auto weapon requested for target %s but all ammo is empty.", self.groupname, Target.name))
|
||||||
_partlyoutofammo=true
|
_partlyoutofammo=true
|
||||||
|
|
||||||
elseif Target.weapontype==ARTY.WeaponType.Cannon and _nshells==0 then
|
elseif Target.weapontype==ARTY.WeaponType.Cannon and _narty==0 then
|
||||||
|
|
||||||
self:T(self.lid..string.format("Group %s, cannons requested for target %s but shells empty.", self.groupname, Target.name))
|
self:T(self.lid..string.format("Group %s, cannons requested for target %s but shells empty.", self.groupname, Target.name))
|
||||||
_partlyoutofammo=true
|
_partlyoutofammo=true
|
||||||
@ -4945,14 +4959,14 @@ end
|
|||||||
function ARTY:_CheckWeaponTypeAvailable(target)
|
function ARTY:_CheckWeaponTypeAvailable(target)
|
||||||
|
|
||||||
-- Get current ammo of group.
|
-- Get current ammo of group.
|
||||||
local Nammo, Nshells, Nrockets, Nmissiles=self:GetAmmo()
|
local Nammo, Nshells, Nrockets, Nmissiles, Narty=self:GetAmmo()
|
||||||
|
|
||||||
-- Check if enough ammo is there for the selected weapon type.
|
-- Check if enough ammo is there for the selected weapon type.
|
||||||
local nfire=Nammo
|
local nfire=Nammo
|
||||||
if target.weapontype==ARTY.WeaponType.Auto then
|
if target.weapontype==ARTY.WeaponType.Auto then
|
||||||
nfire=Nammo
|
nfire=Nammo
|
||||||
elseif target.weapontype==ARTY.WeaponType.Cannon then
|
elseif target.weapontype==ARTY.WeaponType.Cannon then
|
||||||
nfire=Nshells
|
nfire=Narty
|
||||||
elseif target.weapontype==ARTY.WeaponType.TacticalNukes then
|
elseif target.weapontype==ARTY.WeaponType.TacticalNukes then
|
||||||
nfire=self.Nukes
|
nfire=self.Nukes
|
||||||
elseif target.weapontype==ARTY.WeaponType.IlluminationShells then
|
elseif target.weapontype==ARTY.WeaponType.IlluminationShells then
|
||||||
|
|||||||
@ -7946,10 +7946,12 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
local clients=_DATABASE.CLIENTS
|
local clients=_DATABASE.CLIENTS
|
||||||
for clientname, client in pairs(clients) do
|
for clientname, client in pairs(clients) do
|
||||||
local template=_DATABASE:GetGroupTemplateFromUnitName(clientname)
|
local template=_DATABASE:GetGroupTemplateFromUnitName(clientname)
|
||||||
local units=template.units
|
if template then
|
||||||
for i,unit in pairs(units) do
|
local units=template.units
|
||||||
local coord=COORDINATE:New(unit.x, unit.alt, unit.y)
|
for i,unit in pairs(units) do
|
||||||
coords[unit.name]=coord
|
local coord=COORDINATE:New(unit.x, unit.alt, unit.y)
|
||||||
|
coords[unit.name]=coord
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3898,18 +3898,9 @@ function FLIGHTGROUP:_InitGroup(Template)
|
|||||||
-- Group object.
|
-- Group object.
|
||||||
local group=self.group --Wrapper.Group#GROUP
|
local group=self.group --Wrapper.Group#GROUP
|
||||||
|
|
||||||
-- Get template of group.
|
|
||||||
local template=Template or self:_GetTemplate()
|
|
||||||
|
|
||||||
-- Helo group.
|
-- Helo group.
|
||||||
self.isHelo=group:IsHelicopter()
|
self.isHelo=group:IsHelicopter()
|
||||||
|
|
||||||
-- Is (template) group uncontrolled.
|
|
||||||
self.isUncontrolled=template.uncontrolled
|
|
||||||
|
|
||||||
-- Is (template) group late activated.
|
|
||||||
self.isLateActivated=template.lateActivation
|
|
||||||
|
|
||||||
-- Max speed in km/h.
|
-- Max speed in km/h.
|
||||||
self.speedMax=group:GetSpeedMax()
|
self.speedMax=group:GetSpeedMax()
|
||||||
|
|
||||||
@ -3929,25 +3920,38 @@ function FLIGHTGROUP:_InitGroup(Template)
|
|||||||
|
|
||||||
-- Group ammo.
|
-- Group ammo.
|
||||||
self.ammo=self:GetAmmoTot()
|
self.ammo=self:GetAmmoTot()
|
||||||
|
|
||||||
|
-- Get template of group.
|
||||||
|
local template=Template or self:_GetTemplate()
|
||||||
|
|
||||||
-- Radio parameters from template. Default is set on spawn if not modified by user.
|
-- Is (template) group uncontrolled.
|
||||||
self.radio.Freq=tonumber(template.frequency)
|
self.isUncontrolled=template~=nil and template.uncontrolled or false
|
||||||
self.radio.Modu=tonumber(template.modulation)
|
|
||||||
self.radio.On=template.communication
|
|
||||||
|
|
||||||
-- Set callsign. Default is set on spawn if not modified by user.
|
-- Is (template) group late activated.
|
||||||
local callsign=template.units[1].callsign
|
self.isLateActivated=template~=nil and template.lateActivation or false
|
||||||
--self:I({callsign=callsign})
|
|
||||||
if type(callsign)=="number" then -- Sometimes callsign is just "101".
|
if template then
|
||||||
local cs=tostring(callsign)
|
|
||||||
callsign={}
|
-- Radio parameters from template. Default is set on spawn if not modified by user.
|
||||||
callsign[1]=cs:sub(1,1)
|
self.radio.Freq=tonumber(template.frequency)
|
||||||
callsign[2]=cs:sub(2,2)
|
self.radio.Modu=tonumber(template.modulation)
|
||||||
callsign[3]=cs:sub(3,3)
|
self.radio.On=template.communication
|
||||||
|
|
||||||
|
-- Set callsign. Default is set on spawn if not modified by user.
|
||||||
|
local callsign=template.units[1].callsign
|
||||||
|
--self:I({callsign=callsign})
|
||||||
|
if type(callsign)=="number" then -- Sometimes callsign is just "101".
|
||||||
|
local cs=tostring(callsign)
|
||||||
|
callsign={}
|
||||||
|
callsign[1]=cs:sub(1,1)
|
||||||
|
callsign[2]=cs:sub(2,2)
|
||||||
|
callsign[3]=cs:sub(3,3)
|
||||||
|
end
|
||||||
|
self.callsign.NumberSquad=tonumber(callsign[1])
|
||||||
|
self.callsign.NumberGroup=tonumber(callsign[2])
|
||||||
|
self.callsign.NameSquad=UTILS.GetCallsignName(self.callsign.NumberSquad)
|
||||||
|
|
||||||
end
|
end
|
||||||
self.callsign.NumberSquad=tonumber(callsign[1])
|
|
||||||
self.callsign.NumberGroup=tonumber(callsign[2])
|
|
||||||
self.callsign.NameSquad=UTILS.GetCallsignName(self.callsign.NumberSquad)
|
|
||||||
|
|
||||||
-- Set default formation.
|
-- Set default formation.
|
||||||
if self.isHelo then
|
if self.isHelo then
|
||||||
|
|||||||
@ -11378,11 +11378,19 @@ end
|
|||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
|
function OPSGROUP:_InitWaypoints(WpIndexMin, WpIndexMax)
|
||||||
|
|
||||||
-- Template waypoints.
|
|
||||||
self.waypoints0=UTILS.DeepCopy(_DATABASE:GetGroupTemplate(self.groupname).route.points) --self.group:GetTemplateRoutePoints()
|
|
||||||
|
|
||||||
-- Waypoints empty!
|
-- Waypoints empty!
|
||||||
self.waypoints={}
|
self.waypoints={}
|
||||||
|
self.waypoints0={}
|
||||||
|
|
||||||
|
-- Get group template
|
||||||
|
local template=_DATABASE:GetGroupTemplate(self.groupname)
|
||||||
|
|
||||||
|
if template==nil then
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Template waypoints.
|
||||||
|
self.waypoints0=UTILS.DeepCopy(template.route.points) --self.group:GetTemplateRoutePoints()
|
||||||
|
|
||||||
WpIndexMin=WpIndexMin or 1
|
WpIndexMin=WpIndexMin or 1
|
||||||
WpIndexMax=WpIndexMax or #self.waypoints0
|
WpIndexMax=WpIndexMax or #self.waypoints0
|
||||||
@ -13641,11 +13649,7 @@ function OPSGROUP:_AddElementByName(unitname)
|
|||||||
local unit=UNIT:FindByName(unitname)
|
local unit=UNIT:FindByName(unitname)
|
||||||
|
|
||||||
if unit then
|
if unit then
|
||||||
|
|
||||||
-- Get unit template.
|
|
||||||
local unittemplate=unit:GetTemplate()
|
|
||||||
--local unittemplate=_DATABASE:GetUnitTemplateFromUnitName(unitname)
|
|
||||||
|
|
||||||
-- Element table.
|
-- Element table.
|
||||||
local element=self:GetElementByName(unitname)
|
local element=self:GetElementByName(unitname)
|
||||||
|
|
||||||
@ -13672,8 +13676,18 @@ function OPSGROUP:_AddElementByName(unitname)
|
|||||||
element.Nhit=0
|
element.Nhit=0
|
||||||
element.opsgroup=self
|
element.opsgroup=self
|
||||||
|
|
||||||
|
-- Get unit template.
|
||||||
|
local unittemplate=unit:GetTemplate()
|
||||||
|
|
||||||
|
if unittemplate==nil then
|
||||||
|
if element.DCSunit:getPlayerName() then
|
||||||
|
element.skill="Client"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
element.skill=unittemplate~=nil and unittemplate.skill or "Unknown"
|
||||||
|
end
|
||||||
|
|
||||||
-- Skill etc.
|
-- Skill etc.
|
||||||
element.skill=unittemplate.skill or "Unknown"
|
|
||||||
if element.skill=="Client" or element.skill=="Player" then
|
if element.skill=="Client" or element.skill=="Player" then
|
||||||
element.ai=false
|
element.ai=false
|
||||||
element.client=CLIENT:FindByName(unitname)
|
element.client=CLIENT:FindByName(unitname)
|
||||||
@ -13732,24 +13746,22 @@ function OPSGROUP:_AddElementByName(unitname)
|
|||||||
element.weightCargo=0
|
element.weightCargo=0
|
||||||
end
|
end
|
||||||
element.weight=element.weightEmpty+element.weightCargo
|
element.weight=element.weightEmpty+element.weightCargo
|
||||||
|
|
||||||
-- FLIGHTGROUP specific.
|
-- FLIGHTGROUP specific.
|
||||||
if self.isFlightgroup then
|
element.callsign=element.unit:GetCallsign()
|
||||||
element.callsign=element.unit:GetCallsign()
|
element.fuelmass=element.fuelmass0 or 99999
|
||||||
|
element.fuelrel=element.unit:GetFuel() or 1
|
||||||
|
|
||||||
|
if self.isFlightgroup and unittemplate then
|
||||||
element.modex=unittemplate.onboard_num
|
element.modex=unittemplate.onboard_num
|
||||||
element.payload=unittemplate.payload
|
element.payload=unittemplate.payload
|
||||||
element.pylons=unittemplate.payload and unittemplate.payload.pylons or nil
|
element.pylons=unittemplate.payload and unittemplate.payload.pylons or nil
|
||||||
element.fuelmass0=unittemplate.payload and unittemplate.payload.fuel or 0
|
element.fuelmass0=unittemplate.payload and unittemplate.payload.fuel or 0
|
||||||
element.fuelmass=element.fuelmass0
|
|
||||||
element.fuelrel=element.unit:GetFuel()
|
|
||||||
else
|
else
|
||||||
element.callsign="Peter-1-1"
|
element.callsign="Peter-1-1"
|
||||||
element.modex="000"
|
element.modex="000"
|
||||||
element.payload={}
|
element.payload={}
|
||||||
element.pylons={}
|
element.pylons={}
|
||||||
element.fuelmass0=99999
|
|
||||||
element.fuelmass =99999
|
|
||||||
element.fuelrel=1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug text.
|
-- Debug text.
|
||||||
|
|||||||
@ -604,6 +604,14 @@ function OPSZONE:GetAttackDuration()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Find an OPSZONE using the Zone Name.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @param #string ZoneName The zone name.
|
||||||
|
-- @return #OPSZONE The OPSZONE or nil if not found.
|
||||||
|
function OPSZONE:FindByName( ZoneName )
|
||||||
|
local Found = _DATABASE:FindOpsZone( ZoneName )
|
||||||
|
return Found
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if the red coalition is currently owning the zone.
|
--- Check if the red coalition is currently owning the zone.
|
||||||
-- @param #OPSZONE self
|
-- @param #OPSZONE self
|
||||||
|
|||||||
@ -197,6 +197,45 @@ CALLSIGN={
|
|||||||
Cargo=11,
|
Cargo=11,
|
||||||
Ascot=12,
|
Ascot=12,
|
||||||
},
|
},
|
||||||
|
AH64={
|
||||||
|
Army_Air = 9,
|
||||||
|
Apache = 10,
|
||||||
|
Crow = 11,
|
||||||
|
Sioux = 12,
|
||||||
|
Gatling = 13,
|
||||||
|
Gunslinger = 14,
|
||||||
|
Hammerhead = 15,
|
||||||
|
Bootleg = 16,
|
||||||
|
Palehorse = 17,
|
||||||
|
Carnivor = 18,
|
||||||
|
Saber = 19,
|
||||||
|
},
|
||||||
|
Kiowa = {
|
||||||
|
Anvil = 1,
|
||||||
|
Azrael = 2,
|
||||||
|
BamBam = 3,
|
||||||
|
Blackjack = 4,
|
||||||
|
Bootleg = 5,
|
||||||
|
BurninStogie = 6,
|
||||||
|
Chaos = 7,
|
||||||
|
CrazyHorse = 8,
|
||||||
|
Crusader = 9,
|
||||||
|
Darkhorse = 10,
|
||||||
|
Eagle = 11,
|
||||||
|
Lighthorse = 12,
|
||||||
|
Mustang = 13,
|
||||||
|
Outcast = 14,
|
||||||
|
Palehorse = 15,
|
||||||
|
Pegasus = 16,
|
||||||
|
Pistol = 17,
|
||||||
|
Roughneck = 18,
|
||||||
|
Saber = 19,
|
||||||
|
Shamus = 20,
|
||||||
|
Spur = 21,
|
||||||
|
Stetson = 22,
|
||||||
|
Wrath = 23,
|
||||||
|
},
|
||||||
|
|
||||||
} --#CALLSIGN
|
} --#CALLSIGN
|
||||||
|
|
||||||
--- Utilities static class.
|
--- Utilities static class.
|
||||||
@ -1998,7 +2037,19 @@ function UTILS.GetCallsignName(Callsign)
|
|||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for name, value in pairs(CALLSIGN.AH64) do
|
||||||
|
if value==Callsign then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for name, value in pairs(CALLSIGN.Kiowa) do
|
||||||
|
if value==Callsign then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return "Ghostrider"
|
return "Ghostrider"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -445,7 +445,11 @@ function UNIT:IsPlayer()
|
|||||||
if not group then return false end
|
if not group then return false end
|
||||||
|
|
||||||
-- Units of template group.
|
-- Units of template group.
|
||||||
local units=group:GetTemplate().units
|
local template = group:GetTemplate()
|
||||||
|
|
||||||
|
if (template == nil) or (template.units == nil ) then return false end
|
||||||
|
|
||||||
|
local units=template.units
|
||||||
|
|
||||||
-- Get numbers.
|
-- Get numbers.
|
||||||
for _,unit in pairs(units) do
|
for _,unit in pairs(units) do
|
||||||
@ -789,11 +793,13 @@ end
|
|||||||
--- Get the number of ammunition and in particular the number of shells, rockets, bombs and missiles a unit currently has.
|
--- Get the number of ammunition and in particular the number of shells, rockets, bombs and missiles a unit currently has.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #number Total amount of ammo the unit has left. This is the sum of shells, rockets, bombs and missiles.
|
-- @return #number Total amount of ammo the unit has left. This is the sum of shells, rockets, bombs and missiles.
|
||||||
-- @return #number Number of shells left.
|
-- @return #number Number of shells left. Shells include MG ammunition, AP and HE shells, and artillery shells where applicable.
|
||||||
-- @return #number Number of rockets left.
|
-- @return #number Number of rockets left.
|
||||||
-- @return #number Number of bombs left.
|
-- @return #number Number of bombs left.
|
||||||
-- @return #number Number of missiles left.
|
-- @return #number Number of missiles left.
|
||||||
-- @return #number Number of artillery shells left (with explosive mass, included in shells; shells can also be machine gun ammo)
|
-- @return #number Number of artillery shells left (with explosive mass, included in shells; HE will also be reported as artillery shells for tanks)
|
||||||
|
-- @return #number Number of tank AP shells left (for tanks, if applicable)
|
||||||
|
-- @return #number Number of tank HE shells left (for tanks, if applicable)
|
||||||
function UNIT:GetAmmunition()
|
function UNIT:GetAmmunition()
|
||||||
|
|
||||||
-- Init counter.
|
-- Init counter.
|
||||||
@ -803,6 +809,8 @@ function UNIT:GetAmmunition()
|
|||||||
local nmissiles=0
|
local nmissiles=0
|
||||||
local nbombs=0
|
local nbombs=0
|
||||||
local narti=0
|
local narti=0
|
||||||
|
local nAPshells = 0
|
||||||
|
local nHEshells = 0
|
||||||
|
|
||||||
local unit=self
|
local unit=self
|
||||||
|
|
||||||
@ -844,6 +852,14 @@ function UNIT:GetAmmunition()
|
|||||||
narti=narti+Nammo
|
narti=narti+Nammo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ammotable[w].desc.typeName and string.find(ammotable[w].desc.typeName,"_AP",1,true) then
|
||||||
|
nAPshells = nAPshells+Nammo
|
||||||
|
end
|
||||||
|
|
||||||
|
if ammotable[w].desc.typeName and string.find(ammotable[w].desc.typeName,"_HE",1,true) then
|
||||||
|
nHEshells = nHEshells+Nammo
|
||||||
|
end
|
||||||
|
|
||||||
elseif Category==Weapon.Category.ROCKET then
|
elseif Category==Weapon.Category.ROCKET then
|
||||||
|
|
||||||
-- Add up all rockets.
|
-- Add up all rockets.
|
||||||
@ -880,7 +896,55 @@ function UNIT:GetAmmunition()
|
|||||||
-- Total amount of ammunition.
|
-- Total amount of ammunition.
|
||||||
nammo=nshells+nrockets+nmissiles+nbombs
|
nammo=nshells+nrockets+nmissiles+nbombs
|
||||||
|
|
||||||
return nammo, nshells, nrockets, nbombs, nmissiles, narti
|
return nammo, nshells, nrockets, nbombs, nmissiles, narti, nAPshells, nHEshells
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a tank still has AP shells.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean HasAPShells
|
||||||
|
function UNIT:HasAPShells()
|
||||||
|
local _,_,_,_,_,_,shells = self:GetAmmunition()
|
||||||
|
if shells > 0 then return true else return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get number of AP shells from a tank.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #number Number of AP shells
|
||||||
|
function UNIT:GetAPShells()
|
||||||
|
local _,_,_,_,_,_,shells = self:GetAmmunition()
|
||||||
|
return shells or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get number of HE shells from a tank.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #number Number of HE shells
|
||||||
|
function UNIT:GetHEShells()
|
||||||
|
local _,_,_,_,_,_,_,shells = self:GetAmmunition()
|
||||||
|
return shells or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if a tank still has HE shells.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean HasHEShells
|
||||||
|
function UNIT:HasHEShells()
|
||||||
|
local _,_,_,_,_,_,_,shells = self:GetAmmunition()
|
||||||
|
if shells > 0 then return true else return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Checks if an artillery unit still has artillery shells.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean HasArtiShells
|
||||||
|
function UNIT:HasArtiShells()
|
||||||
|
local _,_,_,_,_,shells = self:GetAmmunition()
|
||||||
|
if shells > 0 then return true else return false end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get number of artillery shells from an artillery unit.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #number Number of artillery shells
|
||||||
|
function UNIT:GetArtiShells()
|
||||||
|
local _,_,_,_,_,shells = self:GetAmmunition()
|
||||||
|
return shells or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the unit sensors.
|
--- Returns the unit sensors.
|
||||||
@ -1192,17 +1256,17 @@ function UNIT:GetThreatLevel()
|
|||||||
if self:IsGround() then
|
if self:IsGround() then
|
||||||
|
|
||||||
local ThreatLevels = {
|
local ThreatLevels = {
|
||||||
"Unarmed",
|
[1] = "Unarmed",
|
||||||
"Infantry",
|
[2] = "Infantry",
|
||||||
"Old Tanks & APCs",
|
[3] = "Old Tanks & APCs",
|
||||||
"Tanks & IFVs without ATGM",
|
[4] = "Tanks & IFVs without ATGM",
|
||||||
"Tanks & IFV with ATGM",
|
[5] = "Tanks & IFV with ATGM",
|
||||||
"Modern Tanks",
|
[6] = "Modern Tanks",
|
||||||
"AAA",
|
[7] = "AAA",
|
||||||
"IR Guided SAMs",
|
[8] = "IR Guided SAMs",
|
||||||
"SR SAMs",
|
[9] = "SR SAMs",
|
||||||
"MR SAMs",
|
[10] = "MR SAMs",
|
||||||
"LR SAMs"
|
[11] = "LR SAMs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1228,17 +1292,17 @@ function UNIT:GetThreatLevel()
|
|||||||
if self:IsAir() then
|
if self:IsAir() then
|
||||||
|
|
||||||
local ThreatLevels = {
|
local ThreatLevels = {
|
||||||
"Unarmed",
|
[1] = "Unarmed",
|
||||||
"Tanker",
|
[2] = "Tanker",
|
||||||
"AWACS",
|
[3] = "AWACS",
|
||||||
"Transport Helicopter",
|
[4] = "Transport Helicopter",
|
||||||
"UAV",
|
[5] = "UAV",
|
||||||
"Bomber",
|
[6] = "Bomber",
|
||||||
"Strategic Bomber",
|
[7] = "Strategic Bomber",
|
||||||
"Attack Helicopter",
|
[8] = "Attack Helicopter",
|
||||||
"Battleplane",
|
[9] = "Battleplane",
|
||||||
"Multirole Fighter",
|
[10] = "Multirole Fighter",
|
||||||
"Fighter"
|
[11] = "Fighter"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1272,17 +1336,17 @@ function UNIT:GetThreatLevel()
|
|||||||
--["Unarmed ships"] = {"Ships","HeavyArmoredUnits",},
|
--["Unarmed ships"] = {"Ships","HeavyArmoredUnits",},
|
||||||
|
|
||||||
local ThreatLevels = {
|
local ThreatLevels = {
|
||||||
"Unarmed ship",
|
[1] = "Unarmed ship",
|
||||||
"Light armed ships",
|
[2] = "Light armed ships",
|
||||||
"Corvettes",
|
[3] = "Corvettes",
|
||||||
"",
|
[4] = "",
|
||||||
"Frigates",
|
[5] = "Frigates",
|
||||||
"",
|
[6] = "",
|
||||||
"Cruiser",
|
[7] = "Cruiser",
|
||||||
"",
|
[8] = "",
|
||||||
"Destroyer",
|
[9] = "Destroyer",
|
||||||
"",
|
[10] = "",
|
||||||
"Aircraft Carrier"
|
[11] = "Aircraft Carrier"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user