mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Progress
* Added USERFLAG class to manage user flags * Added USERSOUND class to manage sounds * Added SET_BASE:GetSetNames() to return an array of the object names of a Set. (Created dynamic lists based on mission editor groups defined). * Added SET_BASE:GetSetObjects() * Revised the Messages * Optimized the code for GetScannedCoalition * Markings text optimized for ZONE_CAPTURE_COALITION. Now the owning coalition is also shown. * Removed the stupid naming of messages to coalitions.
This commit is contained in:
parent
9bfca83804
commit
6f151a6c5d
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
93
Moose Development/Moose/Core/UserFlag.lua
Normal file
93
Moose Development/Moose/Core/UserFlag.lua
Normal file
@ -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
|
||||
129
Moose Development/Moose/Core/UserSound.lua
Normal file
129
Moose Development/Moose/Core/UserSound.lua
Normal file
@ -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
|
||||
@ -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 )
|
||||
|
||||
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
|
||||
|
||||
@ -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 )
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user