From 9a2829730c94909d04ed33a7751970f1adb78234 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 12 Oct 2022 12:46:32 +0200 Subject: [PATCH] #CTLD PlayerTask --- Moose Development/Moose/Ops/CTLD.lua | 30 ++++++++++++++++++---- Moose Development/Moose/Ops/PlayerTask.lua | 10 ++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index a25f01a5e..3b5920842 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -288,8 +288,8 @@ CTLD_ENGINEERING = { end -do - + +do ------------------------------------------------------ --- **CTLD_CARGO** class, extends Core.Base#BASE -- @type CTLD_CARGO @@ -308,7 +308,6 @@ do -- @field #string Subcategory Sub-category name. -- @extends Core.Base#BASE - --- -- @field CTLD_CARGO CTLD_CARGO = { @@ -1072,7 +1071,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.12" +CTLD.version="1.0.14" --- Instantiate a new CTLD. -- @param #CTLD self @@ -4434,6 +4433,27 @@ end -- @return #CTLD self function CTLD:onbeforeTroopsDeployed(From, Event, To, Group, Unit, Troops) self:T({From, Event, To}) + if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then + local playername = Unit:GetPlayerName() + local dropcoord = Troops:GetCoordinate() or COORDINATE:New(0,0,0) + local dropvec2 = dropcoord:GetVec2() + self.PlayerTaskQueue:ForEach( + function (Task) + local task = Task -- Ops.PlayerTask#PLAYERTASK + local subtype = task:GetSubType() + -- right subtype? + if Event == subtype and not task:IsDone() then + local targetzone = task.Target:GetObject() -- Core.Zone#ZONE should be a zone in this case .... + if targetzone and targetzone.ClassName and string.match(targetzone.ClassName,"ZONE") and targetzone:IsVec2InZone(dropvec2) then + if task.Clients:HasUniqueID(playername) then + -- success + task:__Success(-1) + end + end + end + end + ) + end return self end @@ -4461,7 +4481,7 @@ end -- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build. -- @return #CTLD self function CTLD:onbeforeCratesBuild(From, Event, To, Group, Unit, Vehicle) - self:T({From, Event, To}) + self:I({From, Event, To}) if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then local playername = Unit:GetPlayerName() local dropcoord = Vehicle:GetCoordinate() or COORDINATE:New(0,0,0) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index af4a207d0..2bbc4f1e7 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -332,6 +332,16 @@ function PLAYERTASK:GetFreetextTTS() return self.FreetextTTS end +--- [USER] Add a short free text description for the menu entry of this task. +-- @param #PLAYERTASK self +-- @param #string Text +-- @return #PLAYERTASK self +function PLAYERTASK:SetMenuName(Text) + self:T(self.lid.."SetMenuName") + self.Target.name = Text + return self +end + --- [User] Check if task is done -- @param #PLAYERTASK self -- @return #boolean done