From e746617139e4adcaf2f7ec3f411a03e7166db82b Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sun, 18 Aug 2024 13:58:18 +0200 Subject: [PATCH] #Rap up changes --- Moose Development/Moose/Core/Base.lua | 91 ++++++++++++++++++- Moose Development/Moose/Core/Message.lua | 32 ++++--- Moose Development/Moose/Core/Set.lua | 2 +- Moose Development/Moose/Core/Settings.lua | 33 ++++--- Moose Development/Moose/Core/Zone.lua | 2 +- .../Moose/Functional/Warehouse.lua | 2 +- Moose Development/Moose/Ops/CTLD.lua | 4 +- Moose Development/Moose/Sound/SRS.lua | 9 +- Moose Development/Moose/Sound/SoundOutput.lua | 6 +- Moose Development/Moose/Sound/UserSound.lua | 2 +- .../Moose/Wrapper/Controllable.lua | 4 +- .../Moose/Wrapper/Positionable.lua | 2 +- 12 files changed, 144 insertions(+), 45 deletions(-) diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index 30ba6d1a2..94d13a9a0 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -741,7 +741,31 @@ do -- Event Handling -- @function [parent=#BASE] OnEventPlayerEnterAircraft -- @param #BASE self -- @param Core.Event#EVENTDATA EventData The EventData structure. - + + --- Occurs when a player creates a dynamic cargo object from the F8 ground crew menu. + -- *** NOTE *** this is a workarounf for DCS not creating these events as of Aug 2024. + -- @function [parent=#BASE] OnEventNewDynamicCargo + -- @param #BASE self + -- @param Core.Event#EVENTDATA EventData The EventData structure. + + --- Occurs when a player loads a dynamic cargo object with the F8 ground crew menu into a helo. + -- *** NOTE *** this is a workarounf for DCS not creating these events as of Aug 2024. + -- @function [parent=#BASE] OnEventDynamicCargoLoaded + -- @param #BASE self + -- @param Core.Event#EVENTDATA EventData The EventData structure. + + --- Occurs when a player unloads a dynamic cargo object with the F8 ground crew menu from a helo. + -- *** NOTE *** this is a workarounf for DCS not creating these events as of Aug 2024. + -- @function [parent=#BASE] OnEventDynamicCargoUnloaded + -- @param #BASE self + -- @param Core.Event#EVENTDATA EventData The EventData structure. + + --- Occurs when a dynamic cargo crate is removed. + -- *** NOTE *** this is a workarounf for DCS not creating these events as of Aug 2024. + -- @function [parent=#BASE] OnEventDynamicCargoRemoved + -- @param #BASE self + -- @param Core.Event#EVENTDATA EventData The EventData structure. + end --- Creation of a Birth Event. @@ -862,6 +886,62 @@ end world.onEvent(Event) end + + --- Creation of a S_EVENT_NEW_DYNAMIC_CARGO event. + -- @param #BASE self + -- @param Wrapper.DynamicCargo#DYNAMICCARGO DynamicCargo the dynamic cargo object + function BASE:CreateEventNewDynamicCargo(DynamicCargo) + self:F({DynamicCargo}) + local Event = { + id = EVENTS.NewDynamicCargo, + time = timer.getTime(), + dynamiccargo = DynamicCargo, + initiator = DynamicCargo:GetDCSObject(), + } + world.onEvent( Event ) + end + + --- Creation of a S_EVENT_DYNAMIC_CARGO_LOADED event. + -- @param #BASE self + -- @param Wrapper.DynamicCargo#DYNAMICCARGO DynamicCargo the dynamic cargo object + function BASE:CreateEventDynamicCargoLoaded(DynamicCargo) + self:F({DynamicCargo}) + local Event = { + id = EVENTS.DynamicCargoLoaded, + time = timer.getTime(), + dynamiccargo = DynamicCargo, + initiator = DynamicCargo:GetDCSObject(), + } + world.onEvent( Event ) + end + + --- Creation of a S_EVENT_DYNAMIC_CARGO_UNLOADED event. + -- @param #BASE self + -- @param Wrapper.DynamicCargo#DYNAMICCARGO DynamicCargo the dynamic cargo object + function BASE:CreateEventDynamicCargoUnloaded(DynamicCargo) + self:F({DynamicCargo}) + local Event = { + id = EVENTS.DynamicCargoUnloaded, + time = timer.getTime(), + dynamiccargo = DynamicCargo, + initiator = DynamicCargo:GetDCSObject(), + } + world.onEvent( Event ) + end + + --- Creation of a S_EVENT_DYNAMIC_CARGO_REMOVED event. + -- @param #BASE self + -- @param Wrapper.DynamicCargo#DYNAMICCARGO DynamicCargo the dynamic cargo object + function BASE:CreateEventDynamicCargoRemoved(DynamicCargo) + self:F({DynamicCargo}) + local Event = { + id = EVENTS.DynamicCargoRemoved, + time = timer.getTime(), + dynamiccargo = DynamicCargo, + initiator = DynamicCargo:GetDCSObject(), + } + world.onEvent( Event ) + end --- The main event handling function... This function captures all events generated for the class. -- @param #BASE self @@ -1157,6 +1237,15 @@ function BASE:_Serialize(Arguments) return text end +----- (Internal) Serialize arguments +---- @param #BASE self +---- @param #table Arguments +---- @return #string Text +--function BASE:_Serialize(Arguments) +-- local text=UTILS.BasicSerialize(Arguments) +-- return text +--end + --- Trace a function call. This function is private. -- @param #BASE self -- @param Arguments A #table or any field. diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua index 1c73e2b03..f432c08f3 100644 --- a/Moose Development/Moose/Core/Message.lua +++ b/Moose Development/Moose/Core/Message.lua @@ -177,7 +177,7 @@ end -- -- -- Send the 2 messages created with the @{New} method to the Client Group. -- -- Note that the Message of MessageClient2 is overwriting the Message of MessageClient1. --- Client = CLIENT:FindByName("UnitNameOfMyClient") +-- Client = CLIENT:FindByName("NameOfClientUnit") -- -- MessageClient1 = MESSAGE:New( "Congratulations, you've just hit a target", 25, "Score" ):ToClient( Client ) -- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", 25, "Score" ):ToClient( Client ) @@ -192,7 +192,7 @@ end -- function MESSAGE:ToClient( Client, Settings ) self:F( Client ) - self:ToUnit(Client, Settings) + self:ToUnit(Client,Settings) return self end @@ -239,6 +239,7 @@ function MESSAGE:ToUnit( Unit, Settings ) if self.MessageDuration ~= 0 then self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) + local ID = Unit:GetID() trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration, self.ClearScreen ) end end @@ -377,7 +378,8 @@ end --- Sends a MESSAGE to all players. -- @param #MESSAGE self -- @param Core.Settings#Settings Settings (Optional) Settings for message display. --- @return #MESSAGE +-- @param #number Delay (Optional) Delay in seconds before the message is send. Default instantly (`nil`). +-- @return #MESSAGE self -- @usage -- -- -- Send a message created to all players. @@ -388,18 +390,24 @@ end -- MessageAll = MESSAGE:New( "To all Players: BLUE has won! Each player of BLUE wins 50 points!", 25, "End of Mission") -- MessageAll:ToAll() -- -function MESSAGE:ToAll( Settings ) +function MESSAGE:ToAll( Settings, Delay ) self:F() - if self.MessageType then - local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS - self.MessageDuration = Settings:GetMessageTime( self.MessageType ) - self.MessageCategory = "" -- self.MessageType .. ": " - end + if Delay and Delay>0 then + self:ScheduleOnce(Delay, MESSAGE.ToAll, self, Settings, 0) + else - if self.MessageDuration ~= 0 then - self:T( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ) .. " / " .. self.MessageDuration ) - trigger.action.outText( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen ) + if self.MessageType then + local Settings = Settings or _SETTINGS -- Core.Settings#SETTINGS + self.MessageDuration = Settings:GetMessageTime( self.MessageType ) + self.MessageCategory = "" -- self.MessageType .. ": " + end + + if self.MessageDuration ~= 0 then + self:T( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ) .. " / " .. self.MessageDuration ) + trigger.action.outText( self.MessageCategory .. self.MessageText:gsub( "\n$", "" ):gsub( "\n$", "" ), self.MessageDuration, self.ClearScreen ) + end + end return self diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index b8edf725c..7e5ee2944 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -27,7 +27,7 @@ -- * @{#SET_CARGO}: Defines a collection of @{Cargo.Cargo}s filtered by filter criteria. -- * @{#SET_ZONE}: Defines a collection of @{Core.Zone}s filtered by filter criteria. -- * @{#SET_SCENERY}: Defines a collection of @{Wrapper.Scenery}s added via a filtered @{#SET_ZONE}. --- * @{#SET_DYNAMICCARGO}: Defines a collection of @{Wrapper.DynamicCargo}s added via a filtered @{#SET_ZONE}. +-- * @{#SET_DYNAMICCARGO}: Defines a collection of @{Wrapper.DynamicCargo}s filtered by filter criteria. -- -- These classes are derived from @{#SET_BASE}, which contains the main methods to manage the collections. -- diff --git a/Moose Development/Moose/Core/Settings.lua b/Moose Development/Moose/Core/Settings.lua index ca5ecc80b..81a60a7f8 100644 --- a/Moose Development/Moose/Core/Settings.lua +++ b/Moose Development/Moose/Core/Settings.lua @@ -29,7 +29,9 @@ -- @module Core.Settings -- @image Core_Settings.JPG ---- @type SETTINGS + +--- +-- @type SETTINGS -- @extends Core.Base#BASE --- Takes care of various settings that influence the behavior of certain functionalities and classes within the MOOSE framework. @@ -218,7 +220,8 @@ SETTINGS = { SETTINGS.__Enum = {} ---- @type SETTINGS.__Enum.Era +--- +-- @type SETTINGS.__Enum.Era -- @field #number WWII -- @field #number Korea -- @field #number Cold @@ -491,7 +494,7 @@ do -- SETTINGS return (self.A2ASystem and self.A2ASystem == "MGRS") or (not self.A2ASystem and _SETTINGS:IsA2A_MGRS()) end - --- @param #SETTINGS self + -- @param #SETTINGS self -- @param Wrapper.Group#GROUP MenuGroup Group for which to add menus. -- @param #table RootMenu Root menu table -- @return #SETTINGS @@ -945,49 +948,49 @@ do -- SETTINGS return self end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:A2GMenuSystem( MenuGroup, RootMenu, A2GSystem ) self.A2GSystem = A2GSystem MESSAGE:New( string.format( "Settings: Default A2G coordinate system set to %s for all players!", A2GSystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:A2AMenuSystem( MenuGroup, RootMenu, A2ASystem ) self.A2ASystem = A2ASystem MESSAGE:New( string.format( "Settings: Default A2A coordinate system set to %s for all players!", A2ASystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuLL_DDM_Accuracy( MenuGroup, RootMenu, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy MESSAGE:New( string.format( "Settings: Default LL accuracy set to %s for all players!", LL_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuMGRS_Accuracy( MenuGroup, RootMenu, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy MESSAGE:New( string.format( "Settings: Default MGRS accuracy set to %s for all players!", MGRS_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuMWSystem( MenuGroup, RootMenu, MW ) self.Metric = MW MESSAGE:New( string.format( "Settings: Default measurement format set to %s for all players!", MW and "Metric" or "Imperial" ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuMessageTimingsSystem( MenuGroup, RootMenu, MessageType, MessageTime ) self:SetMessageTime( MessageType, MessageTime ) MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToAll() end do - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupA2GSystem( PlayerUnit, PlayerGroup, PlayerName, A2GSystem ) --BASE:E( {PlayerUnit:GetName(), A2GSystem } ) self.A2GSystem = A2GSystem @@ -998,7 +1001,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupA2ASystem( PlayerUnit, PlayerGroup, PlayerName, A2ASystem ) self.A2ASystem = A2ASystem MESSAGE:New( string.format( "Settings: A2A format set to %s for player %s.", A2ASystem, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1008,7 +1011,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupLL_DDM_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy MESSAGE:New( string.format( "Settings: LL format accuracy set to %d decimal places for player %s.", LL_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1018,7 +1021,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupMGRS_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy MESSAGE:New( string.format( "Settings: MGRS format accuracy set to %d for player %s.", MGRS_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1028,7 +1031,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupMWSystem( PlayerUnit, PlayerGroup, PlayerName, MW ) self.Metric = MW MESSAGE:New( string.format( "Settings: Measurement format set to %s for player %s.", MW and "Metric" or "Imperial", PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1038,7 +1041,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupMessageTimingsSystem( PlayerUnit, PlayerGroup, PlayerName, MessageType, MessageTime ) self:SetMessageTime( MessageType, MessageTime ) MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToGroup( PlayerGroup ) diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 934188d98..7750851cb 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -3641,7 +3641,7 @@ do -- ZONE_ELASTIC end - --- Create a convec hull. + --- Create a convex hull. -- @param #ZONE_ELASTIC self -- @param #table pl Points -- @return #table Points diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 7a3253bac..cab1d0899 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -1629,7 +1629,7 @@ WAREHOUSE = { -- @field #boolean arrived If true, asset arrived at its destination. -- -- @field #number damage Damage of asset group in percent. --- @field Ops.AirWing#AIRWING.Payload payload The payload of the asset. +-- @field Ops.Airwing#AIRWING.Payload payload The payload of the asset. -- @field Ops.OpsGroup#OPSGROUP flightgroup The flightgroup object. -- @field Ops.Cohort#COHORT cohort The cohort this asset belongs to. -- @field Ops.Legion#LEGION legion The legion this asset belonts to. diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 9ed163259..8cbbc45e3 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -2935,8 +2935,8 @@ 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 - --]] + if IsNoHook == true then GCloaded = false end + --]] --- Testing local distance = self:_GetDistance(location,staticpos) --self:T({name=static:GetName(),IsHook=IsHook,agl=agl,GCloaded=GCloaded,distance=string.format("%.2f",distance or 0)}) diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index 15738dd5a..3f621d594 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -1237,7 +1237,7 @@ function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture self:T({Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate} ) if Delay and Delay>0 then - self:ScheduleOnce(Delay, MSRS.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) + self:ScheduleOnce(Delay, self.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) else Frequencies = Frequencies or self:GetFrequencies() @@ -1559,8 +1559,8 @@ end function MSRS:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate) -- Debug info. - self:F("MSRS_BACKEND_DCSGRPC:_DCSgRPCtts()") - self:F({Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate}) + self:T("MSRS_BACKEND_DCSGRPC:_DCSgRPCtts()") + self:T({Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate}) local options = {} -- #MSRS.GRPCOptions @@ -1586,7 +1586,6 @@ function MSRS:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Lab -- Provider (win, gcloud, ...) local provider = self.provider or MSRS.Provider.WINDOWS - self:F({provider=provider}) -- Provider options: voice, credentials options.provider = {} @@ -1594,7 +1593,7 @@ function MSRS:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Lab -- Voice Voice=Voice or self:GetVoice(self.provider) or self.voice - + if Voice then -- We use a specific voice options.provider[provider].voice = Voice diff --git a/Moose Development/Moose/Sound/SoundOutput.lua b/Moose Development/Moose/Sound/SoundOutput.lua index 466d0fa22..552689fc8 100644 --- a/Moose Development/Moose/Sound/SoundOutput.lua +++ b/Moose Development/Moose/Sound/SoundOutput.lua @@ -24,7 +24,7 @@ do -- Sound Base - --- @type SOUNDBASE + -- @type SOUNDBASE -- @field #string ClassName Name of the class. -- @extends Core.Base#BASE @@ -100,7 +100,7 @@ end do -- Sound File - --- @type SOUNDFILE + -- @type SOUNDFILE -- @field #string ClassName Name of the class -- @field #string filename Name of the flag. -- @field #string path Directory path, where the sound file is located. This includes the final slash "/". @@ -292,7 +292,7 @@ end do -- Text-To-Speech - --- @type SOUNDTEXT + -- @type SOUNDTEXT -- @field #string ClassName Name of the class -- @field #string text Text to speak. -- @field #number duration Duration in seconds. diff --git a/Moose Development/Moose/Sound/UserSound.lua b/Moose Development/Moose/Sound/UserSound.lua index ceaeeb6e2..f78c42e78 100644 --- a/Moose Development/Moose/Sound/UserSound.lua +++ b/Moose Development/Moose/Sound/UserSound.lua @@ -21,7 +21,7 @@ do -- UserSound - --- @type USERSOUND + -- @type USERSOUND -- @extends Core.Base#BASE diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index a891a7ca6..e0b63e914 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1148,10 +1148,10 @@ function CONTROLLABLE:TaskStrafing( Vec2, AttackQty, Length, WeaponType, WeaponE id = 'Strafing', params = { point = Vec2, -- req - weaponType = WeaponType or 1073741822, + weaponType = WeaponType or 805337088, -- Default 805337088 corresponds to guns/cannons (805306368) + any rocket (30720). You can set other types but then the AI uses even bombs for a strafing run! expend = WeaponExpend or "Auto", attackQty = AttackQty or 1, -- req - attackQtyLimit = AttackQty >1 and true or false, + attackQtyLimit = AttackQty~=nil and true or false, direction = Direction and math.rad(Direction) or 0, directionEnabled = Direction and true or false, groupAttack = GroupAttack or false, diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index f181cbd23..fb552427d 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -671,7 +671,7 @@ function POSITIONABLE:GetBoundingRadius( MinDist ) return math.max( math.max( CX, CZ ), boxmin ) end - BASE:E( { "Cannot GetBoundingRadius", Positionable = self, Alive = self:IsAlive() } ) + BASE:T( { "Cannot GetBoundingRadius", Positionable = self, Alive = self:IsAlive() } ) return nil end