From 21b968a9c6ba38499d76e41d504512096081aaf1 Mon Sep 17 00:00:00 2001 From: Shafik Date: Fri, 14 Nov 2025 14:42:52 +0200 Subject: [PATCH 1/2] [ADDED] STATIC:GetVec2Cached() and STATIC:GetVec3Cached() for statics considering respawns --- Moose Development/Moose/Wrapper/Static.lua | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Static.lua b/Moose Development/Moose/Wrapper/Static.lua index 7c2436641..eb0899a5f 100644 --- a/Moose Development/Moose/Wrapper/Static.lua +++ b/Moose Development/Moose/Wrapper/Static.lua @@ -64,6 +64,9 @@ function STATIC:Register( StaticName ) else self:E(string.format("Static object %s does not exist!", tostring(self.StaticName))) end + + -- Cache position + self._vec3 = self:GetVec3() return self end @@ -86,6 +89,30 @@ function STATIC:GetLife() return nil end +--- Get the position of the STATIC even if it is not alive. +-- @param #STATIC self +-- @return DCS#Vec2 The 2D point vector of the POSITIONABLE. +-- @return #nil The position was not cached. +function STATIC:GetVec2Cached() + local vec2 = self:GetVec2() + if not vec2 and self._vec3 then + vec2 = {x = self._vec3.x, y = self._vec3.z } + end + return vec2 +end + +--- Get the position of the STATIC even if it is not alive. +-- @param #STATIC self +-- @return DCS#Vec3 The 3D point vector of the POSITIONABLE. +-- @return #nil The position was not cached. +function STATIC:GetVec3Cached() + local vec3 = self:GetVec3() + if not vec3 and self._vec3 then + vec3 = self._vec3 + end + return vec3 +end + --- Finds a STATIC from the _DATABASE using a DCSStatic object. -- @param #STATIC self -- @param DCS#StaticObject DCSStatic An existing DCS Static object reference. @@ -232,6 +259,8 @@ function STATIC:SpawnAt(Coordinate, Heading, Delay) local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName) SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName ) + -- Cache position + self._vec3 = self:GetVec3() end @@ -255,6 +284,8 @@ function STATIC:ReSpawn(CountryID, Delay) local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID) SpawnStatic:Spawn(nil, self.StaticName) + -- Cache position + self._vec3 = self:GetVec3() end @@ -278,6 +309,8 @@ function STATIC:ReSpawnAt(Coordinate, Heading, Delay) local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry()) SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName) + -- Cache position + self._vec3 = self:GetVec3() end From 5089e7df25ac7fe4f06f98fc4505dbc4afb28cdd Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 14 Nov 2025 17:26:10 +0100 Subject: [PATCH 2/2] xx --- Moose Development/Moose/Wrapper/Controllable.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 780dc31c8..9a5409bdf 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -2855,7 +2855,7 @@ do -- Route methods -- @param Core.Zone#ZONE Zone The zone where to route to. -- @param #boolean Randomize Defines whether to target point gets randomized within the Zone. -- @param #number Speed The speed in m/s. Default is 5.555 m/s = 20 km/h. - -- @param Core.Base#FORMATION Formation The formation string. + -- @param DCS#FORMATION Formation The formation string. function CONTROLLABLE:TaskRouteToZone( Zone, Randomize, Speed, Formation ) self:F2( Zone ) @@ -2915,7 +2915,7 @@ do -- Route methods -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 The Vec2 where to route to. -- @param #number Speed The speed in m/s. Default is 5.555 m/s = 20 km/h. - -- @param Core.Base#FORMATION Formation The formation string. + -- @param DCS#FORMATION Formation The formation string. function CONTROLLABLE:TaskRouteToVec2( Vec2, Speed, Formation ) local DCSControllable = self:GetDCSObject()