From 6f61d160af6c1dcf604ae2b44f81c89844e0f953 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Mon, 18 Nov 2024 08:54:21 +0100 Subject: [PATCH 1/3] Documentation --- Moose Development/Moose/Ops/PlayerTask.lua | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 25d53d788..6e5f33ce0 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -21,7 +21,7 @@ -- === -- @module Ops.PlayerTask -- @image OPS_PlayerTask.jpg --- @date Last Update May 2024 +-- @date Last Update Nov 2024 do @@ -274,7 +274,9 @@ function PLAYERTASK:NewFromTarget(Target, Repeat, Times, TTSType) end --- [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) local group = nil --Wrapper.Group#GROUP @@ -1310,11 +1312,34 @@ do -- * Anti-Ship - Any ship targets, if the controller is of type "A2S" -- * CTLD - Combat transport and logistics deployment -- * 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 -- -- 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) -- -- The system can optionally communicate to players via SRS. Also localization is available, both "en" and "de" has been build in already. From 46d2c9c196ce2fa1f25b93442646367e5dd3e353 Mon Sep 17 00:00:00 2001 From: shaji Date: Mon, 18 Nov 2024 09:25:00 +0100 Subject: [PATCH 2/3] [Added] Usage to doc for `PLAYERTASK:AddStaticObjectSuccessCondition`, `PLAYERTASK:AddOpsZoneCaptureSuccessCondition`, `PLAYERTASK:AddReconSuccessCondition`, `PLAYERTASK:AddTimeLimitFailureCondition` --- Moose Development/Moose/Ops/PlayerTask.lua | 46 +++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 25d53d788..e46b9a989 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -504,6 +504,14 @@ end --- [USER] Adds task success condition for dead STATIC, SET_STATIC, SCENERY or SET_SCENERY target object. -- @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() local task = self -- TODO Check if the killer is one of the task clients @@ -547,6 +555,22 @@ end -- @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( @@ -580,8 +604,18 @@ end --- [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 #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 +-- @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) local task = self task:AddConditionSuccess( @@ -607,6 +641,16 @@ end -- @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 From 93cff9679448d119f687733f531ceef536f52f67 Mon Sep 17 00:00:00 2001 From: shaji Date: Tue, 19 Nov 2024 00:42:37 +0100 Subject: [PATCH 3/3] [Added] `OPSZONE:SetDrawZoneForCoalition` to set if zone is drawn on the F10 map for the owner coalition only instead for all. Useful for recon tasking and fog of war. --- Moose Development/Moose/Ops/OpsZone.lua | 45 ++++++++++++++++++++----- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Ops/OpsZone.lua b/Moose Development/Moose/Ops/OpsZone.lua index e97b0688d..a0bc36226 100644 --- a/Moose Development/Moose/Ops/OpsZone.lua +++ b/Moose Development/Moose/Ops/OpsZone.lua @@ -490,6 +490,19 @@ function OPSZONE:SetDrawZone(Switch) return self 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. -- @param #OPSZONE self -- @param #boolean Switch If `true`, zone is marked. If `false` or `nil`, zone is not marked. @@ -837,8 +850,12 @@ function OPSZONE:onafterCaptured(From, Event, To, NewOwnerCoalition) self.zone:UndrawZone() 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 for _,_chief in pairs(self.chiefs) do @@ -913,8 +930,12 @@ function OPSZONE:onenterGuarded(From, Event, To) self.zone:UndrawZone() 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 @@ -954,9 +975,13 @@ function OPSZONE:onenterAttacked(From, Event, To, AttackerCoalition) -- Color. local color={1, 204/255, 204/255} - + + local coalition = nil + if self.drawZoneForCoalition then + coalition = self.ownerCurrent + end -- Draw zone. - self.zone:DrawZone(nil, color, 1.0, color, 0.5) + self.zone:DrawZone(coalition, color, 1.0, color, 0.5) end self:_CleanMissionTable() @@ -987,8 +1012,12 @@ function OPSZONE:onenterEmpty(From, Event, To) self.zone:UndrawZone() 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