Compare commits

...

4 Commits

Author SHA1 Message Date
Applevangelist
f4cd214823 #TIRESIAS - Avoid creating SET_GROUPs all the time for player objects, cached now 2025-07-27 19:24:43 +02:00
Thomas
bb6db2b7f8 Merge pull request #2352 from FlightControl-Master/master
Merge from Master
2025-07-27 14:16:07 +02:00
Thomas
fd2dacaefb Merge pull request #2351 from shaji-Dev/master
[ADDED] `UTILS.LoadMission` and `UTILS.SetMissionBriefing`
2025-07-27 14:15:16 +02:00
smiki
cc60e85901 [ADDED] UTILS.LoadMission and UTILS.SetMissionBriefing 2025-07-27 13:18:56 +02:00
2 changed files with 30 additions and 3 deletions

View File

@@ -33,7 +33,7 @@
-- - @module Functional.Tiresias
-- - @image Functional.Tiresias.jpg
--- Last Update: Dec 2023 (Optimized July 2025)
--- Last Update: July 2025
--- **TIRESIAS** class, extends Core.Base#BASE
-- @type TIRESIAS
@@ -55,6 +55,7 @@
-- @field #boolean SwitchAAA
-- @field #string lid
-- @field #table _cached_zones
-- @field #table _cached_groupsets
-- @extends Core.Fsm#FSM
---
@@ -104,7 +105,7 @@
TIRESIAS = {
ClassName = "TIRESIAS",
debug = true,
version = " 0.0.6-OPT" ,
version = " 0.0.7-OPT" ,
Interval = 20,
GroundSet = nil,
VehicleSet = nil,
@@ -116,6 +117,7 @@ TIRESIAS = {
PlaneSwitchRange = 25, -- NM
SwitchAAA = true,
_cached_zones = {}, -- Cache for zone objects
_cached_groupsets = {}, -- Cache for group_set objects
}
---
@@ -418,6 +420,7 @@ function TIRESIAS:_SwitchOnGroups(group, radius)
local group_name = group:GetName()
local cache_key = group_name .. " _" .. radius
local zone = self._cached_zones[cache_key]
local ground = self._cached_groupsets[cache_key]
if not zone then
zone = ZONE_GROUP:New(" Zone-" .. group_name, group, UTILS.NMToMeters(radius))
@@ -427,7 +430,13 @@ function TIRESIAS:_SwitchOnGroups(group, radius)
zone:UpdateFromGroup(group)
end
local ground = SET_GROUP:New():FilterCategoryGround():FilterZones({zone}):FilterOnce()
if not ground then
ground = SET_GROUP:New():FilterCategoryGround():FilterZones({zone}):FilterOnce()
self._cached_groupsets[cache_key] = ground
else
ground:FilterZones({zone},true):FilterOnce()
end
local count = ground:CountAlive()
if self.debug then

View File

@@ -4620,6 +4620,24 @@ function UTILS.ShowPicture(FileName, Duration, ClearView, StartDelay, Horizontal
net.dostring_in("mission", string.format("a_out_picture(getValueResourceByKey(\"%s\"), %d, %s, %d, \"%d\", \"%d\", %d, \"%d\")", FileName, Duration or 10, ClearView, StartDelay, HorizontalAlign, VerticalAlign, Size, SizeUnits))
end
--- Load a mission file. This will replace the current mission with the one given carrying along the online clients.
-- @param #string FileName Mission filename
function UTILS.LoadMission(FileName)
net.dostring_in("mission", string.format("a_load_mission(\"%s\")", FileName))
end
--- Set the mission briefing for a coalition.
-- @param #number Coalition Briefing coalition ID, can be coalition.side.BLUE, coalition.side.RED or coalition.side.NEUTRAL
-- @param #string Text Briefing text, can contain newlines, will be converted formatted properly for DCS
-- @param #string Picture Picture filename, can be a file in the DEFAULT folder inside the .miz
function UTILS.SetMissionBriefing(Coalition, Text, Picture)
Text = Text or ""
Text = Text:gsub("\n", "\\n")
Picture = Picture or ""
local coalName = string.lower(UTILS.GetCoalitionName(Coalition))
net.dostring_in("mission", string.format("a_set_briefing(\"%s\", getValueResourceByKey(\"%s\"), \"%s\")", coalName, Picture, Text))
end
--- Show a helper gate at a DCS#Vec3 position
-- @param DCS#Vec3 pos The position
-- @param number heading Heading in degrees, can be 0..359 degrees