mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Correct handling of crashing player
when assigned to a task
This commit is contained in:
parent
9a54462164
commit
cb7ba702ff
@ -189,7 +189,10 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
|
|||||||
function( self, EventData )
|
function( self, EventData )
|
||||||
local PlayerUnit = EventData.IniUnit
|
local PlayerUnit = EventData.IniUnit
|
||||||
for MissionID, Mission in pairs( self:GetMissions() ) do
|
for MissionID, Mission in pairs( self:GetMissions() ) do
|
||||||
Mission:CrashUnit( PlayerUnit )
|
local Mission = Mission -- Tasking.Mission#MISSION
|
||||||
|
if Mission:IsENGAGED() then
|
||||||
|
Mission:CrashUnit( PlayerUnit )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
@ -308,19 +308,17 @@ end
|
|||||||
-- If the Unit is part of a Task in the Mission, true is returned.
|
-- If the Unit is part of a Task in the Mission, true is returned.
|
||||||
-- @param #MISSION self
|
-- @param #MISSION self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player crashing.
|
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player crashing.
|
||||||
-- @return #boolean true if Unit is part of a Task in the Mission.
|
-- @return #MISSION
|
||||||
function MISSION:CrashUnit( PlayerUnit )
|
function MISSION:CrashUnit( PlayerUnit )
|
||||||
self:F( { PlayerUnit = PlayerUnit } )
|
self:F( { PlayerUnit = PlayerUnit } )
|
||||||
|
|
||||||
local PlayerUnitRemoved = false
|
|
||||||
|
|
||||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
for TaskID, Task in pairs( self:GetTasks() ) do
|
||||||
if Task:CrashUnit( PlayerUnit ) then
|
local Task = Task -- Tasking.Task#TASK
|
||||||
PlayerUnitRemoved = true
|
local PlayerGroup = PlayerUnit:GetGroup()
|
||||||
end
|
Task:CrashGroup( PlayerGroup )
|
||||||
end
|
end
|
||||||
|
|
||||||
return PlayerUnitRemoved
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a scoring to the mission.
|
--- Add a scoring to the mission.
|
||||||
|
|||||||
@ -260,7 +260,7 @@ end
|
|||||||
-- If the Unit is part of the Task, true is returned.
|
-- If the Unit is part of the Task, true is returned.
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
||||||
-- @return #boolean true if Unit is part of the Task.
|
-- @return #TASK
|
||||||
function TASK:AbortGroup( PlayerGroup )
|
function TASK:AbortGroup( PlayerGroup )
|
||||||
self:F( { PlayerGroup = PlayerGroup } )
|
self:F( { PlayerGroup = PlayerGroup } )
|
||||||
|
|
||||||
@ -312,14 +312,11 @@ end
|
|||||||
-- If the Unit is part of the Task, true is returned.
|
-- If the Unit is part of the Task, true is returned.
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
||||||
-- @return #boolean true if Unit is part of the Task.
|
-- @return #TASK
|
||||||
function TASK:CrashUnit( PlayerUnit )
|
function TASK:CrashGroup( PlayerGroup )
|
||||||
self:F( { PlayerUnit = PlayerUnit } )
|
self:F( { PlayerGroup = PlayerGroup } )
|
||||||
|
|
||||||
local PlayerUnitCrashed = false
|
|
||||||
|
|
||||||
local PlayerGroups = self:GetGroups()
|
local PlayerGroups = self:GetGroups()
|
||||||
local PlayerGroup = PlayerUnit:GetGroup()
|
|
||||||
|
|
||||||
-- Is the PlayerGroup part of the PlayerGroups?
|
-- Is the PlayerGroup part of the PlayerGroups?
|
||||||
if PlayerGroups:IsIncludeObject( PlayerGroup ) then
|
if PlayerGroups:IsIncludeObject( PlayerGroup ) then
|
||||||
@ -330,18 +327,35 @@ function TASK:CrashUnit( PlayerUnit )
|
|||||||
local IsGroupAssigned = self:IsGroupAssigned( PlayerGroup )
|
local IsGroupAssigned = self:IsGroupAssigned( PlayerGroup )
|
||||||
self:E( { IsGroupAssigned = IsGroupAssigned } )
|
self:E( { IsGroupAssigned = IsGroupAssigned } )
|
||||||
if IsGroupAssigned then
|
if IsGroupAssigned then
|
||||||
self:UnAssignFromUnit( PlayerUnit )
|
local PlayerName = PlayerGroup:GetUnit(1):GetPlayerName()
|
||||||
self:MessageToGroups( PlayerUnit:GetPlayerName() .. " crashed in Task " .. self:GetName() )
|
self:MessageToGroups( PlayerName .. " crashed! " )
|
||||||
self:E( { TaskGroup = PlayerGroup:GetName(), GetUnits = PlayerGroup:GetUnits() } )
|
self:UnAssignFromGroup( PlayerGroup )
|
||||||
if #PlayerGroup:GetUnits() == 1 then
|
|
||||||
self:ClearGroupAssignment( PlayerGroup )
|
-- Now check if the task needs to go to hold...
|
||||||
|
-- It will go to hold, if there are no players in the mission...
|
||||||
|
|
||||||
|
PlayerGroups:Flush()
|
||||||
|
local IsRemaining = false
|
||||||
|
for GroupName, AssignedGroup in pairs( PlayerGroups:GetSet() or {} ) do
|
||||||
|
if self:IsGroupAssigned( AssignedGroup ) == true then
|
||||||
|
IsRemaining = true
|
||||||
|
self:F( { Task = self:GetName(), IsRemaining = IsRemaining } )
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self:PlayerCrashed( PlayerUnit )
|
|
||||||
|
self:F( { Task = self:GetName(), IsRemaining = IsRemaining } )
|
||||||
|
if IsRemaining == false then
|
||||||
|
self:Abort()
|
||||||
|
end
|
||||||
|
|
||||||
|
self:PlayerCrashed( PlayerGroup:GetUnit(1) )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return PlayerUnitCrashed
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user