mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'develop' of https://github.com/FlightControl-Master/MOOSE into develop
This commit is contained in:
@@ -490,6 +490,19 @@ function OPSZONE:SetDrawZone(Switch)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set if zone is drawn on the F10 map for the owner coalition only.
|
||||||
|
-- @param #OPSZONE self
|
||||||
|
-- @param #boolean Switch If `false` or `nil`, draw zone for all coalitions. If `true`, zone is drawn for the owning coalition only if drawZone is true.
|
||||||
|
-- @return #OPSZONE self
|
||||||
|
function OPSZONE:SetDrawZoneForCoalition(Switch)
|
||||||
|
if Switch==true then
|
||||||
|
self.drawZoneForCoalition=true
|
||||||
|
else
|
||||||
|
self.drawZoneForCoalition=false
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Set if a marker on the F10 map shows the current zone status.
|
--- Set if a marker on the F10 map shows the current zone status.
|
||||||
-- @param #OPSZONE self
|
-- @param #OPSZONE self
|
||||||
-- @param #boolean Switch If `true`, zone is marked. If `false` or `nil`, zone is not marked.
|
-- @param #boolean Switch If `true`, zone is marked. If `false` or `nil`, zone is not marked.
|
||||||
@@ -838,7 +851,11 @@ function OPSZONE:onafterCaptured(From, Event, To, NewOwnerCoalition)
|
|||||||
|
|
||||||
local color=self:_GetZoneColor()
|
local color=self:_GetZoneColor()
|
||||||
|
|
||||||
self.zone:DrawZone(nil, color, 1.0, color, 0.5)
|
local coalition = nil
|
||||||
|
if self.drawZoneForCoalition then
|
||||||
|
coalition = self.ownerCurrent
|
||||||
|
end
|
||||||
|
self.zone:DrawZone(coalition, color, 1.0, color, 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,_chief in pairs(self.chiefs) do
|
for _,_chief in pairs(self.chiefs) do
|
||||||
@@ -914,7 +931,11 @@ function OPSZONE:onenterGuarded(From, Event, To)
|
|||||||
|
|
||||||
local color=self:_GetZoneColor()
|
local color=self:_GetZoneColor()
|
||||||
|
|
||||||
self.zone:DrawZone(nil, color, 1.0, color, 0.5)
|
local coalition = nil
|
||||||
|
if self.drawZoneForCoalition then
|
||||||
|
coalition = self.ownerCurrent
|
||||||
|
end
|
||||||
|
self.zone:DrawZone(coalition, color, 1.0, color, 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -955,8 +976,12 @@ function OPSZONE:onenterAttacked(From, Event, To, AttackerCoalition)
|
|||||||
-- Color.
|
-- Color.
|
||||||
local color={1, 204/255, 204/255}
|
local color={1, 204/255, 204/255}
|
||||||
|
|
||||||
|
local coalition = nil
|
||||||
|
if self.drawZoneForCoalition then
|
||||||
|
coalition = self.ownerCurrent
|
||||||
|
end
|
||||||
-- Draw zone.
|
-- Draw zone.
|
||||||
self.zone:DrawZone(nil, color, 1.0, color, 0.5)
|
self.zone:DrawZone(coalition, color, 1.0, color, 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:_CleanMissionTable()
|
self:_CleanMissionTable()
|
||||||
@@ -988,7 +1013,11 @@ function OPSZONE:onenterEmpty(From, Event, To)
|
|||||||
|
|
||||||
local color=self:_GetZoneColor()
|
local color=self:_GetZoneColor()
|
||||||
|
|
||||||
self.zone:DrawZone(nil, color, 1.0, color, 0.2)
|
local coalition = nil
|
||||||
|
if self.drawZoneForCoalition then
|
||||||
|
coalition = self.ownerCurrent
|
||||||
|
end
|
||||||
|
self.zone:DrawZone(coalition, color, 1.0, color, 0.2)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
-- ===
|
-- ===
|
||||||
-- @module Ops.PlayerTask
|
-- @module Ops.PlayerTask
|
||||||
-- @image OPS_PlayerTask.jpg
|
-- @image OPS_PlayerTask.jpg
|
||||||
-- @date Last Update May 2024
|
-- @date Last Update Nov 2024
|
||||||
|
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -274,7 +274,9 @@ function PLAYERTASK:NewFromTarget(Target, Repeat, Times, TTSType)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- [Internal] Determines AUFTRAG type based on the target characteristics.
|
--- [Internal] Determines AUFTRAG type based on the target characteristics.
|
||||||
-- @return #AUFTRAG.Type self
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param Ops.Target#TARGET Target Target for this task
|
||||||
|
-- @return #string AUFTRAG.Type
|
||||||
function PLAYERTASK:_GetTaskTypeForTarget(Target)
|
function PLAYERTASK:_GetTaskTypeForTarget(Target)
|
||||||
|
|
||||||
local group = nil --Wrapper.Group#GROUP
|
local group = nil --Wrapper.Group#GROUP
|
||||||
@@ -299,6 +301,9 @@ function PLAYERTASK:_GetTaskTypeForTarget(Target)
|
|||||||
|
|
||||||
auftrag = AUFTRAG.Type.BOMBING
|
auftrag = AUFTRAG.Type.BOMBING
|
||||||
|
|
||||||
|
elseif Target:IsInstanceOf("OPSZONE")
|
||||||
|
or Target:IsInstanceOf("SET_OPSZONE") then
|
||||||
|
auftrag = AUFTRAG.Type.CAPTUREZONE
|
||||||
end
|
end
|
||||||
|
|
||||||
if group then
|
if group then
|
||||||
@@ -351,6 +356,38 @@ function PLAYERTASK:_GetTaskTypeForTarget(Target)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- [Internal] Check OpsZone capture success condition.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param Ops.OpsZone#OPSZONE OpsZone The OpsZone target object.
|
||||||
|
-- @param #string CaptureSquadGroupNamePrefix The prefix of the group name that needs to capture the zone.
|
||||||
|
-- @param #number Coalition The coalition that needs to capture the zone.
|
||||||
|
-- @param #boolean CheckClientInZone Check if any of the clients are in zone.
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:_CheckCaptureOpsZoneSuccess(OpsZone, CaptureSquadGroupNamePrefix, Coalition, CheckClientInZone)
|
||||||
|
local isClientInZone = true
|
||||||
|
if CheckClientInZone then
|
||||||
|
isClientInZone = false
|
||||||
|
for _, client in ipairs(self:GetClientObjects()) do
|
||||||
|
local clientCoord = client:GetCoordinate()
|
||||||
|
if OpsZone.zone:IsCoordinateInZone(clientCoord) then
|
||||||
|
isClientInZone = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local isCaptureGroupInZone = false
|
||||||
|
OpsZone:GetScannedGroupSet():ForEachGroup(function(group)
|
||||||
|
if string.find(group:GetName(), CaptureSquadGroupNamePrefix) then
|
||||||
|
isCaptureGroupInZone = true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
return OpsZone:GetOwner() == Coalition and isClientInZone and isCaptureGroupInZone
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- [Internal] Add a PLAYERTASKCONTROLLER for this task
|
--- [Internal] Add a PLAYERTASKCONTROLLER for this task
|
||||||
-- @param #PLAYERTASK self
|
-- @param #PLAYERTASK self
|
||||||
-- @param Ops.PlayerTask#PLAYERTASKCONTROLLER Controller
|
-- @param Ops.PlayerTask#PLAYERTASKCONTROLLER Controller
|
||||||
@@ -469,8 +506,17 @@ end
|
|||||||
|
|
||||||
--- [USER] Adds task success condition for dead STATIC, SET_STATIC, SCENERY or SET_SCENERY target object.
|
--- [USER] Adds task success condition for dead STATIC, SET_STATIC, SCENERY or SET_SCENERY target object.
|
||||||
-- @return #PLAYERTASK self
|
-- @return #PLAYERTASK self
|
||||||
|
-- @usage
|
||||||
|
-- -- We can use either STATIC, SET_STATIC, SCENERY or SET_SCENERY as target objects.
|
||||||
|
-- local mytask = PLAYERTASK:NewFromTarget(static, true, 50, "Destroy the target")
|
||||||
|
-- mytask:SetMenuName("Destroy Power Plant")
|
||||||
|
-- mytask:AddFreetext("Locate and destroy the power plant near Olenya.")
|
||||||
|
-- mytask:AddStaticObjectSuccessCondition()
|
||||||
|
--
|
||||||
|
-- playerTaskManager:AddPlayerTaskToQueue(mytask)
|
||||||
function PLAYERTASK:AddStaticObjectSuccessCondition()
|
function PLAYERTASK:AddStaticObjectSuccessCondition()
|
||||||
local task = self
|
local task = self
|
||||||
|
-- TODO Check if the killer is one of the task clients
|
||||||
task:AddConditionSuccess(
|
task:AddConditionSuccess(
|
||||||
function(target)
|
function(target)
|
||||||
if target == nil then return false end
|
if target == nil then return false end
|
||||||
@@ -496,13 +542,82 @@ function PLAYERTASK:AddStaticObjectSuccessCondition()
|
|||||||
return isDead
|
return isDead
|
||||||
end, task:GetTarget()
|
end, task:GetTarget()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- TODO Check if the killer is one of the task clients
|
||||||
|
--task:AddConditionFailure(
|
||||||
|
-- function()
|
||||||
|
--
|
||||||
|
-- end)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Adds task success condition for AUFTRAG.Type.CAPTUREZONE for OpsZone or OpsZone set target object.
|
||||||
|
--- At least one of the task clients and one capture group need to be inside the zone in order for the capture to be successful.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #SET_BASE CaptureSquadGroupNamePrefix The prefix of the group name that needs to capture the zone.
|
||||||
|
-- @param #number Coalition The coalition that needs to capture the zone.
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
-- @usage
|
||||||
|
-- -- We can use either STATIC, SET_STATIC, SCENERY or SET_SCENERY as target objects.
|
||||||
|
-- local opsZone = OPSZONE:New(zone, coalition.side.RED)
|
||||||
|
--
|
||||||
|
-- ...
|
||||||
|
--
|
||||||
|
-- -- We can use either OPSZONE or SET_OPSZONE.
|
||||||
|
-- local mytask = PLAYERTASK:NewFromTarget(opsZone, true, 50, "Capture the zone")
|
||||||
|
-- mytask:SetMenuName("Capture the ops zone")
|
||||||
|
-- mytask:AddFreetext("Transport capture squad to the ops zone.")
|
||||||
|
--
|
||||||
|
-- -- We set CaptureSquadGroupNamePrefix the group name prefix as set in the ME or the spawn of the group that need to be present at the OpsZone like a capture squad,
|
||||||
|
-- -- and set the capturing Coalition in order to trigger a successful task.
|
||||||
|
-- mytask:AddOpsZoneCaptureSuccessCondition("capture-squad", coalition.side.BLUE)
|
||||||
|
--
|
||||||
|
-- playerTaskManager:AddPlayerTaskToQueue(mytask)
|
||||||
|
function PLAYERTASK:AddOpsZoneCaptureSuccessCondition(CaptureSquadGroupNamePrefix, Coalition)
|
||||||
|
local task = self
|
||||||
|
task:AddConditionSuccess(
|
||||||
|
function(target)
|
||||||
|
if target:IsInstanceOf("OPSZONE") then
|
||||||
|
return task:_CheckCaptureOpsZoneSuccess(target, CaptureSquadGroupNamePrefix, Coalition, true)
|
||||||
|
elseif target:IsInstanceOf("SET_OPSZONE") then
|
||||||
|
local successes = 0
|
||||||
|
local isClientInZone = false
|
||||||
|
target:ForEachZone(function(opszone)
|
||||||
|
if task:_CheckCaptureOpsZoneSuccess(opszone, CaptureSquadGroupNamePrefix, Coalition) then
|
||||||
|
successes = successes + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, client in ipairs(task:GetClientObjects()) do
|
||||||
|
local clientCoord = client:GetCoordinate()
|
||||||
|
if opszone.zone:IsCoordinateInZone(clientCoord) then
|
||||||
|
isClientInZone = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return successes == target:Count() and isClientInZone
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end, task:GetTarget()
|
||||||
|
)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- [USER] Adds task success condition for AUFTRAG.Type.RECON when a client is at a certain LOS distance from the target.
|
--- [USER] Adds task success condition for AUFTRAG.Type.RECON when a client is at a certain LOS distance from the target.
|
||||||
-- @param #PLAYERTASK self
|
-- @param #PLAYERTASK self
|
||||||
-- @param #number MinDistance Minimum distance in meters from client to target in LOS for success condition. (Default 5 NM)
|
-- @param #number MinDistance (Optional) Minimum distance in meters from client to target in LOS for success condition. (Default 5 NM)
|
||||||
-- @return #PLAYERTASK self
|
-- @return #PLAYERTASK self
|
||||||
|
-- @usage
|
||||||
|
-- -- target can be any object that has a `GetCoordinate()` function like STATIC, GROUP, ZONE...
|
||||||
|
-- local mytask = PLAYERTASK:New(AUFTRAG.Type.RECON, ZONE:New("WF Zone"), true, 50, "Deep Earth")
|
||||||
|
-- mytask:SetMenuName("Recon weapon factory")
|
||||||
|
-- mytask:AddFreetext("Locate and investigate underground weapons factory near Kovdor.")
|
||||||
|
--
|
||||||
|
-- -- We set the MinDistance (optional) in meters for the client to be in LOS from the target in order to trigger a successful task.
|
||||||
|
-- mytask:AddReconSuccessCondition(10000) -- 10 km (default is 5 NM if not set)
|
||||||
|
--
|
||||||
|
-- playerTaskManager:AddPlayerTaskToQueue(mytask)
|
||||||
function PLAYERTASK:AddReconSuccessCondition(MinDistance)
|
function PLAYERTASK:AddReconSuccessCondition(MinDistance)
|
||||||
local task = self
|
local task = self
|
||||||
task:AddConditionSuccess(
|
task:AddConditionSuccess(
|
||||||
@@ -524,6 +639,34 @@ function PLAYERTASK:AddReconSuccessCondition(MinDistance)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [USER] Adds a time limit for the task to be completed.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #number TimeLimit Time limit in seconds for the task to be completed. (Default 0 = no time limit)
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
-- @usage
|
||||||
|
-- local mytask = PLAYERTASK:New(AUFTRAG.Type.RECON, ZONE:New("WF Zone"), true, 50, "Deep Earth")
|
||||||
|
-- mytask:SetMenuName("Recon weapon factory")
|
||||||
|
-- mytask:AddFreetext("Locate and investigate underground weapons factory near Kovdor.")
|
||||||
|
-- mytask:AddReconSuccessCondition(10000) -- 10 km
|
||||||
|
--
|
||||||
|
-- -- We set the TimeLimit to 10 minutes (600 seconds) from the moment the task is started, once the time has passed and the task is not yet successful it will trigger a failure.
|
||||||
|
-- mytask:AddTimeLimitFailureCondition(600)
|
||||||
|
--
|
||||||
|
-- playerTaskManager:AddPlayerTaskToQueue(mytask)
|
||||||
|
function PLAYERTASK:AddTimeLimitFailureCondition(TimeLimit)
|
||||||
|
local task = self
|
||||||
|
TimeLimit = TimeLimit or 0
|
||||||
|
task.StartTime = -1
|
||||||
|
task:AddConditionFailure(
|
||||||
|
function()
|
||||||
|
if task.StartTime == -1 then
|
||||||
|
task.StartTime = timer.getTime()
|
||||||
|
end
|
||||||
|
return TimeLimit > 0 and timer.getTime() - task.StartTime > TimeLimit
|
||||||
|
end)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- [USER] Add a task to be assigned to same clients when task was a success.
|
--- [USER] Add a task to be assigned to same clients when task was a success.
|
||||||
-- @param #PLAYERTASK self
|
-- @param #PLAYERTASK self
|
||||||
-- @param Ops.PlayerTask#PLAYERTASK Task
|
-- @param Ops.PlayerTask#PLAYERTASK Task
|
||||||
@@ -1213,11 +1356,34 @@ do
|
|||||||
-- * Anti-Ship - Any ship targets, if the controller is of type "A2S"
|
-- * Anti-Ship - Any ship targets, if the controller is of type "A2S"
|
||||||
-- * CTLD - Combat transport and logistics deployment
|
-- * CTLD - Combat transport and logistics deployment
|
||||||
-- * CSAR - Combat search and rescue
|
-- * CSAR - Combat search and rescue
|
||||||
|
-- * RECON - Identify targets
|
||||||
|
-- * CAPTUREZONE - Capture an Ops.OpsZone#OPSZONE
|
||||||
|
-- * Any #string name can be passed as Auftrag type, but then you need to make sure to define a success condition, and possibly also add the task type to the standard scoring list: `PLAYERTASKCONTROLLER.Scores["yournamehere"]=100`
|
||||||
--
|
--
|
||||||
-- ## 3 Task repetition
|
-- ## 3 Task repetition
|
||||||
--
|
--
|
||||||
-- On failure, tasks will be replanned by default for a maximum of 5 times.
|
-- On failure, tasks will be replanned by default for a maximum of 5 times.
|
||||||
--
|
--
|
||||||
|
-- ## 3.1 Pre-configured success conditions
|
||||||
|
--
|
||||||
|
-- Pre-configured success conditions for #PLAYERTASK tasks are available as follows:
|
||||||
|
--
|
||||||
|
-- `mytask:AddStaticObjectSuccessCondition()` -- success if static object is at least 80% dead
|
||||||
|
--
|
||||||
|
-- `mytask:AddOpsZoneCaptureSuccessCondition(CaptureSquadGroupNamePrefix,Coalition)` -- success if a squad of the given (partial) name and coalition captures the OpsZone
|
||||||
|
--
|
||||||
|
-- `mytask:AddReconSuccessCondition(MinDistance)` -- success if object is in line-of-sight with the given min distance in NM
|
||||||
|
--
|
||||||
|
-- `mytask:AddTimeLimitSuccessCondition(TimeLimit)` -- failure if the task is not completed within the time limit in seconds given
|
||||||
|
--
|
||||||
|
-- ## 3.2 Task chaining
|
||||||
|
--
|
||||||
|
-- You can create chains of tasks, which will depend on success or failure of the previous task with the following commands:
|
||||||
|
--
|
||||||
|
-- `mytask:AddNextTaskAfterSuccess(FollowUpTask)` and
|
||||||
|
--
|
||||||
|
-- `mytask:AddNextTaskAfterFailure(FollowUpTask)`
|
||||||
|
--
|
||||||
-- ## 4 SETTINGS, SRS and language options (localization)
|
-- ## 4 SETTINGS, SRS and language options (localization)
|
||||||
--
|
--
|
||||||
-- The system can optionally communicate to players via SRS. Also localization is available, both "en" and "de" has been build in already.
|
-- The system can optionally communicate to players via SRS. Also localization is available, both "en" and "de" has been build in already.
|
||||||
@@ -1534,6 +1700,7 @@ PLAYERTASKCONTROLLER.Scores = {
|
|||||||
[AUFTRAG.Type.RECON] = 100,
|
[AUFTRAG.Type.RECON] = 100,
|
||||||
[AUFTRAG.Type.ESCORT] = 100,
|
[AUFTRAG.Type.ESCORT] = 100,
|
||||||
[AUFTRAG.Type.CAP] = 100,
|
[AUFTRAG.Type.CAP] = 100,
|
||||||
|
[AUFTRAG.Type.CAPTUREZONE] = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user