From bd64d084e94d5e9110333acc70000699328c7a0a Mon Sep 17 00:00:00 2001 From: smiki Date: Thu, 5 Feb 2026 10:49:48 +0100 Subject: [PATCH] Optimizations --- .../Moose/Functional/Autolase.lua | 27 +++++++++---------- Moose Development/Moose/Ops/CTLD.lua | 4 +-- Moose Development/Moose/Ops/Intelligence.lua | 10 +++---- Moose Development/Moose/Wrapper/Unit.lua | 8 ++---- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Moose Development/Moose/Functional/Autolase.lua b/Moose Development/Moose/Functional/Autolase.lua index 1772e24a3..41e167ef8 100644 --- a/Moose Development/Moose/Functional/Autolase.lua +++ b/Moose Development/Moose/Functional/Autolase.lua @@ -693,7 +693,7 @@ end function AUTOLASE:GetLosFromUnit(Unit) local lasedistance = self.LaseDistance local unitheight = Unit:GetHeight() - local coord = Unit:GetCoordinate() + local coord = Unit:GetCoord() local landheight = coord:GetLandHeight() local asl = unitheight - landheight if asl > 100 then @@ -845,7 +845,7 @@ function AUTOLASE:ShowStatus(Group,Unit) locationstring = entry.coordinate:ToStringLLDDM(settings) elseif settings:IsA2G_BR() then -- attention this is the distance from the ASKING unit to target, not from RECCE to target! - local startcoordinate = Unit:GetCoordinate() or Group:GetCoordinate() + local startcoordinate = Unit:GetCoord() or Group:GetCoord() locationstring = entry.coordinate:ToStringBR(startcoordinate,settings,false,self.RoundingPrecision) end end @@ -963,8 +963,8 @@ function AUTOLASE:CanLase(Recce,Unit) end end -- calculate LOS - local reccecoord = Recce:GetCoordinate() - local unitcoord = Unit:GetCoordinate() + local reccecoord = Recce:GetCoord() + local unitcoord = Unit:GetCoord() local islos = reccecoord:IsLOS(unitcoord,2.5) -- calculate distance local distance = math.floor(reccecoord:Get3DDistance(unitcoord)) @@ -1020,8 +1020,8 @@ function AUTOLASE:_Prescient() self:T(self.lid.."Checking possibly visible STATICs for Recce "..unit:GetName()) for _,_static in pairs(Statics) do -- DCS static object here local static = STATIC:Find(_static) - if static and static:GetCoalition() ~= self.coalition and static:GetCoordinate() then - local IsLOS = position:IsLOS(static:GetCoordinate()) + if static and static:GetCoalition() ~= self.coalition and static:GetCoord() then + local IsLOS = position:IsLOS(static:GetCoord()) if IsLOS then unit:KnowUnit(static,true,true) end @@ -1081,7 +1081,7 @@ function AUTOLASE:onafterMonitor(From, Event, To) local threat = contact.threatlevel or 0 local reccegrp = UNIT:FindByName(reccename) if reccegrp then - local reccecoord = reccegrp:GetCoordinate() + local reccecoord = reccegrp:GetCoord() local distance = math.floor(reccecoord:Get3DDistance(coord)) local text = string.format("%s of %s | Distance %d km | Threatlevel %d",contact.attribute, contact.groupname, math.floor(distance/1000), contact.threatlevel) report:Add(text) @@ -1120,7 +1120,6 @@ function AUTOLASE:onafterMonitor(From, Event, To) local unit = _unit -- Wrapper.Unit#UNIT if unit and unit:IsAlive() then local threat = unit:GetThreatLevel() - local coord = unit:GetCoordinate() if threat >= self.minthreatlevel then local unitname = unit:GetName() -- prefer radar units @@ -1176,16 +1175,16 @@ function AUTOLASE:onafterMonitor(From, Event, To) local code = self:GetLaserCode(reccename) local spot = SPOT:New(recce) spot:LaseOn(unit,code,self.LaseDuration) - local locationstring = unit:GetCoordinate():ToStringLLDDM() + local locationstring = unit:GetCoord():ToStringLLDDM() if _SETTINGS:IsA2G_MGRS() then local precision = _SETTINGS:GetMGRS_Accuracy() local settings = {} settings.MGRS_Accuracy = precision - locationstring = unit:GetCoordinate():ToStringMGRS(settings) + locationstring = unit:GetCoord():ToStringMGRS(settings) elseif _SETTINGS:IsA2G_LL_DMS() then - locationstring = unit:GetCoordinate():ToStringLLDMS(_SETTINGS) + locationstring = unit:GetCoord():ToStringLLDMS(_SETTINGS) elseif _SETTINGS:IsA2G_BR() then - locationstring = unit:GetCoordinate():ToStringBULLS(self.coalition,_SETTINGS) + locationstring = unit:GetCoord():ToStringBULLS(self.coalition,_SETTINGS) end local laserspot = { -- #AUTOLASE.LaserSpot @@ -1198,10 +1197,10 @@ function AUTOLASE:onafterMonitor(From, Event, To) unitname = unitname, reccename = reccename, unittype = unit:GetTypeName(), - coordinate = unit:GetCoordinate(), + coordinate = unit:GetCoord(), } if self.smoketargets then - local coord = unit:GetCoordinate() + local coord = unit:GetCoord() if self.smokeoffset then coord:Translate(self.smokeoffset.Distance,self.smokeoffset.Angle,true,true) end diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index a90327df9..2809c7048 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -638,7 +638,7 @@ CTLD_ENGINEERING = { local crate = ctable[1] -- Ops.CTLD#CTLD_CARGO local static = crate:GetPositionable() -- Wrapper.Static#STATIC local crate_pos = static:GetCoordinate() -- Core.Point#COORDINATE - local gpos = group:GetCoordinate() -- Core.Point#COORDINATE + local gpos = group:GetCoord() -- Core.Point#COORDINATE -- see how far we are from the crate local distance = self:_GetDistance(gpos,crate_pos) self:T(string.format("%s Distance to crate: %d", self.lid, distance)) @@ -667,7 +667,7 @@ CTLD_ENGINEERING = { --local COps = self.C_Ops -- Ops.CTLD#CTLD local group = self.Group -- Wrapper.Group#GROUP local tgtpos = self.currwpt -- Core.Point#COORDINATE - local gpos = group:GetCoordinate() -- Core.Point#COORDINATE + local gpos = group:GetCoord() -- Core.Point#COORDINATE -- see how far we are from the crate local distance = self:_GetDistance(gpos,tgtpos) self:T(string.format("%s Distance remaining: %d", self.lid, distance)) diff --git a/Moose Development/Moose/Ops/Intelligence.lua b/Moose Development/Moose/Ops/Intelligence.lua index a20365af8..173abfcdc 100644 --- a/Moose Development/Moose/Ops/Intelligence.lua +++ b/Moose Development/Moose/Ops/Intelligence.lua @@ -1175,7 +1175,7 @@ function INTEL:_CreateContact(Positionable, RecceName) item.category=3 --static:GetCategory() item.categoryname=static:GetCategoryName() or "Unknown" item.threatlevel=static:GetThreatLevel() or 0 - item.position=static:GetCoordinate() + item.position=static:GetCoord() item.velocity=static:GetVelocityVec3() item.speed=0 item.recce=RecceName @@ -1282,15 +1282,15 @@ function INTEL:GetDetectedUnits(Unit, DetectedUnits, RecceDetecting, DetectVisua local DetectionAccepted = true if self.RadarAcceptRange then - local reccecoord = Unit:GetCoordinate() - local coord = unit:GetCoordinate() + local reccecoord = Unit:GetCoord() + local coord = unit:GetCoord() local dist = math.floor(coord:Get2DDistance(reccecoord)/1000) -- km if dist > self.RadarAcceptRangeKilometers then DetectionAccepted = false end end if self.RadarBlur then - local reccecoord = Unit:GetCoordinate() - local coord = unit:GetCoordinate() + local reccecoord = Unit:GetCoord() + local coord = unit:GetCoord() local dist = math.floor(coord:Get2DDistance(reccecoord)/1000) -- km local AGL = unit:GetAltitude(true) local minheight = self.RadarBlurMinHeight or 250 -- meters diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 1ca25ca08..77a2e391d 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -1352,9 +1352,7 @@ function UNIT:GetThreatLevel() end ThreatText = ThreatLevels[ThreatLevel + 1] - end - - if self:IsAir() then + elseif self:IsAir() then local ThreatLevels = { [1] = "Unarmed", @@ -1397,9 +1395,7 @@ function UNIT:GetThreatLevel() end ThreatText = ThreatLevels[ThreatLevel + 1] - end - - if self:IsShip() then + elseif self:IsShip() then --["Aircraft Carriers"] = {"Heavy armed ships",}, --["Cruisers"] = {"Heavy armed ships",},