CTLD - Fix Ship Zones

CTLD - Fix Ship Zones
This commit is contained in:
Thomas 2022-11-07 14:11:16 +01:00 committed by GitHub
parent 2eea8520d8
commit c08d54c16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1072,8 +1072,8 @@ CTLD.UnitTypes = {
--Actually it's longer, but the center coord is off-center of the model. --Actually it's longer, but the center coord is off-center of the model.
["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats ["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo ["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo
["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450}, ["Bronco-OV-10A"] = {type="Bronco-OV-10A", crates= false, troops=true, cratelimit = 0, trooplimit = 5, length = 13, cargoweightlimit = 1450},
} }
--- CTLD class version. --- CTLD class version.
-- @field #string version -- @field #string version
@ -3423,11 +3423,19 @@ function CTLD:AddCTLDZone(Name, Type, Color, Active, HasBeacon, Shiplength, Ship
self:T(self.lid .. " AddCTLDZone") self:T(self.lid .. " AddCTLDZone")
local zone = ZONE:FindByName(Name) local zone = ZONE:FindByName(Name)
if not zone then if not zone and Type ~= CTLD.CargoZoneType.SHIP then
self:E(self.lid.."**** Zone does not exist: "..Name) self:E(self.lid.."**** Zone does not exist: "..Name)
return self return self
end end
if Type == CTLD.CargoZoneType.SHIP then
local Ship = UNIT:FindByName(Name)
if not Ship then
self:E(self.lid.."**** Ship does not exist: "..Name)
return self
end
end
local ctldzone = {} -- #CTLD.CargoZone local ctldzone = {} -- #CTLD.CargoZone
ctldzone.active = Active or false ctldzone.active = Active or false
ctldzone.color = Color or SMOKECOLOR.Red ctldzone.color = Color or SMOKECOLOR.Red
@ -3685,21 +3693,22 @@ function CTLD:IsUnitInZone(Unit,Zonetype)
local zonewidth = 20 local zonewidth = 20
if Zonetype == CTLD.CargoZoneType.SHIP then if Zonetype == CTLD.CargoZoneType.SHIP then
self:T("Checking Type Ship: "..zonename) self:T("Checking Type Ship: "..zonename)
zone = UNIT:FindByName(zonename) ZoneUNIT = UNIT:FindByName(zonename)
zonecoord = zone:GetCoordinate() zonecoord = zone:GetCoordinate()
zoneradius = czone.shiplength zoneradius = czone.shiplength
zonewidth = czone.shipwidth zonewidth = czone.shipwidth
zone = ZONE_UNIT:New( ZoneUNIT:GetName(), ZoneUNIT, zoneradius/2)
elseif ZONE:FindByName(zonename) then elseif ZONE:FindByName(zonename) then
zone = ZONE:FindByName(zonename) zone = ZONE:FindByName(zonename)
self:T("Checking Zone: "..zonename) self:T("Checking Zone: "..zonename)
zonecoord = zone:GetCoordinate() zonecoord = zone:GetCoordinate()
zoneradius = 1500 --zoneradius = 1500
zonewidth = zoneradius zonewidth = zoneradius
elseif AIRBASE:FindByName(zonename) then elseif AIRBASE:FindByName(zonename) then
zone = AIRBASE:FindByName(zonename):GetZone() zone = AIRBASE:FindByName(zonename):GetZone()
self:T("Checking Zone: "..zonename) self:T("Checking Zone: "..zonename)
zonecoord = zone:GetCoordinate() zonecoord = zone:GetCoordinate()
zoneradius = 2500 zoneradius = 2000
zonewidth = zoneradius zonewidth = zoneradius
end end
local distance = self:_GetDistance(zonecoord,unitcoord) local distance = self:_GetDistance(zonecoord,unitcoord)