Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Applevangelist 2025-01-27 18:49:01 +01:00
commit fb276cf812
2 changed files with 41 additions and 10 deletions

View File

@ -201,6 +201,7 @@ BASE = {
States = {}, States = {},
Debug = debug, Debug = debug,
Scheduler = nil, Scheduler = nil,
Properties = {},
} }
-- @field #BASE.__ -- @field #BASE.__
@ -1109,6 +1110,31 @@ function BASE:ClearState( Object, StateName )
end end
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 -- Trace section
-- Log a trace (only shown when trace is on) -- Log a trace (only shown when trace is on)
@ -1440,4 +1466,3 @@ function BASE:I( Arguments )
end end
end end

View File

@ -975,7 +975,7 @@ do
-- --
-- This function is called when a player has re-boarded already deployed troops from the field: -- 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 ... -- ... your code here ...
-- end -- end
-- --
@ -1635,7 +1635,8 @@ function CTLD:New(Coalition, Prefixes, Alias)
-- @param #string To State. -- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object. -- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit 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 -- @return #CTLD self
--- FSM Function OnBeforeCratesPickedUp. --- FSM Function OnBeforeCratesPickedUp.
@ -1723,7 +1724,8 @@ function CTLD:New(Coalition, Prefixes, Alias)
-- @param #string To State. -- @param #string To State.
-- @param Wrapper.Group#GROUP Group Group Object. -- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit 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 -- @return #CTLD self
--- FSM Function OnAfterCratesPickedUp. --- FSM Function OnAfterCratesPickedUp.
@ -2533,7 +2535,8 @@ end
self:ScheduleOnce(running,self._SendMessage,self,"Troops boarded!", 10, false, Group) self:ScheduleOnce(running,self._SendMessage,self,"Troops boarded!", 10, false, Group)
self:_SendMessage("Troops boarding!", 10, false, Group) self:_SendMessage("Troops boarding!", 10, false, Group)
self:_UpdateUnitCargoMass(Unit) 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 coord = Unit:GetCoordinate() or Group:GetCoordinate() -- Core.Point#COORDINATE
local Point local Point
if coord then if coord then
@ -5654,7 +5657,7 @@ end
self.CargoCounter = self.CargoCounter + 1 self.CargoCounter = self.CargoCounter + 1
cargo.ID = self.CargoCounter cargo.ID = self.CargoCounter
cargo.Stock = 1 cargo.Stock = 1
table.insert(self.Cargo_Crates,cargo) table.insert(self.Cargo_Troops,cargo)
end end
if match and CargoObject then if match and CargoObject then
@ -6032,13 +6035,14 @@ end
-- @param Wrapper.Group#GROUP Group Group Object. -- @param Wrapper.Group#GROUP Group Group Object.
-- @param Wrapper.Unit#UNIT Unit Unit Object. -- @param Wrapper.Unit#UNIT Unit Unit Object.
-- @param Wrapper.Group#GROUP Troops Troops #GROUP Object. -- @param Wrapper.Group#GROUP Troops Troops #GROUP Object.
-- @param #string Groupname Name of the extracted #GROUP.
-- @return #CTLD self -- @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}) self:T({From, Event, To})
if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then
local playername = Unit:GetPlayerName() local playername = Unit:GetPlayerName()
local dropcoord = Troops:GetCoordinate() or COORDINATE:New(0,0,0) --local dropcoord = Troops:GetCoordinate() or COORDINATE:New(0,0,0)
local dropvec2 = dropcoord:GetVec2() --local dropvec2 = dropcoord:GetVec2()
self.PlayerTaskQueue:ForEach( self.PlayerTaskQueue:ForEach(
function (Task) function (Task)
local task = Task -- Ops.PlayerTask#PLAYERTASK local task = Task -- Ops.PlayerTask#PLAYERTASK
@ -6046,7 +6050,9 @@ end
-- right subtype? -- right subtype?
if Event == subtype and not task:IsDone() then if Event == subtype and not task:IsDone() then
local targetzone = task.Target:GetObject() -- Core.Zone#ZONE should be a zone in this case .... 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 --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 if task.Clients:HasUniqueID(playername) then
-- success -- success
task:__Success(-1) task:__Success(-1)