From 475153be4c0c511d670d712a3195751b7c09aae6 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 16 Nov 2023 16:10:47 +0100 Subject: [PATCH] #RANGE * Added coalition option to `New()` --- Moose Development/Moose/Functional/Range.lua | 27 ++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Functional/Range.lua b/Moose Development/Moose/Functional/Range.lua index 18630e30b..e9005ace0 100644 --- a/Moose Development/Moose/Functional/Range.lua +++ b/Moose Development/Moose/Functional/Range.lua @@ -105,6 +105,7 @@ -- @field Sound.SRS#MSRSQUEUE controlsrsQ SRS queue for range controller. -- @field Sound.SRS#MSRS instructmsrs SRS wrapper for range instructor. -- @field Sound.SRS#MSRSQUEUE instructsrsQ SRS queue for range instructor. +-- @field #number Coalition Coalition side for the menu, if any. -- @extends Core.Fsm#FSM --- *Don't only practice your art, but force your way into its secrets; art deserves that, for it and knowledge can raise man to the Divine.* - Ludwig van Beethoven @@ -355,7 +356,8 @@ RANGE = { targetsheet = nil, targetpath = nil, targetprefix = nil, -} + Coalition = nil, + } --- Default range parameters. -- @type RANGE.Defaults @@ -591,7 +593,7 @@ RANGE.MenuF10Root = nil --- Range script version. -- @field #string version -RANGE.version = "2.7.1" +RANGE.version = "2.7.3" -- TODO list: -- TODO: Verbosity level for messages. @@ -613,8 +615,9 @@ RANGE.version = "2.7.1" --- RANGE contructor. Creates a new RANGE object. -- @param #RANGE self -- @param #string RangeName Name of the range. Has to be unique. Will we used to create F10 menu items etc. +-- @param #number Coalition (optional) Coalition of the range, if any, e.g. coalition.side.BLUE. -- @return #RANGE RANGE object. -function RANGE:New( RangeName ) +function RANGE:New( RangeName, Coalition ) -- Inherit BASE. local self = BASE:Inherit( self, FSM:New() ) -- #RANGE @@ -622,7 +625,9 @@ function RANGE:New( RangeName ) -- Get range name. -- TODO: make sure that the range name is not given twice. This would lead to problems in the F10 radio menu. self.rangename = RangeName or "Practice Range" - + + self.Coalition = Coalition + -- Log id. self.lid = string.format( "RANGE %s | ", self.rangename ) @@ -1745,10 +1750,16 @@ function RANGE:OnEventBirth( EventData ) -- Reset current strafe status. self.strafeStatus[_uid] = nil - - -- Add Menu commands after a delay of 0.1 seconds. - self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName ) - + + if self.Coalition then + if EventData.IniCoalition == self.Coalition then + self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName ) + end + else + -- Add Menu commands after a delay of 0.1 seconds. + self:ScheduleOnce( 0.1, self._AddF10Commands, self, _unitName ) + end + -- By default, some bomb impact points and do not flare each hit on target. self.PlayerSettings[_playername] = {} -- #RANGE.PlayerData self.PlayerSettings[_playername].smokebombimpact = self.defaultsmokebomb