7 Commits
v1.61 ... v1.63

Author SHA1 Message Date
Ciaran Fisher
ee6977aa96 Version bump 2016-12-07 22:26:01 +00:00
Ciaran Fisher
dc214da0d6 Added New Cargos
Added new cargos
Fixed bug where units / groups would disappear
Updating MIST
Updated all missions
2016-12-07 22:20:41 +00:00
Ciaran Fisher
ee41e86628 Merge pull request #24 from emilianomolina/master
List radio beacons when enabledRadioBeaconDrop is false.
2016-12-03 10:57:25 +00:00
Ciaran Fisher
fdc24a32c5 Merge pull request #25 from mvee/patch-1
Cargo objects were updated
2016-12-03 10:56:18 +00:00
mvee
cb63b37494 Cargo objects were updated
Quickfix for the cargo container hence the catergory and type was changed after Mi8 release
2016-12-02 18:58:49 +02:00
Emiliano Molina
cefd92f720 List radio beacons when enabledRadioBeaconDrop is false.
When radio beacons are programmatically generated, if option to allow
the player to create beacons is not set then there was no way for the
player to get the operating frequency of the programmatically generated
beacons.

This patch modifies addF10MenuOptions to give the user to list radio
beacons when enabledRadioBaconDrop is false.  If enabledRadioBeaconDrop
is true then there is no change to the behaviour of the program.

However if it is false then a check is made to see if
deployedRadioBeacons is empty.  If it is not the the user is given the
option to list radio beacons but not modify them.
2016-12-03 00:16:32 +11:00
Ciaran Fisher
df8f19ee38 Release 1.62
Real Sling load cargo will be destroyed when unpacked
Simulated crate changed back to generator static
2016-08-01 20:40:17 +01:00
7 changed files with 5630 additions and 4858 deletions

192
CTLD.lua
View File

