mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #2189 from shaji-Dev/Heartbreaker
New New Capture OpsZone PlayerTask and Time Limit Conditions
This commit is contained in:
commit
13419171a9
@ -299,6 +299,9 @@ function PLAYERTASK:_GetTaskTypeForTarget(Target)
|
|||||||
|
|
||||||
auftrag = AUFTRAG.Type.BOMBING
|
auftrag = AUFTRAG.Type.BOMBING
|
||||||
|
|
||||||
|
elseif Target:IsInstanceOf("OPSZONE")
|
||||||
|
or Target:IsInstanceOf("SET_OPSZONE") then
|
||||||
|
auftrag = AUFTRAG.Type.CAPTUREZONE
|
||||||
end
|
end
|
||||||
|
|
||||||
if group then
|
if group then
|
||||||
@ -351,6 +354,38 @@ function PLAYERTASK:_GetTaskTypeForTarget(Target)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- [Internal] Check OpsZone capture success condition.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param Ops.OpsZone#OPSZONE OpsZone The OpsZone target object.
|
||||||
|
-- @param #string CaptureSquadGroupNamePrefix The prefix of the group name that needs to capture the zone.
|
||||||
|
-- @param #number Coalition The coalition that needs to capture the zone.
|
||||||
|
-- @param #boolean CheckClientInZone Check if any of the clients are in zone.
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:_CheckCaptureOpsZoneSuccess(OpsZone, CaptureSquadGroupNamePrefix, Coalition, CheckClientInZone)
|
||||||
|
local isClientInZone = true
|
||||||
|
if CheckClientInZone then
|
||||||
|
isClientInZone = false
|
||||||
|
for _, client in ipairs(self:GetClientObjects()) do
|
||||||
|
local clientCoord = client:GetCoordinate()
|
||||||
|
if OpsZone.zone:IsCoordinateInZone(clientCoord) then
|
||||||
|
isClientInZone = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local isCaptureGroupInZone = false
|
||||||
|
OpsZone:GetScannedGroupSet():ForEachGroup(function(group)
|
||||||
|
if string.find(group:GetName(), CaptureSquadGroupNamePrefix) then
|
||||||
|
isCaptureGroupInZone = true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
return OpsZone:GetOwner() == Coalition and isClientInZone and isCaptureGroupInZone
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- [Internal] Add a PLAYERTASKCONTROLLER for this task
|
--- [Internal] Add a PLAYERTASKCONTROLLER for this task
|
||||||
-- @param #PLAYERTASK self
|
-- @param #PLAYERTASK self
|
||||||
-- @param Ops.PlayerTask#PLAYERTASKCONTROLLER Controller
|
-- @param Ops.PlayerTask#PLAYERTASKCONTROLLER Controller
|
||||||
@ -471,6 +506,7 @@ end
|
|||||||
-- @return #PLAYERTASK self
|
-- @return #PLAYERTASK self
|
||||||
function PLAYERTASK:AddStaticObjectSuccessCondition()
|
function PLAYERTASK:AddStaticObjectSuccessCondition()
|
||||||
local task = self
|
local task = self
|
||||||
|
-- TODO Check if the killer is one of the task clients
|
||||||
task:AddConditionSuccess(
|
task:AddConditionSuccess(
|
||||||
function(target)
|
function(target)
|
||||||
if target == nil then return false end
|
if target == nil then return false end
|
||||||
@ -496,6 +532,49 @@ function PLAYERTASK:AddStaticObjectSuccessCondition()
|
|||||||
return isDead
|
return isDead
|
||||||
end, task:GetTarget()
|
end, task:GetTarget()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- TODO Check if the killer is one of the task clients
|
||||||
|
--task:AddConditionFailure(
|
||||||
|
-- function()
|
||||||
|
--
|
||||||
|
-- end)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [USER] Adds task success condition for AUFTRAG.Type.CAPTUREZONE for OpsZone or OpsZone set target object.
|
||||||
|
--- At least one of the task clients and one capture group need to be inside the zone in order for the capture to be successful.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #SET_BASE CaptureSquadGroupNamePrefix The prefix of the group name that needs to capture the zone.
|
||||||
|
-- @param #number Coalition The coalition that needs to capture the zone.
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:AddOpsZoneCaptureSuccessCondition(CaptureSquadGroupNamePrefix, Coalition)
|
||||||
|
local task = self
|
||||||
|
task:AddConditionSuccess(
|
||||||
|
function(target)
|
||||||
|
if target:IsInstanceOf("OPSZONE") then
|
||||||
|
return task:_CheckCaptureOpsZoneSuccess(target, CaptureSquadGroupNamePrefix, Coalition, true)
|
||||||
|
elseif target:IsInstanceOf("SET_OPSZONE") then
|
||||||
|
local successes = 0
|
||||||
|
local isClientInZone = false
|
||||||
|
target:ForEachZone(function(opszone)
|
||||||
|
if task:_CheckCaptureOpsZoneSuccess(opszone, CaptureSquadGroupNamePrefix, Coalition) then
|
||||||
|
successes = successes + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, client in ipairs(task:GetClientObjects()) do
|
||||||
|
local clientCoord = client:GetCoordinate()
|
||||||
|
if opszone.zone:IsCoordinateInZone(clientCoord) then
|
||||||
|
isClientInZone = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return successes == target:Count() and isClientInZone
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end, task:GetTarget()
|
||||||
|
)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -524,6 +603,24 @@ function PLAYERTASK:AddReconSuccessCondition(MinDistance)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- [USER] Adds a time limit for the task to be completed.
|
||||||
|
-- @param #PLAYERTASK self
|
||||||
|
-- @param #number TimeLimit Time limit in seconds for the task to be completed. (Default 0 = no time limit)
|
||||||
|
-- @return #PLAYERTASK self
|
||||||
|
function PLAYERTASK:AddTimeLimitFailureCondition(TimeLimit)
|
||||||
|
local task = self
|
||||||
|
TimeLimit = TimeLimit or 0
|
||||||
|
task.StartTime = -1
|
||||||
|
task:AddConditionFailure(
|
||||||
|
function()
|
||||||
|
if task.StartTime == -1 then
|
||||||
|
task.StartTime = timer.getTime()
|
||||||
|
end
|
||||||
|
return TimeLimit > 0 and timer.getTime() - task.StartTime > TimeLimit
|
||||||
|
end)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- [USER] Add a task to be assigned to same clients when task was a success.
|
--- [USER] Add a task to be assigned to same clients when task was a success.
|
||||||
-- @param #PLAYERTASK self
|
-- @param #PLAYERTASK self
|
||||||
-- @param Ops.PlayerTask#PLAYERTASK Task
|
-- @param Ops.PlayerTask#PLAYERTASK Task
|
||||||
@ -1534,6 +1631,7 @@ PLAYERTASKCONTROLLER.Scores = {
|
|||||||
[AUFTRAG.Type.RECON] = 100,
|
[AUFTRAG.Type.RECON] = 100,
|
||||||
[AUFTRAG.Type.ESCORT] = 100,
|
[AUFTRAG.Type.ESCORT] = 100,
|
||||||
[AUFTRAG.Type.CAP] = 100,
|
[AUFTRAG.Type.CAP] = 100,
|
||||||
|
[AUFTRAG.Type.CAPTUREZONE] = 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user