mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Reordered scripts folder
This commit is contained in:
parent
e4b34b1dbc
commit
9db07b2ff8
@ -1,47 +1,47 @@
|
||||
coal = {}
|
||||
|
||||
function coal.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor)
|
||||
end
|
||||
|
||||
function coal.listRed()
|
||||
coal.coals = env.mission.coalitions.red --solid naming this
|
||||
coal.notify(mist.utils.tableShow(coal.coals),5)
|
||||
pickOne = math.random(#coal.coals)
|
||||
countryIs = country.name[coal.coals[pickOne]]
|
||||
coal.notify(countryIs,10)
|
||||
end
|
||||
|
||||
function coal.listBlue()
|
||||
coal.coals = env.mission.coalitions.blue --solid naming this
|
||||
coal.notify(mist.utils.tableShow(coal.coals),5)
|
||||
pickOne = math.random(#coal.coals)
|
||||
countryIs = country.name[coal.coals[pickOne]]
|
||||
coal.notify(countryIs,10)
|
||||
end
|
||||
|
||||
function coal.listNeutrals()
|
||||
coal.coals = env.mission.coalitions.neutrals --solid naming this
|
||||
coal.notify(mist.utils.tableShow(coal.coals),5)
|
||||
pickOne = math.random(#coal.coals)
|
||||
countryIs = country.name[coal.coals[pickOne]]
|
||||
coal.notify(countryIs,10)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Coal check")
|
||||
missionCommands.addCommand ("List reds", longRangeShots, coal.listRed)
|
||||
missionCommands.addCommand ("List blue", longRangeShots, coal.listBlue)
|
||||
missionCommands.addCommand ("List neutrals", longRangeShots, coal.listNeutrals)
|
||||
|
||||
end
|
||||
|
||||
coal.notify("coals.lua loaded", 2)
|
||||
|
||||
|
||||
-- env.mission.coalitions.red
|
||||
-- env.mission.coalitions.blue
|
||||
-- env.mission.coalitions.neutrals
|
||||
|
||||
coal = {}
|
||||
|
||||
function coal.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor)
|
||||
end
|
||||
|
||||
function coal.listRed()
|
||||
coal.coals = env.mission.coalitions.red --solid naming this
|
||||
coal.notify(mist.utils.tableShow(coal.coals),5)
|
||||
pickOne = math.random(#coal.coals)
|
||||
countryIs = country.name[coal.coals[pickOne]]
|
||||
coal.notify(countryIs,10)
|
||||
end
|
||||
|
||||
function coal.listBlue()
|
||||
coal.coals = env.mission.coalitions.blue --solid naming this
|
||||
coal.notify(mist.utils.tableShow(coal.coals),5)
|
||||
pickOne = math.random(#coal.coals)
|
||||
countryIs = country.name[coal.coals[pickOne]]
|
||||
coal.notify(countryIs,10)
|
||||
end
|
||||
|
||||
function coal.listNeutrals()
|
||||
coal.coals = env.mission.coalitions.neutrals --solid naming this
|
||||
coal.notify(mist.utils.tableShow(coal.coals),5)
|
||||
pickOne = math.random(#coal.coals)
|
||||
countryIs = country.name[coal.coals[pickOne]]
|
||||
coal.notify(countryIs,10)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Coal check")
|
||||
missionCommands.addCommand ("List reds", longRangeShots, coal.listRed)
|
||||
missionCommands.addCommand ("List blue", longRangeShots, coal.listBlue)
|
||||
missionCommands.addCommand ("List neutrals", longRangeShots, coal.listNeutrals)
|
||||
|
||||
end
|
||||
|
||||
coal.notify("coals.lua loaded", 2)
|
||||
|
||||
|
||||
-- env.mission.coalitions.red
|
||||
-- env.mission.coalitions.blue
|
||||
-- env.mission.coalitions.neutrals
|
||||
|
||||
--coalition.getCountryCoalition(countryID)
|
||||
@ -1,305 +1,305 @@
|
||||
effects = {}
|
||||
effects.shooterName = "TestInfantry"
|
||||
effects.napalmCounter = 1
|
||||
|
||||
effects.fireCounter = 1
|
||||
|
||||
function effects.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor, false)
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----NAPALM
|
||||
|
||||
|
||||
function effects.napalmSingle ()
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
effects.spawnNapalm (vec3)
|
||||
end
|
||||
|
||||
|
||||
function effects.spawnNapalm (vec3)
|
||||
|
||||
napeName = "napalmStrike" .. effects.napalmCounter
|
||||
effects.napalmCounter = effects.napalmCounter + 1
|
||||
mist.dynAddStatic(
|
||||
{
|
||||
country = 20,
|
||||
category = 'Fortifications',
|
||||
hidden = true,
|
||||
name = napeName,
|
||||
type ="Fuel tank",
|
||||
x = vec3.x,
|
||||
y = vec3.z,
|
||||
heading = 0,
|
||||
} -- end of function
|
||||
)
|
||||
timer.scheduleFunction(effects.explode,vec3, timer.getTime() + 0.1)
|
||||
timer.scheduleFunction(effects.napalam_death,napeName, timer.getTime() + 0.12)
|
||||
end
|
||||
|
||||
function effects.explode(vec3)
|
||||
trigger.action.explosion(vec3, 10)
|
||||
end
|
||||
|
||||
function effects.napalam_death(staticName) --yes i know bad pun, removes the fuel tank after a set time
|
||||
StaticObject.getByName(staticName):destroy()
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----Basic smoke or fire that despawns
|
||||
function effects.smokeFire ()
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
effects.createFire (vec3, 2)
|
||||
-- 1 = small smoke and fire
|
||||
-- 2 = medium smoke and fire
|
||||
-- 3 = large smoke and fire
|
||||
-- 4 = huge smoke and fire
|
||||
-- 5 = small smoke
|
||||
-- 6 = medium smoke
|
||||
-- 7 = large smoke
|
||||
-- 8 = huge smoke
|
||||
end
|
||||
|
||||
function effects.createFire (vec3, size)
|
||||
smokeName = "smokeName" .. effects.fireCounter
|
||||
effects.fireCounter = effects.fireCounter + 1
|
||||
trigger.action.effectSmokeBig(vec3 , size , 1, smokeName)
|
||||
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
|
||||
end
|
||||
|
||||
function effects.removeFire (smokeName)
|
||||
trigger.action.effectSmokeStop(smokeName)
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----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
|
||||
function effects.secondaries ()
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
--trigger.action.smoke(vec3 , 2 )
|
||||
for i = 1,math.random(3,10) do
|
||||
angle = mist.utils.toRadian((math.random(1,360)))
|
||||
local randVec = mist.utils.makeVec3GL((mist.getRandPointInCircle(vec3 ,5 , 1 ,0 ,360)))
|
||||
trigger.action.signalFlare(randVec , 2 , angle )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----Depth Charges
|
||||
-- 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
|
||||
|
||||
function effects.depthCharge ()
|
||||
local unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
vec3.y = vec3.y - 1000
|
||||
bang = vec3
|
||||
distance = 20
|
||||
explosionSize = 2
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
timer.scheduleFunction(effects.depthChargeMain,vec3, timer.getTime() + 5)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function effects.depthChargeMain (vec3)
|
||||
explosionSize = 250
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.x = vec3.x
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.x = vec3.x - 10
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.z = vec3.z
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.z = vec3.z - 10
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----Normal small explosion
|
||||
|
||||
function effects.normalSmallExplosion (vec3)
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
trigger.action.explosion(vec3,10)
|
||||
end
|
||||
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Effects")
|
||||
missionCommands.addCommand ("Napalm", longRangeShots, effects.napalmSingle)
|
||||
missionCommands.addCommand ("Fire or smoke", longRangeShots, effects.smokeFire)
|
||||
missionCommands.addCommand ("Secondary explosions", longRangeShots, effects.secondaries)
|
||||
missionCommands.addCommand ("Depth Charge", longRangeShots, effects.depthCharge)
|
||||
missionCommands.addCommand ("A regular explosion", longRangeShots, effects.normalSmallExplosion)
|
||||
end
|
||||
|
||||
effects = {}
|
||||
effects.shooterName = "TestInfantry"
|
||||
effects.napalmCounter = 1
|
||||
|
||||
effects.fireCounter = 1
|
||||
|
||||
function effects.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor, false)
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----NAPALM
|
||||
|
||||
|
||||
function effects.napalmSingle ()
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
effects.spawnNapalm (vec3)
|
||||
end
|
||||
|
||||
|
||||
function effects.spawnNapalm (vec3)
|
||||
|
||||
napeName = "napalmStrike" .. effects.napalmCounter
|
||||
effects.napalmCounter = effects.napalmCounter + 1
|
||||
mist.dynAddStatic(
|
||||
{
|
||||
country = 20,
|
||||
category = 'Fortifications',
|
||||
hidden = true,
|
||||
name = napeName,
|
||||
type ="Fuel tank",
|
||||
x = vec3.x,
|
||||
y = vec3.z,
|
||||
heading = 0,
|
||||
} -- end of function
|
||||
)
|
||||
timer.scheduleFunction(effects.explode,vec3, timer.getTime() + 0.1)
|
||||
timer.scheduleFunction(effects.napalam_death,napeName, timer.getTime() + 0.12)
|
||||
end
|
||||
|
||||
function effects.explode(vec3)
|
||||
trigger.action.explosion(vec3, 10)
|
||||
end
|
||||
|
||||
function effects.napalam_death(staticName) --yes i know bad pun, removes the fuel tank after a set time
|
||||
StaticObject.getByName(staticName):destroy()
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----Basic smoke or fire that despawns
|
||||
function effects.smokeFire ()
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
effects.createFire (vec3, 2)
|
||||
-- 1 = small smoke and fire
|
||||
-- 2 = medium smoke and fire
|
||||
-- 3 = large smoke and fire
|
||||
-- 4 = huge smoke and fire
|
||||
-- 5 = small smoke
|
||||
-- 6 = medium smoke
|
||||
-- 7 = large smoke
|
||||
-- 8 = huge smoke
|
||||
end
|
||||
|
||||
function effects.createFire (vec3, size)
|
||||
smokeName = "smokeName" .. effects.fireCounter
|
||||
effects.fireCounter = effects.fireCounter + 1
|
||||
trigger.action.effectSmokeBig(vec3 , size , 1, smokeName)
|
||||
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
|
||||
end
|
||||
|
||||
function effects.removeFire (smokeName)
|
||||
trigger.action.effectSmokeStop(smokeName)
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----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
|
||||
function effects.secondaries ()
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
--trigger.action.smoke(vec3 , 2 )
|
||||
for i = 1,math.random(3,10) do
|
||||
angle = mist.utils.toRadian((math.random(1,360)))
|
||||
local randVec = mist.utils.makeVec3GL((mist.getRandPointInCircle(vec3 ,5 , 1 ,0 ,360)))
|
||||
trigger.action.signalFlare(randVec , 2 , angle )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----Depth Charges
|
||||
-- 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
|
||||
|
||||
function effects.depthCharge ()
|
||||
local unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
vec3.y = vec3.y - 1000
|
||||
bang = vec3
|
||||
distance = 20
|
||||
explosionSize = 2
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
bang = mist.getRandPointInCircle(vec3 , distance ,1,359,0)
|
||||
trigger.action.explosion(mist.utils.makeVec3GL(bang),explosionSize)
|
||||
timer.scheduleFunction(effects.depthChargeMain,vec3, timer.getTime() + 5)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function effects.depthChargeMain (vec3)
|
||||
explosionSize = 250
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.x = vec3.x
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.x = vec3.x - 10
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.z = vec3.z
|
||||
trigger.action.explosion(vec3,explosionSize)
|
||||
vec3.z = vec3.z - 10
|
||||
end
|
||||
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
--------------------------------------------
|
||||
----Normal small explosion
|
||||
|
||||
function effects.normalSmallExplosion (vec3)
|
||||
unit = Unit.getByName(effects.shooterName)
|
||||
local unitPos = unit:getPosition().p
|
||||
vec3 = mist.utils.makeVec3GL(unitPos)
|
||||
trigger.action.explosion(vec3,10)
|
||||
end
|
||||
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Effects")
|
||||
missionCommands.addCommand ("Napalm", longRangeShots, effects.napalmSingle)
|
||||
missionCommands.addCommand ("Fire or smoke", longRangeShots, effects.smokeFire)
|
||||
missionCommands.addCommand ("Secondary explosions", longRangeShots, effects.secondaries)
|
||||
missionCommands.addCommand ("Depth Charge", longRangeShots, effects.depthCharge)
|
||||
missionCommands.addCommand ("A regular explosion", longRangeShots, effects.normalSmallExplosion)
|
||||
end
|
||||
|
||||
effects.notify("effects.lua ran", 2)
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,112 +1,112 @@
|
||||
--Spawn a SAM integrated with IADS
|
||||
--Spawn a normal SAM
|
||||
--SAM bubble shields
|
||||
|
||||
forceBub = {}
|
||||
forceBub.handler = {}
|
||||
forceBub.missileList = {}
|
||||
forceBub.missilesActive = 0
|
||||
forceBub.shieldOn = false
|
||||
|
||||
function forceBub.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor, true)
|
||||
end
|
||||
|
||||
function forceBub.setShield()
|
||||
forceBub.notify("Shield on", 2)
|
||||
end
|
||||
|
||||
function forceBub.stopShield()
|
||||
forceBub.shieldOn = false
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function protectedCall(...)
|
||||
local status, retval = pcall(...)
|
||||
if not status then
|
||||
--rf.notify("Caught error " .. retval,2)
|
||||
end
|
||||
end
|
||||
|
||||
function forceBub.handler:onEvent(event)
|
||||
protectedCall(forceBub.eventHandler, event)
|
||||
end
|
||||
|
||||
function forceBub.checkMissiles ()
|
||||
local currentTime = timer.getTime()
|
||||
if forceBub.missilesActive > 0 then
|
||||
for index, data in pairs(forceBub.missileList) do
|
||||
output = mist.utils.tableShow(forceBub.missileList[index])
|
||||
if forceBub.missileList[index].exists == true then
|
||||
if Object.isExist(forceBub.missileList[index].weapon) == true then
|
||||
forceBub.missileList[index].pos = forceBub.missileList[index].weapon:getPosition()
|
||||
|
||||
|
||||
local missilePosition = forceBub.missileList[index].pos.p
|
||||
|
||||
unit = Unit.getByName("Test")
|
||||
local unitPosition = unit:getPosition().p
|
||||
|
||||
local distance = mist.utils.get3DDist(unitPosition , missilePosition )
|
||||
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
|
||||
|
||||
trigger.action.explosion(missilePosition , 1) --just blows up the missile
|
||||
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
forceBub.missileList[index] = nil
|
||||
forceBub.missilesActive = forceBub.missilesActive - 1
|
||||
end
|
||||
else
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
timer.scheduleFunction(forceBub.checkMisProtectCall,{},currentTime + 0.01)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function forceBub.eventHandler (event)
|
||||
--forceBub.notify(mist.utils.tableShow(event),10)
|
||||
if (event.id == 1) then
|
||||
--check if weapon is a missile
|
||||
--rf.notify("Missile fired id " .. event.weapon.id_ ,2)
|
||||
forceBub.notify(mist.utils.tableShow(Weapon.getDesc(event.weapon)),10)
|
||||
if Weapon.getDesc(event.weapon).missileCategory == 2 then
|
||||
local newMis = {}
|
||||
newMis.id = event.weapon.id_
|
||||
newMis.pos = event.weapon:getPosition()
|
||||
newMis.weapon = event.weapon
|
||||
newMis.exists = Object.isExist(newMis.weapon)
|
||||
forceBub.missileList[event.weapon.id_] = newMis
|
||||
forceBub.missilesActive = forceBub.missilesActive + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function forceBub.checkMisProtectCall()
|
||||
protectedCall(forceBub.checkMissiles,{})
|
||||
end
|
||||
|
||||
function forceBub.setShield()
|
||||
forceBub.shieldOn = true
|
||||
end
|
||||
|
||||
do
|
||||
forceField = missionCommands.addSubMenu("Force Field")
|
||||
missionCommands.addCommand ("Forcefield on", forceField, forceBub.setShield)
|
||||
missionCommands.addCommand ("Stop Field", forceField, forceBub.stopShield)
|
||||
end
|
||||
|
||||
do
|
||||
world.addEventHandler(forceBub.handler)
|
||||
end
|
||||
|
||||
protectedCall(forceBub.checkMissiles,{})
|
||||
--Spawn a SAM integrated with IADS
|
||||
--Spawn a normal SAM
|
||||
--SAM bubble shields
|
||||
|
||||
forceBub = {}
|
||||
forceBub.handler = {}
|
||||
forceBub.missileList = {}
|
||||
forceBub.missilesActive = 0
|
||||
forceBub.shieldOn = false
|
||||
|
||||
function forceBub.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor, true)
|
||||
end
|
||||
|
||||
function forceBub.setShield()
|
||||
forceBub.notify("Shield on", 2)
|
||||
end
|
||||
|
||||
function forceBub.stopShield()
|
||||
forceBub.shieldOn = false
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function protectedCall(...)
|
||||
local status, retval = pcall(...)
|
||||
if not status then
|
||||
--rf.notify("Caught error " .. retval,2)
|
||||
end
|
||||
end
|
||||
|
||||
function forceBub.handler:onEvent(event)
|
||||
protectedCall(forceBub.eventHandler, event)
|
||||
end
|
||||
|
||||
function forceBub.checkMissiles ()
|
||||
local currentTime = timer.getTime()
|
||||
if forceBub.missilesActive > 0 then
|
||||
for index, data in pairs(forceBub.missileList) do
|
||||
output = mist.utils.tableShow(forceBub.missileList[index])
|
||||
if forceBub.missileList[index].exists == true then
|
||||
if Object.isExist(forceBub.missileList[index].weapon) == true then
|
||||
forceBub.missileList[index].pos = forceBub.missileList[index].weapon:getPosition()
|
||||
|
||||
|
||||
local missilePosition = forceBub.missileList[index].pos.p
|
||||
|
||||
unit = Unit.getByName("Test")
|
||||
local unitPosition = unit:getPosition().p
|
||||
|
||||
local distance = mist.utils.get3DDist(unitPosition , missilePosition )
|
||||
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
|
||||
|
||||
trigger.action.explosion(missilePosition , 1) --just blows up the missile
|
||||
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
forceBub.missileList[index] = nil
|
||||
forceBub.missilesActive = forceBub.missilesActive - 1
|
||||
end
|
||||
else
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
timer.scheduleFunction(forceBub.checkMisProtectCall,{},currentTime + 0.01)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function forceBub.eventHandler (event)
|
||||
--forceBub.notify(mist.utils.tableShow(event),10)
|
||||
if (event.id == 1) then
|
||||
--check if weapon is a missile
|
||||
--rf.notify("Missile fired id " .. event.weapon.id_ ,2)
|
||||
forceBub.notify(mist.utils.tableShow(Weapon.getDesc(event.weapon)),10)
|
||||
if Weapon.getDesc(event.weapon).missileCategory == 2 then
|
||||
local newMis = {}
|
||||
newMis.id = event.weapon.id_
|
||||
newMis.pos = event.weapon:getPosition()
|
||||
newMis.weapon = event.weapon
|
||||
newMis.exists = Object.isExist(newMis.weapon)
|
||||
forceBub.missileList[event.weapon.id_] = newMis
|
||||
forceBub.missilesActive = forceBub.missilesActive + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function forceBub.checkMisProtectCall()
|
||||
protectedCall(forceBub.checkMissiles,{})
|
||||
end
|
||||
|
||||
function forceBub.setShield()
|
||||
forceBub.shieldOn = true
|
||||
end
|
||||
|
||||
do
|
||||
forceField = missionCommands.addSubMenu("Force Field")
|
||||
missionCommands.addCommand ("Forcefield on", forceField, forceBub.setShield)
|
||||
missionCommands.addCommand ("Stop Field", forceField, forceBub.stopShield)
|
||||
end
|
||||
|
||||
do
|
||||
world.addEventHandler(forceBub.handler)
|
||||
end
|
||||
|
||||
protectedCall(forceBub.checkMissiles,{})
|
||||
forceBub.notify("forceBubble.lua loaded", 2)
|
||||
@ -1,21 +1,21 @@
|
||||
lddl = {}
|
||||
lddl.refreshRate = 1
|
||||
|
||||
|
||||
|
||||
|
||||
function lddl.pointer ()
|
||||
origin = Unit.getByName("Laser")
|
||||
originPos = origin:getPosition().p
|
||||
targetPos = Unit.getByName("LaserTGT"):getPosition().p
|
||||
laser = Spot.createInfraRed(origin , originPos, targetPos)
|
||||
timer.scheduleFunction(lddl.removePointer,laser, timer.getTime() + lddl.refreshRate)
|
||||
|
||||
end
|
||||
|
||||
function lddl.removePointer(laser)
|
||||
Spot.destroy(laser)
|
||||
timer.scheduleFunction(lddl.pointer,{}, timer.getTime() + lddl.refreshRate)
|
||||
end
|
||||
|
||||
lddl = {}
|
||||
lddl.refreshRate = 1
|
||||
|
||||
|
||||
|
||||
|
||||
function lddl.pointer ()
|
||||
origin = Unit.getByName("Laser")
|
||||
originPos = origin:getPosition().p
|
||||
targetPos = Unit.getByName("LaserTGT"):getPosition().p
|
||||
laser = Spot.createInfraRed(origin , originPos, targetPos)
|
||||
timer.scheduleFunction(lddl.removePointer,laser, timer.getTime() + lddl.refreshRate)
|
||||
|
||||
end
|
||||
|
||||
function lddl.removePointer(laser)
|
||||
Spot.destroy(laser)
|
||||
timer.scheduleFunction(lddl.pointer,{}, timer.getTime() + lddl.refreshRate)
|
||||
end
|
||||
|
||||
lddl.pointer ()
|
||||
@ -1,184 +1,184 @@
|
||||
--------------------------------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
|
||||
|
||||
STTS = {}
|
||||
-- FULL Path to the FOLDER containing DCS-SR-ExternalAudio.exe - EDIT TO CORRECT FOLDER
|
||||
STTS.DIRECTORY = "C:\\Users\\Administrator\\Desktop\\DCS\\SRS Refugees"
|
||||
|
||||
STTS.SRS_PORT = 5002 -- LOCAL SRS PORT - DEFAULT IS 5002
|
||||
STTS.GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json"
|
||||
|
||||
-- DONT CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING
|
||||
STTS.EXECUTABLE = "DCS-SR-ExternalAudio.exe"
|
||||
|
||||
local random = math.random
|
||||
function STTS.uuid()
|
||||
local template ='yxxx-xxxxxxxxxxxx'
|
||||
return string.gsub(template, '[xy]', function (c)
|
||||
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
|
||||
return string.format('%x', v)
|
||||
end)
|
||||
end
|
||||
|
||||
function STTS.round(x, n)
|
||||
n = math.pow(10, n or 0)
|
||||
x = x * n
|
||||
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
|
||||
return x / n
|
||||
end
|
||||
|
||||
function STTS.getSpeechTime(length,speed,isGoogle)
|
||||
-- Function returns estimated speech time in seconds
|
||||
|
||||
-- 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 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
|
||||
|
||||
local maxRateRatio = 3
|
||||
|
||||
speed = speed or 1.0
|
||||
isGoogle = isGoogle or false
|
||||
|
||||
local speedFactor = 1.0
|
||||
if isGoogle then
|
||||
speedFactor = speed
|
||||
else
|
||||
if speed ~= 0 then
|
||||
speedFactor = math.abs(speed) * (maxRateRatio - 1) / 10 + 1
|
||||
end
|
||||
if speed < 0 then
|
||||
speedFactor = 1/speedFactor
|
||||
end
|
||||
end
|
||||
|
||||
local wpm = math.ceil(100 * speedFactor)
|
||||
local cps = math.floor((wpm * 5)/60)
|
||||
|
||||
if type(length) == "string" then
|
||||
length = string.len(length)
|
||||
end
|
||||
|
||||
return math.ceil(length/cps)
|
||||
end
|
||||
|
||||
function STTS.TextToSpeech(message,freqs,modulations, volume,name, coalition,point, speed,gender,culture,voice, googleTTS )
|
||||
if os == nil or io == nil then
|
||||
env.info("[DCS-STTS] LUA modules os or io are sanitized. skipping. ")
|
||||
return
|
||||
end
|
||||
|
||||
speed = speed or 1
|
||||
gender = gender or "female"
|
||||
culture = culture or ""
|
||||
voice = voice or ""
|
||||
|
||||
|
||||
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 )
|
||||
|
||||
if voice ~= "" then
|
||||
cmd = cmd .. string.format(" -V \"%s\"",voice)
|
||||
else
|
||||
|
||||
if culture ~= "" then
|
||||
cmd = cmd .. string.format(" -l %s",culture)
|
||||
end
|
||||
|
||||
if gender ~= "" then
|
||||
cmd = cmd .. string.format(" -g %s",gender)
|
||||
end
|
||||
end
|
||||
|
||||
if googleTTS == true then
|
||||
cmd = cmd .. string.format(" -G \"%s\"",STTS.GOOGLE_CREDENTIALS)
|
||||
end
|
||||
|
||||
if speed ~= 1 then
|
||||
cmd = cmd .. string.format(" -s %s",speed)
|
||||
end
|
||||
|
||||
if volume ~= 1.0 then
|
||||
cmd = cmd .. string.format(" -v %s",volume)
|
||||
end
|
||||
|
||||
if point and type(point) == "table" and point.x then
|
||||
local lat, lon, alt = coord.LOtoLL(point)
|
||||
|
||||
lat = STTS.round(lat,4)
|
||||
lon = STTS.round(lon,4)
|
||||
alt = math.floor(alt)
|
||||
|
||||
cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt)
|
||||
end
|
||||
|
||||
cmd = cmd ..string.format(" -t \"%s\"",message)
|
||||
|
||||
if string.len(cmd) > 255 then
|
||||
local filename = os.getenv('TMP') .. "\\DCS_STTS-" .. STTS.uuid() .. ".bat"
|
||||
local script = io.open(filename,"w+")
|
||||
script:write(cmd .. " && exit" )
|
||||
script:close()
|
||||
cmd = string.format("\"%s\"",filename)
|
||||
timer.scheduleFunction(os.remove, filename, timer.getTime() + 1)
|
||||
end
|
||||
|
||||
if string.len(cmd) > 255 then
|
||||
env.info("[DCS-STTS] - cmd string too long")
|
||||
env.info("[DCS-STTS] TextToSpeech Command :\n" .. cmd.."\n")
|
||||
end
|
||||
os.execute(cmd)
|
||||
|
||||
return STTS.getSpeechTime(message,speed,googleTTS)
|
||||
|
||||
end
|
||||
|
||||
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 )
|
||||
|
||||
if point and type(point) == "table" and point.x then
|
||||
local lat, lon, alt = coord.LOtoLL(point)
|
||||
|
||||
lat = STTS.round(lat,4)
|
||||
lon = STTS.round(lon,4)
|
||||
alt = math.floor(alt)
|
||||
|
||||
cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt)
|
||||
end
|
||||
|
||||
env.info("[DCS-STTS] MP3/OGG Command :\n" .. cmd.."\n")
|
||||
os.execute(cmd)
|
||||
|
||||
end
|
||||
|
||||
------------------------THIS BIT IS THE CODE YOU'D RUN IN GAME
|
||||
|
||||
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.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)
|
||||
trigger.action.outText(message, displayFor)
|
||||
end
|
||||
|
||||
function tts.normal ()
|
||||
STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2)
|
||||
end
|
||||
|
||||
function tts.russian ()
|
||||
STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2,null,1,"female","ru-RU","Microsoft Irina Desktop")
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Crash checks")
|
||||
missionCommands.addCommand ("Speak", longRangeShots, tts.normal)
|
||||
missionCommands.addCommand ("Speak russian", longRangeShots, tts.russian)
|
||||
|
||||
end
|
||||
|
||||
tts.notify("crashTest.lua loaded", 2)
|
||||
|
||||
--------------------------------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
|
||||
|
||||
STTS = {}
|
||||
-- FULL Path to the FOLDER containing DCS-SR-ExternalAudio.exe - EDIT TO CORRECT FOLDER
|
||||
STTS.DIRECTORY = "C:\\Users\\Administrator\\Desktop\\DCS\\SRS Refugees"
|
||||
|
||||
STTS.SRS_PORT = 5002 -- LOCAL SRS PORT - DEFAULT IS 5002
|
||||
STTS.GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json"
|
||||
|
||||
-- DONT CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING
|
||||
STTS.EXECUTABLE = "DCS-SR-ExternalAudio.exe"
|
||||
|
||||
local random = math.random
|
||||
function STTS.uuid()
|
||||
local template ='yxxx-xxxxxxxxxxxx'
|
||||
return string.gsub(template, '[xy]', function (c)
|
||||
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
|
||||
return string.format('%x', v)
|
||||
end)
|
||||
end
|
||||
|
||||
function STTS.round(x, n)
|
||||
n = math.pow(10, n or 0)
|
||||
x = x * n
|
||||
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
|
||||
return x / n
|
||||
end
|
||||
|
||||
function STTS.getSpeechTime(length,speed,isGoogle)
|
||||
-- Function returns estimated speech time in seconds
|
||||
|
||||
-- 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 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
|
||||
|
||||
local maxRateRatio = 3
|
||||
|
||||
speed = speed or 1.0
|
||||
isGoogle = isGoogle or false
|
||||
|
||||
local speedFactor = 1.0
|
||||
if isGoogle then
|
||||
speedFactor = speed
|
||||
else
|
||||
if speed ~= 0 then
|
||||
speedFactor = math.abs(speed) * (maxRateRatio - 1) / 10 + 1
|
||||
end
|
||||
if speed < 0 then
|
||||
speedFactor = 1/speedFactor
|
||||
end
|
||||
end
|
||||
|
||||
local wpm = math.ceil(100 * speedFactor)
|
||||
local cps = math.floor((wpm * 5)/60)
|
||||
|
||||
if type(length) == "string" then
|
||||
length = string.len(length)
|
||||
end
|
||||
|
||||
return math.ceil(length/cps)
|
||||
end
|
||||
|
||||
function STTS.TextToSpeech(message,freqs,modulations, volume,name, coalition,point, speed,gender,culture,voice, googleTTS )
|
||||
if os == nil or io == nil then
|
||||
env.info("[DCS-STTS] LUA modules os or io are sanitized. skipping. ")
|
||||
return
|
||||
end
|
||||
|
||||
speed = speed or 1
|
||||
gender = gender or "female"
|
||||
culture = culture or ""
|
||||
voice = voice or ""
|
||||
|
||||
|
||||
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 )
|
||||
|
||||
if voice ~= "" then
|
||||
cmd = cmd .. string.format(" -V \"%s\"",voice)
|
||||
else
|
||||
|
||||
if culture ~= "" then
|
||||
cmd = cmd .. string.format(" -l %s",culture)
|
||||
end
|
||||
|
||||
if gender ~= "" then
|
||||
cmd = cmd .. string.format(" -g %s",gender)
|
||||
end
|
||||
end
|
||||
|
||||
if googleTTS == true then
|
||||
cmd = cmd .. string.format(" -G \"%s\"",STTS.GOOGLE_CREDENTIALS)
|
||||
end
|
||||
|
||||
if speed ~= 1 then
|
||||
cmd = cmd .. string.format(" -s %s",speed)
|
||||
end
|
||||
|
||||
if volume ~= 1.0 then
|
||||
cmd = cmd .. string.format(" -v %s",volume)
|
||||
end
|
||||
|
||||
if point and type(point) == "table" and point.x then
|
||||
local lat, lon, alt = coord.LOtoLL(point)
|
||||
|
||||
lat = STTS.round(lat,4)
|
||||
lon = STTS.round(lon,4)
|
||||
alt = math.floor(alt)
|
||||
|
||||
cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt)
|
||||
end
|
||||
|
||||
cmd = cmd ..string.format(" -t \"%s\"",message)
|
||||
|
||||
if string.len(cmd) > 255 then
|
||||
local filename = os.getenv('TMP') .. "\\DCS_STTS-" .. STTS.uuid() .. ".bat"
|
||||
local script = io.open(filename,"w+")
|
||||
script:write(cmd .. " && exit" )
|
||||
script:close()
|
||||
cmd = string.format("\"%s\"",filename)
|
||||
timer.scheduleFunction(os.remove, filename, timer.getTime() + 1)
|
||||
end
|
||||
|
||||
if string.len(cmd) > 255 then
|
||||
env.info("[DCS-STTS] - cmd string too long")
|
||||
env.info("[DCS-STTS] TextToSpeech Command :\n" .. cmd.."\n")
|
||||
end
|
||||
os.execute(cmd)
|
||||
|
||||
return STTS.getSpeechTime(message,speed,googleTTS)
|
||||
|
||||
end
|
||||
|
||||
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 )
|
||||
|
||||
if point and type(point) == "table" and point.x then
|
||||
local lat, lon, alt = coord.LOtoLL(point)
|
||||
|
||||
lat = STTS.round(lat,4)
|
||||
lon = STTS.round(lon,4)
|
||||
alt = math.floor(alt)
|
||||
|
||||
cmd = cmd .. string.format(" -L %s -O %s -A %s",lat,lon,alt)
|
||||
end
|
||||
|
||||
env.info("[DCS-STTS] MP3/OGG Command :\n" .. cmd.."\n")
|
||||
os.execute(cmd)
|
||||
|
||||
end
|
||||
|
||||
------------------------THIS BIT IS THE CODE YOU'D RUN IN GAME
|
||||
|
||||
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.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)
|
||||
trigger.action.outText(message, displayFor)
|
||||
end
|
||||
|
||||
function tts.normal ()
|
||||
STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2)
|
||||
end
|
||||
|
||||
function tts.russian ()
|
||||
STTS.TextToSpeech(tts.words,"251","AM","1.0","SRS",2,null,1,"female","ru-RU","Microsoft Irina Desktop")
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Crash checks")
|
||||
missionCommands.addCommand ("Speak", longRangeShots, tts.normal)
|
||||
missionCommands.addCommand ("Speak russian", longRangeShots, tts.russian)
|
||||
|
||||
end
|
||||
|
||||
tts.notify("crashTest.lua loaded", 2)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,319 +1,319 @@
|
||||
shots = {} --https://www.youtube.com/watch?v=XNtTEibFvlQ mandatory terrible listening
|
||||
shots.shooterName = "TestInfantry"
|
||||
shots.targetName = "TestTarget1"
|
||||
|
||||
function shots.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor, false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--infantry
|
||||
|
||||
function shots.set556 () --red
|
||||
roundVelocity = 910
|
||||
unitBarrelHeight = 1
|
||||
shotsToFire = 5
|
||||
shotDelay = 4.5
|
||||
shots.notify("5.56 M4 Georgia", 2)
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
function shots.set556SAW () --red
|
||||
roundVelocity = 915
|
||||
unitBarrelHeight = 0.4
|
||||
shotsToFire = 5
|
||||
shotDelay = 4.5
|
||||
shots.notify("5.56 M249 SAW", 2)
|
||||
shots.fire()
|
||||
|
||||
end
|
||||
|
||||
function shots.setAk74() --red
|
||||
roundVelocity = 900
|
||||
unitBarrelHeight = 0.9
|
||||
shotsToFire = 5
|
||||
shotDelay = 4.5
|
||||
shots.notify("Ak74", 2)
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
--technicals
|
||||
|
||||
function shots.hmmwv() --red
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.6
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.5
|
||||
shots.notify("Humm drumm Vee", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
|
||||
function shots.technicalDHSKA() --green
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.2
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.5
|
||||
shots.notify("technicalDHSKA", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
|
||||
function shots.cobra() --green
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.85
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.6
|
||||
shots.notify("Cobra", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
--IFVs
|
||||
|
||||
function shots.setWarrior() --white
|
||||
roundVelocity = 1070
|
||||
unitBarrelHeight = 2.28
|
||||
shotsToFire = 3
|
||||
shotDelay = 6.3
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
function shots.setBMP2() --red
|
||||
roundVelocity = 970
|
||||
unitBarrelHeight = 1.95
|
||||
shotsToFire = 3
|
||||
shotDelay = 6
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
--Tanks
|
||||
|
||||
function shots.m1a1() --red
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.15
|
||||
shotsToFire = 5
|
||||
shotDelay = 3
|
||||
shots.notify("Abrams 50 cal", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
|
||||
function shots.t55() --red and green
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 1.75
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.6
|
||||
shots.notify("T-72B", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
end
|
||||
|
||||
---aaaaaaaaaaaaaaaa
|
||||
|
||||
function shots.ZSU57() --red
|
||||
roundVelocity = 1070
|
||||
shotsToFire = 2
|
||||
shotDelay = 10.5
|
||||
shots.notify("ZSU57", 2)
|
||||
unitMaxRange = 6000
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
function shots.ZSU23() --red
|
||||
roundVelocity = 1050
|
||||
shotsToFire = 2
|
||||
shotDelay = 12
|
||||
shots.notify("ZSU23", 2)
|
||||
unitMaxRange = 2000
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
function shots.vulcan() --red
|
||||
roundVelocity = 1030
|
||||
shotsToFire = 5
|
||||
shotDelay = 5
|
||||
shots.notify("Vulcan M163", 2)
|
||||
unitMaxRange = 1500
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
function shots.flak18() --red and green
|
||||
roundVelocity = 870
|
||||
shotsToFire = 1
|
||||
shotDelay = 10.5
|
||||
shots.notify("Flak 18", 2)
|
||||
unitMaxRange = 4000
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- This one is really obvious, however I set towards the end of this file the "parameters" of the shots.
|
||||
function shots.fire()
|
||||
unit = Unit.getByName(shots.shooterName)
|
||||
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 = nil
|
||||
local targetPos = target:getPosition().p
|
||||
shots.calculateAngle(roundVelocity, unit, targetPos, unitBarrelHeight, shotsToFire,shotDelay, targetMotionVec)
|
||||
end
|
||||
|
||||
--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)
|
||||
--v muzzle velocity
|
||||
--unit is unit object you want shooting
|
||||
--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
|
||||
--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
|
||||
--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
|
||||
|
||||
local unitPos = unit:getPosition().p
|
||||
local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range
|
||||
local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range
|
||||
|
||||
y = targetPos.y - unitPos.y
|
||||
y = y - unitBarrelHeight
|
||||
|
||||
--works out some stuff for trig later, like x,y and hypoteneueussueee
|
||||
|
||||
if targetMotionVector == nil then
|
||||
--no moving? nothing to ammend
|
||||
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
|
||||
newPosition = mist.utils.tableShow(targetMotionVector)
|
||||
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
|
||||
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
|
||||
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
else
|
||||
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
|
||||
|
||||
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 zPosDifference = (targetPos.z - unitPos.z)
|
||||
local hyp = math.sqrt((xPosDifference*xPosDifference) + (zPosDifference*zPosDifference))
|
||||
xPosDifference = (xPosDifference /hyp) * 10
|
||||
zPosDifference = (zPosDifference / hyp) * 10
|
||||
|
||||
unitPos.x = unitPos.x + xPosDifference
|
||||
unitPos.z = unitPos.z + zPosDifference
|
||||
|
||||
--that was all basic trig maths
|
||||
|
||||
local controller = unit:getController()
|
||||
FireAtPoint = {
|
||||
id = 'FireAtPoint',
|
||||
params = {
|
||||
point = {x = unitPos.x, y = unitPos.z},
|
||||
radius = 0.0001,
|
||||
expendQty = shotsToFire,
|
||||
expendQtyEnabled = true,
|
||||
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
|
||||
}
|
||||
}
|
||||
controller:pushTask(FireAtPoint) --FIREEEEEE
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function shots.fireAAA()
|
||||
unit = Unit.getByName(shots.shooterName)
|
||||
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
|
||||
--local targetMotionVec = nil
|
||||
targetPos = target:getPosition().p
|
||||
shots.aaa(roundVelocity, unit, unitMaxRange, targetPos, shotsToFire,shotDelay, targetMotionVec)
|
||||
end
|
||||
|
||||
--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 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)
|
||||
local unitPos = unit:getPosition().p
|
||||
local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range
|
||||
local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range
|
||||
|
||||
if x3d > unitMaxRange then
|
||||
if targetMotionVector == nil then
|
||||
--no moving? nothing to ammend
|
||||
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
|
||||
newPosition = mist.utils.tableShow(targetMotionVector)
|
||||
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
|
||||
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
|
||||
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
|
||||
end
|
||||
|
||||
difference = mist.vec.sub(targetPos,unitPos)
|
||||
unitVec = mist.vec.getUnitVec(difference)
|
||||
extendPath = mist.vec.scalar_mult(unitVec ,unitMaxRange)
|
||||
targetPos = mist.vec.add(extendPath,unitPos)
|
||||
|
||||
|
||||
local controller = unit:getController()
|
||||
FireAtPoint = {
|
||||
id = 'FireAtPoint',
|
||||
params = {
|
||||
point = {x = targetPos.x, y = targetPos.z},
|
||||
radius = 0.0001,
|
||||
expendQty = shotsToFire,
|
||||
expendQtyEnabled = true,
|
||||
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
|
||||
}
|
||||
}
|
||||
controller:pushTask(FireAtPoint) --FIREEEEEE
|
||||
else
|
||||
if targetMotionVector == nil then
|
||||
--no moving? nothing to ammend
|
||||
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
|
||||
newPosition = mist.utils.tableShow(targetMotionVector)
|
||||
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
|
||||
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
|
||||
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
|
||||
end
|
||||
|
||||
local controller = unit:getController()
|
||||
FireAtPoint = {
|
||||
id = 'FireAtPoint',
|
||||
params = {
|
||||
point = {x = targetPos.x, y = targetPos.z},
|
||||
radius = 0.0001,
|
||||
expendQty = shotsToFire,
|
||||
expendQtyEnabled = true,
|
||||
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
|
||||
}
|
||||
}
|
||||
controller:pushTask(FireAtPoint) --FIREEEEEE
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Firefight")
|
||||
missionCommands.addCommand ("Fire", longRangeShots, shots.vulcan)
|
||||
|
||||
end
|
||||
|
||||
shots = {} --https://www.youtube.com/watch?v=XNtTEibFvlQ mandatory terrible listening
|
||||
shots.shooterName = "TestInfantry"
|
||||
shots.targetName = "TestTarget1"
|
||||
|
||||
function shots.notify(message, displayFor)
|
||||
trigger.action.outText(message, displayFor, false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--infantry
|
||||
|
||||
function shots.set556 () --red
|
||||
roundVelocity = 910
|
||||
unitBarrelHeight = 1
|
||||
shotsToFire = 5
|
||||
shotDelay = 4.5
|
||||
shots.notify("5.56 M4 Georgia", 2)
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
function shots.set556SAW () --red
|
||||
roundVelocity = 915
|
||||
unitBarrelHeight = 0.4
|
||||
shotsToFire = 5
|
||||
shotDelay = 4.5
|
||||
shots.notify("5.56 M249 SAW", 2)
|
||||
shots.fire()
|
||||
|
||||
end
|
||||
|
||||
function shots.setAk74() --red
|
||||
roundVelocity = 900
|
||||
unitBarrelHeight = 0.9
|
||||
shotsToFire = 5
|
||||
shotDelay = 4.5
|
||||
shots.notify("Ak74", 2)
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
--technicals
|
||||
|
||||
function shots.hmmwv() --red
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.6
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.5
|
||||
shots.notify("Humm drumm Vee", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
|
||||
function shots.technicalDHSKA() --green
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.2
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.5
|
||||
shots.notify("technicalDHSKA", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
|
||||
function shots.cobra() --green
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.85
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.6
|
||||
shots.notify("Cobra", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
--IFVs
|
||||
|
||||
function shots.setWarrior() --white
|
||||
roundVelocity = 1070
|
||||
unitBarrelHeight = 2.28
|
||||
shotsToFire = 3
|
||||
shotDelay = 6.3
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
function shots.setBMP2() --red
|
||||
roundVelocity = 970
|
||||
unitBarrelHeight = 1.95
|
||||
shotsToFire = 3
|
||||
shotDelay = 6
|
||||
shots.fire()
|
||||
end
|
||||
|
||||
--Tanks
|
||||
|
||||
function shots.m1a1() --red
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 2.15
|
||||
shotsToFire = 5
|
||||
shotDelay = 3
|
||||
shots.notify("Abrams 50 cal", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
|
||||
end
|
||||
|
||||
function shots.t55() --red and green
|
||||
roundVelocity = 928
|
||||
unitBarrelHeight = 1.75
|
||||
shotsToFire = 5
|
||||
shotDelay = 2.6
|
||||
shots.notify("T-72B", 2)
|
||||
shots.fire()
|
||||
shots.notify(unitBarrelHeight,2)
|
||||
end
|
||||
|
||||
---aaaaaaaaaaaaaaaa
|
||||
|
||||
function shots.ZSU57() --red
|
||||
roundVelocity = 1070
|
||||
shotsToFire = 2
|
||||
shotDelay = 10.5
|
||||
shots.notify("ZSU57", 2)
|
||||
unitMaxRange = 6000
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
function shots.ZSU23() --red
|
||||
roundVelocity = 1050
|
||||
shotsToFire = 2
|
||||
shotDelay = 12
|
||||
shots.notify("ZSU23", 2)
|
||||
unitMaxRange = 2000
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
function shots.vulcan() --red
|
||||
roundVelocity = 1030
|
||||
shotsToFire = 5
|
||||
shotDelay = 5
|
||||
shots.notify("Vulcan M163", 2)
|
||||
unitMaxRange = 1500
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
function shots.flak18() --red and green
|
||||
roundVelocity = 870
|
||||
shotsToFire = 1
|
||||
shotDelay = 10.5
|
||||
shots.notify("Flak 18", 2)
|
||||
unitMaxRange = 4000
|
||||
shots.fireAAA()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- This one is really obvious, however I set towards the end of this file the "parameters" of the shots.
|
||||
function shots.fire()
|
||||
unit = Unit.getByName(shots.shooterName)
|
||||
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 = nil
|
||||
local targetPos = target:getPosition().p
|
||||
shots.calculateAngle(roundVelocity, unit, targetPos, unitBarrelHeight, shotsToFire,shotDelay, targetMotionVec)
|
||||
end
|
||||
|
||||
--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)
|
||||
--v muzzle velocity
|
||||
--unit is unit object you want shooting
|
||||
--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
|
||||
--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
|
||||
--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
|
||||
|
||||
local unitPos = unit:getPosition().p
|
||||
local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range
|
||||
local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range
|
||||
|
||||
y = targetPos.y - unitPos.y
|
||||
y = y - unitBarrelHeight
|
||||
|
||||
--works out some stuff for trig later, like x,y and hypoteneueussueee
|
||||
|
||||
if targetMotionVector == nil then
|
||||
--no moving? nothing to ammend
|
||||
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
|
||||
newPosition = mist.utils.tableShow(targetMotionVector)
|
||||
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
|
||||
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
|
||||
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
else
|
||||
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
|
||||
|
||||
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 zPosDifference = (targetPos.z - unitPos.z)
|
||||
local hyp = math.sqrt((xPosDifference*xPosDifference) + (zPosDifference*zPosDifference))
|
||||
xPosDifference = (xPosDifference /hyp) * 10
|
||||
zPosDifference = (zPosDifference / hyp) * 10
|
||||
|
||||
unitPos.x = unitPos.x + xPosDifference
|
||||
unitPos.z = unitPos.z + zPosDifference
|
||||
|
||||
--that was all basic trig maths
|
||||
|
||||
local controller = unit:getController()
|
||||
FireAtPoint = {
|
||||
id = 'FireAtPoint',
|
||||
params = {
|
||||
point = {x = unitPos.x, y = unitPos.z},
|
||||
radius = 0.0001,
|
||||
expendQty = shotsToFire,
|
||||
expendQtyEnabled = true,
|
||||
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
|
||||
}
|
||||
}
|
||||
controller:pushTask(FireAtPoint) --FIREEEEEE
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function shots.fireAAA()
|
||||
unit = Unit.getByName(shots.shooterName)
|
||||
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
|
||||
--local targetMotionVec = nil
|
||||
targetPos = target:getPosition().p
|
||||
shots.aaa(roundVelocity, unit, unitMaxRange, targetPos, shotsToFire,shotDelay, targetMotionVec)
|
||||
end
|
||||
|
||||
--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 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)
|
||||
local unitPos = unit:getPosition().p
|
||||
local x = mist.utils.get2DDist(unitPos,targetPos) -- horizontal range
|
||||
local x3d = mist.utils.get3DDist(unitPos,targetPos) -- slant range
|
||||
|
||||
if x3d > unitMaxRange then
|
||||
if targetMotionVector == nil then
|
||||
--no moving? nothing to ammend
|
||||
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
|
||||
newPosition = mist.utils.tableShow(targetMotionVector)
|
||||
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
|
||||
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
|
||||
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
|
||||
end
|
||||
|
||||
difference = mist.vec.sub(targetPos,unitPos)
|
||||
unitVec = mist.vec.getUnitVec(difference)
|
||||
extendPath = mist.vec.scalar_mult(unitVec ,unitMaxRange)
|
||||
targetPos = mist.vec.add(extendPath,unitPos)
|
||||
|
||||
|
||||
local controller = unit:getController()
|
||||
FireAtPoint = {
|
||||
id = 'FireAtPoint',
|
||||
params = {
|
||||
point = {x = targetPos.x, y = targetPos.z},
|
||||
radius = 0.0001,
|
||||
expendQty = shotsToFire,
|
||||
expendQtyEnabled = true,
|
||||
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
|
||||
}
|
||||
}
|
||||
controller:pushTask(FireAtPoint) --FIREEEEEE
|
||||
else
|
||||
if targetMotionVector == nil then
|
||||
--no moving? nothing to ammend
|
||||
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
|
||||
newPosition = mist.utils.tableShow(targetMotionVector)
|
||||
targetPos.x = targetPos.x + targetMotionVector.x*shotDelay
|
||||
targetPos.y = targetPos.y + targetMotionVector.y*shotDelay
|
||||
targetPos.z = targetPos.z + targetMotionVector.z*shotDelay
|
||||
end
|
||||
|
||||
local controller = unit:getController()
|
||||
FireAtPoint = {
|
||||
id = 'FireAtPoint',
|
||||
params = {
|
||||
point = {x = targetPos.x, y = targetPos.z},
|
||||
radius = 0.0001,
|
||||
expendQty = shotsToFire,
|
||||
expendQtyEnabled = true,
|
||||
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
|
||||
}
|
||||
}
|
||||
controller:pushTask(FireAtPoint) --FIREEEEEE
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
longRangeShots = missionCommands.addSubMenu("Firefight")
|
||||
missionCommands.addCommand ("Fire", longRangeShots, shots.vulcan)
|
||||
|
||||
end
|
||||
|
||||
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
Loading…
x
Reference in New Issue
Block a user