Merge pull request #18 from ciribob/newFeatures

New features
This commit is contained in:
Ciaran Fisher 2016-03-20 12:54:17 +00:00
commit f3f440f0a3
7 changed files with 5268 additions and 4979 deletions

203
CTLD.lua
View File

@ -13,7 +13,12 @@
Contributors:
- Steggles - https://github.com/Bob7heBuilder
Version: 1.52 - 20/02/2015 - BUG FIX - Disabled Crate static until ED bug is fixed
Version: 1.60 - 20/03/2015
- Added ability to disable hover pickup and instead load crates with F10
- Added new function - ctld.removeExtractZone to stop an extract zone after a while
- Added ability to limit the number of AA systems that can be built and active at one time
]]
ctld = {} -- DONT REMOVE!
@ -22,14 +27,17 @@ ctld = {} -- DONT REMOVE!
-- ********************* USER CONFIGURATION ******************************
-- ************************************************************************
ctld.staticBugFix = true -- When statics are destroyed, DCS Crashes. Set this to FALSE when this bug is fixed :)
ctld.staticBugFix = true -- When statics are destroyed, DCS Crashes. Set this to FALSE when this bug is fixed or if you want to use REAL sling loads :)
ctld.disableAllSmoke = false -- if true, all smoke is diabled at pickup and drop off zones regardless of settings below. Leave false to respect settings below
ctld.hoverPickup = true -- if set to false you can load crates with the F10 menu instead of hovering...
ctld.enableCrates = true -- if false, Helis will not be able to spawn or unpack crates so will be normal CTTS
ctld.slingLoad = false -- if false, crates can be used WITHOUT slingloading, by hovering above the crate, simulating slingloading but not the weight...
-- There are some bug with Sling-loading that can cause crashes, if these occur set slingLoad to false
-- to use the other method.
-- Set staticBugFix to FALSE if use set ctld.slingLoad to TRUE
ctld.enableSmokeDrop = true -- if false, helis and c-130 will not be able to drop smoke
@ -82,6 +90,19 @@ ctld.hoverTime = 10 -- Time to hold hover above a crate for loading in seconds
-- end of Simulated Sling load configuration
-- AA SYSTEM CONFIG --
-- Sets a limit on the number of active AA systems that can be built for RED.
-- A system is counted as Active if its fully functional and has all parts
-- If a system is partially destroyed, it no longer counts towards the total
-- When this limit is hit, a player will still be able to get crates for an AA system, just unable
-- to unpack them
ctld.AASystemLimitRED = 20 -- Red side limit
ctld.AASystemLimitBLUE = 20 -- Blue side limit
--END AA SYSTEM CONFIG --
-- ***************** JTAC CONFIGURATION *****************
ctld.JTAC_LIMIT_RED = 10 -- max number of JTAC Crates for the RED Side
@ -642,8 +663,9 @@ function ctld.createExtractZone(_zone, _flagNumber, _smoke)
trigger.action.setUserFlag(_flagNumber, 0) --start at 0
local _details = { point = _pos3, name = _zone, smoke = _smoke, flag = _flagNumber, radius = _triggerZone.radius }
table.insert(ctld.extractZones, _details)
local _details = { point = _pos3, name = _zone, smoke = _smoke, flag = _flagNumber, radius = _triggerZone.radius}
ctld.extractZones[_zone.."-".._flagNumber] = _details
if _smoke ~= nil and _smoke > -1 then
@ -651,6 +673,14 @@ function ctld.createExtractZone(_zone, _flagNumber, _smoke)
_smokeFunction = function(_args)
local _extractDetails = ctld.extractZones[_zone.."-".._flagNumber]
-- check zone is still active
if _extractDetails == nil then
-- stop refreshing smoke, zone is done
return
end
trigger.action.smoke(_args.point, _args.smoke)
--refresh in 5 minutes
timer.scheduleFunction(_smokeFunction, _args, timer.getTime() + 300)
@ -661,6 +691,29 @@ function ctld.createExtractZone(_zone, _flagNumber, _smoke)
end
end
-- Removes an extraction zone
--
-- The smoke will take up to 5 minutes to disappear depending on the last time the smoke was activated
--
-- The ctld.removeExtractZone function needs to be called once in a trigger action do script.
--
-- e.g. ctld.removeExtractZone("extractzone1", 2) will remove an extraction zone at trigger zone "extractzone1"
-- that was setup with flag 2
--
--
--
function ctld.removeExtractZone(_zone,_flagNumber)
local _extractDetails = ctld.extractZones[_zone.."-".._flagNumber]
if _extractDetails ~= nil then
--remove zone
ctld.extractZones[_zone.."-".._flagNumber] = nil
end
end
-- CONTINUOUS TRIGGER FUNCTION
-- This function will count the current number of extractable RED and BLUE
-- GROUPS in a zone and store the values in two flags
@ -1141,7 +1194,7 @@ function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight,_side)
local _crate
local _spawnedCrate
if ctld.staticBugFix then
if ctld.staticBugFix and ctld.slingLoad == false then
local _groupId = mist.getNextGroupId()
local _groupName = "Crate Group #".._groupId
@ -1162,7 +1215,7 @@ function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight,_side)
_group.category = Group.Category.GROUND;
_group.country = _country;
local _spawnedGroup = Group.getByName(mist.dynAdd(_group).name)
local _spawnedGroup = Group.getByName(mist.dynAdd(_group).name)
-- Turn off AI
trigger.action.setGroupAIOff(_spawnedGroup)
@ -2193,6 +2246,53 @@ function ctld.checkHoverStatus()
end
end
function ctld.loadNearbyCrate(_name)
local _transUnit = ctld.getTransportUnit(_name)
if _transUnit ~= nil then
if ctld.inAir(_transUnit) then
ctld.displayMessageToGroup(_transUnit, "You must land before you can load a crate!", 10,true)
return
end
if ctld.inTransitSlingLoadCrates[_name] == nil then
local _crates = ctld.getCratesAndDistance(_transUnit)
for _, _crate in pairs(_crates) do
if _crate.dist < 50.0 then
ctld.displayMessageToGroup(_transUnit, "Loaded " .. _crate.details.desc .. " crate!", 10,true)
if _transUnit:getCoalition() == 1 then
ctld.spawnedCratesRED[_crate.crateUnit:getName()] = nil
else
ctld.spawnedCratesBLUE[_crate.crateUnit:getName()] = nil
end
_crate.crateUnit:destroy()
local _copiedCrate = mist.utils.deepCopy(_crate.details)
ctld.inTransitSlingLoadCrates[_name] = _copiedCrate
return
end
end
ctld.displayMessageToGroup(_transUnit, "No Crates within 50m to load!", 10,true)
else
-- crate onboard
local _currentCrate = mist.utils.deepCopy(ctld.inTransitSlingLoadCrates[_name])
ctld.displayMessageToGroup(_transUnit, "You already have a ".._currentCrate.desc.." crate onboard!", 10,true)
end
end
end
--recreates beacons to make sure they work!
function ctld.refreshRadioBeacons()
@ -2763,7 +2863,11 @@ function ctld.dropSlingCrate(_args)
local _currentCrate = ctld.inTransitSlingLoadCrates[_heli:getName()]
if _currentCrate == nil then
ctld.displayMessageToGroup(_heli, "You are not currently transporting any crates. \n\nTo Pickup a crate, hover for 10 seconds above the crate", 10)
if ctld.hoverPickup then
ctld.displayMessageToGroup(_heli, "You are not currently transporting any crates. \n\nTo Pickup a crate, hover for "..ctld.hoverTime.." seconds above the crate", 10)
else
ctld.displayMessageToGroup(_heli, "You are not currently transporting any crates. \n\nTo Pickup a crate - land and use F10 Crate Commands to load one.", 10)
end
else
local _heli = ctld.getTransportUnit(_args[1])
@ -3251,7 +3355,7 @@ function ctld.getAASystemDetails(_hawkGroup,_aaSystemTemplate)
local _hawkDetails = {}
for _, _unit in pairs(_units) do
table.insert(_hawkDetails, { point = _unit:getPoint(), unit = _unit:getTypeName(), name = _unit:getName(), system=_aaSystemTemplate})
table.insert(_hawkDetails, { point = _unit:getPoint(), unit = _unit:getTypeName(), name = _unit:getName(), system =_aaSystemTemplate})
end
return _hawkDetails
@ -3350,7 +3454,18 @@ function ctld.unpackAASystem(_heli, _nearestCrate, _nearbyCrates,_aaSystemTempla
end
end
if _txt ~= "" then
local _activeLaunchers = ctld.countCompleteAASystems(_heli)
local _allowed = ctld.getAllowedAASystems(_heli)
env.info("Active: ".._activeLaunchers.." Allowed: ".._allowed)
if _activeLaunchers + 1 > _allowed then
trigger.action.outTextForCoalition(_heli:getCoalition(), "Out of parts for AA Systems. Current limit is ".._allowed.." \n", 10)
return
end
if _txt ~= "" then
ctld.displayMessageToGroup(_heli, "Cannot build ".._aaSystemTemplate.name.."\n" .. _txt .. "\n\nOr the crates are not close enough together", 20)
return
else
@ -3377,11 +3492,70 @@ function ctld.unpackAASystem(_heli, _nearestCrate, _nearbyCrates,_aaSystemTempla
ctld.processCallback({unit = _heli, crate = _nearestCrate , spawnedGroup = _spawnedGroup, action = "unpack"})
trigger.action.outTextForCoalition(_heli:getCoalition(), ctld.getPlayerNameOrType(_heli) .. " successfully deployed a full ".._aaSystemTemplate.name.." to the field", 10)
trigger.action.outTextForCoalition(_heli:getCoalition(), ctld.getPlayerNameOrType(_heli) .. " successfully deployed a full ".._aaSystemTemplate.name.." to the field. \n\nAA Active System limit is: ".._allowed.."\nActive: "..(_activeLaunchers+1), 10)
end
end
--count the number of captured cities, sets the amount of allowed AA Systems
function ctld.getAllowedAASystems(_heli)
if _heli:getCoalition() == 1 then
return ctld.AASystemLimitBLUE
else
return ctld.AASystemLimitRED
end
end
function ctld.countCompleteAASystems(_heli)
local _count = 0
for _groupName, _hawkDetails in pairs(ctld.completeAASystems) do
local _hawkGroup = Group.getByName(_groupName)
-- env.info(_groupName..": "..mist.utils.tableShow(_hawkDetails))
if _hawkGroup ~= nil and _hawkGroup:getCoalition() == _heli:getCoalition() then
local _units = _hawkGroup:getUnits()
if _units ~=nil and #_units > 0 then
--get the system template
local _aaSystemTemplate = _hawkDetails[1].system
local _uniqueTypes = {} -- stores each unique part of system
local _types = {}
local _points = {}
if _units ~= nil and #_units > 0 then
for x = 1, #_units do
if _units[x]:getLife() > 0 then
--this allows us to count each type once
_uniqueTypes[_units[x]:getTypeName()] = _units[x]:getTypeName()
table.insert(_points, _units[x]:getPoint())
table.insert(_types, _units[x]:getTypeName())
end
end
end
-- do we have the correct number of unique pieces and do we have enough points for all the pieces
if ctld.countTableEntries(_uniqueTypes) == _aaSystemTemplate.count and #_points >= _aaSystemTemplate.count then
_count = _count +1
end
end
end
end
return _count
end
function ctld.repairAASystem(_heli, _nearestCrate,_aaSystem)
@ -4224,6 +4398,9 @@ function ctld.addF10MenuOptions()
if ctld.enabledFOBBuilding or ctld.enableCrates then
local _crateCommands = missionCommands.addSubMenuForGroup(_groupId, "CTLD Commands", _rootPath)
if ctld.hoverPickup == false then
missionCommands.addCommandForGroup(_groupId, "Load Nearby Crate", _crateCommands, ctld.loadNearbyCrate, _unitName )
end
missionCommands.addCommandForGroup(_groupId, "Unpack Any Crate", _crateCommands, ctld.unpackCrates, { _unitName })
@ -4386,7 +4563,7 @@ ctld.jtacLaserPointCodes = {}
function ctld.JTACAutoLase(_jtacGroupName, _laserCode, _smoke, _lock, _colour)
if ctld.jtacStop[_jtacGroupName] == true then
ctld.jtacStop[_jtacGroupName] = nil
ctld.jtacStop[_jtacGroupName] = nil -- allow it to be started again
ctld.cleanupJTAC(_jtacGroupName)
return
end
@ -5391,7 +5568,7 @@ timer.scheduleFunction(ctld.checkAIStatus, nil, timer.getTime() + 1)
timer.scheduleFunction(ctld.checkTransportStatus, nil, timer.getTime() + 5)
timer.scheduleFunction(ctld.refreshRadioBeacons, nil, timer.getTime() + 5)
if ctld.enableCrates == true and ctld.slingLoad == false then
if ctld.enableCrates == true and ctld.slingLoad == false and ctld.hoverPickup then
timer.scheduleFunction(ctld.checkHoverStatus, nil, timer.getTime() + 1)
end
@ -5467,4 +5644,4 @@ env.info("CTLD READY")
-- for key, value in pairs(getmetatable(_spawnedCrate)) do
-- env.info(tostring(key))
-- env.info(tostring(value))
-- end
-- end

Binary file not shown.

Binary file not shown.

View File

@ -96,26 +96,34 @@ To use the real cargo sling behaviour, set the ```ctld.slingLoad``` option to ``
-- ************************************************************************
-- ********************* USER CONFIGURATION ******************************
-- ************************************************************************
ctld.staticBugFix = true -- When statics are destroyed, DCS Crashes. Set this to FALSE when this bug is fixed or if you want to use REAL sling loads :)
ctld.disableAllSmoke = false -- if true, all smoke is diabled at pickup and drop off zones regardless of settings below. Leave false to respect settings below
ctld.hoverPickup = true -- if set to false you can load crates with the F10 menu instead of hovering...!
ctld.enableCrates = true -- if false, Helis will not be able to spawn or unpack crates so will be normal CTTS
ctld.slingLoad = false -- if false, crates can be used WITHOUT slingloading, by hovering above the crate, simulating slingloading but not the weight...
-- There are some bug with Sling-loading that can cause crashes, if these occur set slingLoad to false
-- to use the other method.
-- Set staticBugFix to FALSE if use set ctld.slingLoad to TRUE
ctld.enableSmokeDrop = true -- if false, helis and c-130 will not be able to drop smoke
ctld.maxExtractDistance = 125 -- max distance from vehicle to troops to allow a group extraction
ctld.maximumDistanceLogistic = 200 -- max distance from vehicle to logistics to allow a loading or spawning operation
ctld.maximumSearchDistance = 4000 -- max distance for troops to search for enemy
ctld.maximumMoveDistance = 1000 -- max distance for troops to move from drop point if no enemy is nearby
ctld.maximumMoveDistance = 2000 -- max distance for troops to move from drop point if no enemy is nearby
ctld.numberOfTroops = 10 -- default number of troops to load on a transport heli or C-130
ctld.enableFastRopeInsertion = true -- allows you to drop troops by fast rope
ctld.fastRopeMaximumHeight = 18.28 -- in meters which is 60 ft max fast rope (not rappell) safe height
ctld.vehiclesForTransportRED = { "BRDM-2", "BTR_D" } -- vehicles to load onto Il-76 - Alternatives {"Strela-1 9P31","BMP-1"}
ctld.vehiclesForTransportBLUE = { "M1045 HMMWV TOW", "M1043 HMMWV Armament" } -- vehicles to load onto c130 - Alternatives {"M1128 Stryker MGS","M1097 Avenger"}
ctld.hawkLaunchers = 3 -- controls how many launchers to add to the hawk when its spawned.
ctld.aaLaunchers = 3 -- controls how many launchers to add to the kub/buk when its spawned.
ctld.hawkLaunchers = 5 -- controls how many launchers to add to the hawk when its spawned.
ctld.spawnRPGWithCoalition = true --spawns a friendly RPG unit with Coalition forces
ctld.spawnStinger = false -- spawns a stinger / igla soldier with a group of 6 or more soldiers!
@ -125,7 +133,9 @@ ctld.enabledFOBBuilding = true -- if true, you can load a crate INTO a C-130 tha
-- You can also enable troop Pickup at FOBS
ctld.cratesRequiredForFOB = 3 -- The amount of crates required to build a FOB. Once built, helis can spawn crates at this outpost to be carried and deployed in another area.
-- The crates can only be loaded and dropped by large aircraft, like the C-130 and listed in ctld.vehicleTransportEnabled
-- The large crates can only be loaded and dropped by large aircraft, like the C-130 and listed in ctld.vehicleTransportEnabled
-- Small FOB crates can be moved by helicopter. The FOB will require ctld.cratesRequiredForFOB larges crates and small crates are 1/3 of a large fob crate
-- To build the FOB entirely out of small crates you will need ctld.cratesRequiredForFOB * 3
ctld.troopPickupAtFOB = true -- if true, troops can also be picked up at a created FOB
@ -134,9 +144,34 @@ ctld.buildTimeFOB = 120 --time in seconds for the FOB to be built
ctld.radioSound = "beacon.ogg" -- the name of the sound file to use for the FOB radio beacons. If this isnt added to the mission BEACONS WONT WORK!
ctld.radioSoundFC3 = "beaconsilent.ogg" -- name of the second silent radio file, used so FC3 aircraft dont hear ALL the beacon noises... :)
ctld.deployedBeaconBattery = 20 -- the battery on deployed beacons will last for this number minutes before needing to be re-deployed
ctld.deployedBeaconBattery = 30 -- the battery on deployed beacons will last for this number minutes before needing to be re-deployed
ctld.enabledRadioBeaconDrop = true -- if its set to false then beacons cannot be dropped by units
ctld.allowRandomAiTeamPickups = false -- Allows the AI to randomize the loading of infantry teams (specified below) at pickup zones
-- Simulated Sling load configuration
ctld.minimumHoverHeight = 7.5 -- Lowest allowable height for crate hover
ctld.maximumHoverHeight = 12.0 -- Highest allowable height for crate hover
ctld.maxDistanceFromCrate = 5.5 -- Maximum distance from from crate for hover
ctld.hoverTime = 10 -- Time to hold hover above a crate for loading in seconds
-- end of Simulated Sling load configuration
-- AA SYSTEM CONFIG --
-- Sets a limit on the number of active AA systems that can be built for RED.
-- A system is counted as Active if its fully functional and has all parts
-- If a system is partially destroyed, it no longer counts towards the total
-- When this limit is hit, a player will still be able to get crates for an AA system, just unable
-- to unpack them
ctld.AASystemLimitRED = 20 -- Red side limit
ctld.AASystemLimitBLUE = 20 -- Blue side limit
--END AA SYSTEM CONFIG --
```
To change what units can be dropped from crates modify the spawnable crates section. An extra parameter, ```cratesRequired = NUMBER``` can be added so you need more than one crate to build a unit. This parameter cannot be used for the HAWK, BUK or KUB system as that is already broken into 3 crates. You can also specify the coalition side so RED and BLUE have different crates to drop. If the parameter is missing the crate will appear for both sides.
@ -326,7 +361,7 @@ Spawned beacons will broadcast on HF/FM, UHF and VHF until their battery runs ou
**Again, beacons will not work if beacon.ogg and beaconsilent.ogg are not in the mission!**
#### Create Extract Zone
#### Create / Remove Extract Zone
An extact zone is a zone where troops (not vehicles) can be dropped by transports and used to trigger another action based on the number of troops dropped. The radius of the zone sets how big the extract zone will be.
When troops are dropped, the troops disappear and the number of troops dropped added to the flag number configured by the function. This means you can make a trigger such that 10 troops have to be rescued and dropped at the extract zone, and when this happens you can trigger another action.
@ -336,6 +371,10 @@ Where ```"extractzone1"``` is the name of a Trigger Zone added using the mission
The settings for smoke are: Green = 0 , Red = 1, White = 2, Orange = 3, Blue = 4, NO SMOKE = -1
An extract zone can be removed by using DO SCRIPT action of ```ctld.removeExtractZone("extractzone1", 2)```. Where again ```"extractzone1"``` is the name of a Trigger Zone added using the mission editor, ```2``` is the flag
The smoke for the extract zone will take up to 5 minutes to disappate.
#### Count Extractable UNITS in zone
You can count the number of extractable UNITS in a zone using: ```ctld.countDroppedUnitsInZone(_zone, _blueFlag, _redFlag)``` as a DO SCRIPT of a CONTINUOUS TRIGGER.
@ -478,7 +517,7 @@ Smoke colours are: Green = 0 , Red = 1, White = 2, Orange = 3, Blue = 4
The script doesn't care if the unit isn't activated when run, as it'll automatically activate when the JTAC is activated in
the mission but there can be a delay of up to 30 seconds after activation for the JTAC to start searching for targets.
You can also change the name of a unit (unit, not group) to include "hpriority" to make it high priority for the JTAC, or "priority" to set it to be medium priority. JTAC's will prioritize targets within view by first marking hpriority targets, then priority targets, and finally all others. This works seemlessly with the all/vehicle/troop functionality as well. In this way you can have them lase SAMS, then AAA, then armor, or any other order you decide is preferable.
You can also change the **name of a unit*** (unit, not group) to include "**hpriority**" to make it high priority for the JTAC, or "**priority**" to set it to be medium priority. JTAC's will prioritize targets within view by first marking hpriority targets, then priority targets, and finally all others. This works seemlessly with the all/vehicle/troop functionality as well. In this way you can have them lase SAMS, then AAA, then armor, or any other order you decide is preferable.
### Pickup and Dropoff Zones Setup
Pickup zones are used by transport aircraft and helicopters to load troops and vehicles. A transport unit must be inside of the radius of the trigger and the right side (RED or BLUE or BOTH) in order to load troops and vehicles.
@ -687,6 +726,8 @@ Once you've loaded the crate, fly to where you want to drop it and drop using th
Once on the ground unpack as normal using the CTLD Commands Menu - CTLD->CTLD Commands->Unpack Crate
**Note: You can also set ```ctld.hoverPickup = false``` so you can load crates using the F10 menu instead of Hovering. **
### Real Sling Loading
This uses the inbuilt DCS Sling cargo system and crates. Sling cargo weight differs drastically depending on what you are sling loading. The Huey will need to have 20% fuel and no armaments in order to be able to lift a HMMWV TOW crate! The Mi-8 has a higher max lifting weight than a Huey.

9991
mist.lua

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.