diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua
index 1551b5821..5d3450616 100644
--- a/Moose Development/Moose/Core/Message.lua
+++ b/Moose Development/Moose/Core/Message.lua
@@ -265,7 +265,7 @@ function MESSAGE:ToCoalition( CoalitionSide, Settings )
if CoalitionSide then
if self.MessageDuration ~= 0 then
self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration )
- trigger.action.outTextForCoalition( CoalitionSide, self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration )
+ trigger.action.outTextForCoalition( CoalitionSide, self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration )
end
end
diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua
index 8fefad5d5..3f48db8b3 100644
--- a/Moose Development/Moose/Core/Set.lua
+++ b/Moose Development/Moose/Core/Set.lua
@@ -113,6 +113,38 @@ function SET_BASE:GetSet()
return self.Set
end
+--- Gets a list of the Names of the Objects in the Set.
+-- @param #SET_BASE self
+-- @return #SET_BASE self
+function SET_BASE:GetSetNames() -- R2.3
+ self:F2()
+
+ local Names = {}
+
+ for Name, Object in pairs( self.Set ) do
+ table.insert( Names, Name )
+ end
+
+ return Names
+end
+
+
+--- Gets a list of the Objects in the Set.
+-- @param #SET_BASE self
+-- @return #SET_BASE self
+function SET_BASE:GetSetObjects() -- R2.3
+ self:F2()
+
+ local Objects = {}
+
+ for Name, Object in pairs( self.Set ) do
+ table.insert( Objects, Object )
+ end
+
+ return Objects
+end
+
+
--- Adds a @{Base#BASE} object in the @{Set#SET_BASE}, using a given ObjectName as the index.
-- @param #SET_BASE self
-- @param #string ObjectName
diff --git a/Moose Development/Moose/Core/SpawnStatic.lua b/Moose Development/Moose/Core/SpawnStatic.lua
index 0d2b01109..2bc29f6c5 100644
--- a/Moose Development/Moose/Core/SpawnStatic.lua
+++ b/Moose Development/Moose/Core/SpawnStatic.lua
@@ -116,6 +116,33 @@ function SPAWNSTATIC:NewFromType( SpawnTypeName, SpawnShapeName, SpawnCategory,
return self
end
+--- Creates a new @{Static} at the original position.
+-- @param #SPAWNSTATIC self
+-- @param #number Heading The heading of the static, which is a number in degrees from 0 to 360.
+-- @param #string (optional) The name of the new static.
+-- @return #SPAWNSTATIC
+function SPAWNSTATIC:Spawn( Heading, NewName ) --R2.3
+ self:F( { Heading, NewName } )
+
+ local CountryName = _DATABASE.COUNTRY_NAME[self.CountryID]
+
+ local StaticTemplate = _DATABASE:GetStaticUnitTemplate( self.SpawnTemplatePrefix )
+
+ StaticTemplate.name = NewName or string.format("%s#%05d", self.SpawnTemplatePrefix, self.SpawnIndex )
+ StaticTemplate.heading = ( Heading / 180 ) * math.pi
+
+ StaticTemplate.CountryID = nil
+ StaticTemplate.CoalitionID = nil
+ StaticTemplate.CategoryID = nil
+
+ local Static = coalition.addStaticObject( self.CountryID, StaticTemplate )
+
+ self.SpawnIndex = self.SpawnIndex + 1
+
+ return Static
+end
+
+
--- Creates a new @{Static} from a POINT_VEC2.
-- @param #SPAWNSTATIC self
diff --git a/Moose Development/Moose/Core/UserFlag.lua b/Moose Development/Moose/Core/UserFlag.lua
new file mode 100644
index 000000000..67c03a127
--- /dev/null
+++ b/Moose Development/Moose/Core/UserFlag.lua
@@ -0,0 +1,93 @@
+--- **Core (WIP)** -- Manage user flags.
+--
+-- ====
+--
+-- Management of DCS User Flags.
+--
+-- ====
+--
+-- ### Author: **Sven Van de Velde (FlightControl)**
+--
+-- ====
+--
+-- @module UserFlag
+
+do -- UserFlag
+
+ --- @type USERFLAG
+ -- @extends Core.Base#BASE
+
+
+ --- # USERFLAG class, extends @{Base#BASE}
+ --
+ -- Management of DCS User Flags.
+ --
+ -- ## 1. USERFLAG constructor
+ --
+ -- * @{#USERFLAG.New}(): Creates a new USERFLAG object.
+ --
+ -- @field #USERFLAG
+ USERFLAG = {
+ ClassName = "USERFLAG",
+ }
+
+ --- USERFLAG Constructor.
+ -- @param #USERFLAG self
+ -- @param #string UserFlagName The name of the userflag, which is a free text string.
+ -- @return #USERFLAG
+ function USERFLAG:New( UserFlagName ) --R2.3
+
+ local self = BASE:Inherit( self, BASE:New() ) -- #USERFLAG
+
+ self.UserFlagName = UserFlagName
+
+ return self
+ end
+
+
+ --- Set the userflag to a given Number.
+ -- @param #USERFLAG self
+ -- @param #number Number The number value to be checked if it is the same as the userflag.
+ -- @return #USERFLAG The userflag instance.
+ -- @usage
+ -- local BlueVictory = USERFLAG:New( "VictoryBlue" )
+ -- BlueVictory:Set( 100 ) -- Set the UserFlag VictoryBlue to 100.
+ --
+ function USERFLAG:Set( Number ) --R2.3
+
+ trigger.misc.setUserFlag( self.UserFlagName )
+
+ return self
+ end
+
+
+ --- Get the userflag Number.
+ -- @param #USERFLAG self
+ -- @return #number Number The number value to be checked if it is the same as the userflag.
+ -- @usage
+ -- local BlueVictory = USERFLAG:New( "VictoryBlue" )
+ -- local BlueVictoryValue = BlueVictory:Get() -- Get the UserFlag VictoryBlue value.
+ --
+ function USERFLAG:Set( Number ) --R2.3
+
+ return trigger.misc.getUserFlag( self.UserFlagName )
+ end
+
+
+
+ --- Check if the userflag has a value of Number.
+ -- @param #USERFLAG self
+ -- @param #number Number The number value to be checked if it is the same as the userflag.
+ -- @return #boolean true if the Number is the value of the userflag.
+ -- @usage
+ -- local BlueVictory = USERFLAG:New( "VictoryBlue" )
+ -- if BlueVictory:Is( 1 ) then
+ -- return "Blue has won"
+ -- end
+ function USERFLAG:Is( Number ) --R2.3
+
+ return trigger.misc.getUserFlag( self.UserFlagName ) == Number
+
+ end
+
+end
\ No newline at end of file
diff --git a/Moose Development/Moose/Core/UserSound.lua b/Moose Development/Moose/Core/UserSound.lua
new file mode 100644
index 000000000..ff1c316c8
--- /dev/null
+++ b/Moose Development/Moose/Core/UserSound.lua
@@ -0,0 +1,129 @@
+--- **Core (WIP)** -- Manage user sound.
+--
+-- ====
+--
+-- Management of DCS User Sound.
+--
+-- ====
+--
+-- ### Author: **Sven Van de Velde (FlightControl)**
+--
+-- ====
+--
+-- @module UserSound
+
+do -- UserSound
+
+ --- @type USERSOUND
+ -- @extends Core.Base#BASE
+
+
+ --- # USERSOUND class, extends @{Base#BASE}
+ --
+ -- Management of DCS User Sound.
+ --
+ -- ## 1. USERSOUND constructor
+ --
+ -- * @{#USERSOUND.New}(): Creates a new USERSOUND object.
+ --
+ -- @field #USERSOUND
+ USERSOUND = {
+ ClassName = "USERSOUND",
+ }
+
+ --- USERSOUND Constructor.
+ -- @param #USERSOUND self
+ -- @param #string UserSoundFileName The filename of the usersound.
+ -- @return #USERSOUND
+ function USERSOUND:New( UserSoundFileName ) --R2.3
+
+ local self = BASE:Inherit( self, BASE:New() ) -- #USERSOUND
+
+ self.UserSoundFileName = UserSoundFileName
+
+ return self
+ end
+
+
+ --- Set usersound filename.
+ -- @param #USERSOUND self
+ -- @param #string UserSoundFileName The filename of the usersound.
+ -- @return #USERSOUND The usersound instance.
+ -- @usage
+ -- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ -- BlueVictory:SetFileName( "BlueVictoryLoud.ogg" ) -- Set the BlueVictory to change the file name to play a louder sound.
+ --
+ function USERSOUND:SetFileName( UserSoundFileName ) --R2.3
+
+ self.UserSoundFileName = UserSoundFileName
+
+ return self
+ end
+
+
+
+
+ --- Play the usersound to all players.
+ -- @param #USERSOUND self
+ -- @return #USERSOUND The usersound instance.
+ -- @usage
+ -- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ -- BlueVictory:ToAll() -- Play the sound that Blue has won.
+ --
+ function USERSOUND:ToAll() --R2.3
+
+ trigger.action.outSound( self.UserSoundFileName )
+
+ return self
+ end
+
+
+ --- Play the usersound to the given coalition.
+ -- @param #USERSOUND self
+ -- @param Dcs.DCScoalition#coalition Coalition The coalition to play the usersound to.
+ -- @return #USERSOUND The usersound instance.
+ -- @usage
+ -- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ -- BlueVictory:ToCoalition( coalition.side.BLUE ) -- Play the sound that Blue has won to the blue coalition.
+ --
+ function USERSOUND:ToCoalition( Coalition ) --R2.3
+
+ trigger.action.outSoundForCoalition(Coalition, self.UserSoundFileName )
+
+ return self
+ end
+
+
+ --- Play the usersound to the given country.
+ -- @param #USERSOUND self
+ -- @param Dcs.DCScountry#country Country The country to play the usersound to.
+ -- @return #USERSOUND The usersound instance.
+ -- @usage
+ -- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ -- BlueVictory:ToCountry( country.id.USA ) -- Play the sound that Blue has won to the USA country.
+ --
+ function USERSOUND:ToCountry( Country ) --R2.3
+
+ trigger.action.outSoundForCountry( Country, self.UserSoundFileName )
+
+ return self
+ end
+
+
+ --- Play the usersound to the given @{Group}.
+ -- @param #USERSOUND self
+ -- @param Wrapper.Group#GROUP Group The @{Group} to play the usersound to.
+ -- @return #USERSOUND The usersound instance.
+ -- @usage
+ -- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ -- local PlayerGroup = GROUP:FindByName( "PlayerGroup" ) -- Search for the active group named "PlayerGroup", that contains a human player.
+ -- BlueVictory:ToGroup( PlayerGroup ) -- Play the sound that Blue has won to the player group.
+ --
+ function USERSOUND:ToGroup( Group ) --R2.3
+
+ trigger.action.outSoundForGroup( Group:GetID(), self.UserSoundFileName )
+
+ return self
+ end
+
+end
\ No newline at end of file
diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua
index 029cc8cde..90f43f470 100644
--- a/Moose Development/Moose/Core/Zone.lua
+++ b/Moose Development/Moose/Core/Zone.lua
@@ -634,8 +634,31 @@ function ZONE_RADIUS:CountScannedCoalitions()
end
+--- Get Coalitions of the units in the Zone, or Check if there are units of the given Coalition in the Zone.
+-- Returns nil if there are none ot two Coalitions in the zone!
+-- Returns one Coalition if there are only Units of one Coalition in the Zone.
+-- Returns the Coalition for the given Coalition if there are units of the Coalition in the Zone
+-- @param #ZONE_RADIUS self
+-- @return #table
function ZONE_RADIUS:GetScannedCoalition( Coalition )
- return self.ScanData.Coalitions[Coalition]
+
+ if Coalition then
+ return self.ScanData.Coalitions[Coalition]
+ else
+ local Count = 0
+ local ReturnCoalition = nil
+
+ for CoalitionID, Coalition in pairs( self.ScanData.Coalitions ) do
+ Count = Count + 1
+ ReturnCoalition = CoalitionID
+ end
+
+ if Count ~= 1 then
+ ReturnCoalition = nil
+ end
+
+ return ReturnCoalition
+ end
end
@@ -699,26 +722,6 @@ function ZONE_RADIUS:IsNoneInZone()
end
---- Get the Zone Coalitions.
--- Returns nil if there are none ot two coalitions in the zone!
--- @param #ZONE_RADIUS self
--- @return Coalitions
-function ZONE_RADIUS:GetCoalition()
-
- local Count = 0
- local ReturnCoalition = nil
-
- for CoalitionID, Coalition in pairs( self.Coalitions ) do
- Count = Count + 1
- ReturnCoalition = CoalitionID
- end
-
- if Count ~= 1 then
- ReturnCoalition = nil
- end
-
- return ReturnCoalition
-end
--- Searches the zone
diff --git a/Moose Development/Moose/Functional/Scoring.lua b/Moose Development/Moose/Functional/Scoring.lua
index 182b79e48..3831475fb 100644
--- a/Moose Development/Moose/Functional/Scoring.lua
+++ b/Moose Development/Moose/Functional/Scoring.lua
@@ -650,6 +650,36 @@ function SCORING:_AddPlayerFromUnit( UnitData )
end
+--- Add a goal score for a player.
+-- The method takes the Player name for which the Goal score needs to be set.
+-- The GoalTag is a string or identifier that is taken into the CSV file scoring log to identify the goal.
+-- A free text can be given that is shown to the players.
+-- The Score can be both positive and negative.
+-- @param #SCORING self
+-- @param #string PlayerName The name of the Player.
+-- @param #string GoalTag The string or identifier that is used in the CSV file to identify the goal (sort or group later in Excel).
+-- @param #string Text A free text that is shown to the players.
+-- @param #number Score The score can be both positive or negative ( Penalty ).
+function SCORING:AddGoalScorePlayer( PlayerName, GoalTag, Text, Score )
+
+ self:E( { PlayerName, PlayerName, GoalTag, Text, Score } )
+
+ -- PlayerName can be nil, if the Unit with the player crashed or due to another reason.
+ if PlayerName then
+ local PlayerData = self.Players[PlayerName]
+
+ PlayerData.Goals[GoalTag] = PlayerData.Goals[GoalTag] or { Score = 0 }
+ PlayerData.Goals[GoalTag].Score = PlayerData.Goals[GoalTag].Score + Score
+ PlayerData.Score = PlayerData.Score + Score
+
+ MESSAGE:NewType( self.DisplayMessagePrefix .. Text, MESSAGE.Type.Information ):ToAll()
+
+ self:ScoreCSV( PlayerName, "", "GOAL_" .. string.upper( GoalTag ), 1, Score, nil )
+ end
+end
+
+
+
--- Add a goal score for a player.
-- The method takes the PlayerUnit for which the Goal score needs to be set.
-- The GoalTag is a string or identifier that is taken into the CSV file scoring log to identify the goal.
diff --git a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua
index 0c4975b28..d99c4c1c0 100644
--- a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua
+++ b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua
@@ -308,11 +308,11 @@ do -- ZoneGoal
end
if self.Coalition == coalition.side.BLUE then
- self.MarkBlue = Coord:MarkToCoalitionBlue( "Guard Zone: " .. ZoneName .. "\nStatus: " .. State )
- self.MarkRed = Coord:MarkToCoalitionRed( "Capture Zone: " .. ZoneName .. "\nStatus: " .. State )
+ self.MarkBlue = Coord:MarkToCoalitionBlue( "Coalition: Blue\nGuard Zone: " .. ZoneName .. "\nStatus: " .. State )
+ self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Blue\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State )
else
- self.MarkRed = Coord:MarkToCoalitionRed( "Guard Zone: " .. ZoneName .. "\nStatus: " .. State )
- self.MarkBlue = Coord:MarkToCoalitionBlue( "Capture Zone: " .. ZoneName .. "\nStatus: " .. State )
+ self.MarkRed = Coord:MarkToCoalitionRed( "Coalition: Red\nGuard Zone: " .. ZoneName .. "\nStatus: " .. State )
+ self.MarkBlue = Coord:MarkToCoalitionBlue( "Coalition: Red\nCapture Zone: " .. ZoneName .. "\nStatus: " .. State )
end
end
@@ -336,7 +336,7 @@ do -- ZoneGoal
--self:GetParent( self ):onenterCaptured()
- local NewCoalition = self.Zone:GetCoalition()
+ local NewCoalition = self.Zone:GetScannedCoalition()
self:E( { NewCoalition = NewCoalition } )
self:SetCoalition( NewCoalition )
diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua
index 02c6b2ec3..177875c89 100644
--- a/Moose Development/Moose/Wrapper/Positionable.lua
+++ b/Moose Development/Moose/Wrapper/Positionable.lua
@@ -415,7 +415,7 @@ function POSITIONABLE:GetMessageText( Message, Name ) --R2.1 added
local DCSObject = self:GetDCSObject()
if DCSObject then
- Name = Name and ( " => " .. Name ) or ""
+ Name = Name and ( " (" .. Name .. ")" ) or ""
local Callsign = string.format( "%s", self:GetCallsign() ~= "" and self:GetCallsign() or self:GetName() )
local MessageText = string.format("[%s%s]: %s", Callsign, Name, Message )
return MessageText
@@ -489,12 +489,6 @@ function POSITIONABLE:MessageToCoalition( Message, Duration, MessageCoalition )
local DCSObject = self:GetDCSObject()
if DCSObject then
- if MessageCoalition == coalition.side.BLUE then
- Name = "Blue coalition"
- end
- if MessageCoalition == coalition.side.RED then
- Name = "Red coalition"
- end
self:GetMessage( Message, Duration, Name ):ToCoalition( MessageCoalition )
end
@@ -515,12 +509,6 @@ function POSITIONABLE:MessageTypeToCoalition( Message, MessageType, MessageCoali
local DCSObject = self:GetDCSObject()
if DCSObject then
- if MessageCoalition == coalition.side.BLUE then
- Name = "Blue coalition"
- end
- if MessageCoalition == coalition.side.RED then
- Name = "Red coalition"
- end
self:GetMessageType( Message, MessageType, Name ):ToCoalition( MessageCoalition )
end
diff --git a/Moose Mission Setup/Moose.files b/Moose Mission Setup/Moose.files
index 9c19c0000..348844d93 100644
--- a/Moose Mission Setup/Moose.files
+++ b/Moose Mission Setup/Moose.files
@@ -2,6 +2,8 @@ Utilities/Routines.lua
Utilities/Utils.lua
Core/Base.lua
+Core/UserFlag.lua
+Core/UserSound.lua
Core/Report.lua
Core/Scheduler.lua
Core/ScheduleDispatcher.lua
diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua
index a1ae2c475..2b0c46928 100644
--- a/Moose Mission Setup/Moose.lua
+++ b/Moose Mission Setup/Moose.lua
@@ -1,5 +1,5 @@
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
-env.info( 'Moose Generation Timestamp: 20171009_1446' )
+env.info( 'Moose Generation Timestamp: 20171010_1107' )
local base = _G
@@ -24,6 +24,8 @@ __Moose.Includes = {}
__Moose.Include( 'Utilities/Routines.lua' )
__Moose.Include( 'Utilities/Utils.lua' )
__Moose.Include( 'Core/Base.lua' )
+__Moose.Include( 'Core/UserFlag.lua' )
+__Moose.Include( 'Core/UserSound.lua' )
__Moose.Include( 'Core/Report.lua' )
__Moose.Include( 'Core/Scheduler.lua' )
__Moose.Include( 'Core/ScheduleDispatcher.lua' )
diff --git a/Moose Mission Setup/Moose_.lua b/Moose Mission Setup/Moose_.lua
index 92d010362..3facc6990 100644
--- a/Moose Mission Setup/Moose_.lua
+++ b/Moose Mission Setup/Moose_.lua
@@ -1,5 +1,5 @@
env.info('*** MOOSE DYNAMIC INCLUDE START *** ')
-env.info('Moose Generation Timestamp: 20171009_1446')
+env.info('Moose Generation Timestamp: 20171010_1107')
local base=_G
__Moose={}
__Moose.Include=function(IncludeFile)
@@ -19,6 +19,8 @@ __Moose.Includes={}
__Moose.Include('Utilities/Routines.lua')
__Moose.Include('Utilities/Utils.lua')
__Moose.Include('Core/Base.lua')
+__Moose.Include('Core/UserFlag.lua')
+__Moose.Include('Core/UserSound.lua')
__Moose.Include('Core/Report.lua')
__Moose.Include('Core/Scheduler.lua')
__Moose.Include('Core/ScheduleDispatcher.lua')
diff --git a/docs/Documentation/AI_A2A.html b/docs/Documentation/AI_A2A.html
index 090470fc4..38af29dd8 100644
--- a/docs/Documentation/AI_A2A.html
+++ b/docs/Documentation/AI_A2A.html
@@ -99,6 +99,8 @@
The method takes the Player name for which the Goal score needs to be set.
+The GoalTag is a string or identifier that is taken into the CSV file scoring log to identify the goal.
+A free text can be given that is shown to the players.
+The Score can be both positive and negative.
+
+
Parameters
+
+
+
+
#string PlayerName :
+The name of the Player.
+
+
+
+
+
#string GoalTag :
+The string or identifier that is used in the CSV file to identify the goal (sort or group later in Excel).
+
+
+
+
+
#string Text :
+A free text that is shown to the players.
+
+
+
+
+
#number Score :
+The score can be both positive or negative ( Penalty ).
local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ BlueVictory:SetFileName( "BlueVictoryLoud.ogg" ) -- Set the BlueVictory to change the file name to play a louder sound.
+
local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ BlueVictory:ToCoalition( coalition.side.BLUE ) -- Play the sound that Blue has won to the blue coalition.
+
local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ BlueVictory:ToCountry( country.id.USA ) -- Play the sound that Blue has won to the USA country.
+
local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
+ local PlayerGroup = GROUP:FindByName( "PlayerGroup" ) -- Search for the active group named "PlayerGroup", that contains a human player.
+ BlueVictory:ToGroup( PlayerGroup ) -- Play the sound that Blue has won to the player group.
+
Get Coalitions of the units in the Zone, or Check if there are units of the given Coalition in the Zone.
+
+
+
Returns nil if there are none ot two Coalitions in the zone!
+Returns one Coalition if there are only Units of one Coalition in the Zone.
+Returns the Coalition for the given Coalition if there are units of the Coalition in the Zone