From bfb3ae33f4e45e667687203139a12e1b2a255490 Mon Sep 17 00:00:00 2001 From: Pikes Date: Thu, 2 Apr 2020 13:26:03 +0100 Subject: [PATCH 1/7] Changing default altitude to BARO to avoid DCS AI stopping engaging or even flying int he right direction. --- Moose Development/Moose/AI/AI_A2A_Patrol.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/AI/AI_A2A_Patrol.lua b/Moose Development/Moose/AI/AI_A2A_Patrol.lua index 45fef37cf..229e15328 100644 --- a/Moose Development/Moose/AI/AI_A2A_Patrol.lua +++ b/Moose Development/Moose/AI/AI_A2A_Patrol.lua @@ -127,7 +127,7 @@ AI_A2A_PATROL = { -- @param DCS#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol. -- @param DCS#Speed PatrolMinSpeed The minimum speed of the @{Wrapper.Group} in km/h. -- @param DCS#Speed PatrolMaxSpeed The maximum speed of the @{Wrapper.Group} in km/h. --- @param DCS#AltitudeType PatrolAltType The altitude type ("RADIO"=="AGL", "BARO"=="ASL"). Defaults to RADIO +-- @param DCS#AltitudeType PatrolAltType The altitude type ("RADIO"=="AGL", "BARO"=="ASL"). Defaults to BARO -- @return #AI_A2A_PATROL self -- @usage -- -- Define a new AI_A2A_PATROL Object. This PatrolArea will patrol a Group within PatrolZone between 3000 and 6000 meters, with a variying speed between 600 and 900 km/h. @@ -151,8 +151,8 @@ function AI_A2A_PATROL:New( AIPatrol, PatrolZone, PatrolFloorAltitude, PatrolCei self.PatrolMinSpeed = PatrolMinSpeed self.PatrolMaxSpeed = PatrolMaxSpeed - -- defafult PatrolAltType to "RADIO" if not specified - self.PatrolAltType = PatrolAltType or "RADIO" + -- defafult PatrolAltType to "BARO" if not specified + self.PatrolAltType = PatrolAltType or "BARO" self:AddTransition( { "Started", "Airborne", "Refuelling" }, "Patrol", "Patrolling" ) From 6d75b25f579a392872047dedcffab30558d34b59 Mon Sep 17 00:00:00 2001 From: Pikes Date: Thu, 2 Apr 2020 13:50:41 +0100 Subject: [PATCH 2/7] change default to "BARO" addition on AI_A2A_Patrol already done --- Moose Development/Moose/AI/AI_Patrol.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Patrol.lua b/Moose Development/Moose/AI/AI_Patrol.lua index dcb94b99d..767dc4400 100644 --- a/Moose Development/Moose/AI/AI_Patrol.lua +++ b/Moose Development/Moose/AI/AI_Patrol.lua @@ -178,8 +178,8 @@ function AI_PATROL_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltit self.PatrolMinSpeed = PatrolMinSpeed self.PatrolMaxSpeed = PatrolMaxSpeed - -- defafult PatrolAltType to "RADIO" if not specified - self.PatrolAltType = PatrolAltType or "RADIO" + -- defafult PatrolAltType to "BARO" if not specified + self.PatrolAltType = PatrolAltType or "BARO" self:SetRefreshTimeInterval( 30 ) From 0502e0a020de43e94c46c95efc08092fe44f3284 Mon Sep 17 00:00:00 2001 From: Pikes Date: Wed, 22 Apr 2020 14:09:31 +0100 Subject: [PATCH 3/7] Spawn Documentation fixes no code touched no code touched I went through removing where 6-7 year old docs used a non existent method "Schedule" and replaced it with SpawnSchedule() wher ethat worked or Spawn() where I couldnt understand the ancient demo. Also added warnings on IniLimit and InitCleanUp() the two worst offenders of misconfiguration. Couple of Belgian typos corrected. --- Moose Development/Moose/Core/Spawn.lua | 37 +++++++++++++------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index 13dc85702..ebcfb1f99 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -455,7 +455,8 @@ function SPAWN:NewFromTemplate( SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPr end ---- Limits the Maximum amount of Units that can be alive at the same time, and the maximum amount of groups that can be spawned. +--- Stops any more repeat spawns from happening once the UNIT count of Alive units, spawned by the same SPAWN object, exceeds the first parameter. Also can stop spawns from happening once a total GROUP still alive is met. +-- Exceptionally powerful when combined with SpawnSchedule for Respawning. -- Note that this method is exceptionally important to balance the performance of the mission. Depending on the machine etc, a mission can only process a maximum amount of units. -- If the time interval must be short, but there should not be more Units or Groups alive than a maximum amount of units, then this method should be used... -- When a @{#SPAWN.New} is executed and the limit of the amount of units alive is reached, then no new spawn will happen of the group, until some of these units of the spawn object will be destroyed. @@ -815,9 +816,9 @@ end -- Spawn_US_Platoon = { 'US Tank Platoon 1', 'US Tank Platoon 2', 'US Tank Platoon 3', 'US Tank Platoon 4', 'US Tank Platoon 5', -- 'US Tank Platoon 6', 'US Tank Platoon 7', 'US Tank Platoon 8', 'US Tank Platoon 9', 'US Tank Platoon 10', -- 'US Tank Platoon 11', 'US Tank Platoon 12', 'US Tank Platoon 13' } --- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 ) --- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 ) --- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplate( Spawn_US_Platoon ):InitRandomizeRoute( 3, 3, 2000 ) function SPAWN:InitRandomizeTemplate( SpawnTemplatePrefixTable ) self:F( { self.SpawnTemplatePrefix, SpawnTemplatePrefixTable } ) @@ -851,9 +852,9 @@ end -- Spawn_US_PlatoonSet = SET_GROUP:New():FilterPrefixes( "US Tank Platoon Templates" ):FilterOnce() -- -- --- Now use the Spawn_US_PlatoonSet to define the templates using InitRandomizeTemplateSet. --- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) --- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) --- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplateSet( Spawn_US_PlatoonSet ):InitRandomizeRoute( 3, 3, 2000 ) function SPAWN:InitRandomizeTemplateSet( SpawnTemplateSet ) -- R2.3 self:F( { self.SpawnTemplatePrefix } ) @@ -884,9 +885,9 @@ end -- -- Each new SPAWN will randomize the route, with a defined time interval of 200 seconds with 40% time variation (randomization) and -- -- with a limit set of maximum 12 Units alive simulteneously and 150 Groups to be spawned during the whole mission. -- --- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) --- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) --- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):Schedule( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Left = SPAWN:New( 'US Tank Platoon Left' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Middle = SPAWN:New( 'US Tank Platoon Middle' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) +-- Spawn_US_Platoon_Right = SPAWN:New( 'US Tank Platoon Right' ):InitLimit( 12, 150 ):SpawnScheduled( 200, 0.4 ):InitRandomizeTemplatePrefixes( "US Tank Platoon Templates" ):InitRandomizeRoute( 3, 3, 2000 ) function SPAWN:InitRandomizeTemplatePrefixes( SpawnTemplatePrefixes ) --R2.3 self:F( { self.SpawnTemplatePrefix } ) @@ -978,11 +979,9 @@ end -- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically. -- SpawnRU_SU34 = SPAWN -- :New( 'Su-34' ) --- :Schedule( 2, 3, 1800, 0.4 ) --- :SpawnUncontrolled() -- :InitRandomizeRoute( 1, 1, 3000 ) -- :InitRepeatOnLanding() --- +-- :Spawn() function SPAWN:InitRepeatOnLanding() self:F( { self.SpawnTemplatePrefix } ) @@ -1002,11 +1001,10 @@ end -- -- Re-SPAWN the Group(s) after each landing and Engine Shut-Down automatically. -- SpawnRU_SU34 = SPAWN -- :New( 'Su-34' ) --- :Schedule( 2, 3, 1800, 0.4 ) -- :SpawnUncontrolled() -- :InitRandomizeRoute( 1, 1, 3000 ) -- :InitRepeatOnEngineShutDown() --- +-- :Spawn() function SPAWN:InitRepeatOnEngineShutDown() self:F( { self.SpawnTemplatePrefix } ) @@ -1018,7 +1016,8 @@ function SPAWN:InitRepeatOnEngineShutDown() end ---- CleanUp groups when they are still alive, but inactive. +--- Delete groups that have not moved for X seconds - AIR ONLY!!! +-- DO NOT USE ON GROUPS THAT DO NOT MOVE OR YOUR SERVER WILL BURN IN HELL (Pikes - April 2020) -- When groups are still alive and have become inactive due to damage and are unable to contribute anything, then this group will be removed at defined intervals in seconds. -- @param #SPAWN self -- @param #string SpawnCleanUpInterval The interval to check for inactive groups within seconds. @@ -1198,7 +1197,7 @@ function SPAWN:ReSpawn( SpawnIndex ) SpawnIndex = 1 end --- TODO: This logic makes DCS crash and i don't know why (yet). +-- TODO: This logic makes DCS crash and i don't know why (yet). -- ED (Pikes -- not in the least bit scary to see this, right?) local SpawnGroup = self:GetGroupFromIndex( SpawnIndex ) local WayPoints = SpawnGroup and SpawnGroup.WayPoints or nil if SpawnGroup then @@ -1463,7 +1462,7 @@ end -- -- Low limit: 600 * ( 1 - 0.5 / 2 ) = 450 -- -- High limit: 600 * ( 1 + 0.5 / 2 ) = 750 -- -- Between these two values, a random amount of seconds will be choosen for each new spawn of the helicopters. --- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 ) +-- Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):SpawnScheduled( 600, 0.5 ) function SPAWN:SpawnScheduled( SpawnTime, SpawnTimeVariation ) self:F( { SpawnTime, SpawnTimeVariation } ) @@ -2327,7 +2326,7 @@ function SPAWN:ParkAircraft( SpawnAirbase, TerminalType, Parkingdata, SpawnIndex end end - -- Set gereral spawnpoint position. + -- Set general spawnpoint position. SpawnPoint.x = PointVec3.x SpawnPoint.y = PointVec3.z SpawnPoint.alt = PointVec3.y From 0a570da986625431c2fff5253d0e15b1d5c1bdaa Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 24 Apr 2020 21:16:42 +0200 Subject: [PATCH 4/7] Up --- Moose Development/Moose/DCS.lua | 10 +- .../Moose/Wrapper/Controllable.lua | 237 +++++++++--------- 2 files changed, 125 insertions(+), 122 deletions(-) diff --git a/Moose Development/Moose/DCS.lua b/Moose Development/Moose/DCS.lua index 0c8e87a23..206165bd3 100644 --- a/Moose Development/Moose/DCS.lua +++ b/Moose Development/Moose/DCS.lua @@ -47,9 +47,13 @@ do -- world -- @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_MARK ADDED [https://wiki.hoggitworld.com/view/DCS_event_mark_added](https://wiki.hoggitworld.com/view/DCS_event_mark_added) DCS>=2.5.1 + -- @field S_EVENT_MARK CHANGE [https://wiki.hoggitworld.com/view/DCS_event_mark_change](https://wiki.hoggitworld.com/view/DCS_event_mark_change) DCS>=2.5.1 + -- @field S_EVENT_MARK REMOVE [https://wiki.hoggitworld.com/view/DCS_event_mark_remove](https://wiki.hoggitworld.com/view/DCS_event_mark_remove) DCS>=2.5.1 + -- @field S_EVENT_KILL [https://wiki.hoggitworld.com/view/DCS_event_kill](https://wiki.hoggitworld.com/view/DCS_event_kill) DCS>=2.5.6 + -- @field S_EVENT_SCORE [https://wiki.hoggitworld.com/view/DCS_event_score](https://wiki.hoggitworld.com/view/DCS_event_score) DCS>=2.5.6 + -- @field S_EVENT_UNIT_LOST [https://wiki.hoggitworld.com/view/DCS_event_unit_lost](https://wiki.hoggitworld.com/view/DCS_event_unit_lost) DCS>=2.5.6 + -- @field S_EVENT_LANDING_AFTER_EJECTION [https://wiki.hoggitworld.com/view/DCS_event_landing_after_ejection](https://wiki.hoggitworld.com/view/DCS_event_landing_after_ejection) DCS>=2.5.6 -- @field S_EVENT_MAX --- The birthplace enumerator is used to define where an aircraft or helicopter has spawned in association with birth events. diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 9f34f8cf6..3847cdf47 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1091,6 +1091,7 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri local DCSTask = { id = 'Embarking', params = { + --selectedTransport = self:GetID(), Vec2 = Vec2, x = Vec2.x, y = Vec2.y, @@ -1105,6 +1106,123 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri return DCSTask end +--- Used in conjunction with the EmbarkToTransport task for a ground infantry group, the controlled helicopter flight will land at the specified coordinates, +-- pick up boarding troops and transport them to that groups DisembarkFromTransport task. +-- The CONTROLLABLE has to be a helicopter group! +-- @param #CONTROLLABLE self +-- @param Core.Set#SET_GROUP GroupSet Set of groups to be embarked by the controllable. +-- @param Core.Point#COORDINATE Coordinate Coordinate of embarking. +-- @param #number Duration Duration of embarking in seconds. +-- @return #table Embarking task. +function CONTROLLABLE:TaskEmbarking(GroupSet, Coordinate, Duration) + + -- Create table of group IDs. + local gids={} + for _,_group in pairs(GroupSet:GetAliveSet()) do + local group=_group --Wrapper.Group#GROUP + table.insert(gids, group:GetID()) + end + + -- Group ID of controllable. + local id=self:GetID() + + -- Distribution + local distribution={} + distribution[id]=gids + + local durationFlag=false + if Duration then + durationFlag=true + else + Duration=300 + end + + local DCStask={ + id="Embarking", + params={ + + distributionFlag=true, + distribution=distribution, + groupsForEmbarking=gids, + durationFlag=durationFlag, + distribution=distribution, + duration=Duration, + x=Coordinate.x, + y=Coordinate.z, + } + } + + self:E(DCStask) + + return DCStask +end + +--- Used in conjunction with the embarking task for a transport helicopter group. The Ground units will move to the specified location and wait to be picked up by a helicopter. +-- The helicopter will then fly them to their dropoff point defined by another task for the ground forces; DisembarkFromTransport task. +-- The controllable has to be an infantry group! +-- @param #CONTROLLABLE self +-- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up. +-- @param #number Radius Radius in meters. +-- @return #table Embark to transport task. +function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius) + + local EmbarkToTransport = { + id="EmbarkToTransport", + params={ + x=Coordinate.x, + y=Coordinate.z, + zoneRadius=Radius, + --selectedType="UH-1H", + } + } + + self:E(EmbarkToTransport) + return EmbarkToTransport +end + + + +--- Specifies the location an infantry group that is being transported by helicopters will be unloaded at. Used in conjunction with the EmbarkToTransport task. +-- The CONTROLLABLE has to be an infantry group! +-- @param #CONTROLLABLE self +-- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up. +-- @param #number Radius Radius in meters. +-- @return #table Embark to transport task. +function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius) + + local DisembarkFromTransport={ + id="DisembarkFromTransport", + params = { + x=Coordinate.x, + y=Coordinate.y, + zoneRadius=Radius, + }} + + return DisembarkFromTransport +end + + +--- (GROUND) Embark to a Transport landed at a location. +-- Move to a defined Vec2 Point, and embark to a controllable when arrived within a defined Radius. +-- @param #CONTROLLABLE self +-- @param DCS#Vec2 Point The point where to wait. +-- @param #number Radius The radius of the embarking zone around the Point. +-- @return DCS#Task The DCS task structure. +function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius ) + + local DCSTask = { + id = 'EmbarkToTransport', + params = { + point = Point, + x = Point.x, + y = Point.y, + zoneRadius = Radius, + } + } + + return DCSTask +end + --- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed. -- @param #CONTROLLABLE self @@ -1687,125 +1805,6 @@ function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority ) end - ---[[ ---- Used in conjunction with the embarking task for a transport helicopter group. The Ground units will move to the specified location and wait to be picked up by a helicopter. --- The helicopter will then fly them to their dropoff point defined by another task for the ground forces; DisembarkFromTransport task. --- The controllable has to be an infantry group! --- @param #CONTROLLABLE self --- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up. --- @param #number Radius Radius in meters. --- @return #table Embark to transport task. -function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius) - - local EmbarkToTransport = { - id="EmbarkToTransport", - params={ - x=Coordinate.x, - y=Coordinate.z, - zoneRadius=Radius, - --selectedType="UH-1H", - } - } - - self:E(EmbarkToTransport) - return EmbarkToTransport -end - ---- Used in conjunction with the EmbarkToTransport task for a ground infantry group, the controlled helicopter flight will land at the specified coordinates, --- pick up boarding troops and transport them to that groups DisembarkFromTransport task. --- The CONTROLLABLE has to be a helicopter group! --- @param #CONTROLLABLE self --- @param Core.Set#SET_GROUP GroupSet Set of groups to be embarked by the controllable. --- @param Core.Point#COORDINATE Coordinate Coordinate of embarking. --- @param #number Duration Duration of embarking in seconds. --- @return #table Embarking task. -function CONTROLLABLE:TaskEmbarking(GroupSet, Coordinate, Duration) - - -- Create table of group IDs. - local gids={} - for _,_group in pairs(GroupSet:GetAliveSet()) do - local group=_group --Wrapper.Group#GROUP - table.insert(gids, group:GetID()) - end - - -- Group ID of controllable. - local id=self:GetID() - - -- Distribution - local distribution={} - distribution[id]=gids - - local durationFlag=false - if Duration then - durationFlag=true - else - Duration=300 - end - - local DCStask={ - id="Embarking", - params={ - selectedTransport=self:GetID(), - distributionFlag=true, - distribution=distribution, - groupsForEmbarking=gids, - durationFlag=durationFlag, - distribution=distribution, - duration=Duration, - x=Coordinate.x, - y=Coordinate.z, - } - } - - self:E(DCStask) - - return DCStask -end - ---- Specifies the location an infantry group that is being transported by helicopters will be unloaded at. Used in conjunction with the EmbarkToTransport task. --- The CONTROLLABLE has to be an infantry group! --- @param #CONTROLLABLE self --- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up. --- @param #number Radius Radius in meters. --- @return #table Embark to transport task. -function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius) - - local DisembarkFromTransport={ - id="DisembarkFromTransport", - params = { - x=Coordinate.x, - y=Coordinate.y, - zoneRadius=Radius, - }} - - return DisembarkFromTransport -end -]] - - ---- (GROUND) Embark to a Transport landed at a location. --- Move to a defined Vec2 Point, and embark to a controllable when arrived within a defined Radius. --- @param #CONTROLLABLE self --- @param DCS#Vec2 Point The point where to wait. --- @param #number Radius The radius of the embarking zone around the Point. --- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius ) - - local DCSTask = { - id = 'EmbarkToTransport', - params = { - point = Point, - x = Point.x, - y = Point.y, - zoneRadius = Radius, - } - } - - return DCSTask -end - - --- This creates a Task element, with an action to call a function as part of a Wrapped Task. -- This Task can then be embedded at a Waypoint by calling the method @{#CONTROLLABLE.SetTaskWaypoint}. -- @param #CONTROLLABLE self From c3cc76c15b5a2fbd3f62014075a4b3205c2af97c Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 24 Apr 2020 21:57:10 +0200 Subject: [PATCH 5/7] Update Controllable.lua --- Moose Development/Moose/Wrapper/Controllable.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 3847cdf47..193df6889 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1176,7 +1176,6 @@ function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius) } } - self:E(EmbarkToTransport) return EmbarkToTransport end @@ -1196,7 +1195,8 @@ function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius) x=Coordinate.x, y=Coordinate.y, zoneRadius=Radius, - }} + } + } return DisembarkFromTransport end From 68ece29ab52517d57843fde6277ae23201bd6fed Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 24 Apr 2020 22:45:45 +0200 Subject: [PATCH 6/7] Update Controllable.lua --- .../Moose/Wrapper/Controllable.lua | 142 +++++------------- 1 file changed, 40 insertions(+), 102 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 193df6889..dca45845d 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1056,14 +1056,14 @@ function CONTROLLABLE:TaskFollowBigFormation(FollowControllable, Vec3, LastWaypo end ---- (AIR) Move the controllable to a Vec2 Point, wait for a defined duration and embark a controllable. +--- (AIR HELICOPTER) Move the controllable to a Vec2 Point, wait for a defined duration and embark infantry groups. -- @param #CONTROLLABLE self --- @param DCS#Vec2 Vec2 The point where to wait. Needs to have x and y components. +-- @param Core.Point#COORDINATE Coordinate The point where to pickup the troops. -- @param Core.Set#SET_GROUP GroupSetForEmbarking Set of groups to embark. -- @param #number Duration (Optional) The maximum duration in seconds to wait until all groups have embarked. --- @param Core.Set#SET_GROUP DistributionGroupSet (Optional) Set of groups identifying the groups needing to board specific helicopters. +-- @param #table Distribution (Optional) Distribution used to put the infantry groups into specific carrier units. -- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, DistributionGroupSet) +function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distribution) -- Table of group IDs for embarking. local g4e={} @@ -1079,26 +1079,25 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri end -- Table of group IDs for embarking. - local Distribution={} + --local Distribution={} - if DistributionGroupSet then - for _,_group in pairs(DistributionGroupSet:GetSet()) do - local group=_group --Wrapper.Group#GROUP - table.insert(Distribution, group:GetID()) - end - end + -- Distribution + --local distribution={} + --distribution[id]=gids + + local groupID=self and self:GetID() local DCSTask = { id = 'Embarking', params = { - --selectedTransport = self:GetID(), + selectedTransport = groupID, Vec2 = Vec2, x = Vec2.x, y = Vec2.y, groupsForEmbarking = g4e, durationFlag = Duration and true or false, duration = Duration, - distributionFlag = DistributionGroupSet and true or false, + distributionFlag = Distribution and true or false, distribution = Distribution, } } @@ -1106,73 +1105,24 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri return DCSTask end ---- Used in conjunction with the EmbarkToTransport task for a ground infantry group, the controlled helicopter flight will land at the specified coordinates, --- pick up boarding troops and transport them to that groups DisembarkFromTransport task. --- The CONTROLLABLE has to be a helicopter group! --- @param #CONTROLLABLE self --- @param Core.Set#SET_GROUP GroupSet Set of groups to be embarked by the controllable. --- @param Core.Point#COORDINATE Coordinate Coordinate of embarking. --- @param #number Duration Duration of embarking in seconds. --- @return #table Embarking task. -function CONTROLLABLE:TaskEmbarking(GroupSet, Coordinate, Duration) - - -- Create table of group IDs. - local gids={} - for _,_group in pairs(GroupSet:GetAliveSet()) do - local group=_group --Wrapper.Group#GROUP - table.insert(gids, group:GetID()) - end - - -- Group ID of controllable. - local id=self:GetID() - - -- Distribution - local distribution={} - distribution[id]=gids - - local durationFlag=false - if Duration then - durationFlag=true - else - Duration=300 - end - - local DCStask={ - id="Embarking", - params={ - - distributionFlag=true, - distribution=distribution, - groupsForEmbarking=gids, - durationFlag=durationFlag, - distribution=distribution, - duration=Duration, - x=Coordinate.x, - y=Coordinate.z, - } - } - - self:E(DCStask) - - return DCStask -end --- Used in conjunction with the embarking task for a transport helicopter group. The Ground units will move to the specified location and wait to be picked up by a helicopter. -- The helicopter will then fly them to their dropoff point defined by another task for the ground forces; DisembarkFromTransport task. -- The controllable has to be an infantry group! -- @param #CONTROLLABLE self -- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up. --- @param #number Radius Radius in meters. --- @return #table Embark to transport task. -function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius) +-- @param #number Radius Radius in meters. Default 200 m. +-- @param #string UnitType The unit type name of the carrier, e.g. "UH-1H". Must not be specified. +-- @return DCS#Task Embark to transport task. +function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius, UnitType) local EmbarkToTransport = { - id="EmbarkToTransport", + id = "EmbarkToTransport", params={ - x=Coordinate.x, - y=Coordinate.z, - zoneRadius=Radius, - --selectedType="UH-1H", + x = Coordinate.x, + y = Coordinate.z, + zoneRadius = Radius or 200, + selectedType = UnitType, } } @@ -1180,21 +1130,31 @@ function CONTROLLABLE:TaskEmbarkToTransport(Coordinate, Radius) end - ---- Specifies the location an infantry group that is being transported by helicopters will be unloaded at. Used in conjunction with the EmbarkToTransport task. --- The CONTROLLABLE has to be an infantry group! +--- Specifies the location infantry groups that is being transported by helicopters will be unloaded at. Used in conjunction with the EmbarkToTransport task. -- @param #CONTROLLABLE self -- @param Core.Point#COORDINATE Coordinate Coordinates where AI is expecting to be picked up. --- @param #number Radius Radius in meters. --- @return #table Embark to transport task. -function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius) +-- @return DCS#Task Embark to transport task. +function CONTROLLABLE:TaskDisembarking(Coordinate, GroupSetToDisembark) + + -- Table of group IDs for disembarking. + local g4e={} + + if GroupSetToDisembark then + for _,_group in pairs(GroupSetToDisembark:GetSet()) do + local group=_group --Wrapper.Group#GROUP + table.insert(g4e, group:GetID()) + end + else + self:E("ERROR: No groups for disembarking specified!") + return nil + end local DisembarkFromTransport={ id="DisembarkFromTransport", params = { - x=Coordinate.x, - y=Coordinate.y, - zoneRadius=Radius, + x = Coordinate.x, + y = Coordinate.z, + groupsForEmbarking = g4e, -- This is no bug, the entry is really "groupsForEmbarking" even if we disembark the troops. } } @@ -1202,28 +1162,6 @@ function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius) end ---- (GROUND) Embark to a Transport landed at a location. --- Move to a defined Vec2 Point, and embark to a controllable when arrived within a defined Radius. --- @param #CONTROLLABLE self --- @param DCS#Vec2 Point The point where to wait. --- @param #number Radius The radius of the embarking zone around the Point. --- @return DCS#Task The DCS task structure. -function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius ) - - local DCSTask = { - id = 'EmbarkToTransport', - params = { - point = Point, - x = Point.x, - y = Point.y, - zoneRadius = Radius, - } - } - - return DCSTask -end - - --- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed. -- @param #CONTROLLABLE self -- @param DCS#Vec2 Point The point to hold the position. From 4e49184da26c1e7a6ec6f962fec75cadfd4f9c1f Mon Sep 17 00:00:00 2001 From: Frank Date: Fri, 24 Apr 2020 22:53:42 +0200 Subject: [PATCH 7/7] Update Static.lua --- Moose Development/Moose/Wrapper/Static.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Wrapper/Static.lua b/Moose Development/Moose/Wrapper/Static.lua index 64a12a98a..16b07c03f 100644 --- a/Moose Development/Moose/Wrapper/Static.lua +++ b/Moose Development/Moose/Wrapper/Static.lua @@ -76,7 +76,7 @@ end -- @param #string StaticName Name of the DCS **Static** as defined within the Mission Editor. -- @param #boolean RaiseError Raise an error if not found. -- @return #STATIC self or *nil* -function STATIC:FindByName( StaticName ) +function STATIC:FindByName( StaticName, RaiseError ) -- Find static in DB. local StaticFound = _DATABASE:FindStatic( StaticName ) @@ -87,6 +87,10 @@ function STATIC:FindByName( StaticName ) if StaticFound then return StaticFound end + + if RaiseError == nil or RaiseError == true then + error( "STATIC not found for: " .. StaticName ) + end return nil end