diff --git a/modules/aswGUI.lua b/modules/aswGUI.lua index 9c52f74..5d34f8e 100644 --- a/modules/aswGUI.lua +++ b/modules/aswGUI.lua @@ -1,5 +1,5 @@ aswGUI = {} -aswGUI.version = "1.0.0" +aswGUI.version = "1.0.1" aswGUI.verbose = false aswGUI.requiredLibs = { "dcsCommon", -- always @@ -11,6 +11,7 @@ aswGUI.requiredLibs = { --[[-- Version History 1.0.0 - initial version + 1.0.1 - env.info clean-up, verbosity clean-up --]]-- @@ -18,7 +19,7 @@ aswGUI.ups = 1 -- = once every second aswGUI.aswCraft = {} --[[-- -::::::::::::::::: ASSUMES SINGLE_UNIT GROUPS :::::::::::::::::: +::::::::::::::::: ASSUMES SINGLE-UNIT GROUPS :::::::::::::::::: --]]-- @@ -42,7 +43,6 @@ function aswGUI.initUnit(unitName) -- now this unit exists local theGroup = theUnit:getGroup() local asc = {} -- set up player craft config block - --local groupData = cfxMX.playerUnit2Group[unitName] asc.groupName = theGroup:getName() -- groupData.name asc.name = unitName asc.groupID = theGroup:getID() -- groupData.groupId @@ -446,41 +446,36 @@ end -- Event handling -- function aswGUI:onEvent(theEvent) - --env.info("> >ENTER aswGUI:onEvent") if not theEvent then trigger.action.outText("+++aswGUI: nil theEvent", 30) - --env.info("< >Proccing aswGUI:onEvent event <" .. theID .. "") - + -- now let's access it if it was -- used before local conf = aswGUI.aswCraft[name] @@ -530,7 +522,6 @@ function aswGUI:onEvent(theEvent) if theID == 21 then -- player leave aswGUI.resetConf(conf) end - --env.info("< >>ENTER asw GUI start") if not dcsCommon.libCheck then trigger.action.outText("cfx aswGUI requires dcsCommon", 30) return false @@ -584,7 +574,6 @@ function aswGUI.start() -- say Hi trigger.action.outText("cfx ASW GUI v" .. aswGUI.version .. " started.", 30) - --env.info("<< have deployed to the ground with orders " .. orders .. "!", 30) - + trigger.action.outSoundForGroup(conf.id, cfxHeloTroops.actionSound) -- "Quest Snare 3.wav") -- see if this is tracked by a tracker, and pass them back so -- they can un-limbo if groupTracker then @@ -711,6 +713,7 @@ function cfxHeloTroops.doLoadGroup(args) conf.troopsOnBoard.destination = pooledGroup.destination -- may be nil cfxGroundTroops.removeTroopsFromPool(pooledGroup) trigger.action.outTextForGroup(conf.id, "Team '".. conf.troopsOnBoard.name .."' loaded and has orders <" .. conf.troopsOnBoard.orders .. ">", 30) + --trigger.action.outSoundForGroup(conf.id, cfxHeloTroops.actionSound) -- "Quest Snare 3.wav") else if cfxHeloTroops.verbose then trigger.action.outText("+++heloT: ".. conf.troopsOnBoard.name .." was not committed to ground troops", 30) @@ -729,6 +732,7 @@ function cfxHeloTroops.doLoadGroup(args) -- say so trigger.action.outTextForGroup(conf.id, "Team '".. conf.troopsOnBoard.name .."' aboard, ready to go!", 30) + trigger.action.outSoundForGroup(conf.id, cfxHeloTroops.actionSound) -- "Quest Snare 3.wav") -- reset menu cfxHeloTroops.removeComms(conf.unit) @@ -879,6 +883,8 @@ function cfxHeloTroops.readConfigZone() cfxHeloTroops.pickupRange = cfxZones.getNumberFromZoneProperty(theZone, "pickupRange", 100) cfxHeloTroops.combatDropScore = cfxZones.getNumberFromZoneProperty(theZone, "combatDropScore", 200) + cfxHeloTroops.actionSound = cfxZones.getStringFromZoneProperty(theZone, "actionSound", "Quest Snare 3.wav") + -- add own troop carriers if cfxZones.hasProperty(theZone, "troopCarriers") then local tc = cfxZones.getStringFromZoneProperty(theZone, "troopCarriers", "UH-1D") diff --git a/modules/cfxSmokeZones.lua b/modules/cfxSmokeZones.lua index 03125cc..2f98073 100644 --- a/modules/cfxSmokeZones.lua +++ b/modules/cfxSmokeZones.lua @@ -152,8 +152,7 @@ function cfxSmokeZone.checkFlags() end function cfxSmokeZone.start() - if not dcsCommon.libCheck("cfx Smoke Zones", - cfxSmokeZone.requiredLibs) then + if not dcsCommon.libCheck("cfx Smoke Zones", cfxSmokeZone.requiredLibs) then return false end diff --git a/modules/dcsCommon.lua b/modules/dcsCommon.lua index 782da32..1c2e75b 100644 --- a/modules/dcsCommon.lua +++ b/modules/dcsCommon.lua @@ -1,5 +1,5 @@ dcsCommon = {} -dcsCommon.version = "2.8.2" +dcsCommon.version = "2.8.3" --[[-- VERSION HISTORY 2.2.6 - compassPositionOfARelativeToB - clockPositionOfARelativeToB @@ -138,6 +138,8 @@ dcsCommon.version = "2.8.2" - made getEnemyCoalitionFor() more resilient - fix to smallRandom for negative numbers - isTroopCarrierType uses wildArrayContainsString + 2.8.3 - small optimizations in bearingFromAtoB() + - new whichSideOfMine() --]]-- @@ -735,9 +737,9 @@ dcsCommon.version = "2.8.2" return 0 end - dx = B.x - A.x - dz = B.z - A.z - bearing = math.atan2(dz, dx) -- in radiants + local dx = B.x - A.x + local dz = B.z - A.z + local bearing = math.atan2(dz, dx) -- in radiants return bearing end @@ -865,6 +867,38 @@ dcsCommon.version = "2.8.2" return "hot" end + function dcsCommon.whichSideOfMine(theUnit, target) -- returs two values: -1/1 = left/right and "left"/"right" + if not theUnit then return nil end + if not target then return nil end + local uDOF = theUnit:getPosition() -- returns p, x, y, z Vec3 + -- with x, y, z being the normalised vectors for right, up, forward + local heading = math.atan2(uDOF.x.z, uDOF.x.x) -- returns rads + if heading < 0 then + heading = heading + 2 * math.pi -- put heading in range of 0 to 2*pi + end + -- heading now runs from 0 through 2Pi + local A = uDOF.p + local B = target:getPoint() + + -- now get bearing from theUnit to target + local dx = B.x - A.x + local dz = B.z - A.z + local bearing = math.atan2(dz, dx) -- in rads + if bearing < 0 then + bearing = bearing + 2 * math.pi -- make bearing 0 to 2*pi + end + + -- we now have bearing to B, and own heading. + -- subtract own heading from bearing to see at what + -- bearing target would be if we 'turned the world' so + -- that theUnit is heading 0 + local dBearing = bearing - heading + -- if result < 0 or > Pi (=180°), target is left from us + if dBearing < 0 or dBearing > math.pi then return -1, "left" end + return 1, "right" + -- note: no separate case for straight in front or behind + end + function dcsCommon.randomDegrees() local degrees = math.random(360) * 3.14152 / 180 return degrees diff --git a/modules/limitedAirframes.lua b/modules/limitedAirframes.lua index c5793be..6d7315e 100644 --- a/modules/limitedAirframes.lua +++ b/modules/limitedAirframes.lua @@ -1,5 +1,5 @@ limitedAirframes = {} -limitedAirframes.version = "1.5.1" +limitedAirframes.version = "1.5.3" limitedAirframes.verbose = false limitedAirframes.enabled = true -- can be turned off limitedAirframes.userCanToggle = true -- F10 menu? @@ -54,6 +54,8 @@ limitedAirframes.requiredLibs = { - 1.5.1 - new "announcer" attribute - 1.5.2 - integration with autoCSAR: prevent limitedAF from creating csar when autoCSAR is active + - 1.5.3 - ... but do allow it if not coming from 'ejected' so ditching + a plane will again create CSAR missions --]]-- @@ -427,7 +429,7 @@ function limitedAirframes.somethingHappened(event) -- removed dual 21 detection here - if ID == 21 then + if ID == 21 then -- player left unit -- remove pilot name from unit name limitedAirframes.unitFlownByPlayer[unitName] = nil --trigger.action.outText("limAir: 21 -- unit " .. unitName .. " unoccupied", 30) @@ -539,7 +541,7 @@ function limitedAirframes.handlePlayerLeftUnit(event) end limitedAirframes.updatePlayerInUnit(theUnit, "MIA") -- cosmetic only - limitedAirframes.createCSAR(theUnit) + limitedAirframes.createCSAR(theUnit, true) -- will never be 31 event, must force now end @@ -560,7 +562,7 @@ function limitedAirframes.pilotEjected(event) limitedAirframes.updatePlayerInUnit(theUnit, "MIA") -- cosmetic only -- create CSAR if applicable if not hasLostTheWar then - limitedAirframes.createCSAR(theUnit) + limitedAirframes.createCSAR(theUnit) -- not forced, autoCSAR can hande end end @@ -666,9 +668,19 @@ function limitedAirframes.checkPlayerFrameAvailability(event) end -function limitedAirframes.createCSAR(theUnit) +function limitedAirframes.createCSAR(theUnit, forced) + if not forced then forced = false end + -- override if autoCSAR is installed - if autoCSAR then return end + -- and let autoCSAR handle creation of CSAR when pilot's + -- seat hits ground, event 31 + if (not forced) and autoCSAR then + -- csar is going to be created with parachute hitting the ground + if limitedAirframes.verbose then + trigger.action.outText("+++limA: aborting CSAR creation: autoCSAR active", 30) + end + return + end -- only do this if we have installed CSAR Manager if csarManager and csarManager.createCSARforUnit then diff --git a/modules/missionRestart.lua b/modules/missionRestart.lua new file mode 100644 index 0000000..0cfe387 --- /dev/null +++ b/modules/missionRestart.lua @@ -0,0 +1,25 @@ +missionRestart = {} +missionRestart.restarting = false + +function missionRestart.restart() + if missionRestart.restarting then return end + + trigger.action.outText("Server: Mission restarting...", 30) + local res = net.dostring_in("gui", "mn = DCS.getMissionFilename(); success = net.load_mission(mn); return success") + + missionRestart.restarting = true + +end + +function missionRestart.update() + -- call me in a second to poll triggers + timer.scheduleFunction(missionRestart.update, {}, timer.getTime() + 1) + + if trigger.misc.getUserFlag("simpleMissionRestart") > 0 then + missionRestart.restart() + end + +end + +missionRestart.update() + diff --git a/modules/williePete.lua b/modules/williePete.lua index 1802356..59167de 100644 --- a/modules/williePete.lua +++ b/modules/williePete.lua @@ -1,5 +1,5 @@ williePete = {} -williePete.version = "1.0.0" +williePete.version = "1.0.1" williePete.ups = 10 -- we update at 10 fps, so accuracy of a -- missile moving at Mach 2 is within 33 meters, -- with interpolation even at 3 meters @@ -9,6 +9,12 @@ williePete.requiredLibs = { "cfxZones", -- Zones, of course "cfxMX", } +--[[-- + Version History + 1.0.0 - Initial version + 1.0.1 - update to suppress verbosity + +--]]-- williePete.willies = {} williePete.wpZones = {} @@ -407,7 +413,10 @@ function williePete.isWP(theWeapon) for idx, wpw in pairs(williePete.smokeWeapons) do if theDesc == wpw then return true end end - trigger.action.outText(theDesc .. " is no wp, ignoring.", 30) + if williePete.verbose then + trigger.action.outText(theDesc .. " is no wp, ignoring.", 30) + end + return false end diff --git a/tutorial & demo missions/demo - Willie Nillie.miz b/tutorial & demo missions/demo - Willie Nillie.miz new file mode 100644 index 0000000..fc19d12 Binary files /dev/null and b/tutorial & demo missions/demo - Willie Nillie.miz differ