From 7865be43bb4098df0a03e5665e02fd36a246baf3 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 1 Dec 2022 13:27:58 +0100 Subject: [PATCH 1/9] * Minor fixes --- Moose Development/Moose/Core/Set.lua | 2 +- Moose Development/Moose/Functional/RAT.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index d70bc20e5..f3b227e24 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -179,7 +179,7 @@ do -- SET_BASE return Names end - --- Gets a list of the Objects in the Set. + --- Return a table of the Objects in the Set. -- @param #SET_BASE self -- @return #SET_BASE self function SET_BASE:GetSetObjects() -- R2.3 diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index a54533eeb..081132413 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -3492,7 +3492,7 @@ function RAT:Status(message, forID) local fuel=group:GetFuel()*100.0 local airborne=group:InAir() local coords=group:GetCoordinate() - local alt=coords.y + local alt=coords.y or 1000 --local vel=group:GetVelocityKMH() local departure=ratcraft.departure:GetName() local destination=ratcraft.destination:GetName() From b29b9f1b2c71caef118ded5eaf9e56828379a7a3 Mon Sep 17 00:00:00 2001 From: Thomas <72444570+Applevangelist@users.noreply.github.com> Date: Thu, 1 Dec 2022 21:32:19 +0100 Subject: [PATCH 2/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 69ab8403a..aec3cbd3a 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Pene has kindly created a [tutorial series for MOOSE](https://youtube.com/playli -## [MOOSE on Discord](https://discord.gg/yBPfxC6) +## [MOOSE on Discord](https://discord.gg/aQtjcR94Qf) MOOSE has a living (chat and video) community of users, beta testers and contributors. The gathering point is a service provided by discord.com. If you want to join this community, just click Discord and you'll be on board in no time. From 37b1e7366c1f1a7e4003e2bedcc4e59ba91d1255 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 2 Dec 2022 16:39:05 +0100 Subject: [PATCH 3/9] *smaller fixes --- Moose Development/Moose/Core/Message.lua | 29 ++++++++++++++------ Moose Development/Moose/Core/SpawnStatic.lua | 2 +- Moose Development/Moose/Ops/CTLD.lua | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua index 780446109..45c9cd968 100644 --- a/Moose Development/Moose/Core/Message.lua +++ b/Moose Development/Moose/Core/Message.lua @@ -98,7 +98,7 @@ function MESSAGE:New( MessageText, MessageDuration, MessageCategory, ClearScreen self.MessageType = nil - -- When no MessageCategory is given, we don't show it as a title... + -- When no MessageCategory is given, we don't show it as a title... if MessageCategory and MessageCategory ~= "" then if MessageCategory:sub( -1 ) ~= "\n" then self.MessageCategory = MessageCategory .. ": " @@ -204,14 +204,14 @@ function MESSAGE:ToClient( Client, Settings ) local Unit = Client:GetClient() if self.MessageDuration ~= 0 then - local ClientGroupID = Client:GetClientGroupID() - self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) - --trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen) - trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen) - end - end - - return self + local ClientGroupID = Client:GetClientGroupID() + self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) + --trigger.action.outTextForGroup( ClientGroupID, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen) + trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration , self.ClearScreen) + end + end + + return self end --- Sends a MESSAGE to a Group. @@ -443,3 +443,14 @@ function MESSAGE:ToLog() return self end + +--- Sends a MESSAGE to DCS log file if the given Condition is true. +-- @param #MESSAGE self +-- @return #MESSAGE self +function MESSAGE:ToLogIf( Condition ) + + if Condition and Condition == true then + env.info(self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" )) + end + return self +end diff --git a/Moose Development/Moose/Core/SpawnStatic.lua b/Moose Development/Moose/Core/SpawnStatic.lua index d73336464..4420f70ed 100644 --- a/Moose Development/Moose/Core/SpawnStatic.lua +++ b/Moose Development/Moose/Core/SpawnStatic.lua @@ -275,7 +275,7 @@ end --- Initialize as dead. -- @param #SPAWNSTATIC self --- @param #boolean IsCargo If true, this static is dead. +-- @param #boolean IsDead If true, this static is dead. -- @return #SPAWNSTATIC self function SPAWNSTATIC:InitDead(IsDead) self.InitStaticDead=IsDead diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index e370b430e..145c2c9e0 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -3690,7 +3690,7 @@ function CTLD:_AddRadioBeacon(Name, Sound, Mhz, Modulation, IsShip, IsDropped) local Sound = "l10n/DEFAULT/"..Sound trigger.action.radioTransmission(Sound, ZoneVec3, Modulation, false, Frequency, 1000) -- Beacon in MP only runs for 30secs straight elseif Zone then - local ZoneCoord = Zone:GetCoordinate() + local ZoneCoord = Zone:GetCoordinate(2) local ZoneVec3 = ZoneCoord:GetVec3() local Frequency = Mhz * 1000000 -- Freq in Hertz local Sound = "l10n/DEFAULT/"..Sound From 85504fbe6241116e119e6a2ea20745633d1dfdb1 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 3 Dec 2022 14:36:28 +0100 Subject: [PATCH 4/9] Small Fixes --- Moose Development/Moose/Ops/PlayerRecce.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/PlayerRecce.lua b/Moose Development/Moose/Ops/PlayerRecce.lua index ef80816c8..f71b33fa8 100644 --- a/Moose Development/Moose/Ops/PlayerRecce.lua +++ b/Moose Development/Moose/Ops/PlayerRecce.lua @@ -1394,7 +1394,7 @@ end -- @param #string To -- @return #PLAYERRECCE self function PLAYERRECCE:onafterStatus(From, Event, To) - self:I({From, Event, To}) + self:T({From, Event, To}) if not self.timestamp then self.timestamp = timer.getTime() From 508e36d3274a8478aa6a72321777d155ff3eb8ea Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 3 Dec 2022 14:37:01 +0100 Subject: [PATCH 5/9] #CTLD Fix for Beacon Zone disappearing too fast --- Moose Development/Moose/Ops/CTLD.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 145c2c9e0..e36752b3f 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -3522,7 +3522,12 @@ function CTLD:AddCTLDZone(Name, Type, Color, Active, HasBeacon, Shiplength, Ship ctldzone.name = Name or "NONE" ctldzone.type = Type or CTLD.CargoZoneType.MOVE -- #CTLD.CargoZoneType ctldzone.hasbeacon = HasBeacon or false - + + if Type == CTLD.CargoZoneType.BEACON then + self.droppedbeaconref[ctldzone.name] = zone:GetCoordinate() + ctldzone.timestamp = timer.getTime() + end + if HasBeacon then ctldzone.fmbeacon = self:_GetFMBeacon(Name) ctldzone.uhfbeacon = self:_GetUHFBeacon(Name) @@ -3611,7 +3616,7 @@ function CTLD:CheckDroppedBeacons() for _,_beacon in pairs (self.droppedBeacons) do local beacon = _beacon -- #CTLD.CargoZone - if not beacon.timestamp then beacon.timestamp = timer.getTime() end + if not beacon.timestamp then beacon.timestamp = timer.getTime() + timeout end local T0 = beacon.timestamp if timer.getTime() - T0 > timeout then local name = beacon.name @@ -3686,15 +3691,19 @@ function CTLD:_AddRadioBeacon(Name, Sound, Mhz, Modulation, IsShip, IsDropped) if IsDropped and Zone then local ZoneCoord = Zone local ZoneVec3 = ZoneCoord:GetVec3() - local Frequency = Mhz * 1000000 -- Freq in Hertz + local Frequency = string.format("%09d",Mhz * 1000000) -- Freq in Hertz local Sound = "l10n/DEFAULT/"..Sound trigger.action.radioTransmission(Sound, ZoneVec3, Modulation, false, Frequency, 1000) -- Beacon in MP only runs for 30secs straight + --local status = string.format("***** Beacon added Freq %s Mod %s", Mhz, UTILS.GetModulationName(Modulation)) + --MESSAGE:New(status,10,"Debug"):ToLogIf(self.debug) elseif Zone then local ZoneCoord = Zone:GetCoordinate(2) local ZoneVec3 = ZoneCoord:GetVec3() - local Frequency = Mhz * 1000000 -- Freq in Hertz + local Frequency = string.format("%09d",Mhz * 1000000) -- Freq in Hertz local Sound = "l10n/DEFAULT/"..Sound trigger.action.radioTransmission(Sound, ZoneVec3, Modulation, false, Frequency, 1000) -- Beacon in MP only runs for 30secs straight + --local status = string.format("***** Beacon added Freq %s Mod %s", Mhz, UTILS.GetModulationName(Modulation)) + --MESSAGE:New(status,10,"Debug"):ToLogIf(self.debug) end return self end From 55383575e0247930b418252e8931b76b7b7c7d50 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 6 Dec 2022 12:48:20 +0100 Subject: [PATCH 6/9] #PLAYERTASKCONTROLLER * Make callout of MGRS coordinates slower --- Moose Development/Moose/Ops/PlayerTask.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 2c6f3a75f..0f6d95c78 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -21,7 +21,7 @@ -- === -- @module Ops.PlayerTask -- @image OPS_PlayerTask.jpg --- @date Last Update November 2022 +-- @date Last Update December 2022 do @@ -1409,7 +1409,7 @@ PLAYERTASKCONTROLLER.Messages = { --- PLAYERTASK class version. -- @field #string version -PLAYERTASKCONTROLLER.version="0.1.50" +PLAYERTASKCONTROLLER.version="0.1.51" --- Create and run a new TASKCONTROLLER instance. -- @param #PLAYERTASKCONTROLLER self @@ -2922,10 +2922,20 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Group, Client, Task) if self.UseSRS then if string.find(CoordText," BR, ") then - CoordText = string.gsub(CoordText," BR, "," Bee, Arr, ") + CoordText = string.gsub(CoordText," BR, "," Bee, Arr; ") end if self.ShowMagnetic then - text=string.gsub(text,"°M|","° magnetic, ") + text=string.gsub(text,"°M|","° magnetic; ") + end + if string.find(CoordText,"MGRS") then + local Text = string.gsub(CoordText,"%d","%1;") -- "0 5 1 " + Text = string.gsub(Text," $","") -- "0 5 1" + CoordText = string.gsub(Text,"0","zero") + CoordText = string.gsub(Text,"MGRS","MGRS;") + if self.PathToGoogleKey then + CoordText = string.format("%s",CoordText) + end + --self:I(self.lid.." | ".. CoordText) end local ThreatLocaleTextTTS = self.gettext:GetEntry("THREATTEXTTTS",self.locale) local ttstext = string.format(ThreatLocaleTextTTS,self.MenuName or self.Name,ttsplayername,ttstaskname,ThreatLevelText, targets, CoordText) From 9ea4a5dbd4c22b8c01ac9b7b1b7581c07654448a Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 6 Dec 2022 12:49:27 +0100 Subject: [PATCH 7/9] #CTLD less log noise --- Moose Development/Moose/Ops/CTLD.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index e36752b3f..61ff3edbf 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -4621,7 +4621,7 @@ end -- @param Wrapper.Group#GROUP Vehicle The #GROUP object of the vehicle or FOB build. -- @return #CTLD self function CTLD:onbeforeCratesBuild(From, Event, To, Group, Unit, Vehicle) - self:I({From, Event, To}) + self:T({From, Event, To}) if Unit and Unit:IsPlayer() and self.PlayerTaskQueue then local playername = Unit:GetPlayerName() local dropcoord = Vehicle:GetCoordinate() or COORDINATE:New(0,0,0) From 525666be7caf40fa8c73d591f56dff6ffb2c78fb Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 6 Dec 2022 18:05:41 +0100 Subject: [PATCH 8/9] #PLAYERRECCE * Smoke own position on ground, not mid-air --- Moose Development/Moose/Ops/PlayerRecce.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerRecce.lua b/Moose Development/Moose/Ops/PlayerRecce.lua index f71b33fa8..0d0ce1166 100644 --- a/Moose Development/Moose/Ops/PlayerRecce.lua +++ b/Moose Development/Moose/Ops/PlayerRecce.lua @@ -104,7 +104,7 @@ PLAYERRECCE = { ClassName = "PLAYERRECCE", verbose = true, lid = nil, - version = "0.0.15", + version = "0.0.16", ViewZone = {}, ViewZoneVisual = {}, ViewZoneLaser = {}, @@ -958,9 +958,11 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername) end if self.SmokeOwn[playername] then - local cc = client:GetCoordinate() + local cc = client:GetVec2() + -- don't smoke mid-air + local lc = COORDINATE:NewFromVec2(cc,1) local color = self.SmokeColor.ownsmoke - cc:Smoke(color) + lc:Smoke(color) end return self From 813d4edc970915de04591762e02b249d59f88fec Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 7 Dec 2022 18:35:12 +0100 Subject: [PATCH 9/9] CONDITION v0.3.0 - Added methods to remove condition functions - Added option to define output if no condition functions at all were given - --- Moose Development/Moose/Core/Condition.lua | 145 +++++++++++++++++---- 1 file changed, 122 insertions(+), 23 deletions(-) diff --git a/Moose Development/Moose/Core/Condition.lua b/Moose Development/Moose/Core/Condition.lua index 80f80cf52..7e9842a7b 100644 --- a/Moose Development/Moose/Core/Condition.lua +++ b/Moose Development/Moose/Core/Condition.lua @@ -25,10 +25,13 @@ -- @field #string lid Class id string for output to DCS log file. -- @field #string name Name of the condition. -- @field #boolean isAny General functions are evaluated as any condition. --- @field #boolean negateResult Negeate result of evaluation. +-- @field #boolean negateResult Negate result of evaluation. +-- @field #boolean noneResult Boolean that is returned if no condition functions at all were specified. -- @field #table functionsGen General condition functions. -- @field #table functionsAny Any condition functions. -- @field #table functionsAll All condition functions. +-- @field #number functionCounter Running number to determine the unique ID of condition functions. +-- @field #boolean defaultPersist Default persistence of condition functions. -- -- @extends Core.Base#BASE @@ -42,27 +45,34 @@ -- -- @field #CONDITION CONDITION = { - ClassName = "CONDITION", - lid = nil, - functionsGen = {}, - functionsAny = {}, - functionsAll = {}, + ClassName = "CONDITION", + lid = nil, + functionsGen = {}, + functionsAny = {}, + functionsAll = {}, + functionCounter = 0, + defaultPersist = false, } --- Condition function. -- @type CONDITION.Function --- @field #function func Callback function to check for a condition. Should return a `#boolean`. +-- @field #number uid Unique ID of the condition function. +-- @field #string type Type of the condition function: "gen", "any", "all". +-- @field #boolean persistence If `true`, this is persistent. +-- @field #function func Callback function to check for a condition. Must return a `#boolean`. -- @field #table arg (Optional) Arguments passed to the condition callback function if any. --- CONDITION class version. -- @field #string version -CONDITION.version="0.2.0" +CONDITION.version="0.3.0" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- TODO list ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO: Make FSM. +-- TODO: Make FSM. No sure if really necessary. +-- DONE: Option to remove condition functions. +-- DONE: Persistence option for condition functions. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor @@ -79,6 +89,8 @@ function CONDITION:New(Name) self.name=Name or "Condition X" + self:SetNoneResult(false) + self.lid=string.format("%s | ", self.name) return self @@ -102,6 +114,28 @@ function CONDITION:SetNegateResult(Negate) return self end +--- Set whether `true` or `false` is returned, if no conditions at all were specified. By default `false` is returned. +-- @param #CONDITION self +-- @param #boolean ReturnValue Returns this boolean. +-- @return #CONDITION self +function CONDITION:SetNoneResult(ReturnValue) + if not ReturnValue then + self.noneResult=false + else + self.noneResult=true + end + return self +end + +--- Set whether condition functions are persistent, *i.e.* are removed. +-- @param #CONDITION self +-- @param #boolean IsPersistent If `true`, condition functions are persistent. +-- @return #CONDITION self +function CONDITION:SetDefaultPersistence(IsPersistent) + self.defaultPersist=IsPersistent + return self +end + --- Add a function that is evaluated. It must return a `#boolean` value, *i.e.* either `true` or `false` (or `nil`). -- @param #CONDITION self -- @param #function Function The function to call. @@ -114,47 +148,109 @@ end -- -- myCondition:AddFunction(isAequalB, a, b) -- --- @return #CONDITION self +-- @return #CONDITION.Function Condition function table. function CONDITION:AddFunction(Function, ...) -- Condition function. - local condition=self:_CreateCondition(Function, ...) + local condition=self:_CreateCondition(0, Function, ...) -- Add to table. table.insert(self.functionsGen, condition) - return self + return condition end --- Add a function that is evaluated. It must return a `#boolean` value, *i.e.* either `true` or `false` (or `nil`). -- @param #CONDITION self -- @param #function Function The function to call. -- @param ... (Optional) Parameters passed to the function (if any). --- @return #CONDITION self +-- @return #CONDITION.Function Condition function table. function CONDITION:AddFunctionAny(Function, ...) -- Condition function. - local condition=self:_CreateCondition(Function, ...) + local condition=self:_CreateCondition(1, Function, ...) -- Add to table. table.insert(self.functionsAny, condition) - return self + return condition end --- Add a function that is evaluated. It must return a `#boolean` value, *i.e.* either `true` or `false` (or `nil`). -- @param #CONDITION self -- @param #function Function The function to call. -- @param ... (Optional) Parameters passed to the function (if any). --- @return #CONDITION self +-- @return #CONDITION.Function Condition function table. function CONDITION:AddFunctionAll(Function, ...) -- Condition function. - local condition=self:_CreateCondition(Function, ...) + local condition=self:_CreateCondition(2, Function, ...) -- Add to table. table.insert(self.functionsAll, condition) + return condition +end + +--- Remove a condition function. +-- @param #CONDITION self +-- @param #CONDITION.Function ConditionFunction The condition function to be removed. +-- @return #CONDITION self +function CONDITION:RemoveFunction(ConditionFunction) + + if ConditionFunction then + + local data=nil + if ConditionFunction.type==0 then + data=self.functionsGen + elseif ConditionFunction.type==1 then + data=self.functionsAny + elseif ConditionFunction.type==2 then + data=self.functionsAll + end + + if data then + for i=#data,1,-1 do + local cf=data[i] --#CONDITION.Function + if cf.uid==ConditionFunction.uid then + self:T(self.lid..string.format("Removed ConditionFunction UID=%d", cf.uid)) + table.remove(data, i) + return self + end + end + end + + end + + return self +end + +--- Remove all non-persistant condition functions. +-- @param #CONDITION self +-- @return #CONDITION self +function CONDITION:RemoveNonPersistant() + + for i=#self.functionsGen,1,-1 do + local cf=self.functionsGen[i] --#CONDITION.Function + if not cf.persistence then + table.remove(self.functionsGen, i) + end + end + + for i=#self.functionsAll,1,-1 do + local cf=self.functionsAll[i] --#CONDITION.Function + if not cf.persistence then + table.remove(self.functionsAll, i) + end + end + + for i=#self.functionsAny,1,-1 do + local cf=self.functionsAny[i] --#CONDITION.Function + if not cf.persistence then + table.remove(self.functionsAny, i) + end + end + return self end @@ -167,11 +263,7 @@ function CONDITION:Evaluate(AnyTrue) -- Check if at least one function was given. if #self.functionsAll + #self.functionsAny + #self.functionsAll == 0 then - if self.negateResult then - return true - else - return false - end + return self.noneResult end -- Any condition for gen. @@ -280,13 +372,20 @@ end --- Create conditon function object. -- @param #CONDITION self +-- @param #number Ftype Function type: 0=Gen, 1=All, 2=Any. -- @param #function Function The function to call. -- @param ... (Optional) Parameters passed to the function (if any). -- @return #CONDITION.Function Condition function. -function CONDITION:_CreateCondition(Function, ...) +function CONDITION:_CreateCondition(Ftype, Function, ...) + + -- Increase counter. + self.functionCounter=self.functionCounter+1 local condition={} --#CONDITION.Function + condition.uid=self.functionCounter + condition.type=Ftype or 0 + condition.persistence=self.defaultPersist condition.func=Function condition.arg={} if arg then