mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#CTLD
* Added connection to PlayerTask/Controller #PLAYERTASK * Added helper functions
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
-- @image OPS_CTLD.jpg
|
-- @image OPS_CTLD.jpg
|
||||||
|
|
||||||
-- Date: Feb 2022
|
-- Date: Feb 2022
|
||||||
-- Last Update Sep 2022
|
-- Last Update October 2022
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
@@ -288,8 +288,8 @@ CTLD_ENGINEERING = {
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
|
||||||
|
do
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
--- **CTLD_CARGO** class, extends Core.Base#BASE
|
--- **CTLD_CARGO** class, extends Core.Base#BASE
|
||||||
-- @type CTLD_CARGO
|
-- @type CTLD_CARGO
|
||||||
@@ -308,7 +308,6 @@ do
|
|||||||
-- @field #string Subcategory Sub-category name.
|
-- @field #string Subcategory Sub-category name.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @field CTLD_CARGO
|
-- @field CTLD_CARGO
|
||||||
CTLD_CARGO = {
|
CTLD_CARGO = {
|
||||||
@@ -343,7 +342,7 @@ CTLD_CARGO = {
|
|||||||
CRATE = "Crate", -- #string crate
|
CRATE = "Crate", -- #string crate
|
||||||
REPAIR = "Repair", -- #string repair
|
REPAIR = "Repair", -- #string repair
|
||||||
ENGINEERS = "Engineers", -- #string engineers
|
ENGINEERS = "Engineers", -- #string engineers
|
||||||
STATIC = "Static", -- #string engineers
|
STATIC = "Static", -- #string statics
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Function to create new CTLD_CARGO object.
|
--- Function to create new CTLD_CARGO object.
|
||||||
@@ -574,6 +573,10 @@ CTLD_CARGO = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- TODO CTLD
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **CTLD** class, extends Core.Base#BASE, Core.Fsm#FSM
|
--- **CTLD** class, extends Core.Base#BASE, Core.Fsm#FSM
|
||||||
-- @type CTLD
|
-- @type CTLD
|
||||||
@@ -1068,7 +1071,7 @@ CTLD.UnitTypes = {
|
|||||||
|
|
||||||
--- CTLD class version.
|
--- CTLD class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CTLD.version="1.0.11"
|
CTLD.version="1.0.14"
|
||||||
|
|
||||||
--- Instantiate a new CTLD.
|
--- Instantiate a new CTLD.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@@ -1476,6 +1479,19 @@ function CTLD:SetTroopDropZoneRadius(Radius)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- (User) Add a PLAYERTASK - FSM events will check success
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param Ops.PlayerTask#PLAYERTASK PlayerTask
|
||||||
|
-- @return #CTLD self
|
||||||
|
function CTLD:AddPlayerTask(PlayerTask)
|
||||||
|
self:T(self.lid .. " AddPlayerTask")
|
||||||
|
if not self.PlayerTaskQueue then
|
||||||
|
self.PlayerTaskQueue = FIFO:New()
|
||||||
|
end
|
||||||
|
self.PlayerTaskQueue:Push(PlayerTask,PlayerTask.PlayerTaskNr)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- (Internal) Event handler function
|
--- (Internal) Event handler function
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
@@ -4244,7 +4260,7 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
-- FSM functions
|
-- TODO FSM functions
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
--- (Internal) FSM Function onafterStart.
|
--- (Internal) FSM Function onafterStart.
|
||||||
@@ -4417,6 +4433,27 @@ end
|
|||||||
-- @return #CTLD self
|
-- @return #CTLD self
|
||||||
function CTLD:onbeforeTroopsDeployed(From, Event, To, Group, Unit, Troops)
|
function CTLD:onbeforeTroopsDeployed(From, Event, To, Group, Unit, Troops)
|
||||||
self:T({From, Event, To})
|
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
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4444,10 +4481,31 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
|
-- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build.
|
||||||
-- @return #CTLD self
|
-- @return #CTLD self
|
||||||
function CTLD:onbeforeCratesBuild(From, Event, To, Group, Unit, Vehicle)
|
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)
|
||||||
|
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
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- (Internal) FSM Function onbeforeTroopsRTB.
|
--- (Internal) FSM Function onbeforeTroopsRTB.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param #string From State.
|
-- @param #string From State.
|
||||||
@@ -4802,7 +4860,9 @@ end -- end do
|
|||||||
do
|
do
|
||||||
--- **Hercules Cargo AIR Drop Events** by Anubis Yinepu
|
--- **Hercules Cargo AIR Drop Events** by Anubis Yinepu
|
||||||
-- Moose CTLD OO refactoring by Applevangelist
|
-- Moose CTLD OO refactoring by Applevangelist
|
||||||
--
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- TODO CTLD_HERCULES
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- This script will only work for the Herculus mod by Anubis, and only for **Air Dropping** cargo from the Hercules.
|
-- This script will only work for the Herculus mod by Anubis, and only for **Air Dropping** cargo from the Hercules.
|
||||||
-- Use the standard Moose CTLD if you want to unload on the ground.
|
-- Use the standard Moose CTLD if you want to unload on the ground.
|
||||||
-- Payloads carried by pylons 11, 12 and 13 need to be declared in the Herculus_Loadout.lua file
|
-- Payloads carried by pylons 11, 12 and 13 need to be declared in the Herculus_Loadout.lua file
|
||||||
|
|||||||
@@ -332,6 +332,16 @@ function PLAYERTASK:GetFreetextTTS()
|
|||||||
return self.FreetextTTS
|
return self.FreetextTTS
|
||||||
end
|
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
|
--- [User] Check if task is done
|
||||||
-- @param #PLAYERTASK self
|
-- @param #PLAYERTASK self
|
||||||
-- @return #boolean done
|
-- @return #boolean done
|
||||||
|
|||||||
Reference in New Issue
Block a user