This commit is contained in:
Frank 2020-08-15 00:54:36 +02:00
parent 32c9a59ff0
commit adc89feda9
7 changed files with 108 additions and 29 deletions

View File

@ -157,15 +157,15 @@ function ARMYGROUP:GetClosestRoad()
end
--- Add a *scheduled* task.
--- Add a *scheduled* task to fire at a given coordinate.
-- @param #ARMYGROUP self
-- @param Core.Point#COORDINATE Coordinate Coordinate of the target.
-- @param #string Clock Time when to start the attack.
-- @param #number Radius Radius in meters. Default 100 m.
-- @param #number Nshots Number of shots to fire. Default 3.
-- @param #number WeaponType Type of weapon. Default auto.
-- @param #string Clock Time when to start the attack.
-- @param #number Prio Priority of the task.
function ARMYGROUP:AddTaskFireAtPoint(Coordinate, Radius, Nshots, WeaponType, Clock, Prio)
function ARMYGROUP:AddTaskFireAtPoint(Coordinate, Clock, Radius, Nshots, WeaponType, Prio)
local DCStask=CONTROLLABLE.TaskFireAtPoint(nil, Coordinate:GetVec2(), Radius, Nshots, WeaponType)
@ -173,7 +173,7 @@ function ARMYGROUP:AddTaskFireAtPoint(Coordinate, Radius, Nshots, WeaponType, Cl
end
--- Add a *waypoint* task.
--- Add a *waypoint* task to fire at a given coordinate.
-- @param #ARMYGROUP self
-- @param Core.Point#COORDINATE Coordinate Coordinate of the target.
-- @param Ops.OpsGroup#OPSGROUP.Waypoint Waypoint Where the task is executed. Default is next waypoint.

View File

@ -107,8 +107,9 @@
--
-- @field #number optionROE ROE.
-- @field #number optionROT ROT.
-- @field #number optionCM Counter measures.
-- @field #number optionAlarm Alarm state.
-- @field #number optionFormation Formation.
-- @field #number optionCM Counter measures.
-- @field #number optionRTBammo RTB on out-of-ammo.
-- @field #number optionRTBfuel RTB on out-of-fuel.
-- @field #number optionECM ECM.
@ -431,7 +432,7 @@ AUFTRAG.version="0.3.1"
-- TODO list
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Option to assign a specific payload for the mission (requires an AIRWING).
-- DONE: Option to assign a specific payload for the mission (requires an AIRWING).
-- TODO: Mission success options damaged, destroyed.
-- TODO: Recon mission. What input? Set of coordinates?
-- NOPE: Clone mission. How? Deepcopy? ==> Create a new auftrag.
@ -1169,6 +1170,7 @@ function AUFTRAG:NewTargetAir(Target)
self.engageTarget=Target
--[[
if Target.category==TARGET.Category.GROUND then
@ -1184,14 +1186,18 @@ function AUFTRAG:NewTargetAir(Target)
end
]]
local mission=self:NewAUTO()
local target=self.engageTarget:GetObject()
local mission=self:NewAUTO(target)
if mission then
mission:SetPriority(10, true)
end
return mission
end
@ -1411,6 +1417,15 @@ function AUFTRAG:SetRepeatOnFailure(Nrepeat)
return self
end
--- Set how many times the mission is repeated if it was successful.
-- @param #AUFTRAG self
-- @param #number Nrepeat Number of repeats. Default 0.
-- @return #AUFTRAG self
function AUFTRAG:SetRepeatOnSuccess(Nrepeat)
self.NrepeatSuccess=Nrepeat or 0
return self
end
--- Define how many assets are required to do the job.
-- @param #AUFTRAG self
-- @param #number Nassets Number of asset groups. Default 1.
@ -1549,6 +1564,17 @@ function AUFTRAG:SetROT(rot)
return self
end
--- Set alarm state for this mission.
-- @param #AUFTRAG self
-- @param #number Alarmstate Alarm state 0=Auto, 1=Green, 2=Red.
-- @return #AUFTRAG self
function AUFTRAG:SetAlarmstate(Alarmstate)
self.optionAlarm=Alarmstate
return self
end
--- Set formation for this mission.
-- @param #AUFTRAG self
-- @param #number Formation Formation.
@ -1688,7 +1714,7 @@ function AUFTRAG:AssignSquadrons(Squadrons)
self.squadrons=Squadrons
end
--- Set the required payload for this mission.
--- Set the required payload for this mission. Only available for use with an AIRWING.
-- @param #AUFTRAG self
-- @param Ops.AirWing#AIRWING.Payload Required payload
-- @return #AUFTRAG self
@ -2463,21 +2489,6 @@ function AUFTRAG:onafterAssetDead(From, Event, To, Asset)
end
--- On after "Success" event.
-- @param #AUFTRAG self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
function AUFTRAG:onafterSuccess(From, Event, To)
self.status=AUFTRAG.Status.SUCCESS
self:T(self.lid..string.format("New mission status=%s", self.status))
-- Stop mission.
self:Stop()
end
--- On after "Cancel" event. Cancells the mission.
-- @param #AUFTRAG self
-- @param #string From From state.
@ -2493,6 +2504,7 @@ function AUFTRAG:onafterCancel(From, Event, To)
-- No more repeats.
self.missionRepeatMax=self.missionRepeated
self.NrepeatSuccess=self.missionRepeated
-- Not necessary to delay the evaluaton?!
self.dTevaluate=0
@ -2529,6 +2541,32 @@ function AUFTRAG:onafterCancel(From, Event, To)
end
--- On after "Success" event.
-- @param #AUFTRAG self
-- @param #string From From state.
-- @param #string Event Event.
-- @param #string To To state.
function AUFTRAG:onafterSuccess(From, Event, To)
self.status=AUFTRAG.Status.SUCCESS
self:T(self.lid..string.format("New mission status=%s", self.status))
if self.missionRepeated>=self.NrepeatSuccess then
-- Stop mission.
self:I(self.lid..string.format("Mission SUCCESS! Number of max repeats reached [%d>=%d] ==> Stopping mission!", self.missionRepeated, self.NrepeatSuccess))
self:Stop()
else
-- Repeat mission.
self:I(self.lid..string.format("Mission SUCCESS! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.missionRepeated+1, self.NrepeatSuccess))
self:Repeat()
end
end
--- On after "Failed" event.
-- @param #AUFTRAG self
-- @param #string From From state.
@ -2547,7 +2585,7 @@ function AUFTRAG:onafterFailed(From, Event, To)
else
-- Repeat mission.
self:I(self.lid..string.format("Mission failed! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.missionRepeated+1, self.missionRepeatMax))
self:I(self.lid..string.format("Mission FAILED! Repeating mission for the %d time (max %d times) ==> Repeat mission!", self.missionRepeated+1, self.missionRepeatMax))
self:Repeat()
end

View File

@ -189,10 +189,10 @@ end
--- Add a *scheduled* task.
-- @param #NAVYGROUP self
-- @param Core.Point#COORDINATE Coordinate Coordinate of the target.
-- @param #string Clock Time when to start the attack.
-- @param #number Radius Radius in meters. Default 100 m.
-- @param #number Nshots Number of shots to fire. Default 3.
-- @param #number WeaponType Type of weapon. Default auto.
-- @param #string Clock Time when to start the attack.
-- @param #number Prio Priority of the task.
-- @return Ops.OpsGroup#OPSGROUP.Task The task data.
function NAVYGROUP:AddTaskFireAtPoint(Coordinate, Radius, Nshots, WeaponType, Clock, Prio)

View File

@ -252,6 +252,7 @@ OPSGROUP.TaskType={
-- @field #boolean detour If true, this waypoint is not part of the normal route.
-- @field #boolean intowind If true, this waypoint is a turn into wind route point.
-- @field #boolean astar If true, this waypint was found by A* pathfinding algorithm.
-- @field #number npassed Number of times a groups passed this waypoint.
-- @field Core.Point#COORDINATE coordinate Waypoint coordinate.
-- @field Core.Point#COORDINATE roadcoord Closest point to road.
-- @field #number roaddist Distance to closest point on road.
@ -1851,13 +1852,13 @@ function OPSGROUP:onbeforeMissionStart(From, Event, To, Mission)
-- Activate group if it is late activated.
if self:IsLateActivated() then
self:Activate(delay)
--delay=delay+1
delay=delay+1
end
end
-- Startup group if it is uncontrolled.
if self.isAircraft and self:IsParking() and self:IsUncontrolled() then
if self.isAircraft and self:IsUncontrolled() then
self:StartUncontrolled(delay)
end

View File

@ -241,12 +241,12 @@ function SQUADRON:SetSkill(Skill)
return self
end
--- Set maintenance and repair time.
--- Set turnover and repair time. If an asset returns from a mission to the airwing, it will need some time until the asset is available for further missions.
-- @param #SQUADRON self
-- @param #number MaintenanceTime Time in minutes it takes until a flight is combat ready again. Default is 0 min.
-- @param #number RepairTime Time in minutes it takes to repair a flight for each percent damage taken. Default is 0 min.
-- @return #SQUADRON self
function SQUADRON:SetMaintenanceTime(MaintenanceTime, RepairTime)
function SQUADRON:SetTurnoverTime(MaintenanceTime, RepairTime)
self.maintenancetime=MaintenanceTime and MaintenanceTime*60 or 0
self.repairtime=RepairTime and RepairTime*60 or 0
return self

View File

@ -764,6 +764,35 @@ function TARGET:GetTargetByName(ObjectName)
end
--- Get the first target objective alive.
-- @param #TARGET self
-- @return #TARGET.Object The target objective.
function TARGET:GetObjective()
for _,_target in pairs(self.targets) do
local target=_target --#TARGET.Object
if target.Status==TARGET.ObjectStatus.ALIVE then
return target
end
end
return nil
end
--- Get the first target object alive.
-- @param #TARGET self
-- @return Wrapper.Positionable#POSITIONABLE The target object or nil.
function TARGET:GetObject()
local target=self:GetObjective()
if target then
return target.Object
end
return nil
end
--- Count alive targets.
-- @param #TARGET self
-- @return #number Number of alive target objects.

View File

@ -56,6 +56,17 @@ ENUMS.ROT = {
AllowAbortMission=4,
}
--- Alarm state.
-- @type ENUMS.AlarmState
-- @field #number Auto AI will automatically switch alarm states based on the presence of threats. The AI kind of cheats in this regard.
-- @field #number Green Group is not combat ready. Sensors are stowed if possible.
-- @field #number Red Group is combat ready and actively searching for targets. Some groups like infantry will not move in this state.
ENUMS.AlarmState = {
Auto=0,
Green=1,
Red=2,
}
--- Weapon types. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerotor on hoggit wiki.
-- @type ENUMS.WeaponFlag
ENUMS.WeaponFlag={