This commit is contained in:
FlightControl
2017-02-18 19:51:20 +01:00
parent 5c090b108c
commit f9708de598
16 changed files with 318 additions and 137 deletions

View File

@@ -104,11 +104,12 @@ local TargetZone = ZONE:New( "Target Zone" )
-- 2. The set of groups of planes that pilots can join.
-- 3. The name of the Task... This can be any name, and will be provided when the Pilot joins the task.
-- 4. A type of the Task. When Tasks are in state Planned, then a menu can be provided that group the task based on this given type.
local SEADTask = TASK:New(
local SEADTask = TASK_SEAD:New(
Mission,
SEADSet,
"SEAD Radars Vector 1",
"SEAD" ) -- Tasking.Task#TASK
TargetSet,
15000 ) -- Tasking.Task#TASK_SEAD
-- This is now an important part of the Task process definition.
-- Each TASK contains a "Process Template".
@@ -122,56 +123,14 @@ local SEADTask = TASK:New(
local SEADProcess = SEADTask:GetUnitProcess() -- #SEADProcess
-- Adding a new sub-process to the Task Template.
-- At first, the task needs to be accepted by a pilot.
-- We use for this the SUB-PROCESS ACT_ASSIGN_ACCEPT.
-- The method on the FsmSEAD AddProcess accepts the following parameters:
-- 1. State From "Planned". When the Fsm is in state "Planned", allow the event "Accept".
-- 2. Event "Accept". This event can be triggered through FsmSEAD:Accept() or FsmSEAD:__Accept( 1 ). See documentation on state machines.
-- 3. The PROCESS derived class. In this case, we use the ACT_ASSIGN_ACCEPT to accept the task and provide a briefing. So, when the event "Accept" is fired, this process is executed.
-- 4. A table with the "return" states of the ACT_ASSIGN_ACCEPT process. This table indicates that for a certain return state, a further event needs to be called.
-- 4.1 When the return state is Assigned, fire the event in the Task FsmSEAD:Route()
-- 4.2 When the return state is Rejected, fire the event in the Task FsmSEAD:Eject()
-- All other AddProcess calls are working in a similar manner.
SEADProcess:AddProcess( "Planned", "Accept", ACT_ASSIGN_ACCEPT:New( "SEAD the Area" ), { Assigned = "Route", Rejected = "Eject" } ) -- FSM SUB for type SEADProcess.
SEADProcess:AddProcess( "Assigned", "Route", ACT_ROUTE_ZONE:New( TargetZone ), { Arrived = "Update" } ) -- FSM SUB for type SEADProcess.
-- Adding a new Action...
-- Actions define also the flow of the Task, but the actions will need to be programmed within your script.
-- See the state machine explanation for further details.
-- The AddTransition received a couple of parameters:
-- 1. State From "Rejected". When the FsmSEAD is in state "Rejected", the event "Eject" can be fired.
-- 2. Event "Eject". This event can be triggered synchronously through FsmSEAD:Eject() or asynchronously through FsmSEAD:__Eject(secs).
-- 3. State To "Planned". After the event has been fired, the FsmSEAD will transition to Planned.
SEADProcess:AddTransition( "Rejected", "Eject", "Planned" )
SEADProcess:AddTransition( "Arrived", "Update", "Updated" )
SEADProcess:AddProcess( "Updated", "Account", ACT_ACCOUNT_DEADS:New( TargetSet, "SEAD" ), { Accounted = "Success" } )
SEADProcess:AddProcess( "Updated", "Smoke", ACT_ASSIST_SMOKE_TARGETS_ZONE:New( TargetSet, TargetZone ) )
SEADProcess:AddTransition( "Accounted", "Success", "Success" )
SEADProcess:AddTransition( "*", "Fail", "Failed" )
SEADProcess:AddScoreProcess( "Updated", "Account", "Account", "destroyed a radar", 25 )
SEADProcess:AddScoreProcess( "Updated", "Account", "Failed", "failed to destroy a radar", -10 )
SEADProcess:AddScoreProcess( "Accounting", "Account", "Account", "destroyed a radar", 25 )
SEADProcess:AddScoreProcess( "Accounting", "Account", "Failed", "failed to destroy a radar", -10 )
-- Now we will set the SCORING. Scoring is set using the TaskSEAD object.
-- Scores can be set on the status of the Task, and on Process level.
SEADProcess:AddScore( "Success", "Destroyed all target radars", 250 )
SEADProcess:AddScore( "Failed", "Failed to destroy all target radars", -100 )
function SEADProcess:OnEnterUpdated( Controllable, From, Event, To )
self:E( { self } )
self:Account()
self:Smoke()
end
-- Here we handle the PlayerAborted event, which is fired when a Player leaves the unit while being assigned to the Task.
-- Within the event handler, which is passed the PlayerUnit and PlayerName parameter,
-- we check if the SEADTask has still AlivePlayers assigned to the Task.
@@ -184,14 +143,14 @@ function SEADTask:OnEnterPlayerCrashed( PlayerUnit, PlayerName )
end
local TaskSEAD2 = TASK:New( Mission, SEADSet, "SEAD Radars Vector 2", "SEAD" ) -- Tasking.Task#TASK
TaskSEAD2:SetUnitProcess( SEADTask:GetUnitProcess():Copy() )
Mission:AddTask( TaskSEAD2 )
Mission:RemoveTask( SEADTask )
SEADTask = nil
SEADProcess = nil
--local TaskSEAD2 = TASK:New( Mission, SEADSet, "SEAD Radars Vector 2", "SEAD" ) -- Tasking.Task#TASK
--TaskSEAD2:SetUnitProcess( SEADTask:GetUnitProcess():Copy() )
--Mission:AddTask( TaskSEAD2 )
--
--Mission:RemoveTask( SEADTask )
--
--SEADTask = nil
--SEADProcess = nil
collectgarbage()