mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#PLAYERTASKCONTROLLER
* Initial additions for CTLD tasks
This commit is contained in:
parent
11ef7c6a00
commit
a777b40613
@ -1,11 +1,11 @@
|
|||||||
--- **Ops** - PlayerTask (mission) for Players.
|
---- **Ops** - PlayerTask (mission) for Players.
|
||||||
--
|
--
|
||||||
-- ## Main Features:
|
-- ## Main Features:
|
||||||
--
|
--
|
||||||
-- * Simplifies defining and executing Player tasks
|
-- * Simplifies defining and executing Player tasks
|
||||||
-- * FSM events when a mission is added, done, successful or failed, replanned
|
-- * FSM events when a mission is added, done, successful or failed, replanned
|
||||||
-- * Ready to use SRS and localization
|
-- * Ready to use SRS and localization
|
||||||
-- * Mission locations can be smoked, flared and marked on the map
|
-- * Mission locations can be smoked, flared, illuminated and marked on the map
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -21,7 +21,7 @@
|
|||||||
-- ===
|
-- ===
|
||||||
-- @module Ops.PlayerTask
|
-- @module Ops.PlayerTask
|
||||||
-- @image OPS_PlayerTask.jpg
|
-- @image OPS_PlayerTask.jpg
|
||||||
-- @date Last Update September 2022
|
-- @date Last Update October 2022
|
||||||
|
|
||||||
|
|
||||||
do
|
do
|
||||||
@ -50,6 +50,10 @@ do
|
|||||||
-- @field Ops.PlayerTask#PLAYERTASKCONTROLLER TaskController
|
-- @field Ops.PlayerTask#PLAYERTASKCONTROLLER TaskController
|
||||||
-- @field #number timestamp
|
-- @field #number timestamp
|
||||||
-- @field #number lastsmoketime
|
-- @field #number lastsmoketime
|
||||||
|
-- @field #number coalition
|
||||||
|
-- @field #string Freetext
|
||||||
|
-- @field #string FreetextTTS
|
||||||
|
-- @field #string TaskSubType
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
|
||||||
@ -78,11 +82,14 @@ PLAYERTASK = {
|
|||||||
TaskController = nil,
|
TaskController = nil,
|
||||||
timestamp = 0,
|
timestamp = 0,
|
||||||
lastsmoketime = 0,
|
lastsmoketime = 0,
|
||||||
|
Freetext = nil,
|
||||||
|
FreetextTTS = nil,
|
||||||
|
TaskSubType = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- PLAYERTASK class version.
|
--- PLAYERTASK class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
PLAYERTASK.version="0.1.4"
|
PLAYERTASK.version="0.1.6"
|
||||||
|
|
||||||
--- Generic task condition.
|
--- Generic task condition.
|
||||||
-- @type PLAYERTASK.Condition
|
-- @type PLAYERTASK.Condition
|
||||||
@ -95,6 +102,7 @@ PLAYERTASK.version="0.1.4"
|
|||||||
-- @param Ops.Target#TARGET Target Target for this task
|
-- @param Ops.Target#TARGET Target Target for this task
|
||||||
-- @param #boolean Repeat Repeat this task if true (default = false)
|
-- @param #boolean Repeat Repeat this task if true (default = false)
|
||||||
-- @param #number Times Repeat on failure this many times if Repeat is true (default = 1)
|
-- @param #number Times Repeat on failure this many times if Repeat is true (default = 1)
|
||||||
|
-- @param #string TTSType TTS friendly task type name
|
||||||
-- @return #PLAYERTASK self
|
-- @return #PLAYERTASK self
|
||||||
function PLAYERTASK:New(Type, Target, Repeat, Times, TTSType)
|
function PLAYERTASK:New(Type, Target, Repeat, Times, TTSType)
|
||||||
|
|
||||||
@ -252,6 +260,78 @@ function PLAYERTASK:_SetController(Controller)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [User] Set a coalition side for this task
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #number Coalition Coaltion side to add, e.g. coalition.side.BLUE
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:SetCoalition(Coalition)
|
||||||
|
self:T(self.lid.."SetCoalition")
|
||||||
|
self.coalition = Coalition or coalition.side.BLUE
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [User] Get the coalition side for this task
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @return #number Coalition Coaltion side, e.g. coalition.side.BLUE, or nil if not set
|
||||||
|
function PLAYERTASK:GetCoalition()
|
||||||
|
self:T(self.lid.."GetCoalition")
|
||||||
|
return self.coalition
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Add a free text description to this task.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #string Text
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:AddFreetext(Text)
|
||||||
|
self:T(self.lid.."AddFreetext")
|
||||||
|
self.Freetext = Text
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Set a task sub type description to this task.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #string Type
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:SetSubType(Type)
|
||||||
|
self:T(self.lid.."AddSubType")
|
||||||
|
self.TaskSubType = Type
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Get task sub type description from this task.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @return #string Type or nil
|
||||||
|
function PLAYERTASK:GetSubType()
|
||||||
|
self:T(self.lid.."GetSubType")
|
||||||
|
return self.TaskSubType
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Get the free text description from this task.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @return #string Text
|
||||||
|
function PLAYERTASK:GetFreetext()
|
||||||
|
self:T(self.lid.."GetFreetext")
|
||||||
|
return self.Freetext
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Add a free text description for TTS to this task.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #string Text
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:AddFreetextTTS(TextTTS)
|
||||||
|
self:T(self.lid.."AddFreetextTTS")
|
||||||
|
self.FreetextTTS = TextTTS
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Get the free text TTS description from this task.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @return #string Text
|
||||||
|
function PLAYERTASK:GetFreetextTTS()
|
||||||
|
self:T(self.lid.."GetFreetextTTS")
|
||||||
|
return self.FreetextTTS
|
||||||
|
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
|
||||||
@ -423,6 +503,25 @@ function PLAYERTASK:FlareTarget(Color)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [User] Illuminate Target Area
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #number Power Power of illumination bomb in Candela. Default 1000 cd.
|
||||||
|
-- @param #number Height Height above target used to release the bomb, default 150m.
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:IlluminateTarget(Power,Height)
|
||||||
|
self:T(self.lid.."IlluminateTarget")
|
||||||
|
local Power = Power or 1000
|
||||||
|
local Height = Height or 150
|
||||||
|
if self.Target then
|
||||||
|
local coordinate = self.Target:GetCoordinate()
|
||||||
|
if coordinate then
|
||||||
|
local bcoord = COORDINATE:NewFromVec2( coordinate:GetVec2(), Height )
|
||||||
|
bcoord:IlluminationBomb(Power)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
-- success / failure function addion courtesy @FunkyFranky.
|
-- success / failure function addion courtesy @FunkyFranky.
|
||||||
|
|
||||||
--- [User] Add success condition.
|
--- [User] Add success condition.
|
||||||
@ -764,6 +863,7 @@ do
|
|||||||
-- @field #boolean TransmitOnlyWithPlayers
|
-- @field #boolean TransmitOnlyWithPlayers
|
||||||
-- @field #boolean buddylasing
|
-- @field #boolean buddylasing
|
||||||
-- @field Ops.PlayerRecce#PLAYERRECCE PlayerRecce
|
-- @field Ops.PlayerRecce#PLAYERRECCE PlayerRecce
|
||||||
|
-- @field #number Coalition
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -1069,7 +1169,8 @@ PLAYERTASKCONTROLLER = {
|
|||||||
noflaresmokemenu = false,
|
noflaresmokemenu = false,
|
||||||
TransmitOnlyWithPlayers = true,
|
TransmitOnlyWithPlayers = true,
|
||||||
buddylasing = false,
|
buddylasing = false,
|
||||||
PlayerRecce = nil,
|
PlayerRecce = nil,
|
||||||
|
Coalition = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -1085,8 +1186,10 @@ PLAYERTASKCONTROLLER.Type = {
|
|||||||
A2GS = "Air-To-Ground-Sea",
|
A2GS = "Air-To-Ground-Sea",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Define a new AUFTRAG Type
|
--- Define new AUFTRAG Types
|
||||||
AUFTRAG.Type.PRECISIONBOMBING = "Precision Bombing"
|
AUFTRAG.Type.PRECISIONBOMBING = "Precision Bombing"
|
||||||
|
AUFTRAG.Type.CTLD = "Combat Transport"
|
||||||
|
AUFTRAG.Type.CSAR = "Combat Rescue"
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @type SeadAttributes
|
-- @type SeadAttributes
|
||||||
@ -2345,6 +2448,42 @@ function PLAYERTASKCONTROLLER:_AddTask(Target)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [User] Add a PLAYERTASK object to the list of (open) tasks
|
||||||
|
-- @param #PLAYERTASKCONTROLLER self
|
||||||
|
-- @param Ops.PlayerTask#PLAYERTASK PlayerTask
|
||||||
|
-- @return #PLAYERTASKCONTROLLER self
|
||||||
|
-- @usage
|
||||||
|
-- Example to create a PLAYERTASK of type CTLD and give Players 10 minutes to complete:
|
||||||
|
--
|
||||||
|
-- local newtask = PLAYERTASK:New(AUFTRAG.Type.CTLD,ZONE:Find("Unloading"),false,0,"Combat Transport")
|
||||||
|
-- newtask.Time0 = timer.getAbsTime() -- inject a timestamp for T0
|
||||||
|
-- newtask:AddFreetext("Transport crates to the drop zone and build a vehicle in the next 10 minutes!")
|
||||||
|
--
|
||||||
|
-- -- add a condition for failure - fail after 10 minutes
|
||||||
|
-- newtask:AddConditionFailure(
|
||||||
|
-- function()
|
||||||
|
-- local Time = timer.getAbsTime()
|
||||||
|
-- if Time - newtask.Time0 > 600 then
|
||||||
|
-- return true
|
||||||
|
-- end
|
||||||
|
-- return false
|
||||||
|
-- end
|
||||||
|
-- )
|
||||||
|
--
|
||||||
|
-- taskmanager:AddPlayerTaskToQueue(PlayerTask)
|
||||||
|
function PLAYERTASKCONTROLLER:AddPlayerTaskToQueue(PlayerTask)
|
||||||
|
self:T(self.lid.."AddPlayerTaskToQueue")
|
||||||
|
if PlayerTask and PlayerTask.ClassName and PlayerTask.ClassName == "PLAYERTASK" then
|
||||||
|
PlayerTask:_SetController(self)
|
||||||
|
PlayerTask:SetCoalition(self.Coalition)
|
||||||
|
self.TaskQueue:Push(PlayerTask)
|
||||||
|
self:__TaskAdded(-1,PlayerTask)
|
||||||
|
else
|
||||||
|
self:E(self.lid.."***** NO valid PAYERTASK object sent!")
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- [Internal] Join a player to a task
|
--- [Internal] Join a player to a task
|
||||||
-- @param #PLAYERTASKCONTROLLER self
|
-- @param #PLAYERTASKCONTROLLER self
|
||||||
-- @param Wrapper.Group#GROUP Group
|
-- @param Wrapper.Group#GROUP Group
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user