Feature/mark contact (#45)
* fixed for static train carts having no category? * Added lastContact logic to be able to mark the location where a unit was last killed in a mission --------- Co-authored-by: dutchie032 <dutchie032>
This commit is contained in:
committed by
GitHub
co-authored by
dutchie032 <dutchie032>
parent
90c8d113fd
commit
d6178bcdd7
Binary file not shown.
@@ -530,7 +530,7 @@ do -- INIT DCS_UTIL
|
|||||||
dead = group.dead
|
dead = group.dead
|
||||||
}
|
}
|
||||||
|
|
||||||
if string.lower(unit.category) == "planes" then
|
if unit and unit.category and string.lower(unit.category) == "planes" then
|
||||||
staticObj.livery_id = unit.livery_id
|
staticObj.livery_id = unit.livery_id
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1144,18 +1144,24 @@ do -- INIT DCS_UTIL
|
|||||||
return drawID
|
return drawID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local _markID = 200
|
|
||||||
|
|
||||||
---@param groupID number
|
---@param groupID number
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param location Vec3
|
---@param location Vec3
|
||||||
---@return number markID
|
---@return number markID
|
||||||
function DCS_UTIL.AddMarkToGroup(groupID, text, location)
|
function DCS_UTIL.AddMarkToGroup(groupID, text, location)
|
||||||
|
drawID = drawID + 1
|
||||||
|
trigger.action.markToGroup(drawID, text, location, groupID, true, nil)
|
||||||
|
return drawID
|
||||||
|
end
|
||||||
|
|
||||||
_markID = _markID + 1
|
---comment
|
||||||
trigger.action.markToGroup(_markID, text, location, groupID, true, nil)
|
---@param text any
|
||||||
return _markID
|
---@param location Vec3
|
||||||
|
---@return integer
|
||||||
|
function DCS_UTIL.AddMarkToAll(text, location)
|
||||||
|
drawID = drawID + 1
|
||||||
|
trigger.action.markToAll(drawID, text, location, true, nil)
|
||||||
|
return drawID
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param markId number
|
---@param markId number
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ function MissionCommandsHelper:AddOverviewCommand(groupID)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return string.format("[%s]\t%s \t%s \t%s nM\n", mission.code, mission.missionTypeDisplay, mission.name, distanceText)
|
return string.format("[%s]\t%s \t%s \t%s %% \t%s nM\n", mission.code, mission.missionTypeDisplay, mission.name, mission:PercentageComplete(), distanceText)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Primary missions
|
---Primary missions
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
---@field private _completeAtIndex number
|
---@field private _completeAtIndex number
|
||||||
---@field private _parentStage Stage
|
---@field private _parentStage Stage
|
||||||
---@field private _battleManager? BattleManager
|
---@field private _battleManager? BattleManager
|
||||||
|
---@field private _lastContactMarkerID number;
|
||||||
local ZoneMission = {}
|
local ZoneMission = {}
|
||||||
|
|
||||||
--- @class MissionGroups
|
--- @class MissionGroups
|
||||||
@@ -312,6 +313,10 @@ function ZoneMission:UpdateState(checkHealth, messageIfDone)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self._state == "COMPLETED" and self._lastContactMarkerID then
|
||||||
|
Spearhead.DcsUtil.RemoveMarker(self._lastContactMarkerID)
|
||||||
|
end
|
||||||
|
|
||||||
if self._state == "COMPLETED" and self._battleManager then
|
if self._state == "COMPLETED" and self._battleManager then
|
||||||
self._battleManager:Stop()
|
self._battleManager:Stop()
|
||||||
end
|
end
|
||||||
@@ -382,8 +387,8 @@ function ZoneMission:StartCheckingContinuous()
|
|||||||
timer.scheduleFunction(Check, self, timer.getTime() + 30)
|
timer.scheduleFunction(Check, self, timer.getTime() + 30)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@protected
|
---@return number
|
||||||
function ZoneMission:ToStateString()
|
function ZoneMission:PercentageComplete()
|
||||||
if self._missionGroups.hasTargets == true then
|
if self._missionGroups.hasTargets == true then
|
||||||
local dead = 0
|
local dead = 0
|
||||||
local total = 0
|
local total = 0
|
||||||
@@ -399,8 +404,7 @@ function ZoneMission:ToStateString()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if total > 0 then
|
if total > 0 then
|
||||||
local completionPercentage = math.floor((dead / total) * 100)
|
return math.floor((dead / total) * 100)
|
||||||
return "Targets Destroyed: " .. completionPercentage .. "%"
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local dead = 0
|
local dead = 0
|
||||||
@@ -417,10 +421,15 @@ function ZoneMission:ToStateString()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if total > 0 then
|
if total > 0 then
|
||||||
local completionPercentage = math.floor((dead / total) * 100)
|
return math.floor((dead / total) * 100)
|
||||||
return "Units Destroyed: " .. completionPercentage .. "%"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
---@protected
|
||||||
|
function ZoneMission:ToStateString()
|
||||||
|
return "Units Destroyed: " .. self:PercentageComplete() .. "%"
|
||||||
end
|
end
|
||||||
|
|
||||||
function ZoneMission:OnUnitLost(object)
|
function ZoneMission:OnUnitLost(object)
|
||||||
@@ -429,6 +438,10 @@ function ZoneMission:OnUnitLost(object)
|
|||||||
]] --
|
]] --
|
||||||
self._logger:debug("Getting on unit lost event")
|
self._logger:debug("Getting on unit lost event")
|
||||||
|
|
||||||
|
if SpearheadConfig and SpearheadConfig.StageConfig and SpearheadConfig.StageConfig.markLastContact == true then
|
||||||
|
self:MarkLastContact(object)
|
||||||
|
end
|
||||||
|
|
||||||
local category = Object.getCategory(object)
|
local category = Object.getCategory(object)
|
||||||
if category == Object.Category.UNIT then
|
if category == Object.Category.UNIT then
|
||||||
local unitName = object:getName()
|
local unitName = object:getName()
|
||||||
@@ -453,6 +466,29 @@ function ZoneMission:OnUnitLost(object)
|
|||||||
self:UpdateState(false, true)
|
self:UpdateState(false, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@private
|
||||||
|
---@param unit Object
|
||||||
|
function ZoneMission:MarkLastContact(unit)
|
||||||
|
|
||||||
|
if not unit then
|
||||||
|
self._logger:error("MarkLastContact called with nil unit")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local point = unit:getPoint()
|
||||||
|
if not point then
|
||||||
|
self._logger:error("MarkLastContact called with unit without point")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if self._lastContactMarkerID then
|
||||||
|
Spearhead.DcsUtil.RemoveMark(self._lastContactMarkerID)
|
||||||
|
end
|
||||||
|
|
||||||
|
self._lastContactMarkerID = Spearhead.DcsUtil.AddMarkToAll("Last Contact: " .. self.name .. " [" .. self.code .. "]", point)
|
||||||
|
end
|
||||||
|
|
||||||
if not Spearhead.classes then Spearhead.classes = {} end
|
if not Spearhead.classes then Spearhead.classes = {} end
|
||||||
if not Spearhead.classes.stageClasses then Spearhead.classes.stageClasses = {} end
|
if not Spearhead.classes.stageClasses then Spearhead.classes.stageClasses = {} end
|
||||||
if not Spearhead.classes.stageClasses.missions then Spearhead.classes.stageClasses.missions = {} end
|
if not Spearhead.classes.stageClasses.missions then Spearhead.classes.stageClasses.missions = {} end
|
||||||
|
|||||||
@@ -70,7 +70,9 @@ function Mission:SpawnActive() end
|
|||||||
function Mission:UpdateState(checkHealth, messageIfDone) end
|
function Mission:UpdateState(checkHealth, messageIfDone) end
|
||||||
function Mission:StartCheckingContinuous() end
|
function Mission:StartCheckingContinuous() end
|
||||||
|
|
||||||
|
function Mission:PercentageComplete()
|
||||||
|
return 0
|
||||||
|
end
|
||||||
---comment
|
---comment
|
||||||
---@param groupId number
|
---@param groupId number
|
||||||
function Mission:ShowBriefing(groupId)
|
function Mission:ShowBriefing(groupId)
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ SpearheadConfig = {
|
|||||||
drawStages = true, -- default true
|
drawStages = true, -- default true
|
||||||
drawPreActivated = true, -- default true
|
drawPreActivated = true, -- default true
|
||||||
|
|
||||||
|
--Marking the last contact for any mission.
|
||||||
|
--If a unit is killed the location will be permanently marked on the map until the mission is complete.
|
||||||
|
--The location will continously update for the last killed unit.
|
||||||
|
markLastContact = false, -- default false
|
||||||
|
|
||||||
--AutoStages will continue to the next stage automatically on completion of the missions within the stage.
|
--AutoStages will continue to the next stage automatically on completion of the missions within the stage.
|
||||||
-- If you want to make it so the next stage triggers only when you want to disable it here and manually implement the actions needed.
|
-- If you want to make it so the next stage triggers only when you want to disable it here and manually implement the actions needed.
|
||||||
--[[
|
--[[
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ SpearheadConfig = {
|
|||||||
|
|
||||||
--Will draw the active and the next stage
|
--Will draw the active and the next stage
|
||||||
drawStages = true, -- default true
|
drawStages = true, -- default true
|
||||||
|
drawPreActivated = true,
|
||||||
|
markLastContact = true,
|
||||||
|
|
||||||
--AutoStages will continue to the next stage automatically on completion of the missions within the stage.
|
--AutoStages will continue to the next stage automatically on completion of the missions within the stage.
|
||||||
-- If you want to make it so the next stage triggers only when you want to disable it here and manually implement the actions needed.
|
-- If you want to make it so the next stage triggers only when you want to disable it here and manually implement the actions needed.
|
||||||
|
|||||||
Reference in New Issue
Block a user