Skip to content

Commit

Permalink
mission: generate sequential mode 3 iff code to assignees
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmzn committed Dec 31, 2021
1 parent eede025 commit df74fb5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/dct/ai/Mission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function Mission:__init(cmdr, missiontype, tgt, plan)
self:_setComplete(false)
self.state = PrepState()
self.state:enter(self)
self._assignedIds = {}
self._lastAssignedId = 0

-- compose the briefing at mission creation to represent
-- known intel the pilots were given before departing
Expand Down Expand Up @@ -223,6 +225,10 @@ function Mission:addAssigned(asset)
return
end
table.insert(self.assigned, asset.name)
if self._assignedIds[asset.name] == nil then
self._assignedIds[asset.name] = self._lastAssignedId
self._lastAssignedId = self._lastAssignedId + 1
end
Logger:debug("Mission %d: addAssigned(%s)", self.id, asset.name)
asset.missionid = self:getID()
end
Expand Down Expand Up @@ -331,6 +337,16 @@ function Mission:addTime(time)
return time
end

function Mission:getIFFCodes(asset)
local assignedId = 0
if asset ~= nil then
assignedId = (self._assignedIds[asset.name] or 0) % 8
end
local m1 = string.format("%o", self.iffcodes.m1)
local m3 = string.format("%o", self.iffcodes.m3 + assignedId)
return { ["m1"] = m1, ["m3"] = m3 }
end

function Mission:getDescription(fmt)
local tgt = self.cmdr:getAsset(self.target)
if tgt == nil then
Expand Down
4 changes: 2 additions & 2 deletions src/dct/ui/cmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ end

local function briefingmsg(msn, asset)
local tgtinfo = msn:getTargetInfo()
local iff = msn:getIFFCodes(asset)
local msg = string.format("Package: #%s\n", msn:getID())..
string.format("IFF Codes: M1(%02o), M3(%04o)\n",
msn.iffcodes.m1, msn.iffcodes.m3)..
string.format("IFF Codes: M1(%s), M3(%s)\n", iff.m1, iff.m3)..
string.format("%s: %s (%s)\n",
human.locationhdr(msn.type),
dctutils.fmtposition(
Expand Down

0 comments on commit df74fb5

Please sign in to comment.