Merge branch 'main' of https://github.com/dutchie031/Spearhead
This commit is contained in:
Binary file not shown.
@@ -1144,18 +1144,24 @@ do -- INIT DCS_UTIL
|
||||
return drawID
|
||||
end
|
||||
|
||||
|
||||
local _markID = 200
|
||||
|
||||
---@param groupID number
|
||||
---@param text string
|
||||
---@param location Vec3
|
||||
---@return number markID
|
||||
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
|
||||
trigger.action.markToGroup(_markID, text, location, groupID, true, nil)
|
||||
return _markID
|
||||
---comment
|
||||
---@param text any
|
||||
---@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
|
||||
|
||||
---@param markId number
|
||||
|
||||
@@ -188,7 +188,7 @@ function MissionCommandsHelper:AddOverviewCommand(groupID)
|
||||
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
|
||||
|
||||
---Primary missions
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
---@field private _completeAtIndex number
|
||||
---@field private _parentStage Stage
|
||||
---@field private _battleManager? BattleManager
|
||||
---@field private _lastContactMarkerID number;
|
||||
local ZoneMission = {}
|
||||
|
||||
--- @class MissionGroups
|
||||
@@ -312,6 +313,10 @@ function ZoneMission:UpdateState(checkHealth, messageIfDone)
|
||||
end
|
||||
end
|
||||
|
||||
if self._state == "COMPLETED" and self._lastContactMarkerID then
|
||||
Spearhead.DcsUtil.RemoveMarker(self._lastContactMarkerID)
|
||||
end
|
||||
|
||||
if self._state == "COMPLETED" and self._battleManager then
|
||||
self._battleManager:Stop()
|
||||
end
|
||||
@@ -382,8 +387,8 @@ function ZoneMission:StartCheckingContinuous()
|
||||
timer.scheduleFunction(Check, self, timer.getTime() + 30)
|
||||
end
|
||||
|
||||
---@protected
|
||||
function ZoneMission:ToStateString()
|
||||
---@return number
|
||||
function ZoneMission:PercentageComplete()
|
||||
if self._missionGroups.hasTargets == true then
|
||||
local dead = 0
|
||||
local total = 0
|
||||
@@ -399,8 +404,7 @@ function ZoneMission:ToStateString()
|
||||
end
|
||||
|
||||
if total > 0 then
|
||||
local completionPercentage = math.floor((dead / total) * 100)
|
||||
return "Targets Destroyed: " .. completionPercentage .. "%"
|
||||
return math.floor((dead / total) * 100)
|
||||
end
|
||||
else
|
||||
local dead = 0
|
||||
@@ -417,10 +421,15 @@ function ZoneMission:ToStateString()
|
||||
end
|
||||
|
||||
if total > 0 then
|
||||
local completionPercentage = math.floor((dead / total) * 100)
|
||||
return "Units Destroyed: " .. completionPercentage .. "%"
|
||||
return math.floor((dead / total) * 100)
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
---@protected
|
||||
function ZoneMission:ToStateString()
|
||||
return "Units Destroyed: " .. self:PercentageComplete() .. "%"
|
||||
end
|
||||
|
||||
function ZoneMission:OnUnitLost(object)
|
||||
@@ -429,6 +438,10 @@ function ZoneMission:OnUnitLost(object)
|
||||
]] --
|
||||
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)
|
||||
if category == Object.Category.UNIT then
|
||||
local unitName = object:getName()
|
||||
@@ -453,6 +466,29 @@ function ZoneMission:OnUnitLost(object)
|
||||
self:UpdateState(false, true)
|
||||
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.stageClasses then Spearhead.classes.stageClasses = {} 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:StartCheckingContinuous() end
|
||||
|
||||
|
||||
function Mission:PercentageComplete()
|
||||
return 0
|
||||
end
|
||||
---comment
|
||||
---@param groupId number
|
||||
function Mission:ShowBriefing(groupId)
|
||||
|
||||
@@ -45,6 +45,11 @@ SpearheadConfig = {
|
||||
drawStages = 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.
|
||||
-- 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
|
||||
drawStages = true, -- default true
|
||||
drawPreActivated = true,
|
||||
markLastContact = true,
|
||||
|
||||
--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.
|
||||
|
||||
Reference in New Issue
Block a user