Reordered scripts folder

This commit is contained in:
Pax1601
2023-08-15 15:02:49 +02:00
parent e4b34b1dbc
commit 9db07b2ff8
13 changed files with 2830 additions and 2831 deletions

View File

@@ -1,47 +1,47 @@
coal = {} coal = {}
function coal.notify(message, displayFor) function coal.notify(message, displayFor)
trigger.action.outText(message, displayFor) trigger.action.outText(message, displayFor)
end end
function coal.listRed() function coal.listRed()
coal.coals = env.mission.coalitions.red --solid naming this coal.coals = env.mission.coalitions.red --solid naming this
coal.notify(mist.utils.tableShow(coal.coals),5) coal.notify(mist.utils.tableShow(coal.coals),5)
pickOne = math.random(#coal.coals) pickOne = math.random(#coal.coals)
countryIs = country.name[coal.coals[pickOne]] countryIs = country.name[coal.coals[pickOne]]
coal.notify(countryIs,10) coal.notify(countryIs,10)
end end
function coal.listBlue() function coal.listBlue()
coal.coals = env.mission.coalitions.blue --solid naming this coal.coals = env.mission.coalitions.blue --solid naming this
coal.notify(mist.utils.tableShow(coal.coals),5) coal.notify(mist.utils.tableShow(coal.coals),5)
pickOne = math.random(#coal.coals) pickOne = math.random(#coal.coals)
countryIs = country.name[coal.coals[pickOne]] countryIs = country.name[coal.coals[pickOne]]
coal.notify(countryIs,10) coal.notify(countryIs,10)
end end
function coal.listNeutrals() function coal.listNeutrals()
coal.coals = env.mission.coalitions.neutrals --solid naming this coal.coals = env.mission.coalitions.neutrals --solid naming this
coal.notify(mist.utils.tableShow(coal.coals),5) coal.notify(mist.utils.tableShow(coal.coals),5)
pickOne = math.random(#coal.coals) pickOne = math.random(#coal.coals)
countryIs = country.name[coal.coals[pickOne]] countryIs = country.name[coal.coals[pickOne]]
coal.notify(countryIs,10) coal.notify(countryIs,10)
end end
do do
longRangeShots = missionCommands.addSubMenu("Coal check") longRangeShots = missionCommands.addSubMenu("Coal check")
missionCommands.addCommand ("List reds", longRangeShots, coal.listRed) missionCommands.addCommand ("List reds", longRangeShots, coal.listRed)
missionCommands.addCommand ("List blue", longRangeShots, coal.listBlue) missionCommands.addCommand ("List blue", longRangeShots, coal.listBlue)
missionCommands.addCommand ("List neutrals", longRangeShots, coal.listNeutrals) missionCommands.addCommand ("List neutrals", longRangeShots, coal.listNeutrals)
end end
coal.notify("coals.lua loaded", 2) coal.notify("coals.lua loaded", 2)
-- env.mission.coalitions.red -- env.mission.coalitions.red
-- env.mission.coalitions.blue -- env.mission.coalitions.blue
-- env.mission.coalitions.neutrals -- env.mission.coalitions.neutrals
--coalition.getCountryCoalition(countryID) --coalition.getCountryCoalition(countryID)

View File

@@ -1,305 +1,305 @@
effects = {} effects = {}
effects.shooterName = "TestInfantry" effects.shooterName = "TestInfantry"
effects.napalmCounter = 1 effects.napalmCounter = 1
effects.fireCounter = 1 effects.fireCounter = 1
function effects.notify(message, displayFor) function effects.notify(message, displayFor)
trigger.action.outText(message, displayFor, false) trigger.action.outText(message, displayFor, false)
end end
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
----NAPALM ----NAPALM
function effects.napalmSingle () function effects.napalmSingle ()
unit = Unit.getByName(effects.shooterName) unit = Unit.getByName(effects.shooterName)
local unitPos = unit:getPosition().p local unitPos = unit:getPosition().p
vec3 = mist.utils.makeVec3GL(unitPos) vec3 = mist.utils.makeVec3GL(unitPos)
effects.spawnNapalm (vec3) effects.spawnNapalm (vec3)
end end
function effects.spawnNapalm (vec3) function effects.spawnNapalm (vec3)
napeName = "napalmStrike" .. effects.napalmCounter napeName = "napalmStrike" .. effects.napalmCounter
effects.napalmCounter = effects.napalmCounter + 1 effects.napalmCounter = effects.napalmCounter + 1
mist.dynAddStatic( mist.dynAddStatic(
{ {
country = 20, country = 20,
category = 'Fortifications', category = 'Fortifications',
hidden = true, hidden = true,
name = napeName, name = napeName,
type ="Fuel tank", type ="Fuel tank",
x = vec3.x, x = vec3.x,
y = vec3.z, y = vec3.z,
heading = 0, heading = 0,
} -- end of function } -- end of function
) )
timer.scheduleFunction(effects.explode,vec3, timer.getTime() + 0.1) timer.scheduleFunction(effects.explode,vec3, timer.getTime() + 0.1)
timer.scheduleFunction(effects.napalam_death,napeName, timer.getTime() + 0.12) timer.scheduleFunction(effects.napalam_death,napeName, timer.getTime() + 0.12)
end end
function effects.explode(vec3) function effects.explode(vec3)
trigger.action.explosion(vec3, 10) trigger.action.explosion(vec3, 10)
end end
function effects.napalam_death(staticName) --yes i know bad pun, removes the fuel tank after a set time function effects.napalam_death(staticName) --yes i know bad pun, removes the fuel tank after a set time
StaticObject.getByName(staticName):destroy() StaticObject.getByName(staticName):destroy()
end end
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
----Basic smoke or fire that despawns ----Basic smoke or fire that despawns
function effects.smokeFire () function effects.smokeFire ()
unit = Unit.getByName(effects.shooterName) unit = Unit.getByName(effects.shooterName)
local unitPos = unit:getPosition().p local unitPos = unit:getPosition().p
vec3 = mist.utils.makeVec3GL(unitPos) vec3 = mist.utils.makeVec3GL(unitPos)
effects.createFire (vec3, 2) effects.createFire (vec3, 2)
-- 1 = small smoke and fire -- 1 = small smoke and fire
-- 2 = medium smoke and fire -- 2 = medium smoke and fire
-- 3 = large smoke and fire -- 3 = large smoke and fire
-- 4 = huge smoke and fire -- 4 = huge smoke and fire
-- 5 = small smoke -- 5 = small smoke
-- 6 = medium smoke -- 6 = medium smoke
-- 7 = large smoke -- 7 = large smoke
-- 8 = huge smoke -- 8 = huge smoke
end end
function effects.createFire (vec3, size) function effects.createFire (vec3, size)
smokeName = "smokeName" .. effects.fireCounter smokeName = "smokeName" .. effects.fireCounter
effects.fireCounter = effects.fireCounter + 1 effects.fireCounter = effects.fireCounter + 1
trigger.action.effectSmokeBig(vec3 , size , 1, smokeName) trigger.action.effectSmokeBig(vec3 , size , 1, smokeName)
trigger.action.explosion(vec3, 1) -- looks wierd to spawn in on flat land without this trigger.action.explosion(vec3, 1) -- looks wierd to spawn in on flat land without this
timer.scheduleFunction(effects.removeFire,smokeName, timer.getTime() + 20) --you could set a timer, or if selected give option to despawn later timer.scheduleFunction(effects.removeFire,smokeName, timer.getTime() + 20) --you could set a timer, or if selected give option to despawn later
end end
function effects.removeFire (smokeName) function effects.removeFire (smokeName)
trigger.action.effectSmokeStop(smokeName) trigger.action.effectSmokeStop(smokeName)
end end
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
----White phosporus secondaries extra effect, like round cooking off ----White phosporus secondaries extra effect, like round cooking off
--if you up the number going pop to somewhere in the 200-400 region with a white phosporus impact it would look mental cool --if you up the number going pop to somewhere in the 200-400 region with a white phosporus impact it would look mental cool
function effects.secondaries () function effects.secondaries ()
unit = Unit.getByName(effects.shooterName) unit = Unit.getByName(effects.shooterName)
local unitPos = unit:getPosition().p local unitPos = unit:getPosition().p
vec3 = mist.utils.makeVec3GL(unitPos) vec3 = mist.utils.makeVec3GL(unitPos)
--trigger.action.smoke(vec3 , 2 ) --trigger.action.smoke(vec3 , 2 )
for i = 1,math.random(3,10) do for i = 1,math.random(3,10) do
angle = mist.utils.toRadian((math.random(1,360))) angle = mist.utils.toRadian((math.random(1,360)))
local randVec = mist.utils.makeVec3GL((mist.getRandPointInCircle(vec3 ,5 , 1 ,0 ,360))) local randVec = mist.utils.makeVec3GL((mist.getRandPointInCircle(vec3 ,5 , 1 ,0 ,360)))
trigger.action.signalFlare(randVec , 2 , angle ) trigger.action.signalFlare(randVec , 2 , angle )
end end
end end
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
----Depth Charges ----Depth Charges
-- these also make, on land, good dust clouds for a bomb hit in a sandy area? -- these also make, on land, good dust clouds for a bomb hit in a sandy area?
-- local surface = land.getSurfaceType(mist.utils.makeVec2(unitPos)) -- optional check for water, value 3 or 2 -- local surface = land.getSurfaceType(mist.utils.makeVec2(unitPos)) -- optional check for water, value 3 or 2
function effects.depthCharge () function effects.depthCharge ()
local unit = Unit.getByName(effects.shooterName) local unit = Unit.getByName(effects.shooterName)
local unitPos = unit:getPosition().p local unitPos = unit:getPosition().p
vec3 = mist.utils.makeVec3GL(unitPos) vec3 = mist.utils.makeVec3GL(unitPos)
vec3.y = vec3.y - 1000 vec3.y = vec3.y - 1000
bang = vec3 bang = vec3
distance = 20 distance = 20
explosionSize = 2 explosionSize = 2
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
trigger.action.explosion(vec3,explosionSize) trigger.action.explosion(vec3,explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
trigger.action.explosion(vec3,explosionSize) trigger.action.explosion(vec3,explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0) bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize) trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
timer.scheduleFunction(effects.depthChargeMain,vec3, timer.getTime() + 5) timer.scheduleFunction(effects.depthChargeMain,vec3, timer.getTime() + 5)
end end
function effects.depthChargeMain (vec3) function effects.depthChargeMain (vec3)
explosionSize = 250 explosionSize = 250
trigger.action.explosion(vec3,explosionSize) trigger.action.explosion(vec3,explosionSize)
trigger.action.explosion(vec3,explosionSize) trigger.action.explosion(vec3,explosionSize)
vec3.x = vec3.x vec3.x = vec3.x
trigger.action.explosion(vec3,explosionSize) trigger.action.explosion(vec3,explosionSize)
vec3.x = vec3.x - 10 vec3.x = vec3.x - 10
trigger.action.explosion(vec3,explosionSize) trigger.action.explosion(vec3,explosionSize)
vec3.z = vec3.z vec3.z = vec3.z
trigger.action.explosion(vec3,explosionSize) trigger.action.explosion(vec3,explosionSize)
vec3.z = vec3.z - 10 vec3.z = vec3.z - 10
end end
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
-------------------------------------------- --------------------------------------------
----Normal small explosion ----Normal small explosion
function effects.normalSmallExplosion (vec3) function effects.normalSmallExplosion (vec3)
unit = Unit.getByName(effects.shooterName) unit = Unit.getByName(effects.shooterName)
local unitPos = unit:getPosition().p local unitPos = unit:getPosition().p
vec3 = mist.utils.makeVec3GL(unitPos) vec3 = mist.utils.makeVec3GL(unitPos)
trigger.action.explosion(vec3,10) trigger.action.explosion(vec3,10)
end end
do do
longRangeShots = missionCommands.addSubMenu("Effects") longRangeShots = missionCommands.addSubMenu("Effects")
missionCommands.addCommand ("Napalm", longRangeShots, effects.napalmSingle) missionCommands.addCommand ("Napalm", longRangeShots, effects.napalmSingle)
missionCommands.addCommand ("Fire or smoke", longRangeShots, effects.smokeFire) missionCommands.addCommand ("Fire or smoke", longRangeShots, effects.smokeFire)
missionCommands.addCommand ("Secondary explosions", longRangeShots, effects.secondaries) missionCommands.addCommand ("Secondary explosions", longRangeShots, effects.secondaries)
missionCommands.addCommand ("Depth Charge", longRangeShots, effects.depthCharge) missionCommands.addCommand ("Depth Charge", longRangeShots, effects.depthCharge)
missionCommands.addCommand ("A regular explosion", longRangeShots, effects.normalSmallExplosion) missionCommands.addCommand ("A regular explosion", longRangeShots, effects.normalSmallExplosion)
end end
effects.notify("effects.lua ran", 2) effects.notify("effects.lua ran", 2)

View File

@@ -1,112 +1,112 @@
--Spawn a SAM integrated with IADS --Spawn a SAM integrated with IADS
--Spawn a normal SAM --Spawn a normal SAM
--SAM bubble shields --SAM bubble shields
forceBub = {} forceBub = {}
forceBub.handler = {} forceBub.handler = {}
forceBub.missileList = {} forceBub.missileList = {}
forceBub.missilesActive = 0 forceBub.missilesActive = 0
forceBub.shieldOn = false forceBub.shieldOn = false
function forceBub.notify(message, displayFor) function forceBub.notify(message, displayFor)
trigger.action.outText(message, displayFor, true) trigger.action.outText(message, displayFor, true)
end end
function forceBub.setShield() function forceBub.setShield()
forceBub.notify("Shield on", 2) forceBub.notify("Shield on", 2)
end end
function forceBub.stopShield() function forceBub.stopShield()
forceBub.shieldOn = false forceBub.shieldOn = false
end end
local function protectedCall(...) local function protectedCall(...)
local status, retval = pcall(...) local status, retval = pcall(...)
if not status then if not status then
--rf.notify("Caught error " .. retval,2) --rf.notify("Caught error " .. retval,2)
end end
end end
function forceBub.handler:onEvent(event) function forceBub.handler:onEvent(event)
protectedCall(forceBub.eventHandler, event) protectedCall(forceBub.eventHandler, event)
end end
function forceBub.checkMissiles () function forceBub.checkMissiles ()
local currentTime = timer.getTime() local currentTime = timer.getTime()
if forceBub.missilesActive > 0 then if forceBub.missilesActive > 0 then
for index, data in pairs(forceBub.missileList) do for index, data in pairs(forceBub.missileList) do
output = mist.utils.tableShow(forceBub.missileList[index]) output = mist.utils.tableShow(forceBub.missileList[index])
if forceBub.missileList[index].exists == true then if forceBub.missileList[index].exists == true then
if Object.isExist(forceBub.missileList[index].weapon) == true then if Object.isExist(forceBub.missileList[index].weapon) == true then
forceBub.missileList[index].pos = forceBub.missileList[index].weapon:getPosition() forceBub.missileList[index].pos = forceBub.missileList[index].weapon:getPosition()
local missilePosition = forceBub.missileList[index].pos.p local missilePosition = forceBub.missileList[index].pos.p
unit = Unit.getByName("Test") unit = Unit.getByName("Test")
local unitPosition = unit:getPosition().p local unitPosition = unit:getPosition().p
local distance = mist.utils.get3DDist(unitPosition , missilePosition ) local distance = mist.utils.get3DDist(unitPosition , missilePosition )
forceBub.notify(distance,1) forceBub.notify(distance,1)
if forceBub.shieldOn == true and distance < 100 then --this distance is the sweet spot any less and you probably take damage and die, less than 75 death if forceBub.shieldOn == true and distance < 100 then --this distance is the sweet spot any less and you probably take damage and die, less than 75 death
trigger.action.explosion(missilePosition , 1) --just blows up the missile trigger.action.explosion(missilePosition , 1) --just blows up the missile
end end
else else
forceBub.missileList[index] = nil forceBub.missileList[index] = nil
forceBub.missilesActive = forceBub.missilesActive - 1 forceBub.missilesActive = forceBub.missilesActive - 1
end end
else else
end end
end end
end end
timer.scheduleFunction(forceBub.checkMisProtectCall,{},currentTime + 0.01) timer.scheduleFunction(forceBub.checkMisProtectCall,{},currentTime + 0.01)
end end
function forceBub.eventHandler (event) function forceBub.eventHandler (event)
--forceBub.notify(mist.utils.tableShow(event),10) --forceBub.notify(mist.utils.tableShow(event),10)
if (event.id == 1) then if (event.id == 1) then
--check if weapon is a missile --check if weapon is a missile
--rf.notify("Missile fired id " .. event.weapon.id_ ,2) --rf.notify("Missile fired id " .. event.weapon.id_ ,2)
forceBub.notify(mist.utils.tableShow(Weapon.getDesc(event.weapon)),10) forceBub.notify(mist.utils.tableShow(Weapon.getDesc(event.weapon)),10)
if Weapon.getDesc(event.weapon).missileCategory == 2 then if Weapon.getDesc(event.weapon).missileCategory == 2 then
local newMis = {} local newMis = {}
newMis.id = event.weapon.id_ newMis.id = event.weapon.id_
newMis.pos = event.weapon:getPosition() newMis.pos = event.weapon:getPosition()
newMis.weapon = event.weapon newMis.weapon = event.weapon
newMis.exists = Object.isExist(newMis.weapon) newMis.exists = Object.isExist(newMis.weapon)
forceBub.missileList[event.weapon.id_] = newMis forceBub.missileList[event.weapon.id_] = newMis
forceBub.missilesActive = forceBub.missilesActive + 1 forceBub.missilesActive = forceBub.missilesActive + 1
end end
end end
end end
function forceBub.checkMisProtectCall() function forceBub.checkMisProtectCall()
protectedCall(forceBub.checkMissiles,{}) protectedCall(forceBub.checkMissiles,{})
end end
function forceBub.setShield() function forceBub.setShield()
forceBub.shieldOn = true forceBub.shieldOn = true
end end
do do
forceField = missionCommands.addSubMenu("Force Field") forceField = missionCommands.addSubMenu("Force Field")
missionCommands.addCommand ("Forcefield on", forceField, forceBub.setShield) missionCommands.addCommand ("Forcefield on", forceField, forceBub.setShield)
missionCommands.addCommand ("Stop Field", forceField, forceBub.stopShield) missionCommands.addCommand ("Stop Field", forceField, forceBub.stopShield)
end end
do do
world.addEventHandler(forceBub.handler) world.addEventHandler(forceBub.handler)
end end
protectedCall(forceBub.checkMissiles,{}) protectedCall(forceBub.checkMissiles,{})
forceBub.notify("forceBubble.lua loaded", 2) forceBub.notify("forceBubble.lua loaded", 2)

View File

@@ -1,21 +1,21 @@
lddl = {} lddl = {}
lddl.refreshRate = 1 lddl.refreshRate = 1
function lddl.pointer () function lddl.pointer ()
origin = Unit.getByName("Laser") origin = Unit.getByName("Laser")
originPos = origin:getPosition().p originPos = origin:getPosition().p
targetPos = Unit.getByName("LaserTGT"):getPosition().p targetPos = Unit.getByName("LaserTGT"):getPosition().p
laser = Spot.createInfraRed(origin , originPos, targetPos) laser = Spot.createInfraRed(origin , originPos, targetPos)
timer.scheduleFunction(lddl.removePointer,laser, timer.getTime() + lddl.refreshRate) timer.scheduleFunction(lddl.removePointer,laser, timer.getTime() + lddl.refreshRate)
end end
function lddl.removePointer(laser) function lddl.removePointer(laser)
Spot.destroy(laser) Spot.destroy(laser)
timer.scheduleFunction(lddl.pointer,{}, timer.getTime() + lddl.refreshRate) timer.scheduleFunction(lddl.pointer,{}, timer.getTime() + lddl.refreshRate)
end end
lddl.pointer () lddl.pointer ()

View File

@@ -1,184 +1,184 @@
--------------------------------THIS FIRST BIT IS THE SRS CODE BLOCK------------------- --------------------------------THIS FIRST BIT IS THE SRS CODE BLOCK-------------------
-------------------- first 4 things need to be set correctly for the server, they are for ours, we don't do the google creds yet -------------------- first 4 things need to be set correctly for the server, they are for ours, we don't do the google creds yet
STTS = {} STTS = {}
-- FULL Path to the FOLDER containing DCS-SR-ExternalAudio.exe - EDIT TO CORRECT FOLDER -- FULL Path to the FOLDER containing DCS-SR-ExternalAudio.exe - EDIT TO CORRECT FOLDER
STTS.DIRECTORY = "C:\\Users\\Administrator\\Desktop\\DCS\\SRS Refugees" STTS.DIRECTORY = "C:\\Users\\Administrator\\Desktop\\DCS\\SRS Refugees"
STTS.SRS_PORT = 5002 -- LOCAL SRS PORT - DEFAULT IS 5002 STTS.SRS_PORT = 5002 -- LOCAL SRS PORT - DEFAULT IS 5002
STTS.GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json" STTS.GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json"
-- DONT CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING -- DONT CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING
STTS.EXECUTABLE = "DCS-SR-ExternalAudio.exe" STTS.EXECUTABLE = "DCS-SR-ExternalAudio.exe"
local random = math.random local random = math.random
function STTS.uuid() function STTS.uuid()
local template ='yxxx-xxxxxxxxxxxx' local template ='yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c) return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb) local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v) return string.format('%x', v)
end) end)
end end
function STTS.round(x, n) function STTS.round(x, n)
n = math.pow(10, n or 0) n = math.pow(10, n or 0)
x = x * n x = x * n
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
return x / n return x / n
end end
function STTS.getSpeechTime(length,speed,isGoogle) function STTS.getSpeechTime(length,speed,isGoogle)
-- Function returns estimated speech time in seconds -- Function returns estimated speech time in seconds
-- Assumptions for time calc: 100 Words per min, avarage of 5 letters for english word -- Assumptions for time calc: 100 Words per min, avarage of 5 letters for english word
-- so 5 chars * 100wpm = 500 characters per min = 8.3 chars per second -- so 5 chars * 100wpm = 500 characters per min = 8.3 chars per second
-- so lengh of msg / 8.3 = number of seconds needed to read it. rounded down to 8 chars per sec -- so lengh of msg / 8.3 = number of seconds needed to read it. rounded down to 8 chars per sec
-- map function: (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min -- map function: (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
local maxRateRatio = 3 local maxRateRatio = 3
speed = speed or 1.0 speed = speed or 1.0
isGoogle = isGoogle or false isGoogle = isGoogle or false
local speedFactor = 1.0 local speedFactor = 1.0
if isGoogle then if isGoogle then
speedFactor = speed speedFactor = speed
else else
if speed ~= 0 then if speed ~= 0 then
speedFactor = math.abs(speed) * (maxRateRatio - 1) / 10 + 1 speedFactor = math.abs(speed) * (maxRateRatio - 1) / 10 + 1
end end
if speed < 0 then if speed < 0 then
speedFactor = 1/speedFactor speedFactor = 1/speedFactor
end end
end end
local wpm = math.ceil(100 * speedFactor) local wpm = math.ceil(100 * speedFactor)
local cps = math.floor((wpm * 5)/60) local cps = math.floor((wpm * 5)/60)
if type(length) == "string" then if type(length) == "string" then
length = string.len(length) length = string.len(length)
end end
return math.ceil(length/cps) return math.ceil(length/cps)
end end
function STTS.TextToSpeech(message,freqs,modulations, volume,name, coalition,point, speed,gender,culture,voice, googleTTS ) function STTS.TextToSpeech(message,freqs,modulations, volume,name, coalition,point, speed,gender,culture,voice, googleTTS )
if os == nil or io == nil then if os == nil or io == nil then
env.info("[DCS-STTS] LUA modules os or io are sanitized. skipping. ") env.info("[DCS-STTS] LUA modules os or io are sanitized. skipping. ")
return return
end end
speed = speed or 1 speed = speed or 1
gender = gender or "female" gender = gender or "female"
culture = culture or "" culture = culture or ""
voice = voice or "" voice = voice or ""
message = message:gsub("\"","\\\"") message = message:gsub("\"","\\\"")
local cmd = string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", STTS.DIRECTORY, STTS.EXECUTABLE, freqs, modulations, coalition,STTS.SRS_PORT, name ) local cmd = string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", STTS.DIRECTORY, STTS.EXECUTABLE, freqs, modulations, coalition,STTS.SRS_PORT, name )
if voice ~= "" then if voice ~= "" then
cmd = cmd .. string.format(" -V \"%s\"",voice) cmd = cmd .. string.format(" -V \"%s\"",voice)
else else
if culture ~= "" then if culture ~= "" then
cmd = cmd .. string.format(" -l %s",culture) cmd = cmd .. string.format(" -l %s",culture)
end end
if gender ~= "" then if gender ~= "" then
cmd = cmd .. string.format(" -g %s",gender) cmd = cmd .. string.format(" -g %s",gender)
end end
end end
if googleTTS == true then if googleTTS == true then
cmd = cmd .. string.format(" -G \"%s\"",STTS.GOOGLE_CREDENTIALS) cmd = cmd .. string.format(" -G \"%s\"",STTS.GOOGLE_CREDENTIALS)
end end
if speed ~= 1 then if speed ~= 1 then
cmd = cmd .. string.format(" -s %s",speed) cmd = cmd .. string.format(" -s %s",speed)
end end
if volume ~= 1.0 then if volume ~= 1.0 then
cmd = cmd .. string.format(" -v %s",volume) cmd = cmd .. string.format(" -v %s",volume)
end end
if point and type(point) == "table" and point.x then if point and type(point) == "table" and point.x then
local lat, lon, alt = coord.LOtoLL(point) local lat, lon, alt = coord.LOtoLL(point)
lat = STTS.round(lat,4) lat = STTS.round(lat,4)
lon = STTS.round(lon,4) lon = STTS.round(lon,4)
alt = math.floor(alt) alt = math.floor(alt)
cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt) cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt)
end end
cmd = cmd ..string.format(" -t \"%s\"",message) cmd = cmd ..string.format(" -t \"%s\"",message)
if string.len(cmd) > 255 then if string.len(cmd) > 255 then
local filename = os.getenv('TMP') .. "\\DCS_STTS-" .. STTS.uuid() .. ".bat" local filename = os.getenv('TMP') .. "\\DCS_STTS-" .. STTS.uuid() .. ".bat"
local script = io.open(filename,"w+") local script = io.open(filename,"w+")
script:write(cmd .. " && exit" ) script:write(cmd .. " && exit" )
script:close() script:close()
cmd = string.format("\"%s\"",filename) cmd = string.format("\"%s\"",filename)
timer.scheduleFunction(os.remove, filename, timer.getTime() + 1) timer.scheduleFunction(os.remove, filename, timer.getTime() + 1)
end end
if string.len(cmd) > 255 then if string.len(cmd) > 255 then
env.info("[DCS-STTS] - cmd string too long") env.info("[DCS-STTS] - cmd string too long")
env.info("[DCS-STTS] TextToSpeech Command :\n" .. cmd.."\n") env.info("[DCS-STTS] TextToSpeech Command :\n" .. cmd.."\n")
end end
os.execute(cmd) os.execute(cmd)
return STTS.getSpeechTime(message,speed,googleTTS) return STTS.getSpeechTime(message,speed,googleTTS)
end end
function STTS.PlayMP3(pathToMP3,freqs,modulations, volume,name, coalition,point ) function STTS.PlayMP3(pathToMP3,freqs,modulations, volume,name, coalition,point )
local cmd = string.format("start \"\" /d \"%s\" /b /min \"%s\" -i \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -v %s -h", STTS.DIRECTORY, STTS.EXECUTABLE, pathToMP3, freqs, modulations, coalition,STTS.SRS_PORT, name, volume ) local cmd = string.format("start \"\" /d \"%s\" /b /min \"%s\" -i \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -v %s -h", STTS.DIRECTORY, STTS.EXECUTABLE, pathToMP3, freqs, modulations, coalition,STTS.SRS_PORT, name, volume )
if point and type(point) == "table" and point.x then if point and type(point) == "table" and point.x then
local lat, lon, alt = coord.LOtoLL(point) local lat, lon, alt = coord.LOtoLL(point)
lat = STTS.round(lat,4) lat = STTS.round(lat,4)
lon = STTS.round(lon,4) lon = STTS.round(lon,4)
alt = math.floor(alt) alt = math.floor(alt)
cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt) cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt)
end end
env.info("[DCS-STTS] MP3/OGG Command :\n" .. cmd.."\n") env.info("[DCS-STTS] MP3/OGG Command :\n" .. cmd.."\n")
os.execute(cmd) os.execute(cmd)
end end
------------------------THIS BIT IS THE CODE YOU'D RUN IN GAME ------------------------THIS BIT IS THE CODE YOU'D RUN IN GAME
tts = {} tts = {}
tts.words = "All players, all players, AO update in 5 Magic to all players AO update as follows Weather over North ranges is good, recommending full up war. altimeter 3 0 decimal 1 2 , flare restrictions above 5000,in the MOA's and burnout by 100 ft in western ranges. Chaff below 20,000 for all playersAir picture is multiple groups bandits forming a north south CAP 60 miles north west of bullseye, no SAM,manpad or triple A. All units are approved to start moving into tracks for exercise start, exercise commences in 5 minutes" tts.words = "All players, all players, AO update in 5 Magic to all players AO update as follows Weather over North ranges is good, recommending full up war. altimeter 3 0 decimal 1 2 , flare restrictions above 5000,in the MOA's and burnout by 100 ft in western ranges. Chaff below 20,000 for all playersAir picture is multiple groups bandits forming a north south CAP 60 miles north west of bullseye, no SAM,manpad or triple A. All units are approved to start moving into tracks for exercise start, exercise commences in 5 minutes"
tts.atis = "All players, all players, AO update in 5 Magic to all players AO update as follows Weather over North ranges is good, recommending full up war. altimeter 3 0 decimal 1 2 , flare restrictions above 5000,in the MOA's and burnout by 100 ft in western ranges. Chaff below 20,000 for all playersAir picture is multiple groups bandits forming a north south CAP 60 miles north west of bullseye, no SAM,manpad or triple A. All units are approved to start moving into tracks for exercise start, exercise commences in 5 minutes" tts.atis = "All players, all players, AO update in 5 Magic to all players AO update as follows Weather over North ranges is good, recommending full up war. altimeter 3 0 decimal 1 2 , flare restrictions above 5000,in the MOA's and burnout by 100 ft in western ranges. Chaff below 20,000 for all playersAir picture is multiple groups bandits forming a north south CAP 60 miles north west of bullseye, no SAM,manpad or triple A. All units are approved to start moving into tracks for exercise start, exercise commences in 5 minutes"
function tts.notify(message, displayFor) function tts.notify(message, displayFor)
trigger.action.outText(message, displayFor) trigger.action.outText(message, displayFor)
end end
function tts.normal () function tts.normal ()
STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2) STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2)
end end
function tts.russian () function tts.russian ()
STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2,null,1,"female","ru-RU","Microsoft Irina Desktop") STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2,null,1,"female","ru-RU","Microsoft Irina Desktop")
end end
do do
longRangeShots = missionCommands.addSubMenu("Crash checks") longRangeShots = missionCommands.addSubMenu("Crash checks")
missionCommands.addCommand ("Speak", longRangeShots, tts.normal) missionCommands.addCommand ("Speak", longRangeShots, tts.normal)
missionCommands.addCommand ("Speak russian", longRangeShots, tts.russian) missionCommands.addCommand ("Speak russian", longRangeShots, tts.russian)
end end
tts.notify("crashTest.lua loaded", 2) tts.notify("crashTest.lua loaded", 2)

