diff --git a/Moose Development/Moose/Ops/FlightControl.lua b/Moose Development/Moose/Ops/FlightControl.lua index 48755bd0a..840d2e3e2 100644 --- a/Moose Development/Moose/Ops/FlightControl.lua +++ b/Moose Development/Moose/Ops/FlightControl.lua @@ -327,7 +327,7 @@ FLIGHTCONTROL.FlightStatus={ --- FlightControl class version. -- @field #string version -FLIGHTCONTROL.version="0.7.1" +FLIGHTCONTROL.version="0.7.2" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list @@ -591,6 +591,7 @@ function FLIGHTCONTROL:_SetSRSOptions(msrs, Gender, Culture, Voice, Volume, Labe msrs:SetVolume(Volume) msrs:SetLabel(Label) msrs:SetGoogle(PathToGoogleCredentials) + msrs:SetCoalition(self:GetCoalition()) end return self diff --git a/Moose Development/Moose/Ops/OpsZone.lua b/Moose Development/Moose/Ops/OpsZone.lua index ce8f3227b..40d0d7623 100644 --- a/Moose Development/Moose/Ops/OpsZone.lua +++ b/Moose Development/Moose/Ops/OpsZone.lua @@ -30,6 +30,8 @@ -- @field #number Nred Number of red units in the zone. -- @field #number Nblu Number of blue units in the zone. -- @field #number Nnut Number of neutral units in the zone. +-- @field #number TminCaptured Time interval in seconds how long an attacker must have troops inside the zone to capture. +-- @field #number Tcaptured Time stamp (abs.) when the attacker destroyed all owning troops. -- @field #table ObjectCategories Object categories for the scan. -- @field #table UnitCategories Unit categories for the scan. -- @field #number Tattacked Abs. mission time stamp when an attack was started. @@ -74,7 +76,7 @@ OPSZONE = { --- OPSZONE class version. -- @field #string version -OPSZONE.version="0.3.0" +OPSZONE.version="0.3.1" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- ToDo list @@ -163,6 +165,9 @@ function OPSZONE:New(Zone, CoalitionOwner) self.ownerPrevious=self.airbase:GetCoalition() end + -- Set time to capture. + self:SetTimeCapture() + -- Set object categories. self:SetObjectCategories() self:SetUnitCategories() @@ -390,6 +395,18 @@ function OPSZONE:SetThreatlevelOffending(Threatlevel) end +--- Set time how long an attacking coalition must have troops inside a zone before it captures the zone. +-- @param #OPSZONE self +-- @param #number Tcapture Time in seconds. Default 0. +-- @return #OPSZONE self +function OPSZONE:SetTimeCapture(Tcapture) + + self.TminCaptured=Tcapture or 0 + + return self +end + + --- Set whether *neutral* units can capture the zone. -- @param #OPSZONE self -- @param #boolean CanCapture If `true`, neutral units can. @@ -680,6 +697,23 @@ end -- FSM Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +--- On before "Captured" event. +-- @param #OPSZONE self +-- @param #string From From state. +-- @param #string Event Event. +-- @param #string To To state. +-- @param #number NewOwnerCoalition Coalition of the new owner. +function OPSZONE:onbeforeCaptured(From, Event, To, NewOwnerCoalition) + + -- Check if owner changed. + + if self.ownerCurrent==NewOwnerCoalition then + self:T(self.lid.."") + end + + return true +end + --- On after "Captured" event. -- @param #OPSZONE self -- @param #string From From state. @@ -1004,12 +1038,34 @@ function OPSZONE:EvaluateZone() if Nblu>0 then -- Blue captured red zone. if not self.airbase then - self:Captured(coalition.side.BLUE) + local Tnow=timer.getAbsTime() + + -- Set time stamp if it does not exist. + if not self.Tcaptured then + self.Tcaptured=Tnow + end + + -- Check if enough time elapsed. + if Tnow-self.Tcaptured>=self.TminCaptured then + self:Captured(coalition.side.BLUE) + self.Tcaptured=nil + end end elseif Nnut>0 and self.neutralCanCapture then -- Neutral captured red zone. if not self.airbase then - self:Captured(coalition.side.NEUTRAL) + local Tnow=timer.getAbsTime() + + -- Set time stamp if it does not exist. + if not self.Tcaptured then + self.Tcaptured=Tnow + end + + -- Check if enough time elapsed. + if Tnow-self.Tcaptured>=self.TminCaptured then + self:Captured(coalition.side.NEUTRAL) + self.Tcaptured=nil + end end else -- Red zone is now empty (but will remain red).