Skip to content

Commit

Permalink
Merge pull request #2165 from FlightControl-Master/master
Browse files Browse the repository at this point in the history
Various
  • Loading branch information
Applevangelist authored Aug 12, 2024
2 parents 5f7f75b + a54944b commit ebe6e9f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Moose Development/Moose/Ops/CTLD.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2817,6 +2817,7 @@ function CTLD:_FindCratesNearby( _group, _unit, _dist, _ignoreweight)
local capabilities = {}
local maxmass = 2000
local maxloadable = 2000
local IsNoHook = not self:IsHook(_unit)
if not _ignoreweight then
maxloadable = self:_GetMaxLoadableMass(_unit)
end
Expand All @@ -2830,14 +2831,14 @@ function CTLD:_FindCratesNearby( _group, _unit, _dist, _ignoreweight)
local cargoalive = false -- TODO dyn cargo spawn workaround
local dcsunit = nil
local dcsunitpos = nil
if static.DCSCargoObject then
if static and static.DCSCargoObject then
dcsunit = Unit.getByName(static.StaticName)
if dcsunit then
cargoalive = dcsunit:isExist() ~= nil and true or false
end
if cargoalive == true then
local dcsvec3 = dcsunit:getPoint() or dcsunit:getPosition().p or {x=0,y=0,z=0}
self:I({dcsvec3 = dcsunit:getPoint(), dcspos = dcsunit:getPosition().p})
self:T({dcsvec3 = dcsunit:getPoint(), dcspos = dcsunit:getPosition().p})
if dcsvec3 then
dcsunitpos = COORDINATE:New(dcsvec3.x,dcsvec3.z,dcsvec3.y)
end
Expand All @@ -2850,9 +2851,10 @@ function CTLD:_FindCratesNearby( _group, _unit, _dist, _ignoreweight)
local agl = staticpos.y-landheight
agl = UTILS.Round(agl,2)
local GCloaded = agl > 0 and true or false
if IsNoHook == true then GCloaded = false end
--- Testing
local distance = self:_GetDistance(location,staticpos)
self:I({name=static:GetName(),agl=agl,GCloaded=GCloaded,distance=string.format("%.2f",distance or 0)})
self:T({name=static:GetName(),IsNoHook=IsNoHook,agl=agl,GCloaded=GCloaded,distance=string.format("%.2f",distance or 0)})
if (not GCloaded) and distance <= finddist and static and (weight <= maxloadable or _ignoreweight) then
index = index + 1
table.insert(found, staticid, cargo)
Expand Down

0 comments on commit ebe6e9f

Please sign in to comment.