mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-26 23:05:27 +00:00
Progress
This commit is contained in:
+16
-7
@@ -37,9 +37,11 @@ function RecceDetection:OnAfterDetect(From,Event,To)
|
||||
|
||||
local DetectionReport = RecceDetection:DetectedReportDetailed()
|
||||
|
||||
CC:MessageToAll( DetectionReport, 15, "" )
|
||||
CC:GetPositionable():MessageToAll( DetectionReport, 15, "" )
|
||||
end
|
||||
|
||||
local ArtilleryTime = {}
|
||||
local ArtilleryAim = 180
|
||||
|
||||
--- OnAfter Transition Handler for Event Detect.
|
||||
-- @param Functional.Detection#DETECTION_UNITS self
|
||||
@@ -48,14 +50,21 @@ end
|
||||
-- @param #string To The To State string.
|
||||
-- @param Wrapper.Unit#UNIT DetectedUnits
|
||||
function RecceDetection:OnAfterDetected( From, Event, To, DetectedUnits )
|
||||
|
||||
local ArtilleryArray = ArtillerySetGroup:GetSet()
|
||||
local ArtilleryArrayCount = ArtillerySetGroup:Count()
|
||||
self:E( { From, Event, To, DetectedUnits } )
|
||||
|
||||
for DetectedUnitID, DetectedUnit in pairs( DetectedUnits ) do
|
||||
local DetectedUnit = DetectedUnit -- Wrapper.Unit#UNIT
|
||||
local Artillery = ArtilleryArray[ math.random( 1, ArtilleryArrayCount ) ] -- Wrapper.Group#GROUP
|
||||
local Task = Artillery:TaskFireAtPoint( DetectedUnit:GetVec2(), 500, 2 ) -- Fire 2 rockets to the target point.
|
||||
Artillery:SetTask( Task, 0.5 )
|
||||
local Artillery = ArtillerySetGroup:GetRandom() -- Wrapper.Group#GROUP
|
||||
|
||||
if ArtilleryTime[Artillery] and ArtilleryTime[Artillery] <= timer.getTime() - ArtilleryAim then
|
||||
ArtilleryTime[Artillery] = nil
|
||||
end
|
||||
|
||||
if not ArtilleryTime[Artillery] then
|
||||
local Task = Artillery:TaskFireAtPoint( DetectedUnit:GetVec2(), 500, 4 ) -- Fire 2 rockets to the target point.
|
||||
Artillery:SetTask( Task, 0.5 )
|
||||
ArtilleryTime[Artillery] = timer.getTime()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
BIN
Binary file not shown.
+13
-54
@@ -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()
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user