diff --git a/Moose Development/Moose/AI/AI_Cargo_APC.lua b/Moose Development/Moose/AI/AI_Cargo_APC.lua index 2c76f2786..a69f0aa27 100644 --- a/Moose Development/Moose/AI/AI_Cargo_APC.lua +++ b/Moose Development/Moose/AI/AI_Cargo_APC.lua @@ -117,6 +117,7 @@ function AI_CARGO_APC:New( APC, CargoSet, CombatRadius ) -- @param #string Event -- @param #string To -- @param Core.Point#COORDINATE Coordinate + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. -- @return #boolean --- Pickup Handler OnAfter for AI_CARGO_APC @@ -126,17 +127,20 @@ function AI_CARGO_APC:New( APC, CargoSet, CombatRadius ) -- @param #string Event -- @param #string To -- @param Core.Point#COORDINATE Coordinate + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. --- Pickup Trigger for AI_CARGO_APC -- @function [parent=#AI_CARGO_APC] Pickup -- @param #AI_CARGO_APC self -- @param Core.Point#COORDINATE Coordinate + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. --- Pickup Asynchronous Trigger for AI_CARGO_APC -- @function [parent=#AI_CARGO_APC] __Pickup -- @param #AI_CARGO_APC self -- @param #number Delay -- @param Core.Point#COORDINATE Coordinate + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. --- Deploy Handler OnBefore for AI_CARGO_APC -- @function [parent=#AI_CARGO_APC] OnBeforeDeploy @@ -145,6 +149,7 @@ function AI_CARGO_APC:New( APC, CargoSet, CombatRadius ) -- @param #string Event -- @param #string To -- @param Core.Point#COORDINATE Coordinate + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. -- @return #boolean --- Deploy Handler OnAfter for AI_CARGO_APC @@ -154,17 +159,20 @@ function AI_CARGO_APC:New( APC, CargoSet, CombatRadius ) -- @param #string Event -- @param #string To -- @param Core.Point#COORDINATE Coordinate + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. --- Deploy Trigger for AI_CARGO_APC -- @function [parent=#AI_CARGO_APC] Deploy -- @param #AI_CARGO_APC self -- @param Core.Point#COORDINATE Coordinate + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. --- Deploy Asynchronous Trigger for AI_CARGO_APC -- @function [parent=#AI_CARGO_APC] __Deploy -- @param #AI_CARGO_APC self -- @param Core.Point#COORDINATE Coordinate -- @param #number Delay + -- @param #number Speed Speed in km/h. Default is 50% of max possible speed the group can do. --- Loaded Handler OnAfter for AI_CARGO_APC @@ -335,8 +343,12 @@ function AI_CARGO_APC:FollowToCarrier( Me, APCUnit, CargoGroup ) end ---- @param #AI_CARGO_APC self +--- On after Monitor event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. function AI_CARGO_APC:onafterMonitor( APC, From, Event, To ) self:F( { APC, From, Event, To } ) @@ -389,8 +401,12 @@ function AI_CARGO_APC:onafterMonitor( APC, From, Event, To ) end ---- @param #AI_CARGO_APC self +--- On before Load event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. function AI_CARGO_APC:onbeforeLoad( APC, From, Event, To ) self:F( { APC, From, Event, To } ) @@ -427,8 +443,13 @@ function AI_CARGO_APC:onbeforeLoad( APC, From, Event, To ) end ---- @param #AI_CARGO_APC self +--- On after Board event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param #string Cargo.Cargo#CARGO Cargo Cargo object. function AI_CARGO_APC:onafterBoard( APC, From, Event, To, Cargo ) self:F( { APC, From, Event, To, Cargo } ) @@ -443,8 +464,13 @@ function AI_CARGO_APC:onafterBoard( APC, From, Event, To, Cargo ) end ---- @param #AI_CARGO_APC self +--- On before Loaded event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @return #boolean Cargo loaded. function AI_CARGO_APC:onbeforeLoaded( APC, From, Event, To ) self:F( { APC, From, Event, To } ) @@ -470,8 +496,13 @@ function AI_CARGO_APC:onbeforeLoaded( APC, From, Event, To ) end ---- @param #AI_CARGO_APC self +--- On after Unload event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param #boolean Deployed Cargo is deployed. function AI_CARGO_APC:onafterUnload( APC, From, Event, To, Deployed ) self:F( { APC, From, Event, To, Deployed } ) @@ -488,8 +519,14 @@ function AI_CARGO_APC:onafterUnload( APC, From, Event, To, Deployed ) end ---- @param #AI_CARGO_APC self +--- On after Unboard event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param #string Cargo.Cargo#CARGO Cargo Cargo object. +-- @param #boolean Deployed Cargo is deployed. function AI_CARGO_APC:onafterUnboard( APC, From, Event, To, Cargo, Deployed ) self:F( { APC, From, Event, To, Cargo:GetName() } ) @@ -503,8 +540,15 @@ function AI_CARGO_APC:onafterUnboard( APC, From, Event, To, Cargo, Deployed ) end ---- @param #AI_CARGO_APC self +--- On before Unloaded event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param #string Cargo.Cargo#CARGO Cargo Cargo object. +-- @param #boolean Deployed Cargo is deployed. +-- @return #boolean All cargo unloaded. function AI_CARGO_APC:onbeforeUnloaded( APC, From, Event, To, Cargo, Deployed ) self:F( { APC, From, Event, To, Cargo:GetName(), Deployed = Deployed } ) @@ -544,8 +588,12 @@ function AI_CARGO_APC:onbeforeUnloaded( APC, From, Event, To, Cargo, Deployed ) end ---- @param #AI_CARGO_APC self +--- On after Follow event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. function AI_CARGO_APC:onafterFollow( APC, From, Event, To ) self:F( { APC, From, Event, To } ) @@ -591,7 +639,8 @@ end ---- @param #AI_CARGO_APC self +--- On after Pickup event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC -- @param From -- @param Event @@ -626,13 +675,14 @@ function AI_CARGO_APC:onafterPickup( APC, From, Event, To, Coordinate, Speed ) end ---- @param #AI_CARGO_APC self +--- On after Deploy event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC -- @param From -- @param Event -- @param To --- @param Core.Point#COORDINATE Coordinate --- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go. +-- @param Core.Point#COORDINATE Coordinate Deploy place. +-- @param #number Speed Speed in km/h to drive to the depoly coordinate. Default is 50% of max possible speed the unit can go. function AI_CARGO_APC:onafterDeploy( APC, From, Event, To, Coordinate, Speed ) if APC and APC:IsAlive() then @@ -655,12 +705,13 @@ function AI_CARGO_APC:onafterDeploy( APC, From, Event, To, Coordinate, Speed ) end ---- @param #AI_CARGO_APC self +--- On after Home event. +-- @param #AI_CARGO_APC self -- @param Wrapper.Group#GROUP APC -- @param From -- @param Event -- @param To --- @param Core.Point#COORDINATE Coordinate +-- @param Core.Point#COORDINATE Coordinate Home place. -- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go. function AI_CARGO_APC:onafterHome( APC, From, Event, To, Coordinate, Speed ) diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher.lua index 6bce0816e..688bbd759 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher.lua @@ -90,7 +90,7 @@ AI_CARGO_DISPATCHER.PickupCargo = {} -- @param #AI_CARGO_DISPATCHER self -- @param Core.Set#SET_GROUP SetCarrier -- @param Core.Set#SET_CARGO SetCargo --- @param Core.Set#SET_ZONE SetDeployZone +-- @param Core.Set#SET_ZONE SetDeployZones -- @return #AI_CARGO_DISPATCHER -- @usage -- @@ -434,11 +434,11 @@ end --- Loaded Handler OnAfter for AI_CARGO_DISPATCHER -- @function [parent=#AI_CARGO_DISPATCHER] OnAfterLoaded -- @param #AI_CARGO_DISPATCHER self --- @param #string From --- @param #string Event --- @param #string To --- @param Wrapper.Group#GROUP Carrier --- @param Cargo.Cargo#CARGO Cargo +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Wrapper.Group#GROUP Carrier Carrier object. +-- @param Cargo.Cargo#CARGO Cargo Cargo object. --- Unloaded Handler OnAfter for AI_CARGO_DISPATCHER -- @function [parent=#AI_CARGO_DISPATCHER] OnAfterUnloaded diff --git a/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua b/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua index 139af0e16..7a272178a 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua @@ -200,8 +200,6 @@ end -- @param From -- @param Event -- @param To --- @param Core.Point#COORDINATE Coordinate --- @param #number Speed function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To ) Helicopter:F( { Name = Helicopter:GetName() } ) @@ -245,7 +243,7 @@ end -- @param To -- @param Core.Point#COORDINATE Coordinate -- @param #number Speed -function AI_CARGO_HELICOPTER:onafterQueue( Helicopter, From, Event, To, Coordinate ) +function AI_CARGO_HELICOPTER:onafterQueue( Helicopter, From, Event, To, Coordinate, Speed ) local HelicopterInZone = false @@ -359,10 +357,13 @@ function AI_CARGO_HELICOPTER:onafterOrbit( Helicopter, From, Event, To, Coordina end - ---- @param #AI_CARGO_HELICOPTER self +--- On Before event Load. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter -function AI_CARGO_HELICOPTER:onbeforeLoad( Helicopter, From, Event, To, Coordinate ) +-- @param #string From From state. +-- @param #string Event Event +-- @param #string To To state. +function AI_CARGO_HELICOPTER:onbeforeLoad( Helicopter, From, Event, To) local Boarding = false @@ -400,10 +401,15 @@ function AI_CARGO_HELICOPTER:onbeforeLoad( Helicopter, From, Event, To, Coordina end ---- @param #AI_CARGO_HELICOPTER self +--- On after Board event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Cargo.Cargo#CARGO Cargo Cargo object. function AI_CARGO_HELICOPTER:onafterBoard( Helicopter, From, Event, To, Cargo ) - self:F( { APC, From, Event, To, Cargo } ) + self:F( { Helicopter, From, Event, To, Cargo } ) if Helicopter and Helicopter:IsAlive() then self:F({ IsLoaded = Cargo:IsLoaded() } ) @@ -416,10 +422,16 @@ function AI_CARGO_HELICOPTER:onafterBoard( Helicopter, From, Event, To, Cargo ) end ---- @param #AI_CARGO_HELICOPTER self +--- On before Land event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Cargo.Cargo#CARGO Cargo Cargo object. +-- @return #boolean Cargo is loaded. function AI_CARGO_HELICOPTER:onbeforeLoaded( Helicopter, From, Event, To, Cargo ) - self:F( { APC, From, Event, To } ) + self:F( { Helicopter, From, Event, To, Cargo } ) local Loaded = true @@ -439,8 +451,12 @@ function AI_CARGO_HELICOPTER:onbeforeLoaded( Helicopter, From, Event, To, Cargo end ---- @param #AI_CARGO_HELICOPTER self +--- On after Unload event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter +-- @param #string From From state. +-- @param #string Event Event. +-- @param #boolean Deployed Cargo is deployed. function AI_CARGO_HELICOPTER:onafterUnload( Helicopter, From, Event, To, Deployed ) if Helicopter and Helicopter:IsAlive() then @@ -457,8 +473,14 @@ function AI_CARGO_HELICOPTER:onafterUnload( Helicopter, From, Event, To, Deploye end ---- @param #AI_CARGO_HELICOPTER self +--- On after Unboard event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Cargo.Cargo#CARGO Cargo Cargo object. +-- @param #boolean Deployed Cargo is deployed. function AI_CARGO_HELICOPTER:onafterUnboard( Helicopter, From, Event, To, Cargo, Deployed ) if Helicopter and Helicopter:IsAlive() then @@ -471,8 +493,15 @@ function AI_CARGO_HELICOPTER:onafterUnboard( Helicopter, From, Event, To, Cargo, end ---- @param #AI_CARGO_HELICOPTER self +--- On before Unloaded event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Cargo.Cargo#CARGO Cargo Cargo object. +-- @param #boolean Deployed Cargo is deployed. +-- @return #boolean True if all cargo has been unloaded. function AI_CARGO_HELICOPTER:onbeforeUnloaded( Helicopter, From, Event, To, Cargo, Deployed ) self:F( { APC, From, Event, To, Cargo:GetName(), Deployed = Deployed } ) @@ -508,8 +537,14 @@ function AI_CARGO_HELICOPTER:onbeforeUnloaded( Helicopter, From, Event, To, Carg end ---- @param #AI_CARGO_HELICOPTER self +--- On after Unloaded event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param Cargo.Cargo#CARGO Cargo Cargo object. +-- @param #boolean Deployed Cargo is deployed. function AI_CARGO_HELICOPTER:onafterUnloaded( Helicopter, From, Event, To, Cargo, Deployed ) self:Orbit( Helicopter:GetCoordinate(), 50 ) @@ -523,12 +558,13 @@ function AI_CARGO_HELICOPTER:onafterUnloaded( Helicopter, From, Event, To, Cargo end ---- @param #AI_CARGO_HELICOPTER self +--- On after Pickup event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter -- @param From -- @param Event -- @param To --- @param Core.Point#COORDINATE Coordinate +-- @param Core.Point#COORDINATE Coordinate Pickup place. -- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go. function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordinate, Speed ) @@ -537,7 +573,7 @@ function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordin Helicopter:Activate() self.RoutePickup = true - Coordinate.y = math.random( 50, 200 ) + Coordinate.y = math.random( 50, 500 ) local _speed=Speed or Helicopter:GetSpeedMax()*0.5 @@ -586,12 +622,16 @@ function AI_CARGO_HELICOPTER:onafterPickup( Helicopter, From, Event, To, Coordin end - +--- Depoloy function and queue. +-- @param #AI_CARGO_HELICOPTER self +-- @param Wrapper.Group#GROUP AICargoHelicopter +-- @param Core.Point#COORDINATE Coordinate Coordinate function AI_CARGO_HELICOPTER:_Deploy( AICargoHelicopter, Coordinate ) AICargoHelicopter:__Queue( -10, Coordinate, 100 ) end ---- @param #AI_CARGO_HELICOPTER self +--- On after Deploy event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter -- @param From -- @param Event @@ -609,7 +649,7 @@ function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordin --- Calculate the target route point. - Coordinate.y = math.random( 50, 200 ) + Coordinate.y = math.random( 50, 500 ) local _speed=Speed or Helicopter:GetSpeedMax()*0.5 @@ -659,12 +699,13 @@ function AI_CARGO_HELICOPTER:onafterDeploy( Helicopter, From, Event, To, Coordin end ---- @param #AI_CARGO_HELICOPTER self +--- On after Home event. +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter -- @param From -- @param Event -- @param To --- @param Core.Point#COORDINATE Coordinate +-- @param Core.Point#COORDINATE Coordinate Home place. -- @param #number Speed Speed in km/h to drive to the pickup coordinate. Default is 50% of max possible speed the unit can go. function AI_CARGO_HELICOPTER:onafterHome( Helicopter, From, Event, To, Coordinate, Speed ) diff --git a/Moose Development/Moose/Cargo/CargoGroup.lua b/Moose Development/Moose/Cargo/CargoGroup.lua index 3fa26e9ab..459da2a0f 100644 --- a/Moose Development/Moose/Cargo/CargoGroup.lua +++ b/Moose Development/Moose/Cargo/CargoGroup.lua @@ -55,12 +55,12 @@ do -- CARGO_GROUP -- This make a new CARGO_GROUP from a @{Wrapper.Group} object. -- It will "ungroup" the group object within the sim, and will create a @{Set} of individual Unit objects. -- @param #CARGO_GROUP self - -- @param Wrapper.Group#GROUP CargoGroup - -- @param #string Type - -- @param #string Name - -- @param #number LoadRadius (optional) - -- @param #number NearRadius (optional) - -- @return #CARGO_GROUP + -- @param Wrapper.Group#GROUP CargoGroup Group to be transported as cargo. + -- @param #string Type Cargo type, e.g. "Infantry". This is the type used in SET_CARGO:New():FilterTypes("Infantry") to define the valid cargo groups of the set. + -- @param #string Name Some user defined name of the cargo group. + -- @param #number LoadRadius (optional) Distance in meters until which a cargo is loaded into the carrier. Cargo outside this radius has to be routed by other means to within the radius to be loaded. + -- @param #number NearRadius (optional) Once the units are within this radius of the carrier, they are actually loaded, i.e. disappear from the scene. + -- @return #CARGO_GROUP Cargo group object. function CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius ) local self = BASE:Inherit( self, CARGO_REPORTABLE:New( Type, Name, 0, LoadRadius ) ) -- #CARGO_GROUP self:F( { Type, Name, LoadRadius } ) diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua index b50f52ddb..1333a43da 100644 --- a/Moose Development/Moose/Core/Message.lua +++ b/Moose Development/Moose/Core/Message.lua @@ -161,6 +161,7 @@ end --- Sends a MESSAGE to a Client Group. Note that the Group needs to be defined within the ME with the skillset "Client" or "Player". -- @param #MESSAGE self -- @param Wrapper.Client#CLIENT Client is the Group of the Client. +-- @param Core.Settings#SETTINGS Settings Settings used to display the message. -- @return #MESSAGE -- @usage -- -- Send the 2 messages created with the @{New} method to the Client Group. @@ -200,8 +201,8 @@ end --- Sends a MESSAGE to a Group. -- @param #MESSAGE self --- @param Wrapper.Group#GROUP Group is the Group. --- @return #MESSAGE +-- @param Wrapper.Group#GROUP Group to which the message is displayed. +-- @return #MESSAGE Message object. function MESSAGE:ToGroup( Group, Settings ) self:F( Group.GroupName ) @@ -261,8 +262,9 @@ end --- Sends a MESSAGE to a Coalition. -- @param #MESSAGE self --- @param CoalitionSide needs to be filled out by the defined structure of the standard scripting engine @{coalition.side}. --- @return #MESSAGE +-- @param #DCS.coalition.side CoalitionSide @{#DCS.coalition.side} to which the message is displayed. +-- @param Core.Settings#SETTINGS Settings (Optional) Settings for message display. +-- @return #MESSAGE Message object. -- @usage -- -- Send a message created with the @{New} method to the RED coalition. -- MessageRED = MESSAGE:New( "To the RED Players: You receive a penalty because you've killed one of your own units", "Penalty", 25, "Score" ):ToCoalition( coalition.side.RED ) @@ -306,6 +308,7 @@ end --- Sends a MESSAGE to all players. -- @param #MESSAGE self +-- @param Core.Settings#Settings (Optional) Settings for message display -- @return #MESSAGE -- @usage -- -- Send a message created to all players. @@ -315,7 +318,7 @@ end -- or -- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", "End of Mission", 25, "Win" ) -- MessageAll:ToAll() -function MESSAGE:ToAll() +function MESSAGE:ToAll(Settings) self:F() if self.MessageType then diff --git a/Moose Development/Moose/DCS.lua b/Moose Development/Moose/DCS.lua index 0d40a523b..492d1d049 100644 --- a/Moose Development/Moose/DCS.lua +++ b/Moose Development/Moose/DCS.lua @@ -8,38 +8,89 @@ do -- world --- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world) -- @type world - -- @field #world.event event + -- @field #world.event event [https://wiki.hoggitworld.com/view/DCS_enum_world](https://wiki.hoggitworld.com/view/DCS_enum_world) + -- @field #world.BirthPlace BirthPlace The birthplace enumerator is used to define where an aircraft or helicopter has spawned in association with birth events. + -- @field #world.VolumeType VolumeType The volumeType enumerator defines the types of 3d geometery used within the [world.searchObjects](https://wiki.hoggitworld.com/view/DCS_func_searchObjects) function. + + --- The world singleton contains functions centered around two different but extremely useful functions. + -- * Events and event handlers are all governed within world. + -- * A number of functions to get information about the game world. + -- + -- See [https://wiki.hoggitworld.com/view/DCS_singleton_world](https://wiki.hoggitworld.com/view/DCS_singleton_world) + -- @field #world world + world = {} --- [https://wiki.hoggitworld.com/view/DCS_enum_world](https://wiki.hoggitworld.com/view/DCS_enum_world) -- @type world.event - -- @field S_EVENT_INVALID + -- @field S_EVENT_INVALID -- @field S_EVENT_SHOT [https://wiki.hoggitworld.com/view/DCS_event_shot](https://wiki.hoggitworld.com/view/DCS_event_shot) - -- @field S_EVENT_HIT - -- @field S_EVENT_TAKEOFF - -- @field S_EVENT_LAND - -- @field S_EVENT_CRASH - -- @field S_EVENT_EJECTION - -- @field S_EVENT_REFUELING - -- @field S_EVENT_DEAD - -- @field S_EVENT_PILOT_DEAD - -- @field S_EVENT_BASE_CAPTURED - -- @field S_EVENT_MISSION_START - -- @field S_EVENT_MISSION_END - -- @field S_EVENT_TOOK_CONTROL - -- @field S_EVENT_REFUELING_STOP - -- @field S_EVENT_BIRTH - -- @field S_EVENT_HUMAN_FAILURE - -- @field S_EVENT_ENGINE_STARTUP - -- @field S_EVENT_ENGINE_SHUTDOWN - -- @field S_EVENT_PLAYER_ENTER_UNIT - -- @field S_EVENT_PLAYER_LEAVE_UNIT - -- @field S_EVENT_PLAYER_COMMENT - -- @field S_EVENT_SHOOTING_START - -- @field S_EVENT_SHOOTING_END + -- @field S_EVENT_HIT [https://wiki.hoggitworld.com/view/DCS_event_hit](https://wiki.hoggitworld.com/view/DCS_event_hit) + -- @field S_EVENT_TAKEOFF [https://wiki.hoggitworld.com/view/DCS_event_takeoff](https://wiki.hoggitworld.com/view/DCS_event_takeoff) + -- @field S_EVENT_LAND [https://wiki.hoggitworld.com/view/DCS_event_land](https://wiki.hoggitworld.com/view/DCS_event_land) + -- @field S_EVENT_CRASH [https://wiki.hoggitworld.com/view/DCS_event_crash](https://wiki.hoggitworld.com/view/DCS_event_crash) + -- @field S_EVENT_EJECTION [https://wiki.hoggitworld.com/view/DCS_event_ejection](https://wiki.hoggitworld.com/view/DCS_event_ejection) + -- @field S_EVENT_REFUELING [https://wiki.hoggitworld.com/view/DCS_event_refueling](https://wiki.hoggitworld.com/view/DCS_event_refueling) + -- @field S_EVENT_DEAD [https://wiki.hoggitworld.com/view/DCS_event_dead](https://wiki.hoggitworld.com/view/DCS_event_dead) + -- @field S_EVENT_PILOT_DEAD [https://wiki.hoggitworld.com/view/DCS_event_pilot_dead](https://wiki.hoggitworld.com/view/DCS_event_pilot_dead) + -- @field S_EVENT_BASE_CAPTURED [https://wiki.hoggitworld.com/view/DCS_event_base_captured](https://wiki.hoggitworld.com/view/DCS_event_base_captured) + -- @field S_EVENT_MISSION_START [https://wiki.hoggitworld.com/view/DCS_event_mission_start](https://wiki.hoggitworld.com/view/DCS_event_mission_start) + -- @field S_EVENT_MISSION_END [https://wiki.hoggitworld.com/view/DCS_event_mission_end](https://wiki.hoggitworld.com/view/DCS_event_mission_end) + -- @field S_EVENT_TOOK_CONTROL + -- @field S_EVENT_REFUELING_STOP [https://wiki.hoggitworld.com/view/DCS_event_refueling_stop](https://wiki.hoggitworld.com/view/DCS_event_refueling_stop) + -- @field S_EVENT_BIRTH [https://wiki.hoggitworld.com/view/DCS_event_birth](https://wiki.hoggitworld.com/view/DCS_event_birth) + -- @field S_EVENT_HUMAN_FAILURE [https://wiki.hoggitworld.com/view/DCS_event_human_failure](https://wiki.hoggitworld.com/view/DCS_event_human_failure) + -- @field S_EVENT_ENGINE_STARTUP [https://wiki.hoggitworld.com/view/DCS_event_engine_startup](https://wiki.hoggitworld.com/view/DCS_event_engine_startup) + -- @field S_EVENT_ENGINE_SHUTDOWN [https://wiki.hoggitworld.com/view/DCS_event_engine_shutdown](https://wiki.hoggitworld.com/view/DCS_event_engine_shutdown) + -- @field S_EVENT_PLAYER_ENTER_UNIT [https://wiki.hoggitworld.com/view/DCS_event_player_enter_unit](https://wiki.hoggitworld.com/view/DCS_event_player_enter_unit) + -- @field S_EVENT_PLAYER_LEAVE_UNIT [https://wiki.hoggitworld.com/view/DCS_event_player_leave_unit](https://wiki.hoggitworld.com/view/DCS_event_player_leave_unit) + -- @field S_EVENT_PLAYER_COMMENT + -- @field S_EVENT_SHOOTING_START [https://wiki.hoggitworld.com/view/DCS_event_shooting_start](https://wiki.hoggitworld.com/view/DCS_event_shooting_start) + -- @field S_EVENT_SHOOTING_END [https://wiki.hoggitworld.com/view/DCS_event_shooting_end](https://wiki.hoggitworld.com/view/DCS_event_shooting_end) + -- @field S_EVENT_MARK ADDED [https://wiki.hoggitworld.com/view/DCS_event_mark_added](https://wiki.hoggitworld.com/view/DCS_event_mark_added) + -- @field S_EVENT_MARK CHANGE [https://wiki.hoggitworld.com/view/DCS_event_mark_change](https://wiki.hoggitworld.com/view/DCS_event_mark_change) + -- @field S_EVENT_MARK REMOVE [https://wiki.hoggitworld.com/view/DCS_event_mark_remove](https://wiki.hoggitworld.com/view/DCS_event_mark_remove) -- @field S_EVENT_MAX - world = {} --#world + --- The birthplace enumerator is used to define where an aircraft or helicopter has spawned in association with birth events. + -- @type world.BirthPlace + -- @field wsBirthPlace_Air + -- @field wsBirthPlace_RunWay + -- @field wsBirthPlace_Park + -- @field wsBirthPlace_Heliport_Hot + -- @field wsBirthPlace_Heliport_Cold + + --- The volumeType enumerator defines the types of 3d geometery used within the #world.searchObjects function. + -- @type world.VolumeType + -- @field SEGMENT + -- @field BOX + -- @field SPHERE + -- @field PYRAMID + + --- Adds a function as an event handler that executes whenever a simulator event occurs. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_addEventHandler). + -- @function [parent=#world] addEventHandler + -- @param #table handler Event handler table. + --- Removes the specified event handler from handling events. + -- @function [parent=#world] removeEventHandler + -- @param #table handler Event handler table. + + --- Returns a table of the single unit object in the game who's skill level is set as "Player". See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_getPlayer). + -- There is only a single player unit in a mission and in single player the user will always spawn into this unit automatically unless other client or Combined Arms slots are available. + -- @function [parent=#world] getPlayer + -- @return DCS#Unit + + --- Searches a defined volume of 3d space for the specified objects within it and then can run function on each returned object. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_searchObjects). + -- @function [parent=#world] searchObjects + -- @param #DCS.Object.Category objectcategory Category (can be a table) of objects to search. + -- @param #DCS word.VolumeType volume Shape of the search area/volume. + -- @param #ObjectSeachHandler handler A function that handles the search. + -- @param #table any Additional data. + -- @return #DCS.unit + + --- Returns a table of mark panels indexed numerically that are present within the mission. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_getMarkPanels) + -- @function [parent=#world] getMarkPanels + -- @return #table Table of marks. + end -- world @@ -48,7 +99,6 @@ do -- env --- [DCS Singleton env](https://wiki.hoggitworld.com/view/DCS_singleton_env) -- @type env - --- Add message to simulator log with caption "INFO". Message box is optional. -- @function [parent=#env] info -- @param #string message message string to add to log. @@ -68,6 +118,7 @@ do -- env -- @function [parent=#env] setErrorMessageBoxEnabled -- @param #boolean on if true message box appearance is enabled. + --- [DCS Singleton env](https://wiki.hoggitworld.com/view/DCS_singleton_env) env = {} --#env end -- env @@ -116,6 +167,7 @@ do -- timer -- @function [parent=#timer] removeFunction -- @param functionId Function identifier to remove from schedule + --- [DCS Singleton timer](https://wiki.hoggitworld.com/view/DCS_singleton_timer) timer = {} --#timer end @@ -145,6 +197,7 @@ do -- land -- @param #Vec2 point Point on the land. -- @return #land.SurfaceType + --- [DCS Singleton land](https://wiki.hoggitworld.com/view/DCS_singleton_land) land = {} --#land end -- land diff --git a/Moose Development/Moose/Functional/Artillery.lua b/Moose Development/Moose/Functional/Artillery.lua index 880b8d645..54cd4635a 100644 --- a/Moose Development/Moose/Functional/Artillery.lua +++ b/Moose Development/Moose/Functional/Artillery.lua @@ -65,6 +65,8 @@ -- @field #number IniGroupStrength Inital number of units in the ARTY group. -- @field #boolean IsArtillery If true, ARTY group has attribute "Artillery". This is automatically derived from the DCS descriptor table. -- @field #boolean ismobile If true, ARTY group can move. +-- @field #boolean iscargo If true, ARTY group is defined as possible cargo. If it is immobile, targets out of range are not deleted from the queue. +-- @field Cargo.CargoGroup#CARGO_GROUP cargogroup Cargo group object if ARTY group is a cargo that will be transported to another place. -- @field #string groupname Name of the ARTY group as defined in the mission editor. -- @field #string alias Name of the ARTY group. -- @field #table clusters Table of names of clusters the group belongs to. Can be used to address all groups within the cluster simultaniously. @@ -417,7 +419,15 @@ -- -- Setting the rearming group is independent of the position of the mark. Just create one anywhere on the map and type -- arty set, battery "Mortar Bravo", rearming group "Ammo Truck M818" --- Note that the name of the rearming group has to be given in quotation marks and spellt exactly as the group name defined in the mission editor. +-- Note that the name of the rearming group has to be given in quotation marks and spellt exactly as the group name defined in the mission editor. +-- +-- ## Transporting +-- +-- ARTY groups can be transported to another location as @{Cargo.Cargo} by means of classes such as @{AI.AI_Cargo_APC}, @{AI.AI_Cargo_Dispatcher_APC}, +-- @{AI.AI_Cargo_Helicopter}, @{AI.AI_Cargo_Dispatcher_Helicopter} or @{AI.AI_Cargo_Airplane}. +-- +-- In order to do this, one needs to define an ARTY object via the @{#ARTY.NewFromCargoGroup}(*cargogroup*, *alias*) function. +-- The first argument *cargogroup* has to be a @{Cargo.CargoGroup#CARGO_GROUP} object. The second argument *alias* is a string which can be freely chosen by the user. -- -- ## Fine Tuning -- @@ -503,7 +513,25 @@ -- -- Start ARTY process. -- normandy:Start() -- --- +-- ### Transportation as Cargo +-- This example demonstates how an ARTY group can be transported to another location as cargo. +-- -- Define a group as CARGO_GROUP +-- CargoGroupMortars=CARGO_GROUP:New(GROUP:FindByName("Mortars"), "Mortars", "Mortar Platoon Alpha", 100 , 10) +-- +-- -- Define the mortar CARGO GROUP as ARTY object +-- mortars=ARTY:NewFromCargoGroup(CargoGroupMortars, "Mortar Platoon Alpha") +-- +-- -- Start ARTY process +-- mortars:Start() +-- +-- -- Setup AI cargo dispatcher for e.g. helos +-- SetHeloCarriers = SET_GROUP:New():FilterPrefixes("CH-47D"):FilterStart() +-- SetCargoMortars = SET_CARGO:New():FilterTypes("Mortars"):FilterStart() +-- SetZoneDepoly = SET_ZONE:New():FilterPrefixes("Deploy"):FilterStart() +-- CargoHelo=AI_CARGO_DISPATCHER_HELICOPTER:New(SetHeloCarriers, SetCargoMortars, SetZoneDepoly) +-- CargoHelo:Start() +-- The ARTY group will be transported and resume its normal operation after it has been deployed. New targets can be assigned at any time also during the transportation process. +-- -- @field #ARTY ARTY={ ClassName="ARTY", @@ -528,6 +556,8 @@ ARTY={ alias=nil, clusters={}, ismobile=true, + iscargo=false, + cargogroup=nil, IniGroupStrength=0, IsArtillery=nil, RearmingDistance=100, @@ -645,7 +675,7 @@ ARTY.id="ARTY | " --- Arty script version. -- @field #string version -ARTY.version="1.0.4" +ARTY.version="1.0.5" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -677,13 +707,43 @@ ARTY.version="1.0.4" --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Creates a new ARTY object. +--- Creates a new ARTY object from a MOOSE CARGO_GROUP object. +-- @param #ARTY self +-- @param Cargo.CargoGroup#CARGO_GROUP cargogroup The CARGO GROUP object for which artillery tasks should be assigned. +-- @param alias (Optional) Alias name the group will be calling itself when sending messages. Default is the group name. +-- @return #ARTY ARTY object or nil if group does not exist or is not a ground or naval group. +function ARTY:NewFromCargoGroup(cargogroup, alias) + BASE:F2({cargogroup=cargogroup, alias=alias}) + + if cargogroup then + BASE:T(ARTY.id..string.format("ARTY script version %s. Added CARGO group %s.", ARTY.version, cargogroup:GetName())) + else + BASE:E(ARTY.id.."ERROR: Requested ARTY CARGO GROUP does not exist! (Has to be a MOOSE CARGO(!) group.)") + return nil + end + + -- Get group belonging to the cargo group. + local group=cargogroup:GetObject() + + -- Create ARTY object. + local arty=ARTY:New(group,alias) + + -- Set iscargo flag. + arty.iscargo=true + + -- Set cargo group object. + arty.cargogroup=cargogroup + + return arty +end + +--- Creates a new ARTY object from a MOOSE group object. -- @param #ARTY self -- @param Wrapper.Group#GROUP group The GROUP object for which artillery tasks should be assigned. -- @param alias (Optional) Alias name the group will be calling itself when sending messages. Default is the group name. -- @return #ARTY ARTY object or nil if group does not exist or is not a ground or naval group. function ARTY:New(group, alias) - BASE:F2(group) + BASE:F2({group=group, alias=alias}) -- Inherits from FSM_CONTROLLABLE local self=BASE:Inherit(self, FSM_CONTROLLABLE:New()) -- #ARTY @@ -697,7 +757,7 @@ function ARTY:New(group, alias) end -- Check that we actually have a GROUND group. - if group:IsGround()==false and group:IsShip()==false then + if not (group:IsGround() or group:IsShip()) then self:E(ARTY.id..string.format("ERROR: ARTY group %s has to be a GROUND or SHIP group!", group:GetName())) return nil end @@ -785,6 +845,10 @@ function ARTY:New(group, alias) self:AddTransition("*", "NewMove", "*") self:AddTransition("*", "Dead", "*") + -- Transport as cargo (not in diagram). + self:AddTransition("*", "Loaded", "InTransit") + self:AddTransition("InTransit", "UnLoaded", "CombatReady") + -- Unknown transitons. To be checked if adding these causes problems. self:AddTransition("Rearming", "Arrived", "Rearming") self:AddTransition("Rearming", "Move", "Rearming") @@ -1667,6 +1731,7 @@ function ARTY:onafterStart(Controllable, From, Event, To) text=text..string.format("Speed max = %d km/h\n", self.SpeedMax) text=text..string.format("Speed default = %d km/h\n", self.Speed) text=text..string.format("Is mobile = %s\n", tostring(self.ismobile)) + text=text..string.format("Is cargo = %s\n", tostring(self.iscargo)) text=text..string.format("Min range = %.1f km\n", self.minrange/1000) text=text..string.format("Max range = %.1f km\n", self.maxrange/1000) text=text..string.format("Total ammo count = %d\n", self.Nammo0) @@ -2458,10 +2523,29 @@ end function ARTY:onafterStatus(Controllable, From, Event, To) self:_EventFromTo("onafterStatus", Event, From, To) + -- We have a cargo group ==> check if group was loaded into a carrier. + if self.cargogroup then + if self.cargogroup:IsLoaded() and not self:is("InTransit") then + -- Group is now InTransit state. Current target is canceled. + self:T(ARTY.id..string.format("Group %s has been loaded into a carrier and is now transported.", self.alias)) + self:Loaded() + elseif self.cargogroup:IsUnLoaded() then + -- Group has been unloaded and is combat ready again. + self:T(ARTY.id..string.format("Group %s has been unloaded from the carrier.", self.alias)) + self:UnLoaded() + end + end + -- Debug current status info. if self.Debug then self:_StatusReport() end + + -- Group is being transported as cargo ==> skip everything and check again in 5 seconds. + if self:is("InTransit") then + self:__Status(-5) + return + end -- Group on the move. if self:is("Moving") then @@ -2582,6 +2666,34 @@ end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +--- Before "Loaded" event. Checks if group is currently firing and removes the target by calling CeaseFire. +-- @param #ARTY self +-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group. +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @return #boolean If true, proceed to onafterLoaded. +function ARTY:onbeforeLoaded(Controllable, From, Event, To) + if self.currentTarget then + self:CeaseFire(self.currentTarget) + end + + return true +end + +--- After "UnLoaded" event. Group is combat ready again. +-- @param #ARTY self +-- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group. +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @return #boolean If true, proceed to onafterLoaded. +function ARTY:onafterUnLoaded(Controllable, From, Event, To) + self:CombatReady() +end + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + --- Enter "CombatReady" state. Route the group back if necessary. -- @param #ARTY self -- @param Wrapper.Controllable#CONTROLLABLE Controllable Controllable of the group. @@ -2840,7 +2952,7 @@ function ARTY:onafterRearm(Controllable, From, Event, To) self.RearmingGroupCoord=coordRARM end - if self.RearmingGroup and self.RearmingPlaceCoord and self.SpeedMax>0 then + if self.RearmingGroup and self.RearmingPlaceCoord and self.ismobile then -- CASE 1: Rearming unit and ARTY group meet at rearming place. @@ -4615,6 +4727,7 @@ function ARTY:_TargetInRange(target, message) end -- Distance between ARTY group and target. + self:E({controllable=self.Controllable, targetcoord=target.coord}) local _dist=self.Controllable:GetCoordinate():Get2DDistance(target.coord) -- Assume we are in range. @@ -4639,8 +4752,8 @@ function ARTY:_TargetInRange(target, message) MESSAGE:New(text, 5):ToCoalitionIf(self.Controllable:GetCoalition(), (self.report and message) or (self.Debug and message)) end - -- Remove target if ARTY group cannot move, e.g. Mortas. No chance to be ever in range. - if not self.ismobile and _inrange==false then + -- Remove target if ARTY group cannot move, e.g. Mortas. No chance to be ever in range - unless they are cargo. + if not (self.ismobile or self.iscargo) and _inrange==false then self:RemoveTarget(target.name) end diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index 877754efa..2d6ac4660 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -129,10 +129,10 @@ MISSION = { --- This is the main MISSION declaration method. Each Mission is like the master or a Mission orchestration between, Clients, Tasks, Stages etc. -- @param #MISSION self -- @param Tasking.CommandCenter#COMMANDCENTER CommandCenter --- @param #string MissionName is the name of the mission. This name will be used to reference the status of each mission by the players. --- @param #string MissionPriority is a string indicating the "priority" of the Mission. f.e. "Primary", "Secondary" or "First", "Second". It is free format and up to the Mission designer to choose. There are no rules behind this field. --- @param #string MissionBriefing is a string indicating the mission briefing to be shown when a player joins a @{CLIENT}. --- @param #string MissionCoalition is a string indicating the coalition or party to which this mission belongs to. It is free format and can be chosen freely by the mission designer. Note that this field is not to be confused with the coalition concept of the ME. Examples of a Mission Coalition could be "NATO", "CCCP", "Intruders", "Terrorists"... +-- @param #string MissionName Name of the mission. This name will be used to reference the status of each mission by the players. +-- @param #string MissionPriority String indicating the "priority" of the Mission. e.g. "Primary", "Secondary". It is free format and up to the Mission designer to choose. There are no rules behind this field. +-- @param #string MissionBriefing String indicating the mission briefing to be shown when a player joins a @{CLIENT}. +-- @param DCS#coaliton.side MissionCoalition Side of the coalition, i.e. and enumerator @{#DCS.coalition.side} corresponding to RED, BLUE or NEUTRAL. -- @return #MISSION self function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition ) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 587e5987b..4a2596c49 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -526,8 +526,7 @@ end --- Returns the average group height in meters. -- @param Wrapper.Group#GROUP self -- @param #boolean FromGround Measure from the ground or from sea level. Provide **true** for measuring from the ground. **false** or **nil** if you measure from sea level. --- @return DCS#Vec3 The height of the group. --- @return #nil The GROUP is not existing or alive. +-- @return DCS#Vec3 The height of the group or nil if is not existing or alive. function GROUP:GetHeight( FromGround ) self:F2( self.GroupName )