Skip to content

Commit

Permalink
Added: Inaccurate variants of Smoke, Flare & Illumination
Browse files Browse the repository at this point in the history
  • Loading branch information
john681611 committed Jan 7, 2025
1 parent 22c6b2a commit 18496a9
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 79 deletions.
14 changes: 14 additions & 0 deletions Database/ObjectiveFeatures/TargetDesignationFlareInaccurate.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[GUI]
DisplayName=Designation: flare (Inaccurate)
Category=Target designation
Description=Player can ask the target to shoot a flare using the F10 menu.

[Briefing]
Remarks=
Remarks.Enemy=

[Include]
Lua=TargetDesignationFlareInaccurate
LuaSettings=
Ogg=RadioSupportNoTarget,RadioPilotMarkSelfWithFlare,RadioSupportShootingFlareOut,RadioSupportShootingFlare

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[GUI]
DisplayName=Designation: illumination bomb (Inaccurate)
Category=Target designation
Description=Player can ask recon aircraft to drop illumination bombs using the F10 menu.

[Briefing]
Remarks=

[Include]
Lua=TargetDesignationIlluminationBombInaccurate
LuaSettings=
Ogg=RadioPilotDropIlluminationBomb,RadioSupportNoTarget,RadioSupportIlluminationBomb,RadioSupportIlluminationBombOut

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[GUI]
DisplayName=Designation: smoke marker (inaccurate)
DisplayName=Designation: smoke marker (Inaccurate)
Category=Target designation
Description=Adds an F10 menu command to mark the target with green (if it is an ally) or red (if it is an enemy) smoke.

Expand Down
2 changes: 1 addition & 1 deletion Include/Lua/ObjectiveFeatures/TargetDesignationFlare.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb($OBJECTIVEINDEX$)
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb($OBJECTIVEINDEX$, false)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb($OBJECTIVEINDEX$, true)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb($OBJECTIVEINDEX$)
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb($OBJECTIVEINDEX$, false)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb($OBJECTIVEINDEX$, true)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationSmoke($OBJECTIVEINDEX$)
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationSmoke($OBJECTIVEINDEX$, false)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationSmokeInaccurate($OBJECTIVEINDEX$)
briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationSmoke($OBJECTIVEINDEX$, true)
123 changes: 49 additions & 74 deletions Include/Lua/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,8 @@ function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationC
briefingRoom.mission.objectiveFeatures[objectiveIndex].objRadioCommandIndex = #briefingRoom.mission.objectives[objectiveIndex].f10Commands
end

-- Flare

