diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 00abc0922..a6b6606e9 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -591,14 +591,14 @@ RANGE.MenuF10Root = nil --- Range script version. -- @field #string version -RANGE.version = "2.6.0" +RANGE.version = "2.7.0" -- TODO list: --- TODO: Scenery as targets. -- TODO: Verbosity level for messages. -- TODO: Add option for default settings such as smoke off. -- TODO: Add custom weapons, which can be specified by the user. -- TODO: Check if units are still alive. +-- DONE: Scenery as targets. -- DONE: Add statics for strafe pits. -- DONE: Add missiles. -- DONE: Convert env.info() to self:T() @@ -1612,6 +1612,42 @@ function RANGE:AddBombingTargetCoordinate( coord, name, goodhitrange ) return self end +--- Add a scenery object as bombing target. +-- @param #RANGE self +-- @param Wrapper.Scenery#SCENERY scenery Scenary object. +-- @param #number goodhitrange Max distance from unit which is considered as a good hit. +-- @return #RANGE self +function RANGE:AddBombingTargetScenery( scenery, goodhitrange) + + -- Get name of positionable. + local name = scenery:GetName() + + -- Default range is 25 m. + goodhitrange = goodhitrange or RANGE.Defaults.goodhitrange + + -- Debug or error output. + if name then + self:I( self.lid .. string.format( "Adding SCENERY bombing target %s with good hit range %d", name, goodhitrange) ) + else + self:E( self.lid .. string.format( "ERROR! No bombing target with name %s could be found!", name ) ) + end + + + local target = {} -- #RANGE.BombTarget + target.name = name + target.target = scenery + target.goodhitrange = goodhitrange + target.move = false + target.speed = 0 + target.coordinate = scenery:GetCoordinate() + target.type = RANGE.TargetType.SCENERY + + -- Insert target to table. + table.insert( self.bombingTargets, target ) + + return self +end + --- Add all units of a group as bombing targets. -- @param #RANGE self -- @param Wrapper.Group#GROUP group Group of bombing targets. @@ -1933,6 +1969,7 @@ function RANGE._OnImpact(weapon, self, playerData, attackHdg, attackAlt, attackV result.attackHdg = attackHdg result.attackVel = attackVel result.attackAlt = attackAlt + result.date=os and os.date() or "n/a" -- Add to table. table.insert( _results, result ) @@ -2292,10 +2329,7 @@ function RANGE:onafterSave( From, Event, To ) local quality = result.quality local time = UTILS.SecondsToClock(result.time, true) local airframe = result.airframe - local date = "n/a" - if os then - date = os.date() - end + local date = result.date or "n/a" scores = scores .. string.format( "\n%s,%d,%s,%.2f,%03d,%s,%s,%s,%s,%s", playername, i, target, distance, radial, quality, weapon, airframe, time, date ) end end @@ -3399,6 +3433,11 @@ function RANGE:_GetBombTargetCoordinate( target ) -- Coordinates dont move. coord = target.coordinate + + elseif target.type == RANGE.TargetType.SCENERY then + + -- Coordinates dont move. + coord = target.coordinate else self:E( self.lid .. "ERROR: Unknown target type." ) diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index fef3e35f0..57ed7b84d 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -68,7 +68,7 @@ ARMYGROUP = { --- Army Group version. -- @field #string version -ARMYGROUP.version="0.9.0" +ARMYGROUP.version="1.0.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index ff4e95d56..cf646d6f6 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -158,6 +158,7 @@ -- @field Core.Point#COORDINATE missionWaypointCoord Mission waypoint coordinate. -- @field Core.Point#COORDINATE missionEgressCoord Mission egress waypoint coordinate. -- @field #number missionWaypointRadius Random radius in meters. +-- @field #boolean legionReturn If `true`, assets return to their legion (default). If `false`, they will stay alive. -- -- @field #table enrouteTasks Mission enroute tasks. -- @@ -639,7 +640,7 @@ AUFTRAG.Category={ --- AUFTRAG class version. -- @field #string version -AUFTRAG.version="1.0.0" +AUFTRAG.version="1.1.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -648,6 +649,7 @@ AUFTRAG.version="1.0.0" -- TODO: Replace engageRange by missionRange. Here and in other classes. CTRL+H is your friend! -- TODO: Mission success options damaged, destroyed. -- TODO: F10 marker to create new missions. +-- DONE: Add option that assets do not return to their legion. -- DONE: Add Capture zone task. -- DONE: Add orbit mission for moving anker points. -- DONE: Add recovery tanker mission for boat ops. @@ -1039,7 +1041,7 @@ end -- @param #AUFTRAG self -- @param Core.Point#COORDINATE Coordinate Where to orbit. -- @param #number Altitude Orbit altitude in feet above sea level. Default is y component of `Coordinate`. --- @param #number Speed Orbit speed in knots. Default 350 KIAS. +-- @param #number Speed Orbit indicated airspeed in knots at the set altitude ASL. Default 350 KIAS. -- @param #number Heading Heading of race-track pattern in degrees. If not specified, a circular orbit is performed. -- @param #number Leg Length of race-track in NM. If not specified, a circular orbit is performed. -- @return #AUFTRAG self @@ -1058,7 +1060,8 @@ function AUFTRAG:NewORBIT(Coordinate, Altitude, Speed, Heading, Leg) end -- Orbit speed in m/s. - mission.orbitSpeed = UTILS.KnotsToMps(UTILS.KnotsToAltKIAS(Speed or 350, UTILS.MetersToFeet(mission.orbitAltitude))) + --mission.orbitSpeed = UTILS.KnotsToMps(UTILS.KnotsToAltKIAS(Speed or 350, UTILS.MetersToFeet(mission.orbitAltitude))) + mission.orbitSpeed = UTILS.TasToIas(UTILS.KnotsToMps(Speed or 350), mission.orbitAltitude) -- Mission speed in km/h. mission.missionSpeed = UTILS.KnotsToKmph(Speed or 350) @@ -1093,7 +1096,7 @@ end -- @param #AUFTRAG self -- @param Core.Point#COORDINATE Coordinate Position where to orbit around. -- @param #number Altitude Orbit altitude in feet. Default is y component of `Coordinate`. --- @param #number Speed Orbit speed in knots. Default 350 KIAS. +-- @param #number Speed Orbit indicated airspeed in knots at the set altitude ASL. Default 350 KIAS. -- @return #AUFTRAG self function AUFTRAG:NewORBIT_CIRCLE(Coordinate, Altitude, Speed) @@ -1106,7 +1109,7 @@ end -- @param #AUFTRAG self -- @param Core.Point#COORDINATE Coordinate Where to orbit. -- @param #number Altitude Orbit altitude in feet. Default is y component of `Coordinate`. --- @param #number Speed Orbit speed in knots. Default 350 KIAS. +-- @param #number Speed Orbit indicated airspeed in knots at the set altitude ASL. Default 350 KIAS. -- @param #number Heading Heading of race-track pattern in degrees. Default random in [0, 360) degrees. -- @param #number Leg Length of race-track in NM. Default 10 NM. -- @return #AUFTRAG self @@ -1124,7 +1127,7 @@ end -- @param #AUFTRAG self -- @param Wrapper.Group#GROUP Group Group where to orbit around. Can also be a UNIT object. -- @param #number Altitude Orbit altitude in feet. Default is 6,000 ft. --- @param #number Speed Orbit speed in knots. Default 350 KIAS. +-- @param #number Speed Orbit indicated airspeed in knots at the set altitude ASL. Default 350 KIAS. -- @param #number Leg Length of race-track in NM. Default nil. -- @param #number Heading Heading of race-track pattern in degrees. Default is heading of the group. -- @param DCS#Vec2 OffsetVec2 Offset 2D-vector {x=0, y=0} in NM with respect to the group. Default directly overhead. Can also be given in polar coordinates `{r=5, phi=45}`. @@ -1172,7 +1175,7 @@ end -- @param #AUFTRAG self -- @param Core.Point#COORDINATE Coordinate Where to orbit. -- @param #number Altitude Orbit altitude in feet. Default is y component of `Coordinate`. --- @param #number Speed Orbit speed in knots. Default 350 kts. +-- @param #number Speed Orbit indicated airspeed in knots at the set altitude ASL. Default 350 KIAS. -- @param #number Heading Heading of race-track pattern in degrees. Default random in [0, 360) degrees. -- @param #number Leg Length of race-track in NM. Default 10 NM. -- @return #AUFTRAG self @@ -1199,7 +1202,7 @@ end -- @param #AUFTRAG self -- @param Core.Point#COORDINATE Coordinate Where to orbit. -- @param #number Altitude Orbit altitude in feet. Default is y component of `Coordinate`. --- @param #number Speed Orbit speed in knots. Default 350 kts. +-- @param #number Speed Orbit indicated airspeed in knots at the set altitude ASL. Default 350 KIAS. -- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West). -- @param #number Leg Length of race-track in NM. Default 10 NM. -- @param #number RefuelSystem Refueling system (0=boom, 1=probe). This info is *only* for AIRWINGs so they launch the right tanker type. @@ -2657,6 +2660,17 @@ function AUFTRAG:SetTeleport(Switch) return self end +--- **[LEGION, COMMANDER, CHIEF]** Set whether assigned assets return to their legion once the mission is over. This is only applicable to **army** and **navy** groups, *i.e.* aircraft +-- will always return. +-- @param #AUFTRAG self +-- @param #boolean Switch If `true`, assets will return. If `false`, assets will not return and stay where it finishes its last mission. If `nil`, let asset decide. +-- @return #AUFTRAG self +function AUFTRAG:SetReturnToLegion(Switch) + self.legionReturn=Switch + self:T(self.lid..string.format("Setting ReturnToLetion=%s", tostring(self.legionReturn))) + return self +end + --- Set mission push time. This is the time the mission is executed. If the push time is not passed, the group will wait at the mission execution waypoint. -- @param #AUFTRAG self diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index f89d142c7..9ff16c279 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -216,7 +216,7 @@ FLIGHTGROUP.Players={} --- FLIGHTGROUP class version. -- @field #string version -FLIGHTGROUP.version="0.8.4" +FLIGHTGROUP.version="1.0.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index 25af27b3f..a64e6afa4 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -1984,9 +1984,9 @@ end --- Count total number of assets of the legion. -- @param #LEGION self --- @param #boolean InStock If `true`, only assets that are in the warehouse stock/inventory are counted. +-- @param #boolean InStock If `true`, only assets that are in the warehouse stock/inventory are counted. If `false`, only assets that are NOT in stock (i.e. spawned) are counted. If `nil`, all assets are counted. -- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types. --- @param #table Attributes (Optional) Count only assest that have a certain attribute(s), e.g. `WAREHOUSE.Attribute.AIR_BOMBER`. +-- @param #table Attributes (Optional) Count only assest that have a certain attribute(s), e.g. `GROUP.Attribute.AIR_BOMBER`. -- @return #number Amount of asset groups in stock. function LEGION:CountAssets(InStock, MissionTypes, Attributes) diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 3c52c0258..640815a2a 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -90,7 +90,7 @@ NAVYGROUP = { --- NavyGroup version. -- @field #string version -NAVYGROUP.version="0.7.9" +NAVYGROUP.version="1.0.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -199,11 +199,6 @@ function NAVYGROUP:New(group) -- @param #number Speed Speed in knots until next waypoint is reached. - - - - - --- Triggers the FSM event "TurnIntoWind". -- @function [parent=#NAVYGROUP] TurnIntoWind -- @param #NAVYGROUP self @@ -1038,6 +1033,7 @@ end -- @param #number Speed Speed in knots to the next waypoint. -- @param #number Depth Depth in meters to the next waypoint. function NAVYGROUP:onbeforeUpdateRoute(From, Event, To, n, Speed, Depth) + -- Is transition allowed? We assume yes until proven otherwise. local allowed=true local trepeat=nil @@ -1057,6 +1053,9 @@ function NAVYGROUP:onbeforeUpdateRoute(From, Event, To, n, Speed, Depth) elseif self:IsHolding() then self:T(self.lid.."Update route denied. Group is holding position!") return false + elseif self:IsEngaging() then + self:T(self.lid.."Update route allowed. Group is engaging!") + return true end -- Check for a current task. @@ -1074,7 +1073,10 @@ function NAVYGROUP:onbeforeUpdateRoute(From, Event, To, n, Speed, Depth) self:T2(self.lid.."Allowing update route for Task: ReconMission") elseif task.dcstask.id==AUFTRAG.SpecialTask.RELOCATECOHORT then -- For relocate - self:T2(self.lid.."Allowing update route for Task: Relocate Cohort") + self:T2(self.lid.."Allowing update route for Task: Relocate Cohort") + elseif task.dcstask.id==AUFTRAG.SpecialTask.REARMING then + -- For rearming + self:T2(self.lid.."Allowing update route for Task: Rearming") else local taskname=task and task.description or "No description" self:T(self.lid..string.format("WARNING: Update route denied because taskcurrent=%d>0! Task description = %s", self.taskcurrent, tostring(taskname))) @@ -1106,7 +1108,6 @@ function NAVYGROUP:onbeforeUpdateRoute(From, Event, To, n, Speed, Depth) end return allowed - end --- On after "UpdateRoute" event. diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 19b62b238..210c7b90f 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -502,7 +502,7 @@ OPSGROUP.CargoStatus={ --- OpsGroup version. -- @field #string version -OPSGROUP.version="0.9.0" +OPSGROUP.version="1.0.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -625,6 +625,9 @@ function OPSGROUP:New(group) -- Set Default altitude. self:SetDefaultAltitude() + + -- Group will return to its legion when done. + self:SetReturnToLegion() -- Laser. self.spot={} @@ -1011,6 +1014,20 @@ function OPSGROUP:_SetLegion(Legion) return self end +--- **[GROUND, NAVAL]** Set whether this group should return to its legion once all mission etc are finished. Only for ground and naval groups. Aircraft will +-- @param #OPSGROUP self +-- @param #boolean Switch If `true` or `nil`, group will return. If `false`, group will not return and stay where it finishes its last mission. +-- @return #OPSGROUP self +function OPSGROUP:SetReturnToLegion(Switch) + if Switch==false then + self.legionReturn=false + else + self.legionReturn=true + end + self:T(self.lid..string.format("Setting ReturnToLetion=%s", tostring(self.legionReturn))) + return self +end + --- Set default cruise speed. -- @param #OPSGROUP self -- @param #number Speed Speed in knots. @@ -4385,7 +4402,7 @@ function OPSGROUP:_UpdateTask(Task, Mission) if self:IsArmygroup() or self:IsNavygroup() then -- Especially NAVYGROUP needs a full stop as patrol ad infinitum - self:FullStop() + self:__FullStop(0.1) else -- FLIGHTGROUP not implemented (intended!) for this AUFTRAG type. end @@ -5639,6 +5656,11 @@ function OPSGROUP:onafterMissionDone(From, Event, To, Mission) if Mission.icls then self:_SwitchICLS() end + + -- Return to legion? + if self.legion and Mission.legionReturn~=nil then + self:SetReturnToLegion(Mission.legionReturn) + end -- Delay before check if group is done. local delay=1 @@ -5966,7 +5988,7 @@ function OPSGROUP:RouteToMission(mission, delay) formation=ENUMS.Formation.Vehicle.OffRoad end - waypoint=ARMYGROUP.AddWaypoint(self, waypointcoord, SpeedToMission, uid, formation, false) + waypoint=ARMYGROUP.AddWaypoint(self, waypointcoord, SpeedToMission, uid, formation, false) elseif self:IsNavygroup() then @@ -7906,15 +7928,16 @@ function OPSGROUP:_CheckCargoTransport() self.cargoTransport=nil self.cargoTZC=nil end - + + -- Get current mission (if any). local mission=self:GetMissionCurrent() - if mission and mission.type==AUFTRAG.Type.NOTHING then - self:MissionCancel(mission) - end -- Check if there is anything in the queue. - if not self.cargoTransport and not self:IsOnMission() then --(mission==nil or (mission and mission.type==AUFTRAG.Type.NOTHING)) then --not self:IsOnMission() then + if (not self.cargoTransport) and (mission==nil or mission.type==AUFTRAG.Type.NOTHING) then self.cargoTransport=self:_GetNextCargoTransport() + if self.cargoTransport and mission then + self:MissionCancel(mission) + end if self.cargoTransport and not self:IsActive() then self:Activate() end @@ -9000,7 +9023,7 @@ function OPSGROUP:onafterLoading(From, Event, To) -- Check if current mission is using this ops transport. if isOnMission then local mission=cargo.opsgroup:GetMissionCurrent() - if mission and mission.opstransport and mission.opstransport.uid==self.cargoTransport.uid then + if mission and ((mission.opstransport and mission.opstransport.uid==self.cargoTransport.uid) or mission.type==AUFTRAG.Type.NOTHING) then isOnMission=not isHolding end end @@ -10303,7 +10326,7 @@ function OPSGROUP:_CheckGroupDone(delay) -- Passed FINAL waypoint --- - if self.legion then + if self.legion and self.legionReturn then self:T(self.lid..string.format("Passed final WP, adinfinitum=FALSE, LEGION set ==> RTZ")) if self.isArmygroup then