From 8c0e021e82943a0b24f3400e2e2da12019b94770 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 23 Dec 2025 17:16:57 +0100 Subject: [PATCH] #CTLD - Make FSM event CratesDropped useable for tasking --- Moose Development/Moose/Ops/CTLD.lua | 50 +++++++++++++++++++++------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index a9744719c..41ee8ba00 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -25,7 +25,7 @@ -- @module Ops.CTLD -- @image OPS_CTLD.jpg --- Last Update Oct 2025 +-- Last Update Dec 2025 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -1513,7 +1513,7 @@ CTLD.FixedWingTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.3.41" +CTLD.version="1.3.42" --- Instantiate a new CTLD. -- @param #CTLD self @@ -1930,7 +1930,7 @@ function CTLD:New(Coalition, Prefixes, Alias) -- @param #string To State. -- @param Wrapper.Group#GROUP Group Group Object. -- @param Wrapper.Unit#UNIT Unit Unit Object. - -- @param #CTLD_CARGO Cargo Cargo crate. Can be a Wrapper.DynamicCargo#DYNAMICCARGO object, if ground crew loaded! + -- @param #table Cargotable Table of #CTLD_CARGO cargo crates. Can be a Wrapper.DynamicCargo#DYNAMICCARGO objects, if ground crew loaded! -- @return #CTLD self --- FSM Function OnAfterTroopsDeployed. @@ -4118,16 +4118,16 @@ function CTLD:_ListCargo(Group, Unit) report:Add(" N O N E") end if hercInnerCount > 0 then - local hercMass = 0 + local hercMass = 0 for _,_cargo in pairs(hercInnerCrates or {}) do local cargo = _cargo local type = cargo:GetType() if type ~= CTLD_CARGO.Enum.TROOPS and type ~= CTLD_CARGO.Enum.ENGINEERS then report:Add(string.format("Crate: %s size 1",cargo:GetName())) - hercMass = hercMass + cargo:GetMass() + hercMass = hercMass + cargo:GetMass() end end - loadedmass = loadedmass + hercMass + loadedmass = loadedmass + hercMass end --[[ if loadedno > 0 then @@ -5577,8 +5577,8 @@ function CTLD:_RefreshF10Menus() if self.usesubcats then local subcatmenus = {} - - + + for _,cargoObj in pairs(self.Cargo_Crates) do addCrateMenuEntry(cargoObj,cratesmenu,subcatmenus) @@ -8924,10 +8924,36 @@ end -- @return #CTLD self function CTLD:onbeforeCratesDropped(From, Event, To, Group, Unit, Cargotable) self:T({From, Event, To}) + if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then + local playername = Unit:GetPlayerName() + for _,_cargo in pairs(Cargotable) do + local Vehicle = _cargo.Positionable + if Vehicle then + local dropcoord = Vehicle: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 + end + end return self end - --- (Internal) FSM Function onafterGetCrates. + --- (Internal) FSM Function OnAfterGetCrates. -- @param #CTLD self -- @param #string From State. -- @param #string Event Trigger. @@ -8936,12 +8962,12 @@ end -- @param Wrapper.Unit#UNIT Unit Unit Object. -- @param #table Cargotable Table of #CTLD_CARGO objects spawned via "Get". -- @return #CTLD self - function CTLD:onaftergetcrates(From, Event, To, Group, Unit, Cargotable) + function CTLD:OnAfterGetCrates(From, Event, To, Group, Unit, Cargotable) self:T({From, Event, To}) return self end - --- (Internal) FSM Function onafterGetCrates. + --- (Internal) FSM Function OnAfterRemoveCratesNearby. -- @param #CTLD self -- @param #string From State. -- @param #string Event Trigger. @@ -8950,7 +8976,7 @@ end -- @param Wrapper.Unit#UNIT Unit Unit Object. -- @param #table Cargotable Table of #CTLD_CARGO objects spawned via "Get". -- @return #CTLD self - function CTLD:onafterremovecratesnearby(From, Event, To, Group, Unit, Cargotable) + function CTLD:OnAfterRemoveCratesNearby(From, Event, To, Group, Unit, Cargotable) self:T({From, Event, To}) return self end