mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-16 16:06:44 +00:00
OPS Ammo
- Added guns/cannons differentiation to ammo count
This commit is contained in:
@@ -839,8 +839,8 @@ function ARMYGROUP:Status()
|
|||||||
local ammo=self:GetAmmoElement(element)
|
local ammo=self:GetAmmoElement(element)
|
||||||
|
|
||||||
-- Output text for element.
|
-- Output text for element.
|
||||||
text=text..string.format("\n[%d] %s: status=%s, life=%.1f/%.1f, guns=%d, rockets=%d, bombs=%d, missiles=%d, cargo=%d/%d kg",
|
text=text..string.format("\n[%d] %s: status=%s, life=%.1f/%.1f, guns=%d, cannons=%d, rockets=%d, missiles=%d, cargo=%d/%d kg",
|
||||||
i, name, status, life, life0, ammo.Guns, ammo.Rockets, ammo.Bombs, ammo.Missiles, element.weightCargo, element.weightMaxCargo)
|
i, name, status, life, life0, ammo.Guns, ammo.Cannons, ammo.Rockets, ammo.Missiles, element.weightCargo, element.weightMaxCargo)
|
||||||
end
|
end
|
||||||
if #self.elements==0 then
|
if #self.elements==0 then
|
||||||
text=text.." none!"
|
text=text.." none!"
|
||||||
|
|||||||
@@ -1083,7 +1083,7 @@ function NAVYGROUP:onafterSpawned(From, Event, To)
|
|||||||
text=text..string.format("Elements = %d\n", #self.elements)
|
text=text..string.format("Elements = %d\n", #self.elements)
|
||||||
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
||||||
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On))
|
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radio.On))
|
||||||
text=text..string.format("Ammo = %d (G=%d/R=%d/M=%d/T=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Rockets, self.ammo.Missiles, self.ammo.Torpedos)
|
text=text..string.format("Ammo = %d (G=%d/C=%d/R=%d/M=%d/T=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Cannons, self.ammo.Rockets, self.ammo.Missiles, self.ammo.Torpedos)
|
||||||
text=text..string.format("FSM state = %s\n", self:GetState())
|
text=text..string.format("FSM state = %s\n", self:GetState())
|
||||||
text=text..string.format("Is alive = %s\n", tostring(self:IsAlive()))
|
text=text..string.format("Is alive = %s\n", tostring(self:IsAlive()))
|
||||||
text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated()))
|
text=text..string.format("LateActivate = %s\n", tostring(self:IsLateActivated()))
|
||||||
|
|||||||
@@ -405,7 +405,9 @@ OPSGROUP.TaskType={
|
|||||||
--- Ammo data.
|
--- Ammo data.
|
||||||
-- @type OPSGROUP.Ammo
|
-- @type OPSGROUP.Ammo
|
||||||
-- @field #number Total Total amount of ammo.
|
-- @field #number Total Total amount of ammo.
|
||||||
-- @field #number Guns Amount of gun shells.
|
-- @field #number Shells Amount of shells (guns + cannons).
|
||||||
|
-- @field #number Guns Amount of gun shells (caliber < 25).
|
||||||
|
-- @field #number Cannons Amount of cannon shells (caliber >= 25).
|
||||||
-- @field #number Bombs Amount of bombs.
|
-- @field #number Bombs Amount of bombs.
|
||||||
-- @field #number Rockets Amount of rockets.
|
-- @field #number Rockets Amount of rockets.
|
||||||
-- @field #number Torpedos Amount of torpedos.
|
-- @field #number Torpedos Amount of torpedos.
|
||||||
@@ -4758,7 +4760,7 @@ function OPSGROUP:_UpdateTask(Task, Mission)
|
|||||||
elseif weaponType==ENUMS.WeaponFlag.AnyRocket then
|
elseif weaponType==ENUMS.WeaponFlag.AnyRocket then
|
||||||
nAmmo=ammo.Rockets
|
nAmmo=ammo.Rockets
|
||||||
elseif weaponType==ENUMS.WeaponFlag.Cannons then
|
elseif weaponType==ENUMS.WeaponFlag.Cannons then
|
||||||
nAmmo=ammo.Guns
|
nAmmo=ammo.Cannons
|
||||||
end
|
end
|
||||||
|
|
||||||
--TODO: Update target location while we're at it anyway.
|
--TODO: Update target location while we're at it anyway.
|
||||||
@@ -11210,11 +11212,11 @@ function OPSGROUP:_CheckAmmoStatus()
|
|||||||
self:OutOfAmmo()
|
self:OutOfAmmo()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Guns.
|
-- Guns (changed to shells)
|
||||||
if self.outofGuns and ammo.Guns>0 then
|
if self.outofGuns and ammo.Shells>0 then
|
||||||
self.outofGuns=false
|
self.outofGuns=false
|
||||||
end
|
end
|
||||||
if ammo.Guns==0 and self.ammo.Guns>0 and not self.outofGuns then
|
if ammo.Shells==0 and self.ammo.Shells>0 and not self.outofGuns then
|
||||||
self.outofGuns=true
|
self.outofGuns=true
|
||||||
self:OutOfGuns()
|
self:OutOfGuns()
|
||||||
end
|
end
|
||||||
@@ -13390,7 +13392,9 @@ function OPSGROUP:GetAmmoTot()
|
|||||||
|
|
||||||
local Ammo={} --#OPSGROUP.Ammo
|
local Ammo={} --#OPSGROUP.Ammo
|
||||||
Ammo.Total=0
|
Ammo.Total=0
|
||||||
|
Ammo.Shells=0
|
||||||
Ammo.Guns=0
|
Ammo.Guns=0
|
||||||
|
Ammo.Cannons=0
|
||||||
Ammo.Rockets=0
|
Ammo.Rockets=0
|
||||||
Ammo.Bombs=0
|
Ammo.Bombs=0
|
||||||
Ammo.Torpedos=0
|
Ammo.Torpedos=0
|
||||||
@@ -13411,7 +13415,9 @@ function OPSGROUP:GetAmmoTot()
|
|||||||
|
|
||||||
-- Add up total.
|
-- Add up total.
|
||||||
Ammo.Total=Ammo.Total+ammo.Total
|
Ammo.Total=Ammo.Total+ammo.Total
|
||||||
|
Ammo.Shells=Ammo.Shells+ammo.Shells
|
||||||
Ammo.Guns=Ammo.Guns+ammo.Guns
|
Ammo.Guns=Ammo.Guns+ammo.Guns
|
||||||
|
Ammo.Cannons=Ammo.Cannons+ammo.Cannons
|
||||||
Ammo.Rockets=Ammo.Rockets+ammo.Rockets
|
Ammo.Rockets=Ammo.Rockets+ammo.Rockets
|
||||||
Ammo.Bombs=Ammo.Bombs+ammo.Bombs
|
Ammo.Bombs=Ammo.Bombs+ammo.Bombs
|
||||||
Ammo.Torpedos=Ammo.Torpedos+ammo.Torpedos
|
Ammo.Torpedos=Ammo.Torpedos+ammo.Torpedos
|
||||||
@@ -13444,6 +13450,8 @@ function OPSGROUP:GetAmmoUnit(unit, display)
|
|||||||
-- Init counter.
|
-- Init counter.
|
||||||
local nammo=0
|
local nammo=0
|
||||||
local nshells=0
|
local nshells=0
|
||||||
|
local nguns=0
|
||||||
|
local ncannons=0
|
||||||
local nrockets=0
|
local nrockets=0
|
||||||
local nmissiles=0
|
local nmissiles=0
|
||||||
local nmissilesAA=0
|
local nmissilesAA=0
|
||||||
@@ -13468,8 +13476,8 @@ function OPSGROUP:GetAmmoUnit(unit, display)
|
|||||||
if ammotable then
|
if ammotable then
|
||||||
local weapons=#ammotable
|
local weapons=#ammotable
|
||||||
|
|
||||||
--self:I(ammotable)
|
--self:I(ammotable)
|
||||||
--UTILS.PrintTableToLog(ammotable)
|
--UTILS.PrintTableToLog(ammotable)
|
||||||
|
|
||||||
-- Loop over all weapons.
|
-- Loop over all weapons.
|
||||||
for w=1,weapons do
|
for w=1,weapons do
|
||||||
@@ -13477,9 +13485,9 @@ function OPSGROUP:GetAmmoUnit(unit, display)
|
|||||||
-- Number of current weapon.
|
-- Number of current weapon.
|
||||||
local Nammo=ammotable[w]["count"]
|
local Nammo=ammotable[w]["count"]
|
||||||
|
|
||||||
-- Range in meters. Seems only to exist for missiles (not shells).
|
-- Range in meters. Seems only to exist for missiles (not shells).
|
||||||
local rmin=ammotable[w]["desc"]["rangeMin"] or 0
|
local rmin=ammotable[w]["desc"]["rangeMin"] or 0
|
||||||
local rmax=ammotable[w]["desc"]["rangeMaxAltMin"] or 0
|
local rmax=ammotable[w]["desc"]["rangeMaxAltMin"] or 0
|
||||||
|
|
||||||
-- Type name of current weapon.
|
-- Type name of current weapon.
|
||||||
local Tammo=ammotable[w]["desc"]["typeName"]
|
local Tammo=ammotable[w]["desc"]["typeName"]
|
||||||
@@ -13501,6 +13509,16 @@ function OPSGROUP:GetAmmoUnit(unit, display)
|
|||||||
|
|
||||||
-- Add up all shells.
|
-- Add up all shells.
|
||||||
nshells=nshells+Nammo
|
nshells=nshells+Nammo
|
||||||
|
|
||||||
|
-- Add small and large caliber shells for guns and cannons
|
||||||
|
if ammotable[w]["desc"]["warhead"] and ammotable[w]["desc"]["warhead"]["caliber"] then
|
||||||
|
local caliber=ammotable[w]["desc"]["warhead"]["caliber"]
|
||||||
|
if caliber<25 then
|
||||||
|
nguns=nguns+Nammo
|
||||||
|
else
|
||||||
|
ncannons=ncannons+Nammo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
text=text..string.format("- %d shells of type %s, range=%d - %d meters\n", Nammo, _weaponName, rmin, rmax)
|
text=text..string.format("- %d shells of type %s, range=%d - %d meters\n", Nammo, _weaponName, rmin, rmax)
|
||||||
@@ -13579,7 +13597,9 @@ function OPSGROUP:GetAmmoUnit(unit, display)
|
|||||||
|
|
||||||
local ammo={} --#OPSGROUP.Ammo
|
local ammo={} --#OPSGROUP.Ammo
|
||||||
ammo.Total=nammo
|
ammo.Total=nammo
|
||||||
ammo.Guns=nshells
|
ammo.Shells=nshells
|
||||||
|
ammo.Guns=nguns
|
||||||
|
ammo.Cannons=ncannons
|
||||||
ammo.Rockets=nrockets
|
ammo.Rockets=nrockets
|
||||||
ammo.Bombs=nbombs
|
ammo.Bombs=nbombs
|
||||||
ammo.Torpedos=ntorps
|
ammo.Torpedos=ntorps
|
||||||
|
|||||||
Reference in New Issue
Block a user