From 4d24eb82be5183b827f3b827c54b93ac67a6081e Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 27 Jan 2025 08:51:17 +0100 Subject: [PATCH 1/5] Update CTLD.lua #CTLD - Add the group name of the extracted group to TroopsExtracted FSM event --- Moose Development/Moose/Ops/CTLD.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 3ebcd67a2..bdf3a3b5e 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -975,7 +975,7 @@ do -- -- This function is called when a player has re-boarded already deployed troops from the field: -- --- function my_ctld:OnAfterTroopsExtracted(From, Event, To, Group, Unit, Troops) +-- function my_ctld:OnAfterTroopsExtracted(From, Event, To, Group, Unit, Troops, Troopname) -- ... your code here ... -- end -- @@ -1635,7 +1635,8 @@ 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 troops. + -- @param Wrapper.Group#GROUP Troops extracted. + -- @param #string Troopname Name of the extracted group. -- @return #CTLD self --- FSM Function OnBeforeCratesPickedUp. @@ -1723,7 +1724,8 @@ 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 troops. + -- @param Wrapper.Group#GROUP Troops extracted. + -- @param #string Troopname Name of the extracted group. -- @return #CTLD self --- FSM Function OnAfterCratesPickedUp. @@ -2533,7 +2535,8 @@ end self:ScheduleOnce(running,self._SendMessage,self,"Troops boarded!", 10, false, Group) self:_SendMessage("Troops boarding!", 10, false, Group) self:_UpdateUnitCargoMass(Unit) - self:__TroopsExtracted(running,Group, Unit, nearestGroup) + local groupname = nearestGroup:GetName() + self:__TroopsExtracted(running,Group, Unit, nearestGroup, groupname) local coord = Unit:GetCoordinate() or Group:GetCoordinate() -- Core.Point#COORDINATE local Point if coord then @@ -6032,8 +6035,9 @@ end -- @param Wrapper.Group#GROUP Group Group Object. -- @param Wrapper.Unit#UNIT Unit Unit Object. -- @param Wrapper.Group#GROUP Troops Troops #GROUP Object. + -- @param #string Groupname Name of the extracted #GROUP. -- @return #CTLD self - function CTLD:onbeforeTroopsExtracted(From, Event, To, Group, Unit, Troops) + function CTLD:onbeforeTroopsExtracted(From, Event, To, Group, Unit, Troops, Groupname) self:T({From, Event, To}) if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then local playername = Unit:GetPlayerName() From a55959dfbb3d0b90132000c40445c73a77513473 Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 27 Jan 2025 12:00:25 +0100 Subject: [PATCH 2/5] Update Base.lua Added property functions --- Moose Development/Moose/Core/Base.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index 5de2096a3..76671ffce 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -201,6 +201,7 @@ BASE = { States = {}, Debug = debug, Scheduler = nil, + Properties = {}, } -- @field #BASE.__ @@ -1109,6 +1110,31 @@ function BASE:ClearState( Object, StateName ) end end +--- Set one property of an object. +-- @param #BASE self +-- @param Key The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type! +-- @param Value The value that is stored. Note that the value can be a #string, but it can also be any other type! +function BASE:SetProperty(Key,Value) + self.Properties = self.Properties or {} + self.Properties[Key] = Value +end + +--- Get one property of an object by the key. +-- @param #BASE self +-- @param Key The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type! +-- @return Value The value that is stored. Note that the value can be a #string, but it can also be any other type! Nil if not found. +function BASE:GetProperty(Key) + self.Properties = self.Properties or {} + return self.Properties[Key] +end + +--- Get all of the properties of an object in a table. +-- @param #BASE self +-- @return #table of values, indexed by keys. +function BASE:GetProperties() + return self.Properties +end + -- Trace section -- Log a trace (only shown when trace is on) From bfb60b318eebab9f33a6bfc7f8c3b35a8e8f784e Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 27 Jan 2025 13:27:13 +0100 Subject: [PATCH 3/5] Update CTLD.lua update --- Moose Development/Moose/Ops/CTLD.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index bdf3a3b5e..c9440c657 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -6041,8 +6041,8 @@ end 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() + --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 @@ -6050,7 +6050,7 @@ end -- 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 targetzone and targetzone.ClassName and string.match(targetzone.ClassName,"ZONE") and targetzone:GetProperty("Extractname") == Groupname then if task.Clients:HasUniqueID(playername) then -- success task:__Success(-1) From daffd7412acd68b8df2fbbff20530b05d2dc5fd2 Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 27 Jan 2025 18:44:35 +0100 Subject: [PATCH 4/5] Update Base.lua --- Moose Development/Moose/Core/Base.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index 76671ffce..b1a12e740 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -1466,4 +1466,3 @@ function BASE:I( Arguments ) end end - From 6af836c118dffd49fdd1bf96efa82eeeef7dfaa7 Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Mon, 27 Jan 2025 18:45:39 +0100 Subject: [PATCH 5/5] Update CTLD.lua --- Moose Development/Moose/Ops/CTLD.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index c9440c657..5c83896a5 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -5657,7 +5657,7 @@ end self.CargoCounter = self.CargoCounter + 1 cargo.ID = self.CargoCounter cargo.Stock = 1 - table.insert(self.Cargo_Crates,cargo) + table.insert(self.Cargo_Troops,cargo) end if match and CargoObject then @@ -6050,7 +6050,9 @@ end -- 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:GetProperty("Extractname") == Groupname then + --self:T2({Name=Groupname,Property=task:GetProperty("ExtractName")}) + local okaygroup = string.find(Groupname,task:GetProperty("ExtractName"),1,true) + if targetzone and targetzone.ClassName and string.match(targetzone.ClassName,"ZONE") and okaygroup then if task.Clients:HasUniqueID(playername) then -- success task:__Success(-1)