function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationFlareDoFlare(args)
trigger.action.signalFlare(args.position, trigger.flareColor.Yellow, 0)
end
Expand Down Expand Up @@ -1770,19 +1772,31 @@ function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationFlare(arg

local args = { ["position"] = unit:getPoint() }

briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_FLAIRAFFIRM$", "RadioSupportShootingFlare", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationFlareDoFlare, args)
if briefingRoom.mission.objectiveFeatures[objectiveIndex].innacurate then
local heading = math.random(0, 359)
local distance = math.floor(math.random(5, 20)) * 100
args.position.x = args.position.x - math.cos(heading * DEGREES_TO_RADIANS) * distance;
args.position.z = args.position.z - math.sin(heading * DEGREES_TO_RADIANS) * distance;
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_FLAIRAFFIRM$"..dcsExtensions.degreesToCardinalDirection(heading).." of the Flare.", "RadioSupportShootingFlare", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationFlareDoFlare, args)
else
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_FLAIRAFFIRM$", "RadioSupportShootingFlare", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationFlareDoFlare, args)
end
end

function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationFlare(objectiveIndex)
function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationFlare(objectiveIndex, innacurate)
briefingRoom.mission.objectiveFeatures[objectiveIndex].innacurate = innacurate or false
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationFlareFlaresLeft = 5
table.insert(briefingRoom.mission.objectives[objectiveIndex].f10Commands, {text = "$LANG_FLAIRMENU$", func = briefingRoom.mission.objectiveFeaturesCommon.targetDesignationFlare, args = {objectiveIndex}})
end

-- IlluminationBomb

function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationIlluminationBombDoBomb(args)
args.position.y = args.position.y + 1250 + math.random(0, 500)
trigger.action.illuminationBomb(args.position, 100000)
end


function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationIlluminationBomb(args)
local objectiveIndex = args[1]
briefingRoom.radioManager.play("$LANG_PILOT$: $LANG_ILLUMINATIONREQUEST$", "RadioPilotDropIlluminationBomb")
Expand All @@ -1808,19 +1822,29 @@ function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationIlluminat
objectiveFeature.targetDesignationIlluminationBombBombsLeft = objectiveFeature.targetDesignationIlluminationBombBombsLeft - 1

local args = { ["position"] = unit:getPoint() }

briefingRoom.radioManager.play(objective.name.." $LANG_RECON$: $LANG_ILLUMINATIONAFFIRM$", "RadioSupportIlluminationBomb", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationIlluminationBombDoBomb, args)
if briefingRoom.mission.objectiveFeatures[objectiveIndex].innacurate then
local heading = math.random(0, 359)
local distance = math.floor(math.random(5, 20)) * 100
args.position.x = args.position.x - math.cos(heading * DEGREES_TO_RADIANS) * distance;
args.position.z = args.position.z - math.sin(heading * DEGREES_TO_RADIANS) * distance;
briefingRoom.radioManager.play(objective.name.." $LANG_RECON$: $LANG_ILLUMINATIONAFFIRM$"..dcsExtensions.degreesToCardinalDirection(heading).." of the Illumination.", "RadioSupportIlluminationBomb", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationIlluminationBombDoBomb, args)
else
briefingRoom.radioManager.play(objective.name.." $LANG_RECON$: $LANG_ILLUMINATIONAFFIRM$", "RadioSupportIlluminationBomb", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationIlluminationBombDoBomb, args)
end
end

function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb(objectiveIndex)
function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationIlluminationBomb(objectiveIndex, innacurate)
briefingRoom.mission.objectiveFeatures[objectiveIndex].innacurate = innacurate or false
-- Number of bombs available
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationIlluminationBombBombsLeft = 4
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationIlluminationBombBombsLeft = 4

-- Add the command to the F10 menu
table.insert(briefingRoom.mission.objectives[objectiveIndex].f10Commands, {text = "$LANG_ILLUMINATIONMENU$", func = briefingRoom.mission.objectiveFeaturesCommon.targetDesignationIlluminationBomb, args = {objectiveIndex}})

end

-- Laser

briefingRoom.mission.objectiveFeaturesCommon.targetDesignationLaser = {}

function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationLaser.laserWatch(args, time)
Expand Down Expand Up @@ -1959,10 +1983,10 @@ end

function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationLaser(objectiveIndex, laserCode)
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser = { }
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserSpot = nil -- current laser spot
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserIRSpot = nil -- current laser spot
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserTarget = nil -- current lased target
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserCode = laserCode -- current lased target
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserSpot = nil -- current laser spot
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserIRSpot = nil -- current laser spot
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserTarget = nil -- current lased target
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationLaser.laserCode = laserCode -- current lased target


-- Begin updating laser designation
Expand All @@ -1972,6 +1996,8 @@ table.insert(briefingRoom.mission.objectives[objectiveIndex].f10Commands, {text
end


---- SMOKE

function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarker(args)
local objectiveIndex = args[1]
local objective = briefingRoom.mission.objectives[objectiveIndex]
Expand Down Expand Up @@ -2001,79 +2027,28 @@ function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMark
-- Play radio message and setup smoke creating function
local args = { position = unit:getPoint(), color = trigger.smokeColor.Red }
if unit:getCoalition() == briefingRoom.playerCoalition then args.color = trigger.smokeColor.Green end
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_SMOKEAFFIRM$", "RadioSupportTargetMarkedWithSmoke", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarkerDoSmoke, args)
if briefingRoom.mission.objectiveFeatures[objectiveIndex].innacurate then
local heading = math.random(0, 359)
local distance = math.floor(math.random(5, 20)) * 100
args.position.x = args.position.x - math.cos(heading * DEGREES_TO_RADIANS) * distance;
args.position.z = args.position.z - math.sin(heading * DEGREES_TO_RADIANS) * distance;
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_SMOKENEARAFFIRM$"..dcsExtensions.degreesToCardinalDirection(heading).." of the smoke.", "RadioSupportTargetMarkedWithSmoke", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarkerDoSmoke, args)
else
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_SMOKEAFFIRM$", "RadioSupportTargetMarkedWithSmoke", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarkerDoSmoke, args)
end
end

function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarkerDoSmoke(args)
local smokePosition = args.position
if args.innacurate then
local distance = math.floor(math.random(5, 20)) * 100
local heading = args.heading
smokePosition.x = smokePosition.x - math.cos(heading * DEGREES_TO_RADIANS) * distance;
smokePosition.z = smokePosition.z - math.sin(heading * DEGREES_TO_RADIANS) * distance;
end
trigger.action.smoke(smokePosition, args.color)
return nil
end





function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationSmoke(objectiveIndex)
function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationSmoke(objectiveIndex, innacurate)
briefingRoom.mission.objectiveFeatures[objectiveIndex].innacurate = innacurate or false
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationSmokeMarkerNextSmoke = -999999

-- Add the command to the F10 menu
table.insert(briefingRoom.mission.objectives[objectiveIndex].f10Commands, {text = "$LANG_SMOKEMENU$", func = briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarker, args = {objectiveIndex}})
end

function briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarkerInaccurate(args)
local objectiveIndex = args[1]
local objective = briefingRoom.mission.objectives[objectiveIndex]
briefingRoom.radioManager.play("$LANG_PILOT$: $LANG_SMOKENEARREQUEST$", "RadioPilotMarkTargetWithSmoke")

if #briefingRoom.mission.objectives[objectiveIndex].unitNames == 0 then -- no target units left
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$:$LANG_NOTARGET$", "RadioSupportNoTarget", briefingRoom.radioManager.getAnswerDelay())
return
end

local unit = dcsExtensions.getUnitOrStatic(briefingRoom.mission.objectives[objectiveIndex].unitNames[1])
if unit == nil then -- no unit nor static found with the ID
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$:$LANG_NOTARGET$", "RadioSupportNoTarget", briefingRoom.radioManager.getAnswerDelay())
return
end

local timeNow = timer.getAbsTime()

if timeNow < briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationSmokeMarkerInaccurateNextSmoke then -- Smoke not ready
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_SMOKENEARBY$", "RadioSupportTargetAlreadyMarkedWithSmoke", briefingRoom.radioManager.getAnswerDelay())
return
end

-- Set cooldown for next smoke
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationSmokeMarkerInaccurateNextSmoke = timeNow + SMOKE_DURATION

-- Play radio message and setup smoke creating function
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationSmokeMarkerInaccurateHeading = math.random(0, 359)

local args = { position = unit:getPoint(), color = trigger.smokeColor.Red, innacure = true, heading = briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationSmokeMarkerInaccurateHeading }
if unit:getCoalition() == briefingRoom.playerCoalition then args.color = trigger.smokeColor.Green end
briefingRoom.radioManager.play(objective.name.." $LANG_JTAC$: $LANG_SMOKENEARAFFIRM$"..dcsExtensions.degreesToCardinalDirection(briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationSmokeMarkerInaccurateHeading).." of the smoke.", "RadioSupportTargetMarkedWithSmoke", briefingRoom.radioManager.getAnswerDelay(), briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarkerDoSmoke, args)
end

-- this function should not exist TODO add accuracy param to each designation function
function briefingRoom.mission.objectiveFeaturesCommon.registerTargetDesignationSmokeInaccurate(objectiveIndex)
briefingRoom.mission.objectiveFeatures[objectiveIndex].targetDesignationSmokeMarkerInaccurateNextSmoke = -999999

-- Spawn smoke marker


-- "Mark target with smoke" F10 radio command


-- Add the command to the F10 menu
table.insert(briefingRoom.mission.objectives[objectiveIndex].f10Commands, {text = "$LANG_SMOKENEARMENU$", func = briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarkerInaccurate, args = {objectiveIndex}})

-- Add the command to the F10 menu
table.insert(briefingRoom.mission.objectives[objectiveIndex].f10Commands, {text = "$LANG_SMOKEMENU$", func = briefingRoom.mission.objectiveFeaturesCommon.targetDesignationSmokeMarker, args = {objectiveIndex}})
end


Expand Down

0 comments on commit 18496a9

Please sign in to comment.