mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updated according to develop version
This commit is contained in:
parent
b4707bb3eb
commit
0db35a0e9f
@ -213,23 +213,6 @@ CSAR = {
|
||||
-- @field Wrapper.Group#GROUP group Spawned group object.
|
||||
-- @field #number timestamp Timestamp for approach process
|
||||
|
||||
--- Updated and sorted list of known NDB beacons (in kHz!) from the available maps.
|
||||
-- @field #CSAR.SkipFrequencies
|
||||
CSAR.SkipFrequencies = {
|
||||
214,274,291.5,295,297.5,
|
||||
300.5,304,307,309.5,311,312,312.5,316,
|
||||
320,324,328,329,330,336,337,
|
||||
342,343,348,351,352,353,358,
|
||||
363,365,368,372.5,374,
|
||||
380,381,384,389,395,396,
|
||||
414,420,430,432,435,440,450,455,462,470,485,
|
||||
507,515,520,525,528,540,550,560,570,577,580,602,625,641,662,670,680,682,690,
|
||||
705,720,722,730,735,740,745,750,770,795,
|
||||
822,830,862,866,
|
||||
905,907,920,935,942,950,995,
|
||||
1000,1025,1030,1050,1065,1116,1175,1182,1210
|
||||
}
|
||||
|
||||
--- All slot / Limit settings
|
||||
-- @type CSAR.AircraftType
|
||||
-- @field #string typename Unit type name.
|
||||
@ -245,7 +228,7 @@ CSAR.AircraftType["Mi-24V"] = 8
|
||||
|
||||
--- CSAR class version.
|
||||
-- @field #string version
|
||||
CSAR.version="0.1.8r1"
|
||||
CSAR.version="0.1.8r2"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@ -872,7 +855,11 @@ function CSAR:_EventHandler(EventData)
|
||||
end
|
||||
|
||||
if _place:GetCoalition() == self.coalition or _place:GetCoalition() == coalition.side.NEUTRAL then
|
||||
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(_event.IniUnitName) then
|
||||
self:_DisplayMessageToSAR(_unit, "Open the door to let me out!", self.messageTime, true)
|
||||
else
|
||||
self:_RescuePilots(_unit)
|
||||
end
|
||||
else
|
||||
self:T(string.format("Airfield %d, Unit %d", _place:GetCoalition(), _unit:GetCoalition()))
|
||||
end
|
||||
@ -1113,27 +1100,27 @@ function CSAR:_IsLoadingDoorOpen( unit_name )
|
||||
local type_name = unit:getTypeName()
|
||||
|
||||
if type_name == "Mi-8MT" and unit:getDrawArgumentValue(86) == 1 or unit:getDrawArgumentValue(250) == 1 then
|
||||
self:I(unit_name .. " Cargo doors are open or cargo door not present")
|
||||
self:T(unit_name .. " Cargo doors are open or cargo door not present")
|
||||
ret_val = true
|
||||
end
|
||||
|
||||
if type_name == "Mi-24P" and unit:getDrawArgumentValue(38) == 1 or unit:getDrawArgumentValue(86) == 1 then
|
||||
self:I(unit_name .. " a side door is open")
|
||||
self:T(unit_name .. " a side door is open")
|
||||
ret_val = true
|
||||
end
|
||||
|
||||
if type_name == "UH-1H" and unit:getDrawArgumentValue(43) == 1 or unit:getDrawArgumentValue(44) == 1 then
|
||||
self:I(unit_name .. " a side door is open ")
|
||||
self:T(unit_name .. " a side door is open ")
|
||||
ret_val = true
|
||||
end
|
||||
|
||||
if string.find(type_name, "SA342" ) and unit:getDrawArgumentValue(34) == 1 or unit:getDrawArgumentValue(38) == 1 then
|
||||
self:I(unit_name .. " front door(s) are open")
|
||||
self:T(unit_name .. " front door(s) are open")
|
||||
ret_val = true
|
||||
end
|
||||
|
||||
if ret_val == false then
|
||||
self:I(unit_name .. " all doors are closed")
|
||||
self:T(unit_name .. " all doors are closed")
|
||||
end
|
||||
return ret_val
|
||||
|
||||
@ -1346,9 +1333,13 @@ function CSAR:_ScheduledSARFlight(heliname,groupname)
|
||||
end
|
||||
|
||||
if _dist < 200 and _heliUnit:InAir() == false then
|
||||
if self.pilotmustopendoors and not self:_IsLoadingDoorOpen(heliname) then
|
||||
self:_DisplayMessageToSAR(_heliUnit, "Open the door to let me out!", self.messageTime, true)
|
||||
else
|
||||
self:_RescuePilots(_heliUnit)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--queue up
|
||||
self:__Returning(-5,heliname,_woundedGroupName)
|
||||
@ -1755,70 +1746,8 @@ end
|
||||
-- @param #CSAR self
|
||||
function CSAR:_GenerateVHFrequencies()
|
||||
self:T(self.lid .. " _GenerateVHFrequencies")
|
||||
local _skipFrequencies = self.SkipFrequencies
|
||||
|
||||
local FreeVHFFrequencies = {}
|
||||
local UsedVHFFrequencies = {}
|
||||
|
||||
-- first range
|
||||
local _start = 200000
|
||||
while _start < 400000 do
|
||||
|
||||
-- skip existing NDB frequencies
|
||||
local _found = false
|
||||
for _, value in pairs(_skipFrequencies) do
|
||||
if value * 1000 == _start then
|
||||
_found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if _found == false then
|
||||
table.insert(FreeVHFFrequencies, _start)
|
||||
end
|
||||
|
||||
_start = _start + 10000
|
||||
end
|
||||
|
||||
-- second range
|
||||
_start = 400000
|
||||
while _start < 850000 do
|
||||
|
||||
-- skip existing NDB frequencies
|
||||
local _found = false
|
||||
for _, value in pairs(_skipFrequencies) do
|
||||
if value * 1000 == _start then
|
||||
_found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if _found == false then
|
||||
table.insert(FreeVHFFrequencies, _start)
|
||||
end
|
||||
|
||||
_start = _start + 10000
|
||||
end
|
||||
|
||||
-- third range
|
||||
_start = 850000
|
||||
while _start <= 999000 do -- updated for Gazelle
|
||||
|
||||
-- skip existing NDB frequencies
|
||||
local _found = false
|
||||
for _, value in pairs(_skipFrequencies) do
|
||||
if value * 1000 == _start then
|
||||
_found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if _found == false then
|
||||
table.insert(FreeVHFFrequencies, _start)
|
||||
end
|
||||
|
||||
_start = _start + 50000
|
||||
end
|
||||
FreeVHFFrequencies = UTILS.GenerateVHFrequencies()
|
||||
self.FreeVHFFrequencies = FreeVHFFrequencies
|
||||
return self
|
||||
end
|
||||
|
||||
@ -262,6 +262,7 @@ do
|
||||
--
|
||||
-- my_ctld.useprefix = true -- (DO NOT SWITCH THIS OFF UNLESS YOU KNOW WHAT YOU ARE DOING!) Adjust **before** starting CTLD. If set to false, *all* choppers of the coalition side will be enabled for CTLD.
|
||||
-- my_ctld.CrateDistance = 30 -- List and Load crates in this radius only.
|
||||
-- my_ctld.dropcratesanywhere = false -- Option to allow crates to be dropped anywhere.
|
||||
-- my_ctld.maximumHoverHeight = 15 -- Hover max this high to load.
|
||||
-- my_ctld.minimumHoverHeight = 4 -- Hover min this low to load.
|
||||
-- my_ctld.forcehoverload = true -- Crates (not: troops) can only be loaded while hovering.
|
||||
@ -515,26 +516,9 @@ CTLD.UnitTypes = {
|
||||
["Hercules"] = {type="Hercules", crates=true, troops=true, cratelimit = 7, trooplimit = 64}, -- 19t cargo, 64 paratroopers
|
||||
}
|
||||
|
||||
--- Updated and sorted known NDB beacons (in kHz!) from the available maps
|
||||
-- @field #CTLD.SkipFrequencies
|
||||
CTLD.SkipFrequencies = {
|
||||
214,274,291.5,295,297.5,
|
||||
300.5,304,307,309.5,311,312,312.5,316,
|
||||
320,324,328,329,330,336,337,
|
||||
342,343,348,351,352,353,358,
|
||||
363,365,368,372.5,374,
|
||||
380,381,384,389,395,396,
|
||||
414,420,430,432,435,440,450,455,462,470,485,
|
||||
507,515,520,525,528,540,550,560,570,577,580,602,625,641,662,670,680,682,690,
|
||||
705,720,722,730,735,740,745,750,770,795,
|
||||
822,830,862,866,
|
||||
905,907,920,935,942,950,995,
|
||||
1000,1025,1030,1050,1065,1116,1175,1182,1210
|
||||
}
|
||||
|
||||
--- CTLD class version.
|
||||
-- @field #string version
|
||||
CTLD.version="0.1.3r2"
|
||||
CTLD.version="0.1.4r1"
|
||||
|
||||
--- Instantiate a new CTLD.
|
||||
-- @param #CTLD self
|
||||
@ -643,6 +627,7 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
||||
self.minimumHoverHeight = 4
|
||||
self.forcehoverload = true
|
||||
self.hoverautoloading = true
|
||||
self.dropcratesanywhere = false -- #1570
|
||||
|
||||
self.smokedistance = 2000
|
||||
self.movetroopstowpzone = true
|
||||
@ -794,13 +779,7 @@ end
|
||||
function CTLD:_GenerateUHFrequencies()
|
||||
self:T(self.lid .. " _GenerateUHFrequencies")
|
||||
self.FreeUHFFrequencies = {}
|
||||
local _start = 220000000
|
||||
|
||||
while _start < 399000000 do
|
||||
table.insert(self.FreeUHFFrequencies, _start)
|
||||
_start = _start + 500000
|
||||
end
|
||||
|
||||
self.FreeUHFFrequencies = UTILS.GenerateUHFrequencies()
|
||||
return self
|
||||
end
|
||||
|
||||
@ -809,16 +788,7 @@ end
|
||||
function CTLD:_GenerateFMFrequencies()
|
||||
self:T(self.lid .. " _GenerateFMrequencies")
|
||||
self.FreeFMFrequencies = {}
|
||||
|
||||
for _first = 3, 7 do
|
||||
for _second = 0, 5 do
|
||||
for _third = 0, 9 do
|
||||
local _frequency = ((100 * _first) + (10 * _second) + _third) * 100000 --extra 0 because we didnt bother with 4th digit
|
||||
table.insert(self.FreeFMFrequencies, _frequency)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.FreeFMFrequencies = UTILS.GenerateFMFrequencies()
|
||||
return self
|
||||
end
|
||||
|
||||
@ -826,106 +796,13 @@ end
|
||||
-- @param #CTLD self
|
||||
function CTLD:_GenerateVHFrequencies()
|
||||
self:T(self.lid .. " _GenerateVHFrequencies")
|
||||
local _skipFrequencies = self.SkipFrequencies
|
||||
|
||||
self.FreeVHFFrequencies = {}
|
||||
self.UsedVHFFrequencies = {}
|
||||
|
||||
-- first range
|
||||
local _start = 200000
|
||||
while _start < 400000 do
|
||||
|
||||
-- skip existing NDB frequencies#
|
||||
local _found = false
|
||||
for _, value in pairs(_skipFrequencies) do
|
||||
if value * 1000 == _start then
|
||||
_found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if _found == false then
|
||||
table.insert(self.FreeVHFFrequencies, _start)
|
||||
end
|
||||
_start = _start + 10000
|
||||
end
|
||||
|
||||
-- second range
|
||||
_start = 400000
|
||||
while _start < 850000 do
|
||||
-- skip existing NDB frequencies
|
||||
local _found = false
|
||||
for _, value in pairs(_skipFrequencies) do
|
||||
if value * 1000 == _start then
|
||||
_found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if _found == false then
|
||||
table.insert(self.FreeVHFFrequencies, _start)
|
||||
end
|
||||
_start = _start + 10000
|
||||
end
|
||||
|
||||
-- third range
|
||||
_start = 850000
|
||||
while _start <= 999000 do -- adjusted for Gazelle
|
||||
-- skip existing NDB frequencies
|
||||
local _found = false
|
||||
for _, value in pairs(_skipFrequencies) do
|
||||
if value * 1000 == _start then
|
||||
_found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if _found == false then
|
||||
table.insert(self.FreeVHFFrequencies, _start)
|
||||
end
|
||||
_start = _start + 50000
|
||||
end
|
||||
|
||||
self.FreeVHFFrequencies = UTILS.GenerateVHFrequencies()
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Internal) Function to generate valid laser codes.
|
||||
-- @param #CTLD self
|
||||
function CTLD:_GenerateLaserCodes()
|
||||
self:T(self.lid .. " _GenerateLaserCodes")
|
||||
self.jtacGeneratedLaserCodes = {}
|
||||
-- generate list of laser codes
|
||||
local _code = 1111
|
||||
local _count = 1
|
||||
while _code < 1777 and _count < 30 do
|
||||
while true do
|
||||
_code = _code + 1
|
||||
if not self:_ContainsDigit(_code, 8)
|
||||
and not self:_ContainsDigit(_code, 9)
|
||||
and not self:_ContainsDigit(_code, 0) then
|
||||
table.insert(self.jtacGeneratedLaserCodes, _code)
|
||||
break
|
||||
end
|
||||
end
|
||||
_count = _count + 1
|
||||
end
|
||||
end
|
||||
|
||||
--- (Internal) Helper function to generate laser codes.
|
||||
-- @param #CTLD self
|
||||
-- @param #number _number
|
||||
-- @param #number _numberToFind
|
||||
function CTLD:_ContainsDigit(_number, _numberToFind)
|
||||
self:T(self.lid .. " _ContainsDigit")
|
||||
local _thisNumber = _number
|
||||
local _thisDigit = 0
|
||||
while _thisNumber ~= 0 do
|
||||
_thisDigit = _thisNumber % 10
|
||||
_thisNumber = math.floor(_thisNumber / 10)
|
||||
if _thisDigit == _numberToFind then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- (Internal) Event handler function
|
||||
-- @param #CTLD self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
@ -1055,25 +932,27 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop)
|
||||
local drop = drop or false
|
||||
if not drop then
|
||||
inzone = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD)
|
||||
else
|
||||
if self.dropcratesanywhere then -- #1570
|
||||
inzone = true
|
||||
else
|
||||
inzone = self:IsUnitInZone(Unit,CTLD.CargoZoneType.DROP)
|
||||
end
|
||||
end
|
||||
|
||||
if not inzone then
|
||||
self:_SendMessage("You are not close enough to a logistics zone!", 10, false, Group)
|
||||
--local m = MESSAGE:New("You are not close enough to a logistics zone!",15,"CTLD"):ToGroup(Group)
|
||||
if not self.debug then return self end
|
||||
end
|
||||
|
||||
-- avoid crate spam
|
||||
local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities
|
||||
--local capabilities = self.UnitTypes[Unit:GetTypeName()] -- #CTLD.UnitCapabilities
|
||||
local canloadcratesno = capabilities.cratelimit
|
||||
local loaddist = self.CrateDistance or 30
|
||||
local nearcrates, numbernearby = self:_FindCratesNearby(Group,Unit,loaddist)
|
||||
if numbernearby >= canloadcratesno and not drop then
|
||||
self:_SendMessage("There are enough crates nearby already! Take care of those first!", 10, false, Group)
|
||||
--local m = MESSAGE:New("There are enough crates nearby already! Take care of those first!",15,"CTLD"):ToGroup(Group)
|
||||
|
||||
return self
|
||||
end
|
||||
-- spawn crates in front of helicopter
|
||||
@ -1082,7 +961,6 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop)
|
||||
local number = number or cargotype:GetCratesNeeded() --#number
|
||||
local cratesneeded = cargotype:GetCratesNeeded() --#number
|
||||
local cratename = cargotype:GetName()
|
||||
--self:Tself.lid .. string.format("Crate %s requested", cratename))
|
||||
local cratetemplate = "Container"-- #string
|
||||
-- get position and heading of heli
|
||||
local position = Unit:GetCoordinate()
|
||||
@ -1130,7 +1008,6 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop)
|
||||
self:__CratesDropped(1, Group, Unit, droppedcargo)
|
||||
end
|
||||
self:_SendMessage(text, 10, false, Group)
|
||||
--local m = MESSAGE:New(text,15,"CTLD",true):ToGroup(Group)
|
||||
return self
|
||||
end
|
||||
|
||||
@ -1149,7 +1026,6 @@ function CTLD:_ListCratesNearby( _group, _unit)
|
||||
for _,_entry in pairs (crates) do
|
||||
local entry = _entry -- #CTLD_CARGO
|
||||
local name = entry:GetName() --#string
|
||||
-- TODO Meaningful sorting/aggregation
|
||||
local dropped = entry:WasDropped()
|
||||
if dropped then
|
||||
text:Add(string.format("Dropped crate for %s",name))
|
||||
@ -1158,14 +1034,12 @@ function CTLD:_ListCratesNearby( _group, _unit)
|
||||
end
|
||||
end
|
||||
if text:GetCount() == 1 then
|
||||
text:Add("--------- N O N E ------------")
|
||||
text:Add(" N O N E")
|
||||
end
|
||||
text:Add("------------------------------------------------------------")
|
||||
self:_SendMessage(text:Text(), 30, true, _group)
|
||||
--local m = MESSAGE:New(text:Text(),15,"CTLD",true):ToGroup(_group)
|
||||
else
|
||||
self:_SendMessage(string.format("No (loadable) crates within %d meters!",finddist), 10, false, _group)
|
||||
--local m = MESSAGE:New(string.format("No (loadable) crates within %d meters!",finddist),15,"CTLD",true):ToGroup(_group)
|
||||
end
|
||||
return self
|
||||
end
|
||||
@ -1347,7 +1221,7 @@ function CTLD:_ListCargo(Group, Unit)
|
||||
report:Add("------------------------------------------------------------")
|
||||
report:Add(string.format("Troops: %d(%d), Crates: %d(%d)",no_troops,trooplimit,no_crates,cratelimit))
|
||||
report:Add("------------------------------------------------------------")
|
||||
report:Add("-- TROOPS --")
|
||||
report:Add(" -- TROOPS --")
|
||||
for _,_cargo in pairs(cargotable) do
|
||||
local cargo = _cargo -- #CTLD_CARGO
|
||||
local type = cargo:GetType() -- #CTLD_CARGO.Enum
|
||||
@ -1356,10 +1230,10 @@ function CTLD:_ListCargo(Group, Unit)
|
||||
end
|
||||
end
|
||||
if report:GetCount() == 4 then
|
||||
report:Add("--------- N O N E ------------")
|
||||
report:Add(" N O N E")
|
||||
end
|
||||
report:Add("------------------------------------------------------------")
|
||||
report:Add("-- CRATES --")
|
||||
report:Add(" -- CRATES --")
|
||||
local cratecount = 0
|
||||
for _,_cargo in pairs(cargotable) do
|
||||
local cargo = _cargo -- #CTLD_CARGO
|
||||
@ -1370,7 +1244,7 @@ function CTLD:_ListCargo(Group, Unit)
|
||||
end
|
||||
end
|
||||
if cratecount == 0 then
|
||||
report:Add("--------- N O N E ------------")
|
||||
report:Add(" N O N E")
|
||||
end
|
||||
report:Add("------------------------------------------------------------")
|
||||
local text = report:Text()
|
||||
@ -1498,6 +1372,8 @@ end
|
||||
-- @param Wrappe.Unit#UNIT Unit
|
||||
function CTLD:_UnloadCrates(Group, Unit)
|
||||
self:T(self.lid .. " _UnloadCrates")
|
||||
|
||||
if not self.dropcratesanywhere then -- #1570
|
||||
-- check if we are in DROP zone
|
||||
local inzone, zonename, zone, distance = self:IsUnitInZone(Unit,CTLD.CargoZoneType.DROP)
|
||||
if not inzone then
|
||||
@ -1507,6 +1383,7 @@ function CTLD:_UnloadCrates(Group, Unit)
|
||||
return self
|
||||
end
|
||||
end
|
||||
end
|
||||
-- check for hover unload
|
||||
local hoverunload = self:IsCorrectHover(Unit) --if true we\'re hovering in parameters
|
||||
local IsHerc = self:IsHercules(Unit)
|
||||
@ -2058,7 +1935,7 @@ function CTLD:_ListRadioBeacons(Group, Unit)
|
||||
end
|
||||
end
|
||||
if report:GetCount() == 1 then
|
||||
report:Add("--------- N O N E ------------")
|
||||
report:Add(" N O N E")
|
||||
end
|
||||
report:Add("------------------------------------------------------------")
|
||||
self:_SendMessage(report:Text(), 30, true, Group)
|
||||
@ -2431,6 +2308,7 @@ end
|
||||
-- @return #CTLD self
|
||||
function CTLD:onafterStart(From, Event, To)
|
||||
self:T({From, Event, To})
|
||||
self:I(self.lid .. "Started.")
|
||||
if self.useprefix or self.enableHercules then
|
||||
local prefix = self.prefixes
|
||||
--self:T{prefix=prefix})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user