mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#SHORAD - fix typo for maxscootdist
#CTLD - slight refactoring of fixed wing support. * Added `CTLD:AddAllowedFixedWingType(typename)` to add new types * Renamed enabler flags into `enableFixedWing, FixedMinAngels, FixedMaxAngels, FixedMaxSpeed` * Base support for Mosquito added
This commit is contained in:
parent
0a38700edb
commit
dc83af4d02
@ -1154,8 +1154,6 @@ function ESCORT:_ReportTargetsScheduler()
|
|||||||
|
|
||||||
if self.EscortGroup:IsAlive() and self.EscortClient:IsAlive() then
|
if self.EscortGroup:IsAlive() and self.EscortClient:IsAlive() then
|
||||||
|
|
||||||
if true then
|
|
||||||
|
|
||||||
local EscortGroupName = self.EscortGroup:GetName()
|
local EscortGroupName = self.EscortGroup:GetName()
|
||||||
|
|
||||||
self.EscortMenuAttackNearbyTargets:RemoveSubMenus()
|
self.EscortMenuAttackNearbyTargets:RemoveSubMenus()
|
||||||
@ -1226,177 +1224,6 @@ function ESCORT:_ReportTargetsScheduler()
|
|||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
else
|
|
||||||
-- local EscortGroupName = self.EscortGroup:GetName()
|
|
||||||
-- local EscortTargets = self.EscortGroup:GetDetectedTargets()
|
|
||||||
--
|
|
||||||
-- local ClientEscortTargets = self.EscortClient._EscortGroups[EscortGroupName].Targets
|
|
||||||
--
|
|
||||||
-- local EscortTargetMessages = ""
|
|
||||||
-- for EscortTargetID, EscortTarget in pairs( EscortTargets ) do
|
|
||||||
-- local EscortObject = EscortTarget.object
|
|
||||||
-- self:T( EscortObject )
|
|
||||||
-- if EscortObject and EscortObject:isExist() and EscortObject.id_ < 50000000 then
|
|
||||||
--
|
|
||||||
-- local EscortTargetUnit = UNIT:Find( EscortObject )
|
|
||||||
-- local EscortTargetUnitName = EscortTargetUnit:GetName()
|
|
||||||
--
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- -- local EscortTargetIsDetected,
|
|
||||||
-- -- EscortTargetIsVisible,
|
|
||||||
-- -- EscortTargetLastTime,
|
|
||||||
-- -- EscortTargetKnowType,
|
|
||||||
-- -- EscortTargetKnowDistance,
|
|
||||||
-- -- EscortTargetLastPos,
|
|
||||||
-- -- EscortTargetLastVelocity
|
|
||||||
-- -- = self.EscortGroup:IsTargetDetected( EscortObject )
|
|
||||||
-- --
|
|
||||||
-- -- self:T( { EscortTargetIsDetected,
|
|
||||||
-- -- EscortTargetIsVisible,
|
|
||||||
-- -- EscortTargetLastTime,
|
|
||||||
-- -- EscortTargetKnowType,
|
|
||||||
-- -- EscortTargetKnowDistance,
|
|
||||||
-- -- EscortTargetLastPos,
|
|
||||||
-- -- EscortTargetLastVelocity } )
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- local EscortTargetUnitVec3 = EscortTargetUnit:GetVec3()
|
|
||||||
-- local EscortVec3 = self.EscortGroup:GetVec3()
|
|
||||||
-- local Distance = ( ( EscortTargetUnitVec3.x - EscortVec3.x )^2 +
|
|
||||||
-- ( EscortTargetUnitVec3.y - EscortVec3.y )^2 +
|
|
||||||
-- ( EscortTargetUnitVec3.z - EscortVec3.z )^2
|
|
||||||
-- ) ^ 0.5 / 1000
|
|
||||||
--
|
|
||||||
-- self:T( { self.EscortGroup:GetName(), EscortTargetUnit:GetName(), Distance, EscortTarget } )
|
|
||||||
--
|
|
||||||
-- if Distance <= 15 then
|
|
||||||
--
|
|
||||||
-- if not ClientEscortTargets[EscortTargetUnitName] then
|
|
||||||
-- ClientEscortTargets[EscortTargetUnitName] = {}
|
|
||||||
-- end
|
|
||||||
-- ClientEscortTargets[EscortTargetUnitName].AttackUnit = EscortTargetUnit
|
|
||||||
-- ClientEscortTargets[EscortTargetUnitName].visible = EscortTarget.visible
|
|
||||||
-- ClientEscortTargets[EscortTargetUnitName].type = EscortTarget.type
|
|
||||||
-- ClientEscortTargets[EscortTargetUnitName].distance = EscortTarget.distance
|
|
||||||
-- else
|
|
||||||
-- if ClientEscortTargets[EscortTargetUnitName] then
|
|
||||||
-- ClientEscortTargets[EscortTargetUnitName] = nil
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- self:T( { "Sorting Targets Table:", ClientEscortTargets } )
|
|
||||||
-- table.sort( ClientEscortTargets, function( a, b ) return a.Distance < b.Distance end )
|
|
||||||
-- self:T( { "Sorted Targets Table:", ClientEscortTargets } )
|
|
||||||
--
|
|
||||||
-- -- Remove the sub menus of the Attack menu of the Escort for the EscortGroup.
|
|
||||||
-- self.EscortMenuAttackNearbyTargets:RemoveSubMenus()
|
|
||||||
--
|
|
||||||
-- if self.EscortMenuTargetAssistance then
|
|
||||||
-- self.EscortMenuTargetAssistance:RemoveSubMenus()
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- --for MenuIndex = 1, #self.EscortMenuAttackTargets do
|
|
||||||
-- -- self:T( { "Remove Menu:", self.EscortMenuAttackTargets[MenuIndex] } )
|
|
||||||
-- -- self.EscortMenuAttackTargets[MenuIndex] = self.EscortMenuAttackTargets[MenuIndex]:Remove()
|
|
||||||
-- --end
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- if ClientEscortTargets then
|
|
||||||
-- for ClientEscortTargetUnitName, ClientEscortTargetData in pairs( ClientEscortTargets ) do
|
|
||||||
--
|
|
||||||
-- for ClientEscortGroupName, EscortGroupData in pairs( self.EscortClient._EscortGroups ) do
|
|
||||||
--
|
|
||||||
-- if ClientEscortTargetData and ClientEscortTargetData.AttackUnit:IsAlive() then
|
|
||||||
--
|
|
||||||
-- local EscortTargetMessage = ""
|
|
||||||
-- local EscortTargetCategoryName = ClientEscortTargetData.AttackUnit:GetCategoryName()
|
|
||||||
-- local EscortTargetCategoryType = ClientEscortTargetData.AttackUnit:GetTypeName()
|
|
||||||
-- if ClientEscortTargetData.type then
|
|
||||||
-- EscortTargetMessage = EscortTargetMessage .. EscortTargetCategoryName .. " (" .. EscortTargetCategoryType .. ") at "
|
|
||||||
-- else
|
|
||||||
-- EscortTargetMessage = EscortTargetMessage .. "Unknown target at "
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- local EscortTargetUnitVec3 = ClientEscortTargetData.AttackUnit:GetVec3()
|
|
||||||
-- local EscortVec3 = self.EscortGroup:GetVec3()
|
|
||||||
-- local Distance = ( ( EscortTargetUnitVec3.x - EscortVec3.x )^2 +
|
|
||||||
-- ( EscortTargetUnitVec3.y - EscortVec3.y )^2 +
|
|
||||||
-- ( EscortTargetUnitVec3.z - EscortVec3.z )^2
|
|
||||||
-- ) ^ 0.5 / 1000
|
|
||||||
--
|
|
||||||
-- self:T( { self.EscortGroup:GetName(), ClientEscortTargetData.AttackUnit:GetName(), Distance, ClientEscortTargetData.AttackUnit } )
|
|
||||||
-- if ClientEscortTargetData.visible == false then
|
|
||||||
-- EscortTargetMessage = EscortTargetMessage .. string.format( "%.2f", Distance ) .. " estimated km"
|
|
||||||
-- else
|
|
||||||
-- EscortTargetMessage = EscortTargetMessage .. string.format( "%.2f", Distance ) .. " km"
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- if ClientEscortTargetData.visible then
|
|
||||||
-- EscortTargetMessage = EscortTargetMessage .. ", visual"
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- if ClientEscortGroupName == EscortGroupName then
|
|
||||||
--
|
|
||||||
-- MENU_GROUP_COMMAND:New( self.EscortClient,
|
|
||||||
-- EscortTargetMessage,
|
|
||||||
-- self.EscortMenuAttackNearbyTargets,
|
|
||||||
-- ESCORT._AttackTarget,
|
|
||||||
-- { ParamSelf = self,
|
|
||||||
-- ParamUnit = ClientEscortTargetData.AttackUnit
|
|
||||||
-- }
|
|
||||||
-- )
|
|
||||||
-- EscortTargetMessages = EscortTargetMessages .. "\n - " .. EscortTargetMessage
|
|
||||||
-- else
|
|
||||||
-- if self.EscortMenuTargetAssistance then
|
|
||||||
-- local MenuTargetAssistance = MENU_GROUP:New( self.EscortClient, EscortGroupData.EscortName, self.EscortMenuTargetAssistance )
|
|
||||||
-- MENU_GROUP_COMMAND:New( self.EscortClient,
|
|
||||||
-- EscortTargetMessage,
|
|
||||||
-- MenuTargetAssistance,
|
|
||||||
-- ESCORT._AssistTarget,
|
|
||||||
-- self,
|
|
||||||
-- EscortGroupData.EscortGroup,
|
|
||||||
-- ClientEscortTargetData.AttackUnit
|
|
||||||
-- )
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- else
|
|
||||||
-- ClientEscortTargetData = nil
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- if EscortTargetMessages ~= "" and self.ReportTargets == true then
|
|
||||||
-- self.EscortGroup:MessageToClient( "Detected targets within 15 km range:" .. EscortTargetMessages:gsub("\n$",""), 20, self.EscortClient )
|
|
||||||
-- else
|
|
||||||
-- self.EscortGroup:MessageToClient( "No targets detected!", 20, self.EscortClient )
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- if self.EscortMenuResumeMission then
|
|
||||||
-- self.EscortMenuResumeMission:RemoveSubMenus()
|
|
||||||
--
|
|
||||||
-- -- if self.EscortMenuResumeWayPoints then
|
|
||||||
-- -- for MenuIndex = 1, #self.EscortMenuResumeWayPoints do
|
|
||||||
-- -- self:T( { "Remove Menu:", self.EscortMenuResumeWayPoints[MenuIndex] } )
|
|
||||||
-- -- self.EscortMenuResumeWayPoints[MenuIndex] = self.EscortMenuResumeWayPoints[MenuIndex]:Remove()
|
|
||||||
-- -- end
|
|
||||||
-- -- end
|
|
||||||
--
|
|
||||||
-- local TaskPoints = self:RegisterRoute()
|
|
||||||
-- for WayPointID, WayPoint in pairs( TaskPoints ) do
|
|
||||||
-- local EscortVec3 = self.EscortGroup:GetVec3()
|
|
||||||
-- local Distance = ( ( WayPoint.x - EscortVec3.x )^2 +
|
|
||||||
-- ( WayPoint.y - EscortVec3.z )^2
|
|
||||||
-- ) ^ 0.5 / 1000
|
|
||||||
-- MENU_GROUP_COMMAND:New( self.EscortClient, "Waypoint " .. WayPointID .. " at " .. string.format( "%.2f", Distance ).. "km", self.EscortMenuResumeMission, ESCORT._ResumeMission, { ParamSelf = self, ParamWayPoint = WayPointID } )
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
--
|
|
||||||
-- return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -113,7 +113,7 @@ SHORAD = {
|
|||||||
SkateNumber = 3,
|
SkateNumber = 3,
|
||||||
SkateZones = nil,
|
SkateZones = nil,
|
||||||
minscootdist = 100,
|
minscootdist = 100,
|
||||||
minscootdist = 3000,
|
maxscootdist = 3000,
|
||||||
scootrandomcoord = false,
|
scootrandomcoord = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
-- @module Ops.CTLD
|
-- @module Ops.CTLD
|
||||||
-- @image OPS_CTLD.jpg
|
-- @image OPS_CTLD.jpg
|
||||||
|
|
||||||
-- Last Update Feb 2025
|
-- Last Update April 2025
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -923,7 +923,6 @@ do
|
|||||||
-- ["MH-60R"] = {type="MH-60R", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
-- ["MH-60R"] = {type="MH-60R", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
||||||
-- ["SH-60B"] = {type="SH-60B", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
-- ["SH-60B"] = {type="SH-60B", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
||||||
-- ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
|
-- ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
|
||||||
-- ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
|
|
||||||
-- ["OH-6A"] = {type="OH-6A", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 7, cargoweightlimit = 550},
|
-- ["OH-6A"] = {type="OH-6A", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 7, cargoweightlimit = 550},
|
||||||
-- ["OH58D"] = {type="OH58D", crates=false, troops=false, cratelimit = 0, trooplimit = 0, length = 14, cargoweightlimit = 400},
|
-- ["OH58D"] = {type="OH58D", crates=false, troops=false, cratelimit = 0, trooplimit = 0, length = 14, cargoweightlimit = 400},
|
||||||
-- ["CH-47Fbl1"] = {type="CH-47Fbl1", crates=true, troops=true, cratelimit = 4, trooplimit = 31, length = 20, cargoweightlimit = 8000},
|
-- ["CH-47Fbl1"] = {type="CH-47Fbl1", crates=true, troops=true, cratelimit = 4, trooplimit = 31, length = 20, cargoweightlimit = 8000},
|
||||||
@ -1087,11 +1086,11 @@ do
|
|||||||
--
|
--
|
||||||
-- ## 4.7 List Inventory
|
-- ## 4.7 List Inventory
|
||||||
--
|
--
|
||||||
-- Lists invetory of available units to drop or build.
|
-- Lists inventory of available units to drop or build.
|
||||||
--
|
--
|
||||||
-- ## 5. Support for Hercules mod by Anubis
|
-- ## 5. Support for fixed wings
|
||||||
--
|
--
|
||||||
-- Basic support for the Hercules mod By Anubis has been build into CTLD - that is you can load/drop/build the same way and for the same objects as
|
-- Basic support for the Hercules mod By Anubis has been build into CTLD, as well as Bronco and Mosquito - that is you can load/drop/build the same way and for the same objects as
|
||||||
-- the helicopters (main method).
|
-- the helicopters (main method).
|
||||||
-- To cover objects and troops which can be loaded from the groud crew Rearm/Refuel menu (F8), you need to use @{#CTLD_HERCULES.New}() and link
|
-- To cover objects and troops which can be loaded from the groud crew Rearm/Refuel menu (F8), you need to use @{#CTLD_HERCULES.New}() and link
|
||||||
-- this object to your CTLD setup (alternative method). In this case, do **not** use the `Hercules_Cargo.lua` or `Hercules_Cargo_CTLD.lua` which are part of the mod
|
-- this object to your CTLD setup (alternative method). In this case, do **not** use the `Hercules_Cargo.lua` or `Hercules_Cargo_CTLD.lua` which are part of the mod
|
||||||
@ -1103,13 +1102,13 @@ do
|
|||||||
--
|
--
|
||||||
-- Enable these options for Hercules support:
|
-- Enable these options for Hercules support:
|
||||||
--
|
--
|
||||||
-- my_ctld.enableHercules = true
|
-- my_ctld.enableFixedWing = true
|
||||||
-- my_ctld.HercMinAngels = 155 -- for troop/cargo drop via chute in meters, ca 470 ft
|
-- my_ctld.FixedMinAngels = 155 -- for troop/cargo drop via chute in meters, ca 470 ft
|
||||||
-- my_ctld.HercMaxAngels = 2000 -- for troop/cargo drop via chute in meters, ca 6000 ft
|
-- my_ctld.FixedMaxAngels = 2000 -- for troop/cargo drop via chute in meters, ca 6000 ft
|
||||||
-- my_ctld.HercMaxSpeed = 77 -- 77mps or 270kph or 150kn
|
-- my_ctld.FixedMaxSpeed = 77 -- 77mps or 270kph or 150kn
|
||||||
--
|
--
|
||||||
-- Hint: you can **only** airdrop from the Hercules if you are "in parameters", i.e. at or below `HercMaxSpeed` and in the AGL bracket between
|
-- Hint: you can **only** airdrop from the Hercules if you are "in parameters", i.e. at or below `FixedMaxSpeed` and in the AGLFixedMinAngelseen
|
||||||
-- `HercMinAngels` and `HercMaxAngels`!
|
-- `FixedMinAngels` and `FixedMaxAngels`!
|
||||||
--
|
--
|
||||||
-- Also, the following options need to be set to `true`:
|
-- Also, the following options need to be set to `true`:
|
||||||
--
|
--
|
||||||
@ -1117,9 +1116,9 @@ do
|
|||||||
--
|
--
|
||||||
-- ### 5.2 Integrate Hercules ground crew (F8 Menu) loadable objects (alternative method, use either the above OR this method, NOT both!)
|
-- ### 5.2 Integrate Hercules ground crew (F8 Menu) loadable objects (alternative method, use either the above OR this method, NOT both!)
|
||||||
--
|
--
|
||||||
-- Integrate to your CTLD instance like so, where `my_ctld` is a previously created CTLD instance:
|
-- Taking another approach, integrate to your CTLD instance like so, where `my_ctld` is a previously created CTLD instance:
|
||||||
--
|
--
|
||||||
-- my_ctld.enableHercules = false -- avoid dual loading via CTLD F10 and F8 ground crew
|
-- my_ctld.enableFixedWing = false -- avoid dual loading via CTLD F10 and F8 ground crew
|
||||||
-- local herccargo = CTLD_HERCULES:New("blue", "Hercules Test", my_ctld)
|
-- local herccargo = CTLD_HERCULES:New("blue", "Hercules Test", my_ctld)
|
||||||
--
|
--
|
||||||
-- You also need:
|
-- You also need:
|
||||||
@ -1384,11 +1383,20 @@ CTLD.UnitTypeCapabilities = {
|
|||||||
["OH-6A"] = {type="OH-6A", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 7, cargoweightlimit = 550},
|
["OH-6A"] = {type="OH-6A", crates=false, troops=true, cratelimit = 0, trooplimit = 4, length = 7, cargoweightlimit = 550},
|
||||||
["OH58D"] = {type="OH58D", crates=false, troops=false, cratelimit = 0, trooplimit = 0, length = 14, cargoweightlimit = 400},
|
["OH58D"] = {type="OH58D", crates=false, troops=false, cratelimit = 0, trooplimit = 0, length = 14, cargoweightlimit = 400},
|
||||||
["CH-47Fbl1"] = {type="CH-47Fbl1", crates=true, troops=true, cratelimit = 4, trooplimit = 31, length = 20, cargoweightlimit = 10800},
|
["CH-47Fbl1"] = {type="CH-47Fbl1", crates=true, troops=true, cratelimit = 4, trooplimit = 31, length = 20, cargoweightlimit = 10800},
|
||||||
|
["MosquitoFBMkVI"] = {type="MosquitoFBMkVI", crates= true, troops=false, cratelimit = 2, trooplimit = 0, length = 13, cargoweightlimit = 1800},
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Allowed Fixed Wing Types
|
||||||
|
-- @type CTLD.FixedWingTypes
|
||||||
|
CTLD.FixedWingTypes = {
|
||||||
|
["Hercules"] = "Hercules",
|
||||||
|
["Bronco"] = "Bronco",
|
||||||
|
["Mosquito"] = "Mosquito",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- CTLD class version.
|
--- CTLD class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CTLD.version="1.1.30"
|
CTLD.version="1.1.31"
|
||||||
|
|
||||||
--- Instantiate a new CTLD.
|
--- Instantiate a new CTLD.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@ -1528,10 +1536,11 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
|||||||
self.troopdropzoneradius = 100
|
self.troopdropzoneradius = 100
|
||||||
|
|
||||||
-- added support Hercules Mod
|
-- added support Hercules Mod
|
||||||
self.enableHercules = false
|
self.enableHercules = false -- deprecated
|
||||||
self.HercMinAngels = 165 -- for troop/cargo drop via chute
|
self.enableFixedWing = false
|
||||||
self.HercMaxAngels = 2000 -- for troop/cargo drop via chute
|
self.FixedMinAngels = 165 -- for troop/cargo drop via chute
|
||||||
self.HercMaxSpeed = 77 -- 280 kph or 150kn eq 77 mps
|
self.FixedMaxAngels = 2000 -- for troop/cargo drop via chute
|
||||||
|
self.FixedMaxSpeed = 77 -- 280 kph or 150kn eq 77 mps
|
||||||
|
|
||||||
-- message suppression
|
-- message suppression
|
||||||
self.suppressmessages = false
|
self.suppressmessages = false
|
||||||
@ -2015,7 +2024,7 @@ function CTLD:_EventHandler(EventData)
|
|||||||
self:_RefreshF10Menus()
|
self:_RefreshF10Menus()
|
||||||
end
|
end
|
||||||
-- Herc support
|
-- Herc support
|
||||||
if self:IsHercules(_unit) and self.enableHercules then
|
if self:IsFixedWing(_unit) and self.enableFixedWing then
|
||||||
local unitname = event.IniUnitName or "none"
|
local unitname = event.IniUnitName or "none"
|
||||||
self.Loaded_Cargo[unitname] = nil
|
self.Loaded_Cargo[unitname] = nil
|
||||||
self:_RefreshF10Menus()
|
self:_RefreshF10Menus()
|
||||||
@ -2183,6 +2192,22 @@ function CTLD:_FindCratesCargoObject(Name)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (User) Add a new fixed wing type to the list of allowed types.
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param #string typename The typename to add. Can be handed as Wrapper.Unit#UNIT object. Do NOT forget to `myctld:SetUnitCapabilities()` for this type!
|
||||||
|
-- @return #CTLD self
|
||||||
|
function CTLD:AddAllowedFixedWingType(typename)
|
||||||
|
if type(typename) == "string" then
|
||||||
|
self.FixedWingTypes[typename] = typename
|
||||||
|
elseif typename and typename.ClassName and typename:IsInstanceOf("UNIT") then
|
||||||
|
local TypeName = typename:GetTypeName() or "none"
|
||||||
|
self.FixedWingTypes[TypeName] = TypeName
|
||||||
|
else
|
||||||
|
self:E(self.lid.."No valid typename or no UNIT handed!")
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- (User) Pre-load troops into a helo, e.g. for airstart. Unit **must** be alive in-game, i.e. player has taken the slot!
|
--- (User) Pre-load troops into a helo, e.g. for airstart. Unit **must** be alive in-game, i.e. player has taken the slot!
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param Wrapper.Unit#UNIT Unit The unit to load into, can be handed as Wrapper.Client#CLIENT object
|
-- @param Wrapper.Unit#UNIT Unit The unit to load into, can be handed as Wrapper.Client#CLIENT object
|
||||||
@ -2715,7 +2740,7 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
-- spawn crates in front of helicopter
|
-- spawn crates in front of helicopter
|
||||||
local IsHerc = self:IsHercules(Unit) -- Herc, Bronco and Hook load from behind
|
local IsHerc = self:IsFixedWing(Unit) -- Herc, Bronco and Hook load from behind
|
||||||
local IsHook = self:IsHook(Unit) -- Herc, Bronco and Hook load from behind
|
local IsHook = self:IsHook(Unit) -- Herc, Bronco and Hook load from behind
|
||||||
local cargotype = Cargo -- Ops.CTLD#CTLD_CARGO
|
local cargotype = Cargo -- Ops.CTLD#CTLD_CARGO
|
||||||
local number = number or cargotype:GetCratesNeeded() --#number
|
local number = number or cargotype:GetCratesNeeded() --#number
|
||||||
@ -3088,7 +3113,7 @@ function CTLD:_FindCratesNearby( _group, _unit, _dist, _ignoreweight, ignoretype
|
|||||||
--self:I(self.lid .. " Unit can carry: " .. tostring(cando))
|
--self:I(self.lid .. " Unit can carry: " .. tostring(cando))
|
||||||
--- Testing
|
--- Testing
|
||||||
local distance = self:_GetDistance(location,staticpos)
|
local distance = self:_GetDistance(location,staticpos)
|
||||||
--self:I(self.lid .. string.format("Dist %dm/%dm | weight %dkg | maxloadable %dkg",distance,finddist,weight,maxloadable))
|
self:T(self.lid .. string.format("Dist %dm/%dm | weight %dkg | maxloadable %dkg",distance,finddist,weight,maxloadable))
|
||||||
if distance <= finddist and (weight <= maxloadable or _ignoreweight) and restricted == false and cando == true then
|
if distance <= finddist and (weight <= maxloadable or _ignoreweight) and restricted == false and cando == true then
|
||||||
index = index + 1
|
index = index + 1
|
||||||
table.insert(found, staticid, cargo)
|
table.insert(found, staticid, cargo)
|
||||||
@ -3495,16 +3520,18 @@ function CTLD:_ListInventory(Group, Unit)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- (Internal) Function to check if a unit is a Hercules C-130 or a Bronco.
|
--- (Internal) Function to check if a unit is an allowed fixed wing.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param Wrapper.Unit#UNIT Unit
|
-- @param Wrapper.Unit#UNIT Unit
|
||||||
-- @return #boolean Outcome
|
-- @return #boolean Outcome
|
||||||
function CTLD:IsHercules(Unit)
|
function CTLD:IsFixedWing(Unit)
|
||||||
if Unit:GetTypeName() == "Hercules" or string.find(Unit:GetTypeName(),"Bronco") then
|
local typename = Unit:GetTypeName() or "none"
|
||||||
return true
|
for _,_name in pairs(self.FixedWingTypes or {}) do
|
||||||
else
|
if typename == _name or string.find(typename,_name,1,true) then
|
||||||
return false
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- (Internal) Function to check if a unit is a CH-47
|
--- (Internal) Function to check if a unit is a CH-47
|
||||||
@ -3570,7 +3597,7 @@ function CTLD:_UnloadTroops(Group, Unit)
|
|||||||
end
|
end
|
||||||
-- check for hover unload
|
-- check for hover unload
|
||||||
local hoverunload = self:IsCorrectHover(Unit) --if true we\'re hovering in parameters
|
local hoverunload = self:IsCorrectHover(Unit) --if true we\'re hovering in parameters
|
||||||
local IsHerc = self:IsHercules(Unit)
|
local IsHerc = self:IsFixedWing(Unit)
|
||||||
local IsHook = self:IsHook(Unit)
|
local IsHook = self:IsHook(Unit)
|
||||||
if IsHerc and (not IsHook) then
|
if IsHerc and (not IsHook) then
|
||||||
-- no hover but airdrop here
|
-- no hover but airdrop here
|
||||||
@ -3718,7 +3745,7 @@ function CTLD:_UnloadCrates(Group, Unit)
|
|||||||
end
|
end
|
||||||
-- check for hover unload
|
-- check for hover unload
|
||||||
local hoverunload = self:IsCorrectHover(Unit) --if true we\'re hovering in parameters
|
local hoverunload = self:IsCorrectHover(Unit) --if true we\'re hovering in parameters
|
||||||
local IsHerc = self:IsHercules(Unit)
|
local IsHerc = self:IsFixedWing(Unit)
|
||||||
local IsHook = self:IsHook(Unit)
|
local IsHook = self:IsHook(Unit)
|
||||||
if IsHerc and (not IsHook) then
|
if IsHerc and (not IsHook) then
|
||||||
-- no hover but airdrop here
|
-- no hover but airdrop here
|
||||||
@ -3784,7 +3811,7 @@ end
|
|||||||
function CTLD:_BuildCrates(Group, Unit,Engineering)
|
function CTLD:_BuildCrates(Group, Unit,Engineering)
|
||||||
self:T(self.lid .. " _BuildCrates")
|
self:T(self.lid .. " _BuildCrates")
|
||||||
-- avoid users trying to build from flying Hercs
|
-- avoid users trying to build from flying Hercs
|
||||||
if self:IsHercules(Unit) and self.enableHercules and not Engineering then
|
if self:IsFixedWing(Unit) and self.enableFixedWing and not Engineering then
|
||||||
local speed = Unit:GetVelocityKMH()
|
local speed = Unit:GetVelocityKMH()
|
||||||
if speed > 1 then
|
if speed > 1 then
|
||||||
self:_SendMessage("You need to land / stop to build something, Pilot!", 10, false, Group)
|
self:_SendMessage("You need to land / stop to build something, Pilot!", 10, false, Group)
|
||||||
@ -4150,7 +4177,7 @@ function CTLD:_RefreshF10Menus()
|
|||||||
local firstUnit = groupObj:GetFirstUnitAlive()
|
local firstUnit = groupObj:GetFirstUnitAlive()
|
||||||
if firstUnit then
|
if firstUnit then
|
||||||
if firstUnit:IsPlayer() then
|
if firstUnit:IsPlayer() then
|
||||||
if firstUnit:IsHelicopter() or (self.enableHercules and self:IsHercules(firstUnit)) then
|
if firstUnit:IsHelicopter() or (self.enableFixedWing and self:IsFixedWing(firstUnit)) then
|
||||||
local _unit = firstUnit:GetName()
|
local _unit = firstUnit:GetName()
|
||||||
_UnitList[_unit] = _unit
|
_UnitList[_unit] = _unit
|
||||||
end
|
end
|
||||||
@ -4362,7 +4389,7 @@ function CTLD:_RefreshF10Menus()
|
|||||||
MENU_GROUP_COMMAND:New(_group, "Fire flare now", smoketopmenu, self.SmokePositionNow, self, _unit, true)
|
MENU_GROUP_COMMAND:New(_group, "Fire flare now", smoketopmenu, self.SmokePositionNow, self, _unit, true)
|
||||||
MENU_GROUP_COMMAND:New(_group, "Drop beacon now", smoketopmenu, self.DropBeaconNow, self, _unit):Refresh()
|
MENU_GROUP_COMMAND:New(_group, "Drop beacon now", smoketopmenu, self.DropBeaconNow, self, _unit):Refresh()
|
||||||
|
|
||||||
if self:IsHercules(_unit) then
|
if self:IsFixedWing(_unit) then
|
||||||
MENU_GROUP_COMMAND:New(_group, "Show flight parameters", topmenu, self._ShowFlightParams, self, _group, _unit):Refresh()
|
MENU_GROUP_COMMAND:New(_group, "Show flight parameters", topmenu, self._ShowFlightParams, self, _group, _unit):Refresh()
|
||||||
else
|
else
|
||||||
MENU_GROUP_COMMAND:New(_group, "Show hover parameters", topmenu, self._ShowHoverParams, self, _group, _unit):Refresh()
|
MENU_GROUP_COMMAND:New(_group, "Show hover parameters", topmenu, self._ShowHoverParams, self, _group, _unit):Refresh()
|
||||||
@ -4597,7 +4624,7 @@ function CTLD:_UnloadSingleCrateSet(Group, Unit, setIndex)
|
|||||||
-- Check hover/airdrop/landed logic
|
-- Check hover/airdrop/landed logic
|
||||||
local grounded = not self:IsUnitInAir(Unit)
|
local grounded = not self:IsUnitInAir(Unit)
|
||||||
local hoverunload = self:IsCorrectHover(Unit)
|
local hoverunload = self:IsCorrectHover(Unit)
|
||||||
local isHerc = self:IsHercules(Unit)
|
local isHerc = self:IsFixedWing(Unit)
|
||||||
local isHook = self:IsHook(Unit)
|
local isHook = self:IsHook(Unit)
|
||||||
if isHerc and not isHook then
|
if isHerc and not isHook then
|
||||||
hoverunload = self:IsCorrectFlightParameters(Unit)
|
hoverunload = self:IsCorrectFlightParameters(Unit)
|
||||||
@ -4758,7 +4785,7 @@ function CTLD:_UnloadSingleTroopByID(Group, Unit, chunkID)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local hoverunload = self:IsCorrectHover(Unit)
|
local hoverunload = self:IsCorrectHover(Unit)
|
||||||
local isHerc = self:IsHercules(Unit)
|
local isHerc = self:IsFixedWing(Unit)
|
||||||
local isHook = self:IsHook(Unit)
|
local isHook = self:IsHook(Unit)
|
||||||
if isHerc and not isHook then
|
if isHerc and not isHook then
|
||||||
hoverunload = self:IsCorrectFlightParameters(Unit)
|
hoverunload = self:IsCorrectFlightParameters(Unit)
|
||||||
@ -4900,7 +4927,7 @@ function CTLD:_UnloadSingleTroopByID(Group, Unit, chunkID)
|
|||||||
self.Loaded_Cargo[unitName].Cratesloaded = cratesLoaded
|
self.Loaded_Cargo[unitName].Cratesloaded = cratesLoaded
|
||||||
self:_RefreshDropTroopsMenu(Group, Unit)
|
self:_RefreshDropTroopsMenu(Group, Unit)
|
||||||
else
|
else
|
||||||
local isHerc = self:IsHercules(Unit)
|
local isHerc = self:IsFixedWing(Unit)
|
||||||
if isHerc then
|
if isHerc then
|
||||||
self:_SendMessage("Nothing loaded or not within airdrop parameters!", 10, false, Group)
|
self:_SendMessage("Nothing loaded or not within airdrop parameters!", 10, false, Group)
|
||||||
else
|
else
|
||||||
@ -5802,9 +5829,9 @@ end
|
|||||||
end
|
end
|
||||||
local gheight = ucoord:GetLandHeight()
|
local gheight = ucoord:GetLandHeight()
|
||||||
local aheight = uheight - gheight -- height above ground
|
local aheight = uheight - gheight -- height above ground
|
||||||
local minh = self.HercMinAngels-- 1500m
|
local minh = self.FixedMinAngels-- 1500m
|
||||||
local maxh = self.HercMaxAngels -- 5000m
|
local maxh = self.FixedMaxAngels -- 5000m
|
||||||
local maxspeed = self.HercMaxSpeed -- 77 mps
|
local maxspeed = self.FixedMaxSpeed -- 77 mps
|
||||||
-- DONE: TEST - Speed test for Herc, should not be above 280kph/150kn
|
-- DONE: TEST - Speed test for Herc, should not be above 280kph/150kn
|
||||||
local kmspeed = uspeed * 3.6
|
local kmspeed = uspeed * 3.6
|
||||||
local knspeed = kmspeed / 1.86
|
local knspeed = kmspeed / 1.86
|
||||||
@ -5847,12 +5874,12 @@ end
|
|||||||
if not inhover then htxt = "false" end
|
if not inhover then htxt = "false" end
|
||||||
local text = ""
|
local text = ""
|
||||||
if _SETTINGS:IsImperial() then
|
if _SETTINGS:IsImperial() then
|
||||||
local minheight = UTILS.MetersToFeet(self.HercMinAngels)
|
local minheight = UTILS.MetersToFeet(self.FixedMinAngels)
|
||||||
local maxheight = UTILS.MetersToFeet(self.HercMaxAngels)
|
local maxheight = UTILS.MetersToFeet(self.FixedMaxAngels)
|
||||||
text = string.format("Flight parameters (airdrop):\n - Min height %dft \n - Max height %dft \n - In parameter: %s", minheight, maxheight, htxt)
|
text = string.format("Flight parameters (airdrop):\n - Min height %dft \n - Max height %dft \n - In parameter: %s", minheight, maxheight, htxt)
|
||||||
else
|
else
|
||||||
local minheight = self.HercMinAngels
|
local minheight = self.FixedMinAngels
|
||||||
local maxheight = self.HercMaxAngels
|
local maxheight = self.FixedMaxAngels
|
||||||
text = string.format("Flight parameters (airdrop):\n - Min height %dm \n - Max height %dm \n - In parameter: %s", minheight, maxheight, htxt)
|
text = string.format("Flight parameters (airdrop):\n - Min height %dm \n - Max height %dm \n - In parameter: %s", minheight, maxheight, htxt)
|
||||||
end
|
end
|
||||||
self:_SendMessage(text, 10, false, Group)
|
self:_SendMessage(text, 10, false, Group)
|
||||||
@ -5865,7 +5892,7 @@ end
|
|||||||
-- @return #boolean Outcome
|
-- @return #boolean Outcome
|
||||||
function CTLD:CanHoverLoad(Unit)
|
function CTLD:CanHoverLoad(Unit)
|
||||||
self:T(self.lid .. " CanHoverLoad")
|
self:T(self.lid .. " CanHoverLoad")
|
||||||
if self:IsHercules(Unit) then return false end
|
if self:IsFixedWing(Unit) then return false end
|
||||||
local outcome = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD) and self:IsCorrectHover(Unit)
|
local outcome = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD) and self:IsCorrectHover(Unit)
|
||||||
if not outcome then
|
if not outcome then
|
||||||
outcome = self:IsUnitInZone(Unit,CTLD.CargoZoneType.SHIP) --and self:IsCorrectHover(Unit)
|
outcome = self:IsUnitInZone(Unit,CTLD.CargoZoneType.SHIP) --and self:IsCorrectHover(Unit)
|
||||||
@ -5880,7 +5907,7 @@ end
|
|||||||
function CTLD:IsUnitInAir(Unit)
|
function CTLD:IsUnitInAir(Unit)
|
||||||
-- get speed and height
|
-- get speed and height
|
||||||
local minheight = self.minimumHoverHeight
|
local minheight = self.minimumHoverHeight
|
||||||
if self.enableHercules and self:IsHercules(Unit) then
|
if self.enableFixedWing and self:IsFixedWing(Unit) then
|
||||||
minheight = 5.1 -- herc is 5m AGL on the ground
|
minheight = 5.1 -- herc is 5m AGL on the ground
|
||||||
end
|
end
|
||||||
local uheight = Unit:GetHeight()
|
local uheight = Unit:GetHeight()
|
||||||
@ -6727,11 +6754,12 @@ end
|
|||||||
function CTLD:onafterStart(From, Event, To)
|
function CTLD:onafterStart(From, Event, To)
|
||||||
self:T({From, Event, To})
|
self:T({From, Event, To})
|
||||||
self:I(self.lid .. "Started ("..self.version..")")
|
self:I(self.lid .. "Started ("..self.version..")")
|
||||||
|
if self.enableHercules then self.enableFixedWing = true end
|
||||||
if self.UserSetGroup then
|
if self.UserSetGroup then
|
||||||
self.PilotGroups = self.UserSetGroup
|
self.PilotGroups = self.UserSetGroup
|
||||||
elseif self.useprefix or self.enableHercules then
|
elseif self.useprefix or self.enableFixedWing then
|
||||||
local prefix = self.prefixes
|
local prefix = self.prefixes
|
||||||
if self.enableHercules then
|
if self.enableFixedWing then
|
||||||
self.PilotGroups = SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterPrefixes(prefix):FilterStart()
|
self.PilotGroups = SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterPrefixes(prefix):FilterStart()
|
||||||
else
|
else
|
||||||
self.PilotGroups = SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterPrefixes(prefix):FilterCategories("helicopter"):FilterStart()
|
self.PilotGroups = SET_GROUP:New():FilterCoalitions(self.coalitiontxt):FilterPrefixes(prefix):FilterCategories("helicopter"):FilterStart()
|
||||||
@ -7533,7 +7561,7 @@ CTLD_HERCULES.Types = {
|
|||||||
-- @usage
|
-- @usage
|
||||||
-- Integrate to your CTLD instance like so, where `my_ctld` is a previously created CTLD instance:
|
-- Integrate to your CTLD instance like so, where `my_ctld` is a previously created CTLD instance:
|
||||||
--
|
--
|
||||||
-- my_ctld.enableHercules = false -- avoid dual loading via CTLD F10 and F8 ground crew
|
-- my_ctld.enableFixedWing = false -- avoid dual loading via CTLD F10 and F8 ground crew
|
||||||
-- local herccargo = CTLD_HERCULES:New("blue", "Hercules Test", my_ctld)
|
-- local herccargo = CTLD_HERCULES:New("blue", "Hercules Test", my_ctld)
|
||||||
--
|
--
|
||||||
-- You also need:
|
-- You also need:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user