Update Auftrag.lua

- condition success and failure evaluation
This commit is contained in:
Frank
2023-01-28 22:31:53 +01:00
parent f3d1378692
commit 4cc1db1365

View File

@@ -639,7 +639,7 @@ AUFTRAG.Category={
--- AUFTRAG class version. --- AUFTRAG class version.
-- @field #string version -- @field #string version
AUFTRAG.version="0.9.10" AUFTRAG.version="1.0.0"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@@ -3375,7 +3375,7 @@ function AUFTRAG:GetPriority()
return self.prio return self.prio
end end
--- Get casualties, i.e. number of units that died during this mission. --- Get casualties, *i.e.* number of own units that died during this mission.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @return #number Number of dead units. -- @return #number Number of dead units.
function AUFTRAG:GetCasualties() function AUFTRAG:GetCasualties()
@@ -3903,6 +3903,15 @@ function AUFTRAG:onafterStatus(From, Event, To)
local Nassigned=self.Nassigned and self.Nassigned-self.Ndead or 0 local Nassigned=self.Nassigned and self.Nassigned-self.Ndead or 0
-- check conditions if set
local conditionDone=false
if self.conditionFailureSet then
conditionDone = self:EvalConditionsAny(self.conditionFailure)
end
if self.conditionSuccessSet and not conditionDone then
conditionDone = self:EvalConditionsAny(self.conditionSuccess)
end
-- Check if mission is not OVER yet. -- Check if mission is not OVER yet.
if self:IsNotOver() then if self:IsNotOver() then
@@ -3916,6 +3925,11 @@ function AUFTRAG:onafterStatus(From, Event, To)
-- Cancel mission if stop time passed. -- Cancel mission if stop time passed.
self:Cancel() self:Cancel()
elseif conditionDone then
-- Cancel mission if conditions were met.
self:Cancel()
elseif self.durationExe and self.Texecuting and Tnow-self.Texecuting>self.durationExe then elseif self.durationExe and self.Texecuting and Tnow-self.Texecuting>self.durationExe then
-- Backup repeat values -- Backup repeat values
@@ -4015,17 +4029,6 @@ function AUFTRAG:onafterStatus(From, Event, To)
self:I(self.lid..text) self:I(self.lid..text)
end end
-- check conditions if set
if self.conditionFailureSet then
local failed = self:EvalConditionsAny(self.conditionFailure)
if failed then self:__Failed(-1) end
end
if self.conditionSuccessSet then
local success = self:EvalConditionsAny(self.conditionSuccess)
if success then self:__Success(-1) end
end
-- Ready to evaluate mission outcome? -- Ready to evaluate mission outcome?
local ready2evaluate=self.Tover and Tnow-self.Tover>=self.dTevaluate or false local ready2evaluate=self.Tover and Tnow-self.Tover>=self.dTevaluate or false