File diff suppressed because it is too large Load Diff

View File

@@ -1,319 +1,319 @@
shots = {} --https://www.youtube.com/watch?v=XNtTEibFvlQ mandatory terrible listening shots = {} --https://www.youtube.com/watch?v=XNtTEibFvlQ mandatory terrible listening
shots.shooterName = "TestInfantry" shots.shooterName = "TestInfantry"
shots.targetName = "TestTarget1" shots.targetName = "TestTarget1"
function shots.notify(message, displayFor) function shots.notify(message, displayFor)
trigger.action.outText(message, displayFor, false) trigger.action.outText(message, displayFor, false)
end end
--infantry --infantry
function shots.set556 () --red function shots.set556 () --red
roundVelocity = 910 roundVelocity = 910
unitBarrelHeight = 1 unitBarrelHeight = 1
shotsToFire = 5 shotsToFire = 5
shotDelay = 4.5 shotDelay = 4.5
shots.notify("5.56 M4 Georgia", 2) shots.notify("5.56 M4 Georgia", 2)
shots.fire() shots.fire()
end end
function shots.set556SAW () --red function shots.set556SAW () --red
roundVelocity = 915 roundVelocity = 915
unitBarrelHeight = 0.4 unitBarrelHeight = 0.4
shotsToFire = 5 shotsToFire = 5
shotDelay = 4.5 shotDelay = 4.5
shots.notify("5.56 M249 SAW", 2) shots.notify("5.56 M249 SAW", 2)
shots.fire() shots.fire()
end end
function shots.setAk74() --red function shots.setAk74() --red
roundVelocity = 900 roundVelocity = 900
unitBarrelHeight = 0.9 unitBarrelHeight = 0.9
shotsToFire = 5 shotsToFire = 5
shotDelay = 4.5 shotDelay = 4.5
shots.notify("Ak74", 2) shots.notify("Ak74", 2)
shots.fire() shots.fire()
end end
--technicals --technicals
function shots.hmmwv() --red function shots.hmmwv() --red
roundVelocity = 928 roundVelocity = 928
unitBarrelHeight = 2.6 unitBarrelHeight = 2.6
shotsToFire = 5 shotsToFire = 5
shotDelay = 2.5 shotDelay = 2.5
shots.notify("Humm drumm Vee", 2) shots.notify("Humm drumm Vee", 2)
shots.fire() shots.fire()
shots.notify(unitBarrelHeight,2) shots.notify(unitBarrelHeight,2)
end end
function shots.technicalDHSKA() --green function shots.technicalDHSKA() --green
roundVelocity = 928 roundVelocity = 928
unitBarrelHeight = 2.2 unitBarrelHeight = 2.2
shotsToFire = 5 shotsToFire = 5
shotDelay = 2.5 shotDelay = 2.5
shots.notify("technicalDHSKA", 2) shots.notify("technicalDHSKA", 2)
shots.fire() shots.fire()
shots.notify(unitBarrelHeight,2) shots.notify(unitBarrelHeight,2)
end end
function shots.cobra() --green function shots.cobra() --green
roundVelocity = 928 roundVelocity = 928
unitBarrelHeight = 2.85 unitBarrelHeight = 2.85
shotsToFire = 5 shotsToFire = 5
shotDelay = 2.6 shotDelay = 2.6
shots.notify("Cobra", 2) shots.notify("Cobra", 2)
shots.fire() shots.fire()
shots.notify(unitBarrelHeight,2) shots.notify(unitBarrelHeight,2)
end end
--IFVs --IFVs
function shots.setWarrior() --white function shots.setWarrior() --white
roundVelocity = 1070 roundVelocity = 1070
unitBarrelHeight = 2.28 unitBarrelHeight = 2.28
shotsToFire = 3 shotsToFire = 3
shotDelay = 6.3 shotDelay = 6.3
shots.fire() shots.fire()
end end
function shots.setBMP2() --red function shots.setBMP2() --red
roundVelocity = 970 roundVelocity = 970
unitBarrelHeight = 1.95 unitBarrelHeight = 1.95
shotsToFire = 3 shotsToFire = 3
shotDelay = 6 shotDelay = 6
shots.fire() shots.fire()
end end
--Tanks --Tanks
function shots.m1a1() --red function shots.m1a1() --red
roundVelocity = 928 roundVelocity = 928
unitBarrelHeight = 2.15 unitBarrelHeight = 2.15
shotsToFire = 5 shotsToFire = 5
shotDelay = 3 shotDelay = 3
shots.notify("Abrams 50 cal", 2) shots.notify("Abrams 50 cal", 2)
shots.fire() shots.fire()
shots.notify(unitBarrelHeight,2) shots.notify(unitBarrelHeight,2)
end end
function shots.t55() --red and green function shots.t55() --red and green
roundVelocity = 928 roundVelocity = 928
unitBarrelHeight = 1.75 unitBarrelHeight = 1.75
shotsToFire = 5 shotsToFire = 5
shotDelay = 2.6 shotDelay = 2.6
shots.notify("T-72B", 2) shots.notify("T-72B", 2)
shots.fire() shots.fire()
shots.notify(unitBarrelHeight,2) shots.notify(unitBarrelHeight,2)
end end
---aaaaaaaaaaaaaaaa ---aaaaaaaaaaaaaaaa
function shots.ZSU57() --red function shots.ZSU57() --red
roundVelocity = 1070 roundVelocity = 1070
shotsToFire = 2 shotsToFire = 2
shotDelay = 10.5 shotDelay = 10.5
shots.notify("ZSU57", 2) shots.notify("ZSU57", 2)
unitMaxRange = 6000 unitMaxRange = 6000
shots.fireAAA() shots.fireAAA()
end end
function shots.ZSU23() --red function shots.ZSU23() --red
roundVelocity = 1050 roundVelocity = 1050
shotsToFire = 2 shotsToFire = 2
shotDelay = 12 shotDelay = 12
shots.notify("ZSU23", 2) shots.notify("ZSU23", 2)
unitMaxRange = 2000 unitMaxRange = 2000
shots.fireAAA() shots.fireAAA()
end end
function shots.vulcan() --red function shots.vulcan() --red
roundVelocity = 1030 roundVelocity = 1030
shotsToFire = 5 shotsToFire = 5
shotDelay = 5 shotDelay = 5
shots.notify("Vulcan M163", 2) shots.notify("Vulcan M163", 2)
unitMaxRange = 1500 unitMaxRange = 1500
shots.fireAAA() shots.fireAAA()
end end
function shots.flak18() --red and green function shots.flak18() --red and green
roundVelocity = 870 roundVelocity = 870
shotsToFire = 1 shotsToFire = 1
shotDelay = 10.5 shotDelay = 10.5
shots.notify("Flak 18", 2) shots.notify("Flak 18", 2)
unitMaxRange = 4000 unitMaxRange = 4000
shots.fireAAA() shots.fireAAA()
end end
-- This one is really obvious, however I set towards the end of this file the "parameters" of the shots. -- This one is really obvious, however I set towards the end of this file the "parameters" of the shots.
function shots.fire() function shots.fire()
unit = Unit.getByName(shots.shooterName) unit = Unit.getByName(shots.shooterName)
target = Unit.getByName(shots.targetName) target = Unit.getByName(shots.targetName)
local targetMotionVec = Object.getVelocity(target) --if you don't want to do this i.e. shoot a point send a nil or a vec3 of 0's local targetMotionVec = Object.getVelocity(target) --if you don't want to do this i.e. shoot a point send a nil or a vec3 of 0's
--local targetMotionVec = nil --local targetMotionVec = nil
local targetPos = target:getPosition().p local targetPos = target:getPosition().p
shots.calculateAngle(roundVelocity, unit, targetPos, unitBarrelHeight, shotsToFire,shotDelay, targetMotionVec) shots.calculateAngle(roundVelocity, unit, targetPos, unitBarrelHeight, shotsToFire,shotDelay, targetMotionVec)
end end
--main bit that does the maths for simulating a "roughly level" fire fight, not to be used when aiming AAA at aircraft --main bit that does the maths for simulating a "roughly level" fire fight, not to be used when aiming AAA at aircraft
function shots.calculateAngle(v, unit, targetPos, unitBarrelHeight, shotsToFire,shotDelay, targetMotionVector) function shots.calculateAngle(v, unit, targetPos, unitBarrelHeight, shotsToFire,shotDelay, targetMotionVector)
--v muzzle velocity --v muzzle velocity
--unit is unit object you want shooting --unit is unit object you want shooting
--targetPos is a position on the ground, doesn't have to be a targets actual location --targetPos is a position on the ground, doesn't have to be a targets actual location
--unitBarrelHeigh is the height the gun is at when it fires --unitBarrelHeigh is the height the gun is at when it fires
--shotsToFire is how many rounds to shoot, 5 is a nice number except for large calibre slow guns --shotsToFire is how many rounds to shoot, 5 is a nice number except for large calibre slow guns
--shotDelay how long it on average takes to aim from scratch at something and shoot, mostly used in aiming lead --shotDelay how long it on average takes to aim from scratch at something and shoot, mostly used in aiming lead
--targetMotionVector a vec3 of the targets motion if nil just shoots at a spot --targetMotionVector a vec3 of the targets motion if nil just shoots at a spot
g = 9.81 -- gravity, change if on the moon veltro you comment reading prick g = 9.81 -- gravity, change if on the moon veltro you comment reading prick
local unitPos = unit:getPosition().p local unitPos = unit:getPosition().p
local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range
local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range
y = targetPos.y - unitPos.y y = targetPos.y - unitPos.y
y = y - unitBarrelHeight y = y - unitBarrelHeight
--works out some stuff for trig later, like x,y and hypoteneueussueee --works out some stuff for trig later, like x,y and hypoteneueussueee
if targetMotionVector == nil then if targetMotionVector == nil then
--no moving? nothing to ammend --no moving? nothing to ammend
else --work out where target will be when the bullet arrives else --work out where target will be when the bullet arrives
shotDelay = shotDelay + x3d/v --time taken to aim and time for bullet to fly to spot shotDelay = shotDelay + x3d/v --time taken to aim and time for bullet to fly to spot
newPosition = mist.utils.tableShow(targetMotionVector) newPosition = mist.utils.tableShow(targetMotionVector)
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
end end
x = x - 10 --we actually are aiming 10m in front always so need to remove this x = x - 10 --we actually are aiming 10m in front always so need to remove this
local inner = v^4 - g * (g * x^2 + 2 * y * v^2) -- this is the inner bit of the quadratic equation for ease of code local inner = v^4 - g * (g * x^2 + 2 * y * v^2) -- this is the inner bit of the quadratic equation for ease of code
if inner < 0 then if inner < 0 then
-- No solution exists for these parameters, too far away do nothing we can't hit it, saves us crashing if sqrt of negative -- No solution exists for these parameters, too far away do nothing we can't hit it, saves us crashing if sqrt of negative
else else
local angle2 = math.atan((v^2 - math.sqrt(inner)) / (g * x)) -- do the whole quadratic equation local angle2 = math.atan((v^2 - math.sqrt(inner)) / (g * x)) -- do the whole quadratic equation
-- we didn't need to do the +- sqrt b^2..... bits as we care about the flat path not the one shot miles up falling down -- we didn't need to do the +- sqrt b^2..... bits as we care about the flat path not the one shot miles up falling down
local aimUp = 10 * math.tan(angle2)*math.cos(angle2) -- we have to tell dcs to "aim up" at a point 10m ahead of it, this is distance * tan(angle) , so where the fuck has the cos come from? That is because aim correction for shooting up and down is basically modfied by cos(angle) so lazy correction and dcs can't shoot vertically up local aimUp = 10 * math.tan(angle2)*math.cos(angle2) -- we have to tell dcs to "aim up" at a point 10m ahead of it, this is distance * tan(angle) , so where the fuck has the cos come from? That is because aim correction for shooting up and down is basically modfied by cos(angle) so lazy correction and dcs can't shoot vertically up
local xPosDifference = (targetPos.x - unitPos.x) local xPosDifference = (targetPos.x - unitPos.x)
local zPosDifference = (targetPos.z - unitPos.z) local zPosDifference = (targetPos.z - unitPos.z)
local hyp = math.sqrt((xPosDifference*xPosDifference) + (zPosDifference*zPosDifference)) local hyp = math.sqrt((xPosDifference*xPosDifference) + (zPosDifference*zPosDifference))
xPosDifference = (xPosDifference /hyp) * 10 xPosDifference = (xPosDifference /hyp) * 10
zPosDifference = (zPosDifference / hyp) * 10 zPosDifference = (zPosDifference / hyp) * 10
unitPos.x = unitPos.x + xPosDifference unitPos.x = unitPos.x + xPosDifference
unitPos.z = unitPos.z + zPosDifference unitPos.z = unitPos.z + zPosDifference
--that was all basic trig maths --that was all basic trig maths
local controller = unit:getController() local controller = unit:getController()
FireAtPoint = { FireAtPoint = {
id = 'FireAtPoint', id = 'FireAtPoint',
params = { params = {
point = {x = unitPos.x, y = unitPos.z}, point = {x = unitPos.x, y = unitPos.z},
radius = 0.0001, radius = 0.0001,
expendQty = shotsToFire, expendQty = shotsToFire,
expendQtyEnabled = true, expendQtyEnabled = true,
altitude = unitPos.y+unitBarrelHeight +aimUp, --this is a realtive to sea level shot, so we can shoot down altitude = unitPos.y+unitBarrelHeight +aimUp, --this is a realtive to sea level shot, so we can shoot down
alt_type = 0, --0 = sea level, 1 = ground level alt_type = 0, --0 = sea level, 1 = ground level
} }
} }
controller:pushTask(FireAtPoint) --FIREEEEEE controller:pushTask(FireAtPoint) --FIREEEEEE
end end
end end
function shots.fireAAA() function shots.fireAAA()
unit = Unit.getByName(shots.shooterName) unit = Unit.getByName(shots.shooterName)
target = Unit.getByName(shots.targetName) target = Unit.getByName(shots.targetName)
targetMotionVec = Object.getVelocity(target) --if you don't want to do this i.e. shoot a point send a nil or a vec3 of 0's targetMotionVec = Object.getVelocity(target) --if you don't want to do this i.e. shoot a point send a nil or a vec3 of 0's
--local targetMotionVec = nil --local targetMotionVec = nil
targetPos = target:getPosition().p targetPos = target:getPosition().p
shots.aaa(roundVelocity, unit, unitMaxRange, targetPos, shotsToFire,shotDelay, targetMotionVec) shots.aaa(roundVelocity, unit, unitMaxRange, targetPos, shotsToFire,shotDelay, targetMotionVec)
end end
--aaa fires almost straight up, no line of sight fakery needed or working out lobbing bullets onto random points --aaa fires almost straight up, no line of sight fakery needed or working out lobbing bullets onto random points
--if in range just needs to be told to shoot where the target will be in a few seconds --if in range just needs to be told to shoot where the target will be in a few seconds
--if out of range, we just need to extrapolate back and fire inside max range and randomise the up and down, then let it miss --if out of range, we just need to extrapolate back and fire inside max range and randomise the up and down, then let it miss
function shots.aaa(v, unit, unitMaxRange, targetPos, shotsToFire,shotDelay, targetMotionVector) function shots.aaa(v, unit, unitMaxRange, targetPos, shotsToFire,shotDelay, targetMotionVector)
local unitPos = unit:getPosition().p local unitPos = unit:getPosition().p
local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range
local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range
if x3d > unitMaxRange then if x3d > unitMaxRange then
if targetMotionVector == nil then if targetMotionVector == nil then
--no moving? nothing to ammend --no moving? nothing to ammend
else --work out where target will be when the bullet arrives else --work out where target will be when the bullet arrives
shotDelay = shotDelay + x3d/(v/2) --time taken to aim and time for bullet to fly to spot long range roughly 50% slowdown shotDelay = shotDelay + x3d/(v/2) --time taken to aim and time for bullet to fly to spot long range roughly 50% slowdown
newPosition = mist.utils.tableShow(targetMotionVector) newPosition = mist.utils.tableShow(targetMotionVector)
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
end end
difference = mist.vec.sub(targetPos,unitPos) difference = mist.vec.sub(targetPos,unitPos)
unitVec = mist.vec.getUnitVec(difference) unitVec = mist.vec.getUnitVec(difference)
extendPath = mist.vec.scalar_mult(unitVec ,unitMaxRange) extendPath = mist.vec.scalar_mult(unitVec ,unitMaxRange)
targetPos = mist.vec.add(extendPath,unitPos) targetPos = mist.vec.add(extendPath,unitPos)
local controller = unit:getController() local controller = unit:getController()
FireAtPoint = { FireAtPoint = {
id = 'FireAtPoint', id = 'FireAtPoint',
params = { params = {
point = {x = targetPos.x, y = targetPos.z}, point = {x = targetPos.x, y = targetPos.z},
radius = 0.0001, radius = 0.0001,
expendQty = shotsToFire, expendQty = shotsToFire,
expendQtyEnabled = true, expendQtyEnabled = true,
altitude = targetPos.y+math.random(1,500), --this is a realtive to sea level shot, so we can shoot down altitude = targetPos.y+math.random(1,500), --this is a realtive to sea level shot, so we can shoot down
alt_type = 0, --0 = sea level, 1 = ground level alt_type = 0, --0 = sea level, 1 = ground level
} }
} }
controller:pushTask(FireAtPoint) --FIREEEEEE controller:pushTask(FireAtPoint) --FIREEEEEE
else else
if targetMotionVector == nil then if targetMotionVector == nil then
--no moving? nothing to ammend --no moving? nothing to ammend
else --work out where target will be when the bullet arrives else --work out where target will be when the bullet arrives
shotDelay = shotDelay + x3d/v --time taken to aim and time for bullet to fly to spot shotDelay = shotDelay + x3d/v --time taken to aim and time for bullet to fly to spot
newPosition = mist.utils.tableShow(targetMotionVector) newPosition = mist.utils.tableShow(targetMotionVector)
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
end end
local controller = unit:getController() local controller = unit:getController()
FireAtPoint = { FireAtPoint = {
id = 'FireAtPoint', id = 'FireAtPoint',
params = { params = {
point = {x = targetPos.x, y = targetPos.z}, point = {x = targetPos.x, y = targetPos.z},
radius = 0.0001, radius = 0.0001,
expendQty = shotsToFire, expendQty = shotsToFire,
expendQtyEnabled = true, expendQtyEnabled = true,
altitude = targetPos.y, --this is a realtive to sea level shot, so we can shoot down altitude = targetPos.y, --this is a realtive to sea level shot, so we can shoot down
alt_type = 0, --0 = sea level, 1 = ground level alt_type = 0, --0 = sea level, 1 = ground level
} }
} }
controller:pushTask(FireAtPoint) --FIREEEEEE controller:pushTask(FireAtPoint) --FIREEEEEE
end end
end end
do do
longRangeShots = missionCommands.addSubMenu("Firefight") longRangeShots = missionCommands.addSubMenu("Firefight")
missionCommands.addCommand ("Fire", longRangeShots, shots.vulcan) missionCommands.addCommand ("Fire", longRangeShots, shots.vulcan)
end end
shots.notify("raisedShots.lua ran", 2) shots.notify("raisedShots.lua ran", 2)

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long