mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2026-08-20 17:07:48 +00:00
Ability to repair a damaged HAWK system in the field
You can now repair a damaged HAWK system with a repair crate as long as something is left of the original system
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
See https://github.com/ciribob/DCS-CTLD for a user manual and the latest version
|
See https://github.com/ciribob/DCS-CTLD for a user manual and the latest version
|
||||||
|
|
||||||
Version: 1.27 - 29/08/2015 - Added new optional parameter to a pickupzone setup to limit the number of groups that can be loaded
|
Version: 1.28 - 08/09/2015 - Ability to Repair damaged HAWK systems in the field, even if parts have been destroyed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -294,6 +294,7 @@ ctld.spawnableCrates = {
|
|||||||
{ weight = 1000, desc = "HAWK Launcher", unit = "Hawk ln" },
|
{ weight = 1000, desc = "HAWK Launcher", unit = "Hawk ln" },
|
||||||
{ weight = 1010, desc = "HAWK Search Radar", unit = "Hawk sr" },
|
{ weight = 1010, desc = "HAWK Search Radar", unit = "Hawk sr" },
|
||||||
{ weight = 1020, desc = "HAWK Track Radar", unit = "Hawk tr" },
|
{ weight = 1020, desc = "HAWK Track Radar", unit = "Hawk tr" },
|
||||||
|
{ weight = 1021, desc = "HAWK Repair", unit = "HAWK Repair" },
|
||||||
--
|
--
|
||||||
|
|
||||||
{ weight = 505, desc = "Strela-1 9P31", unit = "Strela-1 9P31", side = 1, cratesRequired = 4 },
|
{ weight = 505, desc = "Strela-1 9P31", unit = "Strela-1 9P31", side = 1, cratesRequired = 4 },
|
||||||
@@ -1811,21 +1812,26 @@ function ctld.findNearestHawk(_heli)
|
|||||||
local _shortestDistance = -1
|
local _shortestDistance = -1
|
||||||
local _distance = 0
|
local _distance = 0
|
||||||
|
|
||||||
for _, _groupName in pairs(ctld.completeHawkSystems) do
|
for _groupName, _hawkDetails in pairs(ctld.completeHawkSystems) do
|
||||||
|
|
||||||
local _hawkGroup = Group.getByName(_groupName)
|
local _hawkGroup = Group.getByName(_groupName)
|
||||||
|
|
||||||
if _hawkGroup ~= nil and _hawkGroup:getCoalition() == _heli:getCoalition() then
|
if _hawkGroup ~= nil and _hawkGroup:getCoalition() == _heli:getCoalition() then
|
||||||
|
|
||||||
local _leader = _hawkGroup:getUnit(1)
|
local _units = _hawkGroup:getUnits()
|
||||||
|
|
||||||
if _leader ~= nil and _leader:getLife() > 0 then
|
for _,_leader in pairs(_units) do
|
||||||
|
|
||||||
_distance = ctld.getDistance(_leader:getPoint(), _heli:getPoint())
|
if _leader ~= nil and _leader:getLife() > 0 then
|
||||||
|
|
||||||
if _distance ~= nil and (_shortestDistance == -1 or _distance < _shortestDistance) then
|
_distance = ctld.getDistance(_leader:getPoint(), _heli:getPoint())
|
||||||
_shortestDistance = _distance
|
|
||||||
_closestHawkGroup = _hawkGroup
|
if _distance ~= nil and (_shortestDistance == -1 or _distance < _shortestDistance) then
|
||||||
|
_shortestDistance = _distance
|
||||||
|
_closestHawkGroup = _hawkGroup
|
||||||
|
end
|
||||||
|
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2548,7 +2554,7 @@ function ctld.rearmHawk(_heli, _nearestCrate, _nearbyCrates)
|
|||||||
|
|
||||||
local _spawnedGroup = ctld.spawnCrateGroup(_heli, _points, _types)
|
local _spawnedGroup = ctld.spawnCrateGroup(_heli, _points, _types)
|
||||||
|
|
||||||
ctld.completeHawkSystems[_spawnedGroup:getName()] = _spawnedGroup:getName()
|
ctld.completeHawkSystems[_spawnedGroup:getName()] = ctld.getHawkDetails(_spawnedGroup)
|
||||||
|
|
||||||
trigger.action.outTextForCoalition(_heli:getCoalition(), ctld.getPlayerNameOrType(_heli) .. " successfully rearmed a full HAWK AA System in the field", 10)
|
trigger.action.outTextForCoalition(_heli:getCoalition(), ctld.getPlayerNameOrType(_heli) .. " successfully rearmed a full HAWK AA System in the field", 10)
|
||||||
|
|
||||||
@@ -2571,6 +2577,20 @@ function ctld.rearmHawk(_heli, _nearestCrate, _nearbyCrates)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ctld.getHawkDetails(_hawkGroup)
|
||||||
|
|
||||||
|
local _units = _hawkGroup:getUnits()
|
||||||
|
|
||||||
|
local _hawkDetails = {}
|
||||||
|
|
||||||
|
for _,_unit in pairs(_units) do
|
||||||
|
table.insert(_hawkDetails, {point=_unit:getPoint(), unit = _unit:getTypeName(), name= _unit:getName()})
|
||||||
|
end
|
||||||
|
|
||||||
|
return _hawkDetails
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function ctld.countTableEntries(_table)
|
function ctld.countTableEntries(_table)
|
||||||
|
|
||||||
if _table == nil then
|
if _table == nil then
|
||||||
@@ -2680,16 +2700,67 @@ function ctld.unpackHawk(_heli, _nearestCrate, _nearbyCrates)
|
|||||||
-- HAWK READY!
|
-- HAWK READY!
|
||||||
local _spawnedGroup = ctld.spawnCrateGroup(_heli, _posArray, _typeArray)
|
local _spawnedGroup = ctld.spawnCrateGroup(_heli, _posArray, _typeArray)
|
||||||
|
|
||||||
ctld.completeHawkSystems[_spawnedGroup:getName()] = _spawnedGroup:getName()
|
ctld.completeHawkSystems[_spawnedGroup:getName()] = ctld.getHawkDetails(_spawnedGroup)
|
||||||
|
|
||||||
trigger.action.outTextForCoalition(_heli:getCoalition(), ctld.getPlayerNameOrType(_heli) .. " successfully deployed a full HAWK AA System to the field", 10)
|
trigger.action.outTextForCoalition(_heli:getCoalition(), ctld.getPlayerNameOrType(_heli) .. " successfully deployed a full HAWK AA System to the field", 10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ctld.repairHawk(_heli, _nearestCrate)
|
||||||
|
|
||||||
|
-- find nearest COMPLETE hawk system
|
||||||
|
local _nearestHawk = ctld.findNearestHawk(_heli)
|
||||||
|
|
||||||
|
if _nearestHawk ~= nil and _nearestHawk.dist < 300 then
|
||||||
|
|
||||||
|
local _oldHawk = ctld.completeHawkSystems[_nearestHawk.group:getName()]
|
||||||
|
|
||||||
|
--spawn new one
|
||||||
|
|
||||||
|
local _types = {}
|
||||||
|
local _points = {}
|
||||||
|
|
||||||
|
for _, _part in pairs(_oldHawk) do
|
||||||
|
table.insert(_points,_part.point)
|
||||||
|
table.insert(_types,_part.unit)
|
||||||
|
end
|
||||||
|
|
||||||
|
--remove old system
|
||||||
|
ctld.completeHawkSystems[_nearestHawk.group:getName()] = nil
|
||||||
|
_nearestHawk.group:destroy()
|
||||||
|
|
||||||
|
local _spawnedGroup = ctld.spawnCrateGroup(_heli, _points, _types)
|
||||||
|
|
||||||
|
ctld.completeHawkSystems[_spawnedGroup:getName()] = ctld.getHawkDetails(_spawnedGroup)
|
||||||
|
|
||||||
|
trigger.action.outTextForCoalition(_heli:getCoalition(), ctld.getPlayerNameOrType(_heli) .. " successfully repaired a full HAWK AA System in the field", 10)
|
||||||
|
|
||||||
|
if _heli:getCoalition() == 1 then
|
||||||
|
ctld.spawnedCratesRED[_nearestCrate.crateUnit:getName()] = nil
|
||||||
|
else
|
||||||
|
ctld.spawnedCratesBLUE[_nearestCrate.crateUnit:getName()] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- remove crate
|
||||||
|
if ctld.slingLoad == false then
|
||||||
|
_nearestCrate.crateUnit:destroy()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
ctld.displayMessageToGroup(_heli, "Cannot repair a HAWK System. No damaged HAWK systems within 300m", 10)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ctld.unpackMultiCrate(_heli, _nearestCrate, _nearbyCrates)
|
function ctld.unpackMultiCrate(_heli, _nearestCrate, _nearbyCrates)
|
||||||
|
|
||||||
if string.match(_nearestCrate.details.desc, "HAWK") then
|
if string.match(_nearestCrate.details.desc, "HAWK") then
|
||||||
ctld.unpackHawk(_heli, _nearestCrate, _nearbyCrates)
|
|
||||||
|
if string.match(_nearestCrate.details.desc, "Repair") then
|
||||||
|
ctld.repairHawk(_heli, _nearestCrate)
|
||||||
|
else
|
||||||
|
ctld.unpackHawk(_heli, _nearestCrate, _nearbyCrates)
|
||||||
|
end
|
||||||
|
|
||||||
return -- stop processing
|
return -- stop processing
|
||||||
end
|
end
|
||||||
@@ -3265,7 +3336,7 @@ function ctld.updateZoneCounter(_index,_diff)
|
|||||||
|
|
||||||
ctld.pickupZones[_index][3] = ctld.pickupZones[_index][3]+_diff
|
ctld.pickupZones[_index][3] = ctld.pickupZones[_index][3]+_diff
|
||||||
|
|
||||||
-- env.info(ctld.pickupZones[_index][1].." = " ..ctld.pickupZones[_index][3])
|
-- env.info(ctld.pickupZones[_index][1].." = " ..ctld.pickupZones[_index][3])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user