mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2025-08-15 06:17:22 +00:00
Release 1.43
Added two new editor functions ctld.spawnCrateAtZone ctld.spawnCrateAtPoint Added test mission demonstrating crate spawning Changed menu structure back to old style to fix a possible bug
This commit is contained in:
129
CTLD.lua
129
CTLD.lua
@@ -13,10 +13,9 @@
|
|||||||
Contributors:
|
Contributors:
|
||||||
- Steggles - https://github.com/Bob7heBuilder
|
- Steggles - https://github.com/Bob7heBuilder
|
||||||
|
|
||||||
Version: 1.42 - 11/11/2015 - Added new callback interface
|
Version: 1.43 - 13/12/2015 - Added Spawn crate at zone
|
||||||
- Added Different Pickup Groups for F10 and for the spawn group command
|
- Added Spawn crate at Point
|
||||||
- EWR now activates
|
- Changed menu to have a maximum level of 3
|
||||||
- Bug fix for AI Group Load
|
|
||||||
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
@@ -933,12 +932,90 @@ function ctld.loadTransport(_unitName)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- adds a callback that will be called for many actions ingame
|
||||||
function ctld.addCallback(_callback)
|
function ctld.addCallback(_callback)
|
||||||
|
|
||||||
table.insert(ctld.callbacks,_callback)
|
table.insert(ctld.callbacks,_callback)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Spawns a sling loadable crate at a Trigger Zone
|
||||||
|
--
|
||||||
|
-- Weights can be found in the ctld.spawnableCrates list
|
||||||
|
-- e.g. ctld.spawnCrateAtZone("red", 500,"triggerzone1") -- spawn a humvee at triggerzone 1 for red side
|
||||||
|
-- e.g. ctld.spawnCrateAtZone("blue", 505,"triggerzone1") -- spawn a tow humvee at triggerzone1 for blue side
|
||||||
|
--
|
||||||
|
function ctld.spawnCrateAtZone(_side, _weight,_zone)
|
||||||
|
local _spawnTrigger = trigger.misc.getZone(_zone) -- trigger to use as reference position
|
||||||
|
|
||||||
|
if _spawnTrigger == nil then
|
||||||
|
trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zone, 10)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local _crateType = ctld.crateLookupTable[tostring(_weight)]
|
||||||
|
|
||||||
|
if _crateType == nil then
|
||||||
|
trigger.action.outText("CTLD.lua ERROR: Cant find crate with weight " .. _weight, 10)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local _country
|
||||||
|
if _side == "red" then
|
||||||
|
_side = 1
|
||||||
|
_country = 0
|
||||||
|
else
|
||||||
|
_side = 2
|
||||||
|
_country = 2
|
||||||
|
end
|
||||||
|
|
||||||
|
local _pos2 = { x = _spawnTrigger.point.x, y = _spawnTrigger.point.z }
|
||||||
|
local _alt = land.getHeight(_pos2)
|
||||||
|
local _point = { x = _pos2.x, y = _alt, z = _pos2.y }
|
||||||
|
|
||||||
|
local _unitId = mist.getNextUnitId()
|
||||||
|
|
||||||
|
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
||||||
|
|
||||||
|
local _spawnedCrate = ctld.spawnCrateStatic(_country, _unitId, _point, _name, _crateType.weight,_side)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Spawns a sling loadable crate at a Point
|
||||||
|
--
|
||||||
|
-- Weights can be found in the ctld.spawnableCrates list
|
||||||
|
-- Points can be made by hand or obtained from a Unit position by Unit.getByName("PilotName"):getPoint()
|
||||||
|
-- e.g. ctld.spawnCrateAtZone("red", 500,{x=1,y=2,z=3}) -- spawn a humvee at triggerzone 1 for red side at a specified point
|
||||||
|
-- e.g. ctld.spawnCrateAtZone("blue", 505,{x=1,y=2,z=3}) -- spawn a tow humvee at triggerzone1 for blue side at a specified point
|
||||||
|
--
|
||||||
|
--
|
||||||
|
function ctld.spawnCrateAtPoint(_side, _weight,_point)
|
||||||
|
|
||||||
|
|
||||||
|
local _crateType = ctld.crateLookupTable[tostring(_weight)]
|
||||||
|
|
||||||
|
if _crateType == nil then
|
||||||
|
trigger.action.outText("CTLD.lua ERROR: Cant find crate with weight " .. _weight, 10)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local _country
|
||||||
|
if _side == "red" then
|
||||||
|
_side = 1
|
||||||
|
_country = 0
|
||||||
|
else
|
||||||
|
_side = 2
|
||||||
|
_country = 2
|
||||||
|
end
|
||||||
|
|
||||||
|
local _unitId = mist.getNextUnitId()
|
||||||
|
|
||||||
|
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
||||||
|
|
||||||
|
local _spawnedCrate = ctld.spawnCrateStatic(_country, _unitId, _point, _name, _crateType.weight,_side)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
-- **************** BE CAREFUL BELOW HERE ************************
|
-- **************** BE CAREFUL BELOW HERE ************************
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
@@ -960,7 +1037,7 @@ function ctld.getTransportUnit(_unitName)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight)
|
function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight,_side)
|
||||||
|
|
||||||
local _crate
|
local _crate
|
||||||
if ctld.slingLoad then
|
if ctld.slingLoad then
|
||||||
@@ -999,6 +1076,14 @@ function ctld.spawnCrateStatic(_country, _unitId, _point, _name, _weight)
|
|||||||
local _spawnedCrate = StaticObject.getByName(_crate["name"])
|
local _spawnedCrate = StaticObject.getByName(_crate["name"])
|
||||||
--local _spawnedCrate = coalition.addStaticObject(_country, _crate)
|
--local _spawnedCrate = coalition.addStaticObject(_country, _crate)
|
||||||
|
|
||||||
|
local _crateType = ctld.crateLookupTable[tostring(_weight)]
|
||||||
|
|
||||||
|
if _side == 1 then
|
||||||
|
ctld.spawnedCratesRED[_name] =_crateType
|
||||||
|
else
|
||||||
|
ctld.spawnedCratesBLUE[_name] = _crateType
|
||||||
|
end
|
||||||
|
|
||||||
return _spawnedCrate
|
return _spawnedCrate
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1124,15 +1209,7 @@ function ctld.spawnCrate(_arguments)
|
|||||||
|
|
||||||
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
local _name = string.format("%s #%i", _crateType.desc, _unitId)
|
||||||
|
|
||||||
local _spawnedCrate = ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _crateType.weight)
|
local _spawnedCrate = ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _crateType.weight,_side)
|
||||||
|
|
||||||
if _side == 1 then
|
|
||||||
-- _spawnedCrate = coalition.addStaticObject(_side, _spawnedCrate)
|
|
||||||
ctld.spawnedCratesRED[_name] = _crateType
|
|
||||||
else
|
|
||||||
-- _spawnedCrate = coalition.addStaticObject(_side, _spawnedCrate)
|
|
||||||
ctld.spawnedCratesBLUE[_name] = _crateType
|
|
||||||
end
|
|
||||||
|
|
||||||
ctld.displayMessageToGroup(_heli, string.format("A %s crate weighing %s kg has been brought out and is at your 12 o'clock ", _crateType.desc, _crateType.weight), 20)
|
ctld.displayMessageToGroup(_heli, string.format("A %s crate weighing %s kg has been brought out and is at your 12 o'clock ", _crateType.desc, _crateType.weight), 20)
|
||||||
|
|
||||||
@@ -2510,15 +2587,7 @@ function ctld.dropSlingCrate(_args)
|
|||||||
--remove crate from cargo
|
--remove crate from cargo
|
||||||
ctld.inTransitSlingLoadCrates[_heli:getName()] = nil
|
ctld.inTransitSlingLoadCrates[_heli:getName()] = nil
|
||||||
|
|
||||||
local _spawnedCrate = ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _currentCrate.weight)
|
local _spawnedCrate = ctld.spawnCrateStatic(_heli:getCountry(), _unitId, _point, _name, _currentCrate.weight,_side)
|
||||||
|
|
||||||
if _side == 1 then
|
|
||||||
-- _spawnedCrate = coalition.addStaticObject(_side, _spawnedCrate)
|
|
||||||
ctld.spawnedCratesRED[_name] = _currentCrate
|
|
||||||
else
|
|
||||||
-- _spawnedCrate = coalition.addStaticObject(_side, _spawnedCrate)
|
|
||||||
ctld.spawnedCratesBLUE[_name] = _currentCrate
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3858,13 +3927,13 @@ function ctld.checkAIStatus()
|
|||||||
-- no player name means AI!
|
-- no player name means AI!
|
||||||
if _unit ~= nil and _unit:getPlayerName() == nil then
|
if _unit ~= nil and _unit:getPlayerName() == nil then
|
||||||
local _zone = ctld.inPickupZone(_unit)
|
local _zone = ctld.inPickupZone(_unit)
|
||||||
-- env.error("Checking.. ".._unit:getName())
|
-- env.error("Checking.. ".._unit:getName())
|
||||||
if _zone.inZone == true and not ctld.troopsOnboard(_unit, true) then
|
if _zone.inZone == true and not ctld.troopsOnboard(_unit, true) then
|
||||||
-- env.error("in zone, loading.. ".._unit:getName())
|
-- env.error("in zone, loading.. ".._unit:getName())
|
||||||
ctld.loadTroopsFromZone({ _unitName, true,"",true })
|
ctld.loadTroopsFromZone({ _unitName, true,"",true })
|
||||||
|
|
||||||
elseif ctld.inDropoffZone(_unit) and ctld.troopsOnboard(_unit, true) then
|
elseif ctld.inDropoffZone(_unit) and ctld.troopsOnboard(_unit, true) then
|
||||||
-- env.error("in dropoff zone, unloading.. ".._unit:getName())
|
-- env.error("in dropoff zone, unloading.. ".._unit:getName())
|
||||||
ctld.unloadTroops( { _unitName, true })
|
ctld.unloadTroops( { _unitName, true })
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3920,10 +3989,10 @@ function ctld.addF10MenuOptions()
|
|||||||
|
|
||||||
missionCommands.addCommandForGroup(_groupId, "Check Cargo", _troopCommandsPath, ctld.checkTroopStatus, { _unitName })
|
missionCommands.addCommandForGroup(_groupId, "Check Cargo", _troopCommandsPath, ctld.checkTroopStatus, { _unitName })
|
||||||
|
|
||||||
local _loadPath = missionCommands.addSubMenuForGroup(_groupId, "Load From Zone", _troopCommandsPath)
|
-- local _loadPath = missionCommands.addSubMenuForGroup(_groupId, "Load From Zone", _troopCommandsPath)
|
||||||
for _,_loadGroup in pairs(ctld.loadableGroups) do
|
for _,_loadGroup in pairs(ctld.loadableGroups) do
|
||||||
if not _loadGroup.side or _loadGroup.side == _unit:getCoalition() then
|
if not _loadGroup.side or _loadGroup.side == _unit:getCoalition() then
|
||||||
missionCommands.addCommandForGroup(_groupId, "Load ".._loadGroup.name, _loadPath, ctld.loadTroopsFromZone, { _unitName, true,_loadGroup,false })
|
missionCommands.addCommandForGroup(_groupId, "Load ".._loadGroup.name, _troopCommandsPath, ctld.loadTroopsFromZone, { _unitName, true,_loadGroup,false })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -3946,11 +4015,11 @@ function ctld.addF10MenuOptions()
|
|||||||
|
|
||||||
if ctld.unitCanCarryVehicles(_unit) == false then
|
if ctld.unitCanCarryVehicles(_unit) == false then
|
||||||
|
|
||||||
local _cratePath = missionCommands.addSubMenuForGroup(_groupId, "Spawn Crate", _rootPath)
|
-- local _cratePath = missionCommands.addSubMenuForGroup(_groupId, "Spawn Crate", _rootPath)
|
||||||
-- add menu for spawning crates
|
-- add menu for spawning crates
|
||||||
for _subMenuName, _crates in pairs(ctld.spawnableCrates) do
|
for _subMenuName, _crates in pairs(ctld.spawnableCrates) do
|
||||||
|
|
||||||
local _cratePath = missionCommands.addSubMenuForGroup(_groupId, _subMenuName, _cratePath)
|
local _cratePath = missionCommands.addSubMenuForGroup(_groupId, _subMenuName, _rootPath)
|
||||||
for _, _crate in pairs(_crates) do
|
for _, _crate in pairs(_crates) do
|
||||||
|
|
||||||
if ctld.isJTACUnitType(_crate.unit) == false
|
if ctld.isJTACUnitType(_crate.unit) == false
|
||||||
|
|||||||
BIN
Cargo Spawn Test.miz
Normal file
BIN
Cargo Spawn Test.miz
Normal file
Binary file not shown.
Binary file not shown.
28
README.md
28
README.md
@@ -56,6 +56,7 @@ The script supports:
|
|||||||
* Radio Beacon Deployment
|
* Radio Beacon Deployment
|
||||||
* Ability to deploy a homing beacon that the A10C, Ka-50, Mi-8 and Huey can home on
|
* Ability to deploy a homing beacon that the A10C, Ka-50, Mi-8 and Huey can home on
|
||||||
* Pre loading of units into AI vehicles via a DO SCRIPT
|
* Pre loading of units into AI vehicles via a DO SCRIPT
|
||||||
|
* Spawning of sling loadable crates at a specified zone or Point
|
||||||
* Mission Editor Trigger functions - They store the numbers in flags for use by triggers
|
* Mission Editor Trigger functions - They store the numbers in flags for use by triggers
|
||||||
* Count Crates in Zone
|
* Count Crates in Zone
|
||||||
* Works for both crates added by the Mission Editor and Crates spawned by Transports
|
* Works for both crates added by the Mission Editor and Crates spawned by Transports
|
||||||
@@ -335,6 +336,33 @@ A crate drop zone can be added to any zone by adding a Trigger Once with a Time
|
|||||||
|
|
||||||
Where ```"crateZone"``` is the name of a Trigger Zone added using the mission editor, and ```1``` is the number of the flag where the current number of crates in the zone will be stored.
|
Where ```"crateZone"``` is the name of a Trigger Zone added using the mission editor, and ```1``` is the number of the flag where the current number of crates in the zone will be stored.
|
||||||
|
|
||||||
|
#### Spawn Sling loadable crate at a Zone
|
||||||
|
You can spawn a sling loadable crate at a specified trigger zone using the code below:
|
||||||
|
|
||||||
|
The parameters are:
|
||||||
|
* group side ("red" or "blue")
|
||||||
|
* weight of the crate - Determines what the crate contains. Weights are on the ctld.spawnableCrates list.
|
||||||
|
* the name of the trigger to spawn the crate at
|
||||||
|
```lua
|
||||||
|
ctld.spawnCrateAtZone("blue", 500, "crateSpawnTrigger") -- spawns a BLUE coalition HMMWV at the trigger zone "crateSpawnTrigger"
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```lua
|
||||||
|
ctld.spawnCrateAtZone("red", 500, "crateSpawnTrigger") -- spawns a RED coalition HMMWV at the trigger zone "crateSpawnTrigger"
|
||||||
|
```
|
||||||
|
#### Spawn Sling loadable crate at a Point
|
||||||
|
You can spawn a sling loadable crate at a specified point using the code below:
|
||||||
|
|
||||||
|
The parameters are:
|
||||||
|
* group side ("red" or "blue")
|
||||||
|
* weight of the crate - Determines what the crate contains. Weights are on the ctld.spawnableCrates list.
|
||||||
|
* Point (x,y,z) of where to spawn the crate
|
||||||
|
|
||||||
|
The point of a unit can be obtained by Unit.getByName("PilotName"):getPoint().
|
||||||
|
|
||||||
|
```lua
|
||||||
|
ctld.spawnCrateAtPoint("blue",500, {x=20, y=10,z=20}) -- spawns a RED coalition HMMWV at the specified point
|
||||||
|
```
|
||||||
|
|
||||||
#### JTAC Automatic Targeting and Laser
|
#### JTAC Automatic Targeting and Laser
|
||||||
This script has been merged with https://github.com/ciribob/DCS-JTACAutoLaze . JTACs can either be deployed by Helicopters and configured with the options in the script or pre added to the mission. By default each side can drop 5 JTACs.
|
This script has been merged with https://github.com/ciribob/DCS-JTACAutoLaze . JTACs can either be deployed by Helicopters and configured with the options in the script or pre added to the mission. By default each side can drop 5 JTACs.
|
||||||
|
|||||||
BIN
test-mission.miz
BIN
test-mission.miz
Binary file not shown.
Reference in New Issue
Block a user