@@ -12,12 +12,13 @@
Contributors:
- Steggles - https://github.com/Bob7heBuilder
- mvee - https://github.com/mvee
- jmontleon - https://github.com/jmontleon
- emilianomolina - https://github.com/emilianomolina
Version: 1.61 - 19/04/2015
- Added ability to add Waypoint zones
-- Troops dropped in a waypoint zone will automatically head to the center of the zone
Version: 1.63 - 07/12/2016
- Added new sling load crates
- Fixed bug where crates and / or groups would disappear
]]
ctld = {} -- DONT REMOVE!
@@ -26,11 +27,11 @@ ctld = {} -- DONT REMOVE!
-- ********************* 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.staticBugWorkaround = false -- DCS had a bug where destroying statics would cause a crash. If this happens again, set this to TRUE
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.hoverPickup = true -- if set to false you can load crates with the F10 menu instead of hovering... Only if not using real crates!
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...
@@ -475,6 +476,22 @@ ctld.jtacUnitTypes = {
"SKP", "Hummer" -- there are some wierd encoding issues so if you write SKP-11 it wont match as the - sign is encoded differently...
}
ctld.nextUnitId = 1;
ctld.getNextUnitId = function()
ctld.nextUnitId = ctld.nextUnitId + 1
return ctld.nextUnitId
end
ctld.nextGroupId = 1;
ctld.getNextGroupId = function()
ctld.nextGroupId = ctld.nextGroupId + 1
return ctld.nextGroupId
end
-- ***************************************************************
-- **************** Mission Editor Functions *********************
-- ***************************************************************
@@ -1172,7 +1189,7 @@ function ctld.spawnCrateAtZone(_side, _weight,_zone)
local _alt = land.getHeight(_pos2)
local _point = { x = _pos2.x, y = _alt, z = _pos2.y }
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _name = string.format("%s #%i", _crateType.desc, _unitId)
@@ -1207,7 +1224,7 @@ function ctld.spawnCrateAtPoint(_side, _weight,_point)
_country = 2
end
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _name = string.format("%s #%i", _crateType.desc, _unitId)
@@ -1278,13 +1295,13 @@ function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight,_side)
local _crate
local _spawnedCrate
if ctld.staticBugFix and ctld.slingLoad == false then
local _groupId = mist.getNextGroupId()
if ctld.staticBugWorkaround and ctld.slingLoad == false then
local _groupId = ctld.getNextGroupId()
local _groupName = "Crate Group #".._groupId
local _group = {
["visible"] = false,
["groupId"] = _groupId,
-- ["groupId"] = _groupId,
["hidden"] = false,
["units"] = {},
-- ["y"] = _positions[1].z,
@@ -1309,10 +1326,10 @@ function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight,_side)
if ctld.slingLoad then
_crate = {
["category"] = "Cargo",
["shape_name"] = "ab-212_cargo",
["type"] = "Cargo1",
["unitId"] = _unitId,
["category"] = "Cargos", --now plurar
["shape_name"] = "bw_container_cargo", --new slingloadable container
["type"] = "container_cargo", --new type
-- ["unitId"] = _unitId,
["y"] = _point.z,
["x"] = _point.x,
["mass"] = _weight,
@@ -1324,11 +1341,55 @@ function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight,_side)
-- ["cargoDisplayName"] = "cargo123",
-- ["CargoDisplayName"] = "cargo123",
}
else
--[[ Placeholder for different type of cargo containers. Let's say pipes and trunks, fuel for FOB building
["shape_name"] = "ab-212_cargo",
["type"] = "uh1h_cargo" --new type for the container previously used
["shape_name"] = "ammo_box_cargo",
["type"] = "ammo_cargo",
["shape_name"] = "barrels_cargo",
["type"] = "barrels_cargo",
["shape_name"] = "bw_container_cargo",
["type"] = "container_cargo",
["shape_name"] = "f_bar_cargo",
["type"] = "f_bar_cargo",
["shape_name"] = "fueltank_cargo",
["type"] = "fueltank_cargo",
["shape_name"] = "iso_container_cargo",
["type"] = "iso_container",
["shape_name"] = "iso_container_small_cargo",
["type"] = "iso_container_small",
["shape_name"] = "oiltank_cargo",
["type"] = "oiltank_cargo",
["shape_name"] = "pipes_big_cargo",
["type"] = "pipes_big_cargo",
["shape_name"] = "pipes_small_cargo",
["type"] = "pipes_small_cargo",
["shape_name"] = "tetrapod_cargo",
["type"] = "tetrapod_cargo",
["shape_name"] = "trunks_long_cargo",
["type"] = "trunks_long_cargo",
["shape_name"] = "trunks_small_cargo",
["type"] = "trunks_small_cargo",
]]--
else
_crate = {
["shape_name"] = "GeneratorF",
["type"] = "GeneratorF",
["unitId"] = _unitId,
-- ["unitId"] = _unitId,
["y"] = _point.z,
["x"] = _point.x,
["name"] = _name,
@@ -1362,7 +1423,7 @@ function ctld.spawnFOBCrateStatic(_country, _unitId, _point, _name)
["category"] = "Fortifications",
["shape_name"] = "konteiner_red1",
["type"] = "Container red 1",
["unitId"] = _unitId,
-- ["unitId"] = _unitId,
["y"] = _point.z,
["x"] = _point.x,
["name"] = _name,
@@ -1386,7 +1447,7 @@ function ctld.spawnFOB(_country, _unitId, _point, _name)
local _crate = {
["category"] = "Fortifications",
["type"] = "outpost",
["unitId"] = _unitId,
-- ["unitId"] = _unitId,
["y"] = _point.z,
["x"] = _point.x,
["name"] = _name,
@@ -1399,10 +1460,10 @@ function ctld.spawnFOB(_country, _unitId, _point, _name)
local _spawnedCrate = StaticObject.getByName(_crate["name"])
--local _spawnedCrate = coalition.addStaticObject(_country, _crate)
local _id = mist.getNextUnitId()
local _id = ctld.getNextUnitId()
local _tower = {
["type"] = "house2arm",
["unitId"] = _id,
-- ["unitId"] = _id,
["rate"] = 100,
["y"] = _point.z + -36.57142857,
["x"] = _point.x + 14.85714286,
@@ -1472,7 +1533,7 @@ function ctld.spawnCrate(_arguments)
local _point = ctld.getPointAt12Oclock(_heli, 30)
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _side = _heli:getCoalition()
@@ -1676,7 +1737,7 @@ end
function ctld.insertIntoTroopsArray(_troopType,_count,_troopArray)
for _i = 1, _count do
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
table.insert(_troopArray, { type = _troopType, unitId = _unitId, name = string.format("Dropped %s #%i", _troopType, _unitId) })
end
@@ -1749,13 +1810,13 @@ function ctld.generateTroopTypes(_side, _countOrTemplate, _country)
end
end
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
_troops[_i] = { type = _unitType, unitId = _unitId, name = string.format("Dropped %s #%i", _unitType, _unitId) }
end
end
local _groupId = mist.getNextGroupId()
local _groupId = ctld.getNextGroupId()
local _details = { units = _troops, groupId = _groupId, groupName = string.format("Dropped Group %i", _groupId), side = _side, country = _country }
return _details
@@ -1849,13 +1910,13 @@ function ctld.generateVehiclesForTransport(_side, _country)
for _i, _type in ipairs(_list) do
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
_vehicles[_i] = { type = _type, unitId = _unitId, name = string.format("Dropped %s #%i", _type, _unitId) }
end
local _groupId = mist.getNextGroupId()
local _groupId = ctld.getNextGroupId()
local _details = { units = _vehicles, groupId = _groupId, groupName = string.format("Dropped Group %i", _groupId), side = _side, country = _country }
return _details
@@ -1895,11 +1956,11 @@ function ctld.loadUnloadFOBCrate(_args)
local _side = _heli:getCoalition()
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _name = string.format("FOB Crate #%i", _unitId)
local _spawnedCrate = ctld.spawnFOBCrateStatic(_heli:getCountry(), mist.getNextUnitId(), { x = _point.x + _xOffset, z = _point.z + _yOffset }, _name)
local _spawnedCrate = ctld.spawnFOBCrateStatic(_heli:getCountry(), ctld.getNextUnitId(), { x = _point.x + _xOffset, z = _point.z + _yOffset }, _name)
if _side == 1 then
ctld.droppedFOBCratesRED[_name] = _name
@@ -2717,7 +2778,7 @@ end
function ctld.getCrateObject(_name)
local _crate
if ctld.staticBugFix then
if ctld.staticBugWorkaround then
_crate = Unit.getByName(_name)
else
_crate = StaticObject.getByName(_name)
@@ -2780,12 +2841,12 @@ function ctld.unpackCrates(_arguments)
local _cratePoint = _crate.crateUnit:getPoint()
local _crateName = _crate.crateUnit:getName()
-- ctld.spawnCrateStatic( _heli:getCoalition(),mist.getNextUnitId(),{x=100,z=100},_crateName,100)
-- ctld.spawnCrateStatic( _heli:getCoalition(),ctld.getNextUnitId(),{x=100,z=100},_crateName,100)
--remove crate
if ctld.slingLoad == false then
-- if ctld.slingLoad == false then
_crate.crateUnit:destroy()
end
-- end
local _spawnedGroups = ctld.spawnCrateGroup(_heli, { _cratePoint }, { _crate.details.unit })
@@ -2898,7 +2959,7 @@ function ctld.unpackFOBCrates(_crates, _heli)
timer.scheduleFunction(function(_args)
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _name = "Deployed FOB #" .. _unitId
local _fob = ctld.spawnFOB(_args[2], _unitId, _args[1], _name)
@@ -2958,7 +3019,7 @@ function ctld.dropSlingCrate(_args)
local _point = _heli:getPoint()
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _side = _heli:getCoalition()
@@ -3107,20 +3168,20 @@ end
function ctld.spawnRadioBeaconUnit(_point, _country, _type)
local _groupId = mist.getNextGroupId()
local _groupId = ctld.getNextGroupId()
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _radioGroup = {
["visible"] = false,
["groupId"] = _groupId,
-- ["groupId"] = _groupId,
["hidden"] = false,
["units"] = {
[1] = {
["y"] = _point.z,
["type"] = "2B11 mortar",
["name"] = _type .. " Radio Beacon Unit #" .. _unitId,
["unitId"] = _unitId,
-- ["unitId"] = _unitId,
["heading"] = 0,
["playerCanDrive"] = true,
["skill"] = "Excellent",
@@ -3420,9 +3481,9 @@ function ctld.rearmAASystem(_heli, _nearestCrate, _nearbyCrates, _aaSystemTempla
end
-- remove crate
if ctld.slingLoad == false then
-- if ctld.slingLoad == false then
_nearestCrate.crateUnit:destroy()
end
-- end
return true -- all done so quit
end
@@ -3564,9 +3625,9 @@ function ctld.unpackAASystem(_heli, _nearestCrate, _nearbyCrates,_aaSystemTempla
end
--destroy
if ctld.slingLoad == false then
-- if ctld.slingLoad == false then
_systemPart.crate.crateUnit:destroy()
end
--end
end
-- HAWK / BUK READY!
@@ -3681,9 +3742,9 @@ function ctld.repairAASystem(_heli, _nearestCrate,_aaSystem)
end
-- remove crate
if ctld.slingLoad == false then
-- if ctld.slingLoad == false then
_nearestCrate.crateUnit:destroy()
end
-- end
else
ctld.displayMessageToGroup(_heli, "Cannot repair ".._aaSystem.name..". No damaged ".._aaSystem.name.." within 300m", 10)
@@ -3729,9 +3790,9 @@ function ctld.unpackMultiCrate(_heli, _nearestCrate, _nearbyCrates)
end
--destroy
if ctld.slingLoad == false then
-- if ctld.slingLoad == false then
_crate.crateUnit:destroy()
end
-- end
end
@@ -3754,7 +3815,7 @@ end
function ctld.spawnCrateGroup(_heli, _positions, _types)
local _id = mist.getNextGroupId()
local _id = ctld.getNextGroupId()
local _groupName = _types[1] .. " #" .. _id
@@ -3762,7 +3823,7 @@ function ctld.spawnCrateGroup(_heli, _positions, _types)
local _group = {
["visible"] = false,
["groupId"] = _id,
-- ["groupId"] = _id,
["hidden"] = false,
["units"] = {},
-- ["y"] = _positions[1].z,
@@ -3773,7 +3834,7 @@ function ctld.spawnCrateGroup(_heli, _positions, _types)
if #_positions == 1 then
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _details = { type = _types[1], unitId = _unitId, name = string.format("Unpacked %s #%i", _types[1], _unitId) }
_group.units[1] = ctld.createUnit(_positions[1].x + 5, _positions[1].z + 5, 120, _details)
@@ -3782,7 +3843,7 @@ function ctld.spawnCrateGroup(_heli, _positions, _types)
for _i, _pos in ipairs(_positions) do
local _unitId = mist.getNextUnitId()
local _unitId = ctld.getNextUnitId()
local _details = { type = _types[_i], unitId = _unitId, name = string.format("Unpacked %s #%i", _types[_i], _unitId) }
_group.units[_i] = ctld.createUnit(_pos.x + 5, _pos.z + 5, 120, _details)
@@ -3816,7 +3877,7 @@ function ctld.spawnDroppedGroup(_point, _details, _spawnBehind, _maxSearch)
local _group = {
["visible"] = false,
["groupId"] = _details.groupId,
-- ["groupId"] = _details.groupId,
["hidden"] = false,
["units"] = {},
-- ["y"] = _positions[1].z,
@@ -3880,7 +3941,7 @@ function ctld.spawnDroppedGroup(_point, _details, _spawnBehind, _maxSearch)
ctld.orderGroupToMoveToPoint(_spawnedGroup:getUnit(1), _enemyPos)
end
return _spawnedGroup
end
@@ -4013,7 +4074,7 @@ function ctld.createUnit(_x, _y, _angle, _details)
["y"] = _y,
["type"] = _details.type,
["name"] = _details.name,
["unitId"] = _details.unitId,
-- ["unitId"] = _details.unitId,
["heading"] = _angle,
["playerCanDrive"] = true,
["skill"] = "Excellent",
@@ -4270,7 +4331,7 @@ function ctld.refreshSmoke()
end
--waypoint zones
for _, _zoneDetails in pairs(ctld.wpZones) do
for _, _zoneDetails in pairs(ctld.wpZones) do
local _triggerZone = trigger.misc.getZone(_zoneDetails[1])
@@ -4491,7 +4552,7 @@ function ctld.addF10MenuOptions()
missionCommands.addCommandForGroup(_groupId, "Unload Vehicles", _vehicleCommandsPath, ctld.unloadTroops, { _unitName, false })
missionCommands.addCommandForGroup(_groupId, "Load / Extract Vehicles", _vehicleCommandsPath, ctld.loadTroopsFromZone, { _unitName, false,"",true })
if ctld.enabledFOBBuilding and ctld.staticBugFix == false then
if ctld.enabledFOBBuilding and ctld.staticBugWorkaround == false then
missionCommands.addCommandForGroup(_groupId, "Load / Unload FOB Crate", _vehicleCommandsPath, ctld.loadUnloadFOBCrate, { _unitName, false })
end
@@ -4532,7 +4593,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 )
if ctld.slingLoad == false then
missionCommands.addCommandForGroup(_groupId, "Load Nearby Crate", _crateCommands, ctld.loadNearbyCrate, _unitName )
end
end
missionCommands.addCommandForGroup(_groupId, "Unpack Any Crate", _crateCommands, ctld.unpackCrates, { _unitName })
@@ -4563,6 +4626,9 @@ function ctld.addF10MenuOptions()
missionCommands.addCommandForGroup(_groupId, "List Beacons", _radioCommands, ctld.listRadioBeacons, { _unitName })
missionCommands.addCommandForGroup(_groupId, "Drop Beacon", _radioCommands, ctld.dropRadioBeacon, { _unitName })
missionCommands.addCommandForGroup(_groupId, "Remove Closet Beacon", _radioCommands, ctld.removeRadioBeacon, { _unitName })
elseif ctld.deployedRadioBeacons ~= {} then
local _radioCommands = missionCommands.addSubMenuForGroup(_groupId, "Radio Beacons", _rootPath)
missionCommands.addCommandForGroup(_groupId, "List Beacons", _radioCommands, ctld.listRadioBeacons, { _unitName })
end
ctld.addedTo[tostring(_groupId)] = true
@@ -5118,9 +5184,9 @@ function ctld.findNearestVisibleEnemy(_jtacUnit, _targetType,_distance)
_allowedTarget = (string.match(_units[_x]:getName(), "priority") ~= nil) and ctld.isVehicle(_units[_x])
elseif _targetType == "vehicle" then
_allowedTarget = ctld.isVehicle(_units[_x])
elseif _targetType == "troop" and _hpriority == true then
elseif _targetType == "troop" and _thpriority == true then
_allowedTarget = (string.match(_units[_x]:getName(), "hpriority") ~= nil) and ctld.isInfantry(_units[_x])
elseif _targetType == "troop" and _priority == true then
elseif _targetType == "troop" and _tpriority == true then
_allowedTarget = (string.match(_units[_x]:getName(), "priority") ~= nil) and ctld.isInfantry(_units[_x])
elseif _targetType == "troop" then
_allowedTarget = ctld.isInfantry(_units[_x])
@@ -5729,7 +5795,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 and ctld.hoverPickup then
if ctld.enableCrates == true and ctld.slingLoad == false and ctld.hoverPickup == true then
timer.scheduleFunction(ctld.checkHoverStatus, nil, timer.getTime() + 1)
end
@@ -5781,7 +5847,7 @@ for _coalitionName, _coalitionData in pairs(env.mission.coalition) do
for _groupId, _group in pairs(_objectTypeData.group) do
if _group and _group.units and type(_group.units) == 'table' then
for _unitNum, _unit in pairs(_group.units) do
if _unit.type == "Cargo1" and _unit.canCargo == true then
if _unit.canCargo == true then
ctld.missionEditorCargoCrates[_unit.name] = _unit.name
env.info("Crate Found: " .. _unit.name)
end
@@ -5805,4 +5871,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.

10296
mist.lua

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.