mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1174 from FlightControl-Master/FF/Develop
MISC Fixes and Improvements
This commit is contained in:
commit
ab1ba9595d
@ -1095,7 +1095,7 @@ do -- AI_A2A_DISPATCHER
|
||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||
end
|
||||
DefenderUnit:Destroy()
|
||||
self:ParkDefender( Squadron, Defender )
|
||||
self:ParkDefender( Squadron )
|
||||
return
|
||||
end
|
||||
if DefenderUnit:GetLife() ~= DefenderUnit:GetLife0() then
|
||||
@ -1122,7 +1122,7 @@ do -- AI_A2A_DISPATCHER
|
||||
self:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||
end
|
||||
DefenderUnit:Destroy()
|
||||
self:ParkDefender( Squadron, Defender )
|
||||
self:ParkDefender( Squadron )
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -2873,7 +2873,7 @@ do -- AI_A2A_DISPATCHER
|
||||
if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
|
||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||
Defender:Destroy()
|
||||
self:ParkDefender( Squadron, Defender )
|
||||
Dispatcher:ParkDefender( Squadron )
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -3060,7 +3060,7 @@ do -- AI_A2A_DISPATCHER
|
||||
if Dispatcher:GetSquadronLanding( Squadron.Name ) == AI_A2A_DISPATCHER.Landing.NearAirbase then
|
||||
Dispatcher:RemoveDefenderFromSquadron( Squadron, Defender )
|
||||
Defender:Destroy()
|
||||
self:ParkDefender( Squadron, Defender )
|
||||
Dispatcher:ParkDefender( Squadron )
|
||||
end
|
||||
end
|
||||
end -- if DefenderGCI then
|
||||
|
||||
@ -1102,7 +1102,7 @@ function AI_FORMATION:onenterFollowing( FollowGroupSet ) --R2.1
|
||||
|
||||
if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation then
|
||||
|
||||
self:I({Mode=FollowGroup:GetState( FollowGroup, "Mode" )})
|
||||
self:T({Mode=FollowGroup:GetState( FollowGroup, "Mode" )})
|
||||
|
||||
FollowGroup:OptionROTEvadeFire()
|
||||
FollowGroup:OptionROEReturnFire()
|
||||
|
||||
@ -1571,6 +1571,35 @@ do -- SET_GROUP
|
||||
return Count
|
||||
end
|
||||
|
||||
--- Iterate the SET_GROUP and count how many GROUPs and UNITs are alive.
|
||||
-- @param #SET_GROUP self
|
||||
-- @return #number The number of GROUPs completely in the Zone
|
||||
-- @return #number The number of UNITS alive.
|
||||
function SET_GROUP:CountAlive()
|
||||
local CountG = 0
|
||||
local CountU = 0
|
||||
|
||||
local Set = self:GetSet()
|
||||
|
||||
for GroupID, GroupData in pairs(Set) do -- For each GROUP in SET_GROUP
|
||||
if GroupData and GroupData:IsAlive() then
|
||||
|
||||
CountG = CountG + 1
|
||||
|
||||
--Count Units.
|
||||
for _,_unit in pairs(GroupData:GetUnits()) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
if unit and unit:IsAlive() then
|
||||
CountU=CountU+1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return CountG,CountU
|
||||
end
|
||||
|
||||
----- Iterate the SET_GROUP and call an interator function for each **alive** player, providing the Group of the player and optional parameters.
|
||||
---- @param #SET_GROUP self
|
||||
---- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_GROUP. The function needs to accept a GROUP parameter.
|
||||
|
||||
@ -126,6 +126,39 @@ do
|
||||
-- @param Wrapper.Positionable#POSITIONABLE Target
|
||||
-- @param #number LaserCode Laser code.
|
||||
-- @param #number Duration Duration of lasing in seconds.
|
||||
|
||||
self:AddTransition( "Off", "LaseOnCoordinate", "On" )
|
||||
|
||||
--- LaseOnCoordinate Handler OnBefore for SPOT.
|
||||
-- @function [parent=#SPOT] OnBeforeLaseOnCoordinate
|
||||
-- @param #SPOT self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
-- @return #boolean
|
||||
|
||||
--- LaseOnCoordinate Handler OnAfter for SPOT.
|
||||
-- @function [parent=#SPOT] OnAfterLaseOnCoordinate
|
||||
-- @param #SPOT self
|
||||
-- @param #string From
|
||||
-- @param #string Event
|
||||
-- @param #string To
|
||||
|
||||
--- LaseOnCoordinate Trigger for SPOT.
|
||||
-- @function [parent=#SPOT] LaseOnCoordinate
|
||||
-- @param #SPOT self
|
||||
-- @param Core.Point#COORDINATE Coordinate The coordinate to lase.
|
||||
-- @param #number LaserCode Laser code.
|
||||
-- @param #number Duration Duration of lasing in seconds.
|
||||
|
||||
--- LaseOn Asynchronous Trigger for SPOT
|
||||
-- @function [parent=#SPOT] __LaseOn
|
||||
-- @param #SPOT self
|
||||
-- @param #number Delay
|
||||
-- @param Wrapper.Positionable#POSITIONABLE Target
|
||||
-- @param #number LaserCode Laser code.
|
||||
-- @param #number Duration Duration of lasing in seconds.
|
||||
|
||||
|
||||
|
||||
self:AddTransition( "On", "Lasing", "On" )
|
||||
@ -194,7 +227,8 @@ do
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param #SPOT self
|
||||
--- On after LaseOn event. Activates the laser spot.
|
||||
-- @param #SPOT self
|
||||
-- @param From
|
||||
-- @param Event
|
||||
-- @param To
|
||||
@ -226,6 +260,43 @@ do
|
||||
|
||||
self:__Lasing( -1 )
|
||||
end
|
||||
|
||||
|
||||
--- On after LaseOnCoordinate event. Activates the laser spot.
|
||||
-- @param #SPOT self
|
||||
-- @param From
|
||||
-- @param Event
|
||||
-- @param To
|
||||
-- @param Core.Point#COORDINATE Coordinate The coordinate at which the laser is pointing.
|
||||
-- @param #number LaserCode Laser code.
|
||||
-- @param #number Duration Duration of lasing in seconds.
|
||||
function SPOT:onafterLaseOnCoordinate(From, Event, To, Coordinate, LaserCode, Duration)
|
||||
self:F( { "LaseOnCoordinate", Coordinate, LaserCode, Duration } )
|
||||
|
||||
local function StopLase( self )
|
||||
self:LaseOff()
|
||||
end
|
||||
|
||||
self.Target = nil
|
||||
self.TargetCoord=Coordinate
|
||||
self.LaserCode = LaserCode
|
||||
|
||||
self.Lasing = true
|
||||
|
||||
local RecceDcsUnit = self.Recce:GetDCSObject()
|
||||
|
||||
local aimat=Coordinate
|
||||
aimat.y=aimat.y+1
|
||||
|
||||
self.SpotIR = Spot.createInfraRed( RecceDcsUnit, { x = 0, y = 2, z = 0 }, aimat:GetVec3() )
|
||||
self.SpotLaser = Spot.createLaser( RecceDcsUnit, { x = 0, y = 2, z = 0 }, aimat:GetVec3(), LaserCode )
|
||||
|
||||
if Duration then
|
||||
self.ScheduleID = self.LaseScheduler:Schedule( self, StopLase, {self}, Duration )
|
||||
end
|
||||
|
||||
self:__Lasing(-1)
|
||||
end
|
||||
|
||||
--- @param #SPOT self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
@ -246,10 +317,20 @@ do
|
||||
-- @param To
|
||||
function SPOT:onafterLasing( From, Event, To )
|
||||
|
||||
if self.Target:IsAlive() then
|
||||
if self.Target and self.Target:IsAlive() then
|
||||
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() )
|
||||
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
|
||||
self:__Lasing( -0.2 )
|
||||
elseif self.TargetCoord then
|
||||
|
||||
local aimat=self.TargetCoord --Core.Point#COORDINATE
|
||||
aimat.y=aimat.y+1+math.random(-100,100)/100
|
||||
aimat.x=aimat.x+math.random(-100,100)/100
|
||||
|
||||
self.SpotIR:setPoint(aimat:GetVec3())
|
||||
self.SpotLaser:setPoint(self.TargetCoord:GetVec3())
|
||||
|
||||
self:__Lasing( -0.2 )
|
||||
else
|
||||
self:F( { "Target is not alive", self.Target:IsAlive() } )
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -541,7 +541,8 @@ do -- DETECTION_BASE
|
||||
|
||||
end
|
||||
|
||||
self.DetectionCount = self.DetectionSet:Count()
|
||||
-- Count alive(!) groups only. Solves issue #1173 https://github.com/FlightControl-Master/MOOSE/issues/1173
|
||||
self.DetectionCount = self.DetectionSet:CountAlive()
|
||||
|
||||
self.DetectionSet:ForEachGroupAlive(
|
||||
function( DetectionGroup )
|
||||
|
||||
@ -77,6 +77,8 @@
|
||||
-- @field #boolean safeparking If true, parking spots for aircraft are considered as occupied if e.g. a client aircraft is parked there. Default false.
|
||||
-- @field #boolean isunit If true, warehouse is represented by a unit instead of a static.
|
||||
-- @field #number lowfuelthresh Low fuel threshold. Triggers the event AssetLowFuel if for any unit fuel goes below this number.
|
||||
-- @field #boolean respawnafterdestroyed If true, warehouse is respawned after it was destroyed. Assets are kept.
|
||||
-- @field #number respawndelay Delay before respawn in seconds.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- Have your assets at the right place at the right time - or not!
|
||||
@ -1569,6 +1571,8 @@ WAREHOUSE = {
|
||||
saveparking = false,
|
||||
isunit = false,
|
||||
lowfuelthresh = 0.15,
|
||||
respawnafterdestroyed=false,
|
||||
respawndelay = nil,
|
||||
}
|
||||
|
||||
--- Item of the warehouse stock table.
|
||||
@ -1634,11 +1638,13 @@ WAREHOUSE = {
|
||||
-- @field #string UNITTYPE Typename of the DCS unit, e.g. "A-10C".
|
||||
-- @field #string ATTRIBUTE Generalized attribute @{#WAREHOUSE.Attribute}.
|
||||
-- @field #string CATEGORY Asset category of type DCS#Group.Category, i.e. GROUND, AIRPLANE, HELICOPTER, SHIP, TRAIN.
|
||||
-- @field #string ASSIGNMENT Assignment of asset when it was added.
|
||||
WAREHOUSE.Descriptor = {
|
||||
GROUPNAME="templatename",
|
||||
UNITTYPE="unittype",
|
||||
ATTRIBUTE="attribute",
|
||||
CATEGORY="category",
|
||||
ASSIGNMENT="assignment",
|
||||
}
|
||||
|
||||
--- Generalized asset attributes. Can be used to request assets with certain general characteristics. See [DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes) on hoggit.
|
||||
@ -1743,7 +1749,7 @@ _WAREHOUSEDB = {
|
||||
|
||||
--- Warehouse class version.
|
||||
-- @field #string version
|
||||
WAREHOUSE.version="0.9.2"
|
||||
WAREHOUSE.version="0.9.5"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO: Warehouse todo list.
|
||||
@ -1906,6 +1912,7 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
self:AddTransition("*", "AirbaseRecaptured", "*") -- Airbase was re-captured from other coalition.
|
||||
self:AddTransition("*", "AssetDead", "*") -- An asset group died.
|
||||
self:AddTransition("*", "Destroyed", "Destroyed") -- Warehouse was destroyed. All assets in stock are gone and warehouse is stopped.
|
||||
self:AddTransition("Destroyed", "Respawn", "Running") -- Respawn warehouse after it was destroyed.
|
||||
|
||||
------------------------
|
||||
--- Pseudo Functions ---
|
||||
@ -1938,6 +1945,22 @@ function WAREHOUSE:New(warehouse, alias)
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
--- Triggers the FSM event "Respawn".
|
||||
-- @function [parent=#WAREHOUSE] Respawn
|
||||
-- @param #WAREHOUSE self
|
||||
|
||||
--- Triggers the FSM event "Respawn" after a delay.
|
||||
-- @function [parent=#WAREHOUSE] __Respawn
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #number delay Delay in seconds.
|
||||
|
||||
--- On after "Respawn" event user function.
|
||||
-- @function [parent=#WAREHOUSE] OnAfterRespawn
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
|
||||
--- Triggers the FSM event "Pause". Pauses the warehouse. Assets can still be added and requests be made. However, requests are not processed.
|
||||
-- @function [parent=#WAREHOUSE] Pause
|
||||
-- @param #WAREHOUSE self
|
||||
@ -2531,6 +2554,15 @@ function WAREHOUSE:SetSaveOnMissionEnd(path, filename)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set respawn after destroy.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @return #WAREHOUSE self
|
||||
function WAREHOUSE:SetRespawnAfterDestroyed(delay)
|
||||
self.respawnafterdestroyed=true
|
||||
self.respawndelay=delay
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set the airbase belonging to this warehouse.
|
||||
-- Note that it has to be of the same coalition as the warehouse.
|
||||
@ -3684,7 +3716,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
||||
self:_DebugMessage(string.format("Warehouse %s: Adding %d NEW assets of group %s to stock.", self.alias, n, tostring(group:GetName())), 5)
|
||||
|
||||
-- This is a group that is not in the db yet. Add it n times.
|
||||
local assets=self:_RegisterAsset(group, n, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill)
|
||||
local assets=self:_RegisterAsset(group, n, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill, assignment)
|
||||
|
||||
-- Add created assets to stock of this warehouse.
|
||||
for _,asset in pairs(assets) do
|
||||
@ -3720,8 +3752,9 @@ end
|
||||
-- @param #number loadradius Radius in meters when cargo is loaded into the carrier.
|
||||
-- @param #table liveries Table of liveries.
|
||||
-- @param DCS#AI.Skill skill Skill of AI.
|
||||
-- @param #string assignment Assignment attached to the asset item.
|
||||
-- @return #table A table containing all registered assets.
|
||||
function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill)
|
||||
function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay, forceweight, loadradius, liveries, skill, assignment)
|
||||
self:F({groupname=group:GetName(), ngroups=ngroups, forceattribute=forceattribute, forcecargobay=forcecargobay, forceweight=forceweight})
|
||||
|
||||
-- Set default.
|
||||
@ -3823,6 +3856,7 @@ function WAREHOUSE:_RegisterAsset(group, ngroups, forceattribute, forcecargobay,
|
||||
asset.livery=liveries[math.random(#liveries)]
|
||||
end
|
||||
asset.skill=skill
|
||||
asset.assignment=assignment
|
||||
|
||||
if i==1 then
|
||||
self:_AssetItemInfo(asset)
|
||||
@ -3937,8 +3971,15 @@ function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescripto
|
||||
okay=false
|
||||
end
|
||||
|
||||
elseif AssetDescriptor==WAREHOUSE.Descriptor.ASSIGNMENT then
|
||||
|
||||
if type(AssetDescriptorValue)~="string" then
|
||||
self:_ErrorMessage("ERROR: Invalid request. Asset assignment type must be passed as a string!", 5)
|
||||
okay=false
|
||||
end
|
||||
|
||||
else
|
||||
self:_ErrorMessage("ERROR: Invalid request. Asset descriptor is not ATTRIBUTE, CATEGORY, GROUPNAME or UNITTYPE!", 5)
|
||||
self:_ErrorMessage("ERROR: Invalid request. Asset descriptor is not ATTRIBUTE, CATEGORY, GROUPNAME, UNITTYPE or ASSIGNMENT!", 5)
|
||||
okay=false
|
||||
end
|
||||
|
||||
@ -3949,7 +3990,7 @@ function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescripto
|
||||
end
|
||||
|
||||
-- Warehouse is destroyed?
|
||||
if self:IsDestroyed() then
|
||||
if self:IsDestroyed() and not self.respawnafterdestroyed then
|
||||
self:_ErrorMessage("ERROR: Invalid request. Warehouse is destroyed!", 0)
|
||||
okay=false
|
||||
end
|
||||
@ -4816,6 +4857,21 @@ function WAREHOUSE:onbeforeChangeCountry(From, Event, To, Country)
|
||||
return false
|
||||
end
|
||||
|
||||
--- Respawn warehouse.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string From From state.
|
||||
-- @param #string Event Event.
|
||||
-- @param #string To To state.
|
||||
function WAREHOUSE:onafterRespawn(From, Event, To)
|
||||
|
||||
-- Info message.
|
||||
local text=string.format("Respawning warehouse %s.", self.alias)
|
||||
self:_InfoMessage(text)
|
||||
|
||||
-- Respawn warehouse.
|
||||
self.warehouse:ReSpawn()
|
||||
|
||||
end
|
||||
|
||||
--- On after "ChangeCountry" event. Warehouse is respawned with the specified country. All queued requests are deleted and the owned airbase is reset if the coalition is changed by changing the
|
||||
-- country.
|
||||
@ -4952,22 +5008,34 @@ end
|
||||
function WAREHOUSE:onafterDestroyed(From, Event, To)
|
||||
|
||||
-- Message.
|
||||
local text=string.format("Warehouse %s was destroyed! Assets lost %d.", self.alias, #self.stock)
|
||||
local text=string.format("Warehouse %s was destroyed! Assets lost %d. Respawn=%s", self.alias, #self.stock, tostring(self.respawnafterdestroyed))
|
||||
self:_InfoMessage(text)
|
||||
|
||||
-- Remove all table entries from waiting queue and stock.
|
||||
for k,_ in pairs(self.queue) do
|
||||
self.queue[k]=nil
|
||||
if self.respawnafterdestroyed then
|
||||
|
||||
if self.respawndelay then
|
||||
self:Pause()
|
||||
self:__Respawn(self.respawndelay)
|
||||
else
|
||||
self:Respawn()
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- Remove all table entries from waiting queue and stock.
|
||||
for k,_ in pairs(self.queue) do
|
||||
self.queue[k]=nil
|
||||
end
|
||||
for k,_ in pairs(self.stock) do
|
||||
self.stock[k]=nil
|
||||
end
|
||||
|
||||
--self.queue=nil
|
||||
--self.queue={}
|
||||
|
||||
--self.stock=nil
|
||||
--self.stock={}
|
||||
end
|
||||
for k,_ in pairs(self.stock) do
|
||||
self.stock[k]=nil
|
||||
end
|
||||
|
||||
--self.queue=nil
|
||||
--self.queue={}
|
||||
|
||||
--self.stock=nil
|
||||
--self.stock={}
|
||||
|
||||
end
|
||||
|
||||
@ -6332,7 +6400,7 @@ function WAREHOUSE:_CheckRequestConsistancy(queue)
|
||||
end
|
||||
|
||||
-- Is receiving warehouse destroyed?
|
||||
if request.warehouse:IsDestroyed() then
|
||||
if request.warehouse:IsDestroyed() and not self.respawnafterdestroyed then
|
||||
self:E(self.wid..string.format("ERROR: INVALID request. Requesting warehouse is destroyed!"))
|
||||
valid=false
|
||||
end
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
-- * Advanced F10 radio menu including carrier info, weather, radio frequencies, TACAN/ICLS channels, player LSO grades, marking of zones etc.
|
||||
-- * Recovery tanker and refueling option via integration of @{Ops.RecoveryTanker} class.
|
||||
-- * Rescue helicopter option via @{Ops.RescueHelo} class.
|
||||
-- * Combine multiple human players to sections (WIP).
|
||||
-- * Combine multiple human players to sections.
|
||||
-- * Many parameters customizable by convenient user API functions.
|
||||
-- * Multiple carrier support due to object oriented approach.
|
||||
-- * Unlimited number of players.
|
||||
@ -32,7 +32,7 @@
|
||||
-- **Supported Aircraft:**
|
||||
--
|
||||
-- * [F/A-18C Hornet Lot 20](https://forums.eagle.ru/forumdisplay.php?f=557) (Player & AI)
|
||||
-- * [F-14B Tomcat](https://forums.eagle.ru/forumdisplay.php?f=395) (Player & AI) [**WIP**]
|
||||
-- * [F-14B Tomcat](https://forums.eagle.ru/forumdisplay.php?f=395) (Player & AI)
|
||||
-- * [A-4E Skyhawk Community Mod](https://forums.eagle.ru/showthread.php?t=224989) (Player & AI)
|
||||
-- * [AV-8B N/A Harrier](https://forums.eagle.ru/forumdisplay.php?f=555) (Player & AI) [**WIP**]
|
||||
-- * F/A-18C Hornet (AI)
|
||||
@ -46,10 +46,8 @@
|
||||
-- the no other fixed wing aircraft (human or AI controlled) are supposed to land on the Tarawa. Currently only Case I is supported. Case II/III take slightly steps from the CVN carrier.
|
||||
-- However, the two Case II/III pattern are very similar so this is not a big drawback.
|
||||
--
|
||||
-- Heatblur's mighty F-14B Tomcat has just been added (March 13th 2019). Beware that this is currently WIP - both the module and the AIRBOSS implementation.
|
||||
-- Heatblur's mighty F-14B Tomcat has been added (March 13th 2019) as well.
|
||||
--
|
||||
-- **PLEASE NOTE** that his class is work in progress. Many/most things work already very nicely but there a lot of cases I did not run into yet.
|
||||
-- Therefore, your *constructive* feedback is both necessary and appreciated!
|
||||
--
|
||||
-- ## Discussion
|
||||
--
|
||||
@ -174,7 +172,6 @@
|
||||
-- @field #number NmaxStack Number of max flights per stack. Default 2.
|
||||
-- @field #boolean handleai If true (default), handle AI aircraft.
|
||||
-- @field Ops.RecoveryTanker#RECOVERYTANKER tanker Recovery tanker flying overhead of carrier.
|
||||
-- @field Functional.Warehouse#WAREHOUSE warehouse Warehouse object of the carrier.
|
||||
-- @field DCS#Vec3 Corientation Carrier orientation in space.
|
||||
-- @field DCS#Vec3 Corientlast Last known carrier orientation.
|
||||
-- @field Core.Point#COORDINATE Cposition Carrier position.
|
||||
@ -1182,7 +1179,6 @@ AIRBOSS = {
|
||||
NmaxStack = nil,
|
||||
handleai = nil,
|
||||
tanker = nil,
|
||||
warehouse = nil,
|
||||
Corientation = nil,
|
||||
Corientlast = nil,
|
||||
Cposition = nil,
|
||||
@ -1685,7 +1681,7 @@ AIRBOSS.MenuF10Root=nil
|
||||
|
||||
--- Airboss class version.
|
||||
-- @field #string version
|
||||
AIRBOSS.version="1.0.2"
|
||||
AIRBOSS.version="1.0.3"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -1802,6 +1798,15 @@ function AIRBOSS:New(carriername, alias)
|
||||
|
||||
-- Init player scores table.
|
||||
self.playerscores={}
|
||||
|
||||
-- Initialize ME waypoints.
|
||||
self:_InitWaypoints()
|
||||
|
||||
-- Current waypoint.
|
||||
self.currentwp=1
|
||||
|
||||
-- Patrol route.
|
||||
self:_PatrolRoute()
|
||||
|
||||
-------------
|
||||
--- Defaults:
|
||||
@ -2432,6 +2437,19 @@ function AIRBOSS:SetExcludeAI(setgroup)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add a group to the exclude set. If no set exists, it is created.
|
||||
-- @param #AIRBOSS self
|
||||
-- @param Wrapper.Group#GROUP group The group to be excluded.
|
||||
-- @return #AIRBOSS self
|
||||
function AIRBOSS:AddExcludeAI(group)
|
||||
|
||||
self.excludesetAI=self.excludesetAI or SET_GROUP:New()
|
||||
|
||||
self.excludesetAI:AddGroup(group)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Close currently running recovery window and stop recovery ops. Recovery window is deleted.
|
||||
-- @param #AIRBOSS self
|
||||
-- @param #number delay (Optional) Delay in seconds before the window is deleted.
|
||||
@ -3044,15 +3062,6 @@ function AIRBOSS:SetRecoveryTanker(recoverytanker)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Define warehouse associated with the carrier.
|
||||
-- @param #AIRBOSS self
|
||||
-- @param Functional.Warehouse#WAREHOUSE warehouse Warehouse object of the carrier.
|
||||
-- @return #AIRBOSS self
|
||||
function AIRBOSS:SetWarehouse(warehouse)
|
||||
self.warehouse=warehouse
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set default player skill. New players will be initialized with this skill.
|
||||
--
|
||||
-- * "Flight Student" = @{#AIRBOSS.Difficulty.Easy}
|
||||
@ -3202,9 +3211,6 @@ function AIRBOSS:onafterStart(From, Event, To)
|
||||
self.Corientlast=self.Corientation
|
||||
self.Tpupdate=timer.getTime()
|
||||
|
||||
-- Init patrol route of carrier.
|
||||
self:_PatrolRoute(1)
|
||||
|
||||
-- Check if no recovery window is set. DISABLED!
|
||||
if #self.recoverytimes==0 and false then
|
||||
|
||||
@ -3232,9 +3238,6 @@ function AIRBOSS:onafterStart(From, Event, To)
|
||||
self:HandleEvent(EVENTS.PlayerLeaveUnit, self._PlayerLeft)
|
||||
self:HandleEvent(EVENTS.MissionEnd)
|
||||
|
||||
-- DCS event handler.
|
||||
--world.addEventHandler(self)
|
||||
|
||||
-- Start status check in 1 second.
|
||||
self:__Status(1)
|
||||
end
|
||||
@ -3617,15 +3620,31 @@ function AIRBOSS:_CheckRecoveryTimes()
|
||||
|
||||
if self:IsRecovering() and not recovery.OVER then
|
||||
|
||||
-- Set carrier to idle.
|
||||
self:RecoveryStop()
|
||||
state="closing now"
|
||||
-- Get number of airborne aircraft units(!) currently in pattern.
|
||||
local _,npattern=self:_GetQueueInfo(self.Qpattern)
|
||||
|
||||
if npattern>0 then
|
||||
|
||||
-- Extend recovery time. 5 min per flight.
|
||||
local extmin=5*npattern
|
||||
recovery.STOP=recovery.STOP+extmin*60
|
||||
|
||||
local text=string.format("We still got flights in the pattern.\nRecovery time prolonged by %d minutes.\nNow get your act together and no more bolters!", extmin)
|
||||
self:MessageToPattern(text, "AIRBOSS", "99", 10, false, nil)
|
||||
|
||||
-- Closed.
|
||||
recovery.OPEN=false
|
||||
else
|
||||
|
||||
-- Set carrier to idle.
|
||||
self:RecoveryStop()
|
||||
state="closing now"
|
||||
|
||||
-- Closed.
|
||||
recovery.OPEN=false
|
||||
|
||||
-- Window just closed.
|
||||
recovery.OVER=true
|
||||
|
||||
-- Window just closed.
|
||||
recovery.OVER=true
|
||||
end
|
||||
else
|
||||
|
||||
-- Carrier is already idle.
|
||||
@ -3689,10 +3708,11 @@ function AIRBOSS:_CheckRecoveryTimes()
|
||||
|
||||
--Debug info
|
||||
self:T(self.lid..string.format("Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s", hdg, wind,UTILS.MpsToKnots(vwind), delta, tostring(uturn)))
|
||||
|
||||
-- Time into the wind 1 day or if longer recovery time + the 5 min early.
|
||||
local t=math.max(nextwindow.STOP-nextwindow.START+300, 60*60*24)
|
||||
|
||||
|
||||
-- Time into the wind + the 5 min early.
|
||||
local t=nextwindow.STOP-nextwindow.START+300
|
||||
-- Recovery wind on deck in knots.
|
||||
local v=UTILS.KnotsToMps(nextwindow.SPEED)
|
||||
|
||||
-- Check that we do not go above max possible speed.
|
||||
@ -13206,6 +13226,42 @@ function AIRBOSS:_GetNextWaypoint()
|
||||
return nextwp,Nextwp
|
||||
end
|
||||
|
||||
|
||||
--- Initialize Mission Editor waypoints.
|
||||
-- @param #AIRBOSS self
|
||||
-- @return #AIRBOSS self
|
||||
function AIRBOSS:_InitWaypoints()
|
||||
|
||||
-- Waypoints of group as defined in the ME.
|
||||
local Waypoints=self.carrier:GetGroup():GetTemplateRoutePoints()
|
||||
|
||||
-- Init array.
|
||||
self.waypoints={}
|
||||
|
||||
-- Set waypoint table.
|
||||
for i,point in ipairs(Waypoints) do
|
||||
|
||||
-- Coordinate of the waypoint
|
||||
local coord=COORDINATE:New(point.x, point.alt, point.y)
|
||||
|
||||
-- Set velocity of the coordinate.
|
||||
coord:SetVelocity(point.speed)
|
||||
|
||||
-- Add to table.
|
||||
table.insert(self.waypoints, coord)
|
||||
|
||||
-- Debug info.
|
||||
if self.Debug then
|
||||
coord:MarkToAll(string.format("Carrier Waypoint %d, Speed=%.1f knots", i, UTILS.MpsToKnots(point.speed)))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
--- Patrol carrier.
|
||||
-- @param #AIRBOSS self
|
||||
-- @param #number n Current waypoint.
|
||||
@ -13259,6 +13315,58 @@ function AIRBOSS:_PatrolRoute(n)
|
||||
return self
|
||||
end
|
||||
|
||||
]]
|
||||
|
||||
--- Patrol carrier.
|
||||
-- @param #AIRBOSS self
|
||||
-- @param #number n Next waypoint number.
|
||||
-- @return #AIRBOSS self
|
||||
function AIRBOSS:_PatrolRoute(n)
|
||||
|
||||
-- Get next waypoint coordinate and number.
|
||||
local nextWP, N=self:_GetNextWaypoint()
|
||||
|
||||
-- Default resume is to next waypoint.
|
||||
n=n or N
|
||||
|
||||
-- Get carrier group.
|
||||
local CarrierGroup=self.carrier:GetGroup()
|
||||
|
||||
-- Waypoints table.
|
||||
local Waypoints={}
|
||||
|
||||
-- Create a waypoint from the current coordinate.
|
||||
local wp=self:GetCoordinate():WaypointGround(CarrierGroup:GetVelocityKMH())
|
||||
|
||||
-- Add current position as first waypoint.
|
||||
table.insert(Waypoints, wp)
|
||||
|
||||
-- Loop over waypoints.
|
||||
for i=n,#self.waypoints do
|
||||
local coord=self.waypoints[i] --Core.Point#COORDINATE
|
||||
|
||||
-- Create a waypoint from the coordinate.
|
||||
local wp=coord:WaypointGround(UTILS.MpsToKmph(coord.Velocity))
|
||||
|
||||
-- Passing waypoint taskfunction
|
||||
local TaskPassingWP=CarrierGroup:TaskFunction("AIRBOSS._PassingWaypoint", self, i, #self.waypoints)
|
||||
|
||||
-- Call task function when carrier arrives at waypoint.
|
||||
CarrierGroup:SetTaskWaypoint(wp, TaskPassingWP)
|
||||
|
||||
-- Add waypoint to table.
|
||||
table.insert(Waypoints, wp)
|
||||
end
|
||||
|
||||
-- Route carrier group.
|
||||
CarrierGroup:Route(Waypoints)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--- Estimated the carrier position at some point in the future given the current waypoints and speeds.
|
||||
-- @param #AIRBOSS self
|
||||
-- @return DCS#time ETA abs. time in seconds.
|
||||
@ -13484,7 +13592,7 @@ function AIRBOSS._PassingWaypoint(group, airboss, i, final)
|
||||
|
||||
-- If final waypoint reached, do route all over again.
|
||||
if i==final and final>1 and airboss.adinfinitum then
|
||||
airboss:_PatrolRoute(i)
|
||||
airboss:_PatrolRoute()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -553,14 +553,14 @@ function AIRBASE:GetParkingSpotsTable(termtype)
|
||||
local spots={}
|
||||
for _,_spot in pairs(parkingdata) do
|
||||
if AIRBASE._CheckTerminalType(_spot.Term_Type, termtype) then
|
||||
self:I({_spot=_spot})
|
||||
self:T2({_spot=_spot})
|
||||
local _free=_isfree(_spot)
|
||||
local _coord=COORDINATE:NewFromVec3(_spot.vTerminalPos)
|
||||
table.insert(spots, {Coordinate=_coord, TerminalID=_spot.Term_Index, TerminalType=_spot.Term_Type, TOAC=_spot.TO_AC, Free=_free, TerminalID0=_spot.Term_Index_0, DistToRwy=_spot.fDistToRW})
|
||||
end
|
||||
end
|
||||
|
||||
self:I({ spots = spots } )
|
||||
self:T2({ spots = spots } )
|
||||
|
||||
return spots
|
||||
end
|
||||
@ -711,7 +711,7 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
||||
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
||||
local _termid=parkingspot.TerminalID
|
||||
|
||||
self:I({_termid=_termid})
|
||||
self:T2({_termid=_termid})
|
||||
|
||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) then
|
||||
|
||||
|
||||
@ -1388,7 +1388,7 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType )
|
||||
DCSTask = { id = 'FireAtPoint',
|
||||
params = {
|
||||
point = Vec2,
|
||||
radius = Radius,
|
||||
zoneRadius = Radius,
|
||||
expendQty = 100, -- dummy value
|
||||
expendQtyEnabled = false,
|
||||
}
|
||||
@ -3165,7 +3165,8 @@ function CONTROLLABLE:OptionAlarmStateAuto()
|
||||
if self:IsGround() then
|
||||
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.AUTO)
|
||||
elseif self:IsShip() then
|
||||
Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO)
|
||||
--Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.AUTO)
|
||||
Controller:setOption(9, 0)
|
||||
end
|
||||
|
||||
return self
|
||||
@ -3189,6 +3190,7 @@ function CONTROLLABLE:OptionAlarmStateGreen()
|
||||
elseif self:IsShip() then
|
||||
-- AI.Option.Naval.id.ALARM_STATE does not seem to exist!
|
||||
--Controller:setOption( AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.GREEN )
|
||||
Controller:setOption(9, 1)
|
||||
end
|
||||
|
||||
return self
|
||||
@ -3210,7 +3212,8 @@ function CONTROLLABLE:OptionAlarmStateRed()
|
||||
if self:IsGround() then
|
||||
Controller:setOption(AI.Option.Ground.id.ALARM_STATE, AI.Option.Ground.val.ALARM_STATE.RED)
|
||||
elseif self:IsShip() then
|
||||
Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED)
|
||||
--Controller:setOption(AI.Option.Naval.id.ALARM_STATE, AI.Option.Naval.val.ALARM_STATE.RED)
|
||||
Controller:setOption(9, 2)
|
||||
end
|
||||
|
||||
return self
|
||||
|
||||
@ -1184,6 +1184,24 @@ function POSITIONABLE:LaseUnit( Target, LaserCode, Duration ) --R2.1
|
||||
|
||||
end
|
||||
|
||||
--- Start Lasing a COORDINATE.
|
||||
-- @param #POSITIONABLE self
|
||||
-- @param Core.Point#COORDIUNATE Coordinate The coordinate where the lase is pointing at.
|
||||
-- @param #number LaserCode Laser code or random number in [1000, 9999].
|
||||
-- @param #number Duration Duration of lasing in seconds.
|
||||
-- @return Core.Spot#SPOT
|
||||
function POSITIONABLE:LaseCoordinate(Coordinate, LaserCode, Duration)
|
||||
self:F2()
|
||||
|
||||
LaserCode = LaserCode or math.random(1000, 9999)
|
||||
|
||||
self.Spot = SPOT:New(self) -- Core.Spot#SPOT
|
||||
self.Spot:LaseOnCoordinate(Coordinate, LaserCode, Duration)
|
||||
self.LaserCode = LaserCode
|
||||
|
||||
return self.Spot
|
||||
end
|
||||
|
||||
--- Stop Lasing a POSITIONABLE
|
||||
-- @param #POSITIONABLE self
|
||||
-- @return #POSITIONABLE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user