mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Merge branch 'develop' into FF/Ops
This commit is contained in:
commit
3a6b58ea8c
@ -10,6 +10,7 @@
|
||||
-- * Send message to all players.
|
||||
-- * Send messages to a coalition.
|
||||
-- * Send messages to a specific group.
|
||||
-- * Send messages to a specific unit or client.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@ -35,6 +36,7 @@
|
||||
--
|
||||
-- * To a @{Client} using @{#MESSAGE.ToClient}().
|
||||
-- * To a @{Wrapper.Group} using @{#MESSAGE.ToGroup}()
|
||||
-- * To a @{Wrapper.Unit} using @{#MESSAGE.ToUnit}()
|
||||
-- * To a coalition using @{#MESSAGE.ToCoalition}().
|
||||
-- * To the red coalition using @{#MESSAGE.ToRed}().
|
||||
-- * To the blue coalition using @{#MESSAGE.ToBlue}().
|
||||
@ -200,10 +202,13 @@ function MESSAGE:ToClient( Client, Settings )
|
||||
self.MessageCategory = "" -- self.MessageType .. ": "
|
||||
end
|
||||
|
||||
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.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
|
||||
|
||||
@ -233,6 +238,31 @@ function MESSAGE:ToGroup( Group, Settings )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Sends a MESSAGE to a Unit.
|
||||
-- @param #MESSAGE self
|
||||
-- @param Wrapper.Unit#UNIT Unit to which the message is displayed.
|
||||
-- @return #MESSAGE Message object.
|
||||
function MESSAGE:ToUnit( Unit, Settings )
|
||||
self:F( Unit.IdentifiableName )
|
||||
|
||||
if Unit then
|
||||
|
||||
if self.MessageType then
|
||||
local Settings = Settings or ( Unit and _DATABASE:GetPlayerSettings( Unit:GetPlayerName() ) ) 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.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration, self.ClearScreen )
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Sends a MESSAGE to the Blue coalition.
|
||||
-- @param #MESSAGE self
|
||||
-- @return #MESSAGE
|
||||
|
||||
@ -2768,9 +2768,10 @@ do -- COORDINATE
|
||||
--- Create a BRAA NATO call string to this COORDINATE from the FromCOORDINATE. Note - BRA delivered if no aspect can be obtained and "Merged" if range < 3nm
|
||||
-- @param #COORDINATE self
|
||||
-- @param #COORDINATE FromCoordinate The coordinate to measure the distance and the bearing from.
|
||||
-- @param #boolean Bogey Add "Bogey" at the end if true (not yet declared hostile or friendly)
|
||||
-- @param #boolean Spades Add "Spades" at the end if true (no IFF/VID ID yet known)
|
||||
-- @return #string The BRAA text.
|
||||
function COORDINATE:ToStringBRAANATO(FromCoordinate,Spades)
|
||||
function COORDINATE:ToStringBRAANATO(FromCoordinate,Bogey,Spades)
|
||||
|
||||
-- Thanks to @Pikey
|
||||
local BRAANATO = "Merged."
|
||||
@ -2796,8 +2797,12 @@ do -- COORDINATE
|
||||
else
|
||||
BRAANATO = string.format("BRAA, %03d, %d miles, Angels %d, %s, Track %s",bearing, rangeNM, alt, aspect, track)
|
||||
end
|
||||
if Spades then
|
||||
BRAANATO = BRAANATO..", Spades."
|
||||
if Bogey and Spades then
|
||||
BRAANATO = BRAANATO..", Bogey, Spades."
|
||||
elseif Bogey then
|
||||
BRAANATO = BRAANATO..", Bogey."
|
||||
elseif Spades then
|
||||
BRAANATO = BRAANATO..", Spades."
|
||||
else
|
||||
BRAANATO = BRAANATO.."."
|
||||
end
|
||||
|
||||
@ -1085,14 +1085,20 @@ do -- SET_GROUP
|
||||
-- Note that for each unit in the group that is set, a default cargo bay limit is initialized.
|
||||
-- @param Core.Set#SET_GROUP self
|
||||
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
||||
-- @param #boolean DontSetCargoBayLimit If true, do not attempt to auto-add the cargo bay limit per unit in this group.
|
||||
-- @return Core.Set#SET_GROUP self
|
||||
function SET_GROUP:AddGroup( group )
|
||||
function SET_GROUP:AddGroup( group, DontSetCargoBayLimit )
|
||||
|
||||
self:Add( group:GetName(), group )
|
||||
|
||||
-- I set the default cargo bay weight limit each time a new group is added to the set.
|
||||
for UnitID, UnitData in pairs( group:GetUnits() ) do
|
||||
UnitData:SetCargoBayWeightLimit()
|
||||
if not DontSetCargoBayLimit then
|
||||
-- I set the default cargo bay weight limit each time a new group is added to the set.
|
||||
-- TODO Why is this here in the first place?
|
||||
for UnitID, UnitData in pairs( group:GetUnits() ) do
|
||||
if UnitData and UnitData:IsAlive() then
|
||||
UnitData:SetCargoBayWeightLimit()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
|
||||
@ -3010,7 +3010,7 @@ function RANGE:_CheckInZone(_unitName)
|
||||
Straferesult.rangename=self.rangename
|
||||
|
||||
-- Save trap sheet.
|
||||
if playerData.targeton and self.targetsheet then
|
||||
if playerData and playerData.targeton and self.targetsheet then
|
||||
self:_SaveTargetSheet(_playername, result)
|
||||
end
|
||||
--RangeBoss edit for strafe data saved to file
|
||||
|
||||
@ -100,6 +100,7 @@ __Moose.Include( 'Scripts/Moose/Ops/OpsZone.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Chief.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Flotilla.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Fleet.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Awacs.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air.lua' )
|
||||
|
||||
@ -5713,7 +5713,7 @@ function AIRBOSS:_ScanCarrierZone()
|
||||
local putintomarshal = false
|
||||
|
||||
-- Get flight group.
|
||||
local flight = _DATABASE:GetFlightGroup( groupname )
|
||||
local flight = _DATABASE:GetOpsGroup( groupname )
|
||||
|
||||
if flight and flight:IsInbound() and flight.destbase:GetName() == self.carrier:GetName() then
|
||||
if flight.ishelo then
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -122,8 +122,11 @@ INTEL = {
|
||||
-- @field Ops.Auftrag#AUFTRAG mission The current Auftrag attached to this contact.
|
||||
-- @field Ops.Target#TARGET target The Target attached to this contact.
|
||||
-- @field #string recce The name of the recce unit that detected this contact.
|
||||
-- @field #string ctype Contact type.
|
||||
-- @field #string ctype Contact type of #INTEL.Ctype.
|
||||
-- @field #string platform [AIR] Contact platform name, e.g. Foxbat, Flanker_E, defaults to Bogey if unknown
|
||||
-- @field #number heading [AIR] Heading of the contact, if available.
|
||||
-- @field #boolean maneuvering [AIR] Contact has changed direction by >10 deg.
|
||||
-- @field #number altitude [AIR] Flight altitude of the contact in meters.
|
||||
|
||||
--- Cluster info.
|
||||
-- @type INTEL.Cluster
|
||||
@ -137,7 +140,8 @@ INTEL = {
|
||||
-- @field Wrapper.Marker#MARKER marker F10 marker.
|
||||
-- @field #number markerID Marker ID.
|
||||
-- @field Ops.Auftrag#AUFTRAG mission The current Auftrag attached to this cluster.
|
||||
-- @field #string ctype Cluster type.
|
||||
-- @field #string ctype Cluster type of #INTEL.Ctype.
|
||||
-- @field #number altitude [AIR] Average flight altitude of the cluster in meters.
|
||||
|
||||
--- Contact or cluster type.
|
||||
-- @type INTEL.Ctype
|
||||
@ -541,6 +545,7 @@ function INTEL:SetDetectStatics(Switch)
|
||||
else
|
||||
self.detectStatics=false
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set verbosity level for debugging.
|
||||
@ -692,6 +697,7 @@ function INTEL:onafterStart(From, Event, To)
|
||||
|
||||
-- Start the status monitoring.
|
||||
self:__Status(-math.random(10))
|
||||
return self
|
||||
end
|
||||
|
||||
--- On after "Status" event.
|
||||
@ -737,6 +743,7 @@ function INTEL:onafterStatus(From, Event, To)
|
||||
end
|
||||
|
||||
self:__Status(self.statusupdate)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@ -857,6 +864,7 @@ function INTEL:UpdateIntel()
|
||||
self:PaintPicture()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Update an #INTEL.Contact item.
|
||||
@ -877,11 +885,23 @@ function INTEL:_UpdateContact(Contact)
|
||||
Contact.position=Contact.group:GetCoordinate()
|
||||
Contact.velocity=Contact.group:GetVelocityVec3()
|
||||
Contact.speed=Contact.group:GetVelocityMPS()
|
||||
|
||||
if Contact.group:IsAir() then
|
||||
Contact.altitude=Contact.group:GetAltitude()
|
||||
local oldheading = Contact.heading or 1
|
||||
local newheading = Contact.group:GetHeading()
|
||||
if newheading == 0 then newheading = 1 end
|
||||
local changeh = math.abs(((oldheading - newheading) + 360) % 360)
|
||||
Contact.heading = newheading
|
||||
if changeh > 10 then
|
||||
Contact.maneuvering = true
|
||||
else
|
||||
Contact.maneuvering = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Create an #INTEL.Contact item from a given GROUP or STATIC object.
|
||||
@ -917,9 +937,13 @@ function INTEL:_CreateContact(Positionable, RecceName)
|
||||
item.isStatic=false
|
||||
if group:IsAir() then
|
||||
item.platform=group:GetNatoReportingName()
|
||||
item.heading = group:GetHeading()
|
||||
item.maneuvering = false
|
||||
item.altitude = group:GetAltitude()
|
||||
else
|
||||
-- TODO optionally add ground types?
|
||||
item.platform="Unknown"
|
||||
item.altitude = group:GetAltitude(true)
|
||||
end
|
||||
if item.category==Group.Category.AIRPLANE or item.category==Group.Category.HELICOPTER then
|
||||
item.ctype=INTEL.Ctype.AIRCRAFT
|
||||
@ -1006,7 +1030,7 @@ function INTEL:CreateDetectedItems(DetectedGroups, DetectedStatics, RecceDetecti
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Internal) Return the detected target groups of the controllable as a @{SET_GROUP}.
|
||||
@ -1084,7 +1108,7 @@ function INTEL:onafterNewContact(From, Event, To, Contact)
|
||||
|
||||
-- Add to table of unknown contacts.
|
||||
table.insert(self.ContactsUnknown, Contact)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- On after "LostContact" event.
|
||||
@ -1100,7 +1124,7 @@ function INTEL:onafterLostContact(From, Event, To, Contact)
|
||||
|
||||
-- Add to table of lost contacts.
|
||||
table.insert(self.ContactsLost, Contact)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- On after "NewCluster" event.
|
||||
@ -1116,7 +1140,7 @@ function INTEL:onafterNewCluster(From, Event, To, Cluster)
|
||||
|
||||
-- Add cluster to table.
|
||||
self:_AddCluster(Cluster)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- On after "LostCluster" event.
|
||||
@ -1137,7 +1161,7 @@ function INTEL:onafterLostCluster(From, Event, To, Cluster, Mission)
|
||||
end
|
||||
|
||||
self:T(text)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1261,7 +1285,7 @@ function INTEL:RemoveContact(Contact)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Check if a contact was lost.
|
||||
@ -1458,6 +1482,8 @@ function INTEL:PaintPicture()
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Create a new cluster.
|
||||
@ -1474,6 +1500,7 @@ function INTEL:_CreateCluster()
|
||||
cluster.threatlevelMax=0
|
||||
cluster.size=0
|
||||
cluster.Contacts={}
|
||||
cluster.altitude=0
|
||||
|
||||
-- Increase counter.
|
||||
self.clustercounter=self.clustercounter+1
|
||||
@ -1510,6 +1537,7 @@ function INTEL:_AddCluster(Cluster)
|
||||
-- Add cluster.
|
||||
table.insert(self.Clusters, Cluster)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add a contact to the cluster.
|
||||
@ -1529,10 +1557,14 @@ function INTEL:AddContactToCluster(contact, cluster)
|
||||
-- Increase size.
|
||||
cluster.size=cluster.size+1
|
||||
|
||||
-- alt
|
||||
self:GetClusterAltitude(cluster,true)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Adding contact %s to cluster #%d [%s] ==> New size=%d", contact.groupname, cluster.index, cluster.ctype, cluster.size))
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Remove a contact from a cluster.
|
||||
@ -1560,13 +1592,13 @@ function INTEL:RemoveContactFromCluster(contact, cluster)
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Removing contact %s from cluster #%d ==> New cluster size=%d", contact.groupname, cluster.index, cluster.size))
|
||||
|
||||
return
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Calculate cluster threat level sum.
|
||||
@ -1643,6 +1675,8 @@ function INTEL:CalcClusterDirection(cluster)
|
||||
-- Second group is going East, i.e. heading 270
|
||||
-- Total is 360/2=180, i.e. South!
|
||||
-- It should not go anywhere as the two movements cancel each other.
|
||||
-- Correct, edge case for N=2^x, but when 2 pairs of groups drive in exact opposite directions, the cluster will split at some point?
|
||||
-- maybe add the speed as weight to get a factor
|
||||
|
||||
if n==0 then
|
||||
return 0
|
||||
@ -1774,7 +1808,17 @@ function INTEL:IsContactConnectedToCluster(contact, cluster)
|
||||
--local dist=Contact.position:Get2DDistance(contact.position)
|
||||
local dist=Contact.position:DistanceFromPointVec2(contact.position)
|
||||
|
||||
if dist<self.clusterradius then
|
||||
-- AIR - check for spatial proximity
|
||||
local airprox = false
|
||||
if contact.ctype == INTEL.Ctype.AIRCRAFT then
|
||||
self:T(string.format("Cluster Alt=%d | Contact Alt=%d",cluster.altitude,contact.altitude))
|
||||
local adist = math.abs(cluster.altitude - contact.altitude)
|
||||
if adist < UTILS.FeetToMeters(10000) then -- limit to 10kft
|
||||
airprox = true
|
||||
end
|
||||
end
|
||||
|
||||
if dist<self.clusterradius and airprox then
|
||||
return true, dist
|
||||
end
|
||||
|
||||
@ -1839,6 +1883,10 @@ function INTEL:_GetClosestClusterOfContact(Contact)
|
||||
|
||||
local distmin=self.clusterradius
|
||||
|
||||
if not Contact.altitude then
|
||||
Contact.altitude = Contact.group:GetAltitude()
|
||||
end
|
||||
|
||||
for _,_cluster in pairs(self.Clusters) do
|
||||
local cluster=_cluster --#INTEL.Cluster
|
||||
|
||||
@ -1846,7 +1894,20 @@ function INTEL:_GetClosestClusterOfContact(Contact)
|
||||
|
||||
local dist=self:_GetDistContactToCluster(Contact, cluster)
|
||||
|
||||
if dist<distmin then
|
||||
-- AIR - check for spatial proximity
|
||||
local airprox = false
|
||||
if Contact.ctype == INTEL.Ctype.AIRCRAFT then
|
||||
if not cluster.altitude then
|
||||
cluster.altitude = self:GetClusterAltitude(cluster,true)
|
||||
end
|
||||
local adist = math.abs(cluster.altitude - Contact.altitude)
|
||||
self:T(string.format("Cluster Alt=%d | Contact Alt=%d",cluster.altitude,Contact.altitude))
|
||||
if adist < UTILS.FeetToMeters(10000) then
|
||||
airprox = true
|
||||
end
|
||||
end
|
||||
|
||||
if dist<distmin and airprox then
|
||||
Cluster=cluster
|
||||
distmin=dist
|
||||
end
|
||||
@ -1878,6 +1939,40 @@ function INTEL:GetClusterOfContact(contact)
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Get the altitude of a cluster.
|
||||
-- @param #INTEL self
|
||||
-- @param #INTEL.Cluster Cluster The cluster.
|
||||
-- @param #boolean Update If `true`, update the altitude. Default is to just return the last stored altitude.
|
||||
-- @return #number The average altitude (ASL) of this cluster in meters.
|
||||
function INTEL:GetClusterAltitude(Cluster, Update)
|
||||
|
||||
-- Init.
|
||||
local newalt = 0
|
||||
local n=0
|
||||
|
||||
-- Loop over all contacts.
|
||||
for _,_contact in pairs(Cluster.Contacts) do
|
||||
local contact=_contact --#INTEL.Contact
|
||||
if contact.altitude then
|
||||
newalt = newalt + contact.altitude
|
||||
n=n+1
|
||||
end
|
||||
end
|
||||
|
||||
-- Average.
|
||||
local avgalt = 0
|
||||
if n>0 then
|
||||
avgalt = newalt/n
|
||||
end
|
||||
|
||||
-- Update cluster coordinate.
|
||||
Cluster.altitude = avgalt
|
||||
|
||||
self:T(string.format("Updating Cluster Altitude: %d",Cluster.altitude))
|
||||
|
||||
return Cluster.altitude
|
||||
end
|
||||
|
||||
--- Get the coordinate of a cluster.
|
||||
-- @param #INTEL self
|
||||
-- @param #INTEL.Cluster Cluster The cluster.
|
||||
@ -1963,10 +2058,12 @@ function INTEL:_UpdateClusterPositions()
|
||||
|
||||
-- Update cluster coordinate.
|
||||
local coord = self:GetClusterCoordinate(cluster, true)
|
||||
local alt = self:GetClusterAltitude(cluster,true)
|
||||
|
||||
-- Debug info.
|
||||
self:T(self.lid..string.format("Updating Cluster position size: %s", cluster.size))
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Count number of alive units in contact.
|
||||
|
||||
@ -2085,7 +2085,7 @@ function OPSGROUP:RadioTransmission(Text, Delay, SayCallsign, Frequency)
|
||||
end
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Radio transmission on %.3f MHz %s: %s", freq, UTILS.GetModulationName(modu), Text))
|
||||
self:T(self.lid..string.format("Radio transmission on %.3f MHz %s: %s", freq, UTILS.GetModulationName(modu), Text))
|
||||
|
||||
self.msrs:PlayText(Text)
|
||||
end
|
||||
|
||||
@ -40,7 +40,7 @@ do -- UserSound
|
||||
-- @param #USERSOUND self
|
||||
-- @param #string UserSoundFileName The filename of the usersound.
|
||||
-- @return #USERSOUND
|
||||
function USERSOUND:New( UserSoundFileName ) --R2.3
|
||||
function USERSOUND:New( UserSoundFileName )
|
||||
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #USERSOUND
|
||||
|
||||
@ -58,7 +58,7 @@ do -- UserSound
|
||||
-- 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
|
||||
function USERSOUND:SetFileName( UserSoundFileName )
|
||||
|
||||
self.UserSoundFileName = UserSoundFileName
|
||||
|
||||
@ -75,7 +75,7 @@ do -- UserSound
|
||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||
-- BlueVictory:ToAll() -- Play the sound that Blue has won.
|
||||
--
|
||||
function USERSOUND:ToAll() --R2.3
|
||||
function USERSOUND:ToAll()
|
||||
|
||||
trigger.action.outSound( self.UserSoundFileName )
|
||||
|
||||
@ -91,7 +91,7 @@ do -- UserSound
|
||||
-- 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
|
||||
function USERSOUND:ToCoalition( Coalition )
|
||||
|
||||
trigger.action.outSoundForCoalition(Coalition, self.UserSoundFileName )
|
||||
|
||||
@ -107,7 +107,7 @@ do -- UserSound
|
||||
-- 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
|
||||
function USERSOUND:ToCountry( Country )
|
||||
|
||||
trigger.action.outSoundForCountry( Country, self.UserSoundFileName )
|
||||
|
||||
@ -123,9 +123,9 @@ do -- UserSound
|
||||
-- @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.
|
||||
-- BlueVictory:ToGroup( PlayerGroup ) -- Play the victory sound to the player group.
|
||||
--
|
||||
function USERSOUND:ToGroup( Group, Delay ) --R2.3
|
||||
function USERSOUND:ToGroup( Group, Delay )
|
||||
|
||||
Delay=Delay or 0
|
||||
if Delay>0 then
|
||||
@ -137,4 +137,26 @@ do -- UserSound
|
||||
return self
|
||||
end
|
||||
|
||||
--- Play the usersound to the given @{Wrapper.Unit}.
|
||||
-- @param #USERSOUND self
|
||||
-- @param Wrapper.Unit#UNIT Unit The @{Wrapper.Unit} to play the usersound to.
|
||||
-- @param #number Delay (Optional) Delay in seconds, before the sound is played. Default 0.
|
||||
-- @return #USERSOUND The usersound instance.
|
||||
-- @usage
|
||||
-- local BlueVictory = USERSOUND:New( "BlueVictory.ogg" )
|
||||
-- local PlayerUnit = UNIT:FindByName( "PlayerUnit" ) -- Search for the active unit named "PlayerUnit", a human player.
|
||||
-- BlueVictory:ToUnit( PlayerUnit ) -- Play the victory sound to the player unit.
|
||||
--
|
||||
function USERSOUND:ToUnit( Unit, Delay )
|
||||
|
||||
Delay=Delay or 0
|
||||
if Delay>0 then
|
||||
SCHEDULER:New(nil, USERSOUND.ToUnit,{self, Unit}, Delay)
|
||||
else
|
||||
trigger.action.outSoundForUnit( Unit:GetID(), self.UserSoundFileName )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
@ -509,11 +509,12 @@ ENUMS.ReportingName =
|
||||
Atlas = "A400",
|
||||
Lancer = "B1-B",
|
||||
Stratofortress = "B-52H",
|
||||
Hercules = "C-130", -- modded version has type name "Hercules", unfortunately
|
||||
Hercules = "C-130",
|
||||
Super_Hercules = "Hercules",
|
||||
Globemaster = "C-17",
|
||||
Greyhound = "C-2A",
|
||||
Galaxy = "C-5",
|
||||
Hawkexe = "E-2D",
|
||||
Hawkeye = "E-2D",
|
||||
Sentry = "E-3A",
|
||||
Stratotanker = "KC-135",
|
||||
Extender = "KC-10",
|
||||
|
||||
@ -249,7 +249,11 @@ end
|
||||
-- @return #boolean exists
|
||||
function FIFO:HasUniqueID(UniqueID)
|
||||
self:T(self.lid.."HasUniqueID")
|
||||
return self.stackbyid[UniqueID] and true or false
|
||||
if self.stackbyid[UniqueID] ~= nil then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
--- FIFO Get the data stack by UniqueID
|
||||
|
||||
@ -631,7 +631,7 @@ function GROUP:GetUnits()
|
||||
local DCSGroup = self:GetDCSObject()
|
||||
|
||||
if DCSGroup then
|
||||
local DCSUnits = DCSGroup:getUnits()
|
||||
local DCSUnits = DCSGroup:getUnits() or {}
|
||||
local Units = {}
|
||||
for Index, UnitData in pairs( DCSUnits ) do
|
||||
Units[#Units+1] = UNIT:Find( UnitData )
|
||||
@ -667,6 +667,29 @@ function GROUP:GetPlayerUnits()
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Check if an (air) group is a client or player slot. Information is retrieved from the group template.
|
||||
-- @param #GROUP self
|
||||
-- @return #boolean If true, group is associated with a client or player slot.
|
||||
function GROUP:IsPlayer()
|
||||
|
||||
-- Get group.
|
||||
-- local group=self:GetGroup()
|
||||
|
||||
-- Units of template group.
|
||||
local units=self:GetTemplate().units
|
||||
|
||||
-- Get numbers.
|
||||
for _,unit in pairs(units) do
|
||||
|
||||
-- Check if unit name matach and skill is Client or Player.
|
||||
if unit.name==self:GetName() and (unit.skill=="Client" or unit.skill=="Player") then
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--- Returns the UNIT wrapper class with number UnitNumber.
|
||||
-- If the underlying DCS Unit does not exist, the method will return nil. .
|
||||
@ -1028,15 +1051,24 @@ end
|
||||
-- @return Core.Point#COORDINATE The COORDINATE of the GROUP.
|
||||
function GROUP:GetCoordinate()
|
||||
|
||||
local FirstUnit = self:GetUnit(1)
|
||||
|
||||
if FirstUnit then
|
||||
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
||||
local Heading = self:GetHeading()
|
||||
FirstUnitCoordinate.Heading = Heading
|
||||
return FirstUnitCoordinate
|
||||
local Units = self:GetUnits() or {}
|
||||
|
||||
for _,_unit in pairs(Units) do
|
||||
local FirstUnit = _unit -- Wrapper.Unit#UNIT
|
||||
|
||||
if FirstUnit then
|
||||
|
||||
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
||||
|
||||
if FirstUnitCoordinate then
|
||||
local Heading = self:GetHeading()
|
||||
FirstUnitCoordinate.Heading = Heading
|
||||
return FirstUnitCoordinate
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
BASE:E( { "Cannot GetCoordinate", Group = self, Alive = self:IsAlive() } )
|
||||
|
||||
return nil
|
||||
|
||||
@ -1187,6 +1187,33 @@ function POSITIONABLE:MessageToGroup( Message, Duration, MessageGroup, Name )
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Send a message to a @{Wrapper.Unit}.
|
||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||
-- @param #POSITIONABLE self
|
||||
-- @param #string Message The message text
|
||||
-- @param DCS#Duration Duration The duration of the message.
|
||||
-- @param Wrapper.Unit#UNIT MessageUnit The UNIT object receiving the message.
|
||||
-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable.
|
||||
function POSITIONABLE:MessageToUnit( Message, Duration, MessageUnit, Name )
|
||||
self:F2( { Message, Duration } )
|
||||
|
||||
local DCSObject = self:GetDCSObject()
|
||||
if DCSObject then
|
||||
if DCSObject:isExist() then
|
||||
if MessageUnit:IsAlive() then
|
||||
self:GetMessage( Message, Duration, Name ):ToUnit( MessageUnit )
|
||||
else
|
||||
BASE:E( { "Message not sent to Unit; Unit is not alive...", Message = Message, MessageUnit = MessageUnit } )
|
||||
end
|
||||
else
|
||||
BASE:E( { "Message not sent to Unit; Positionable is not alive ...", Message = Message, Positionable = self, MessageUnit = MessageUnit } )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Send a message of a message type to a @{Wrapper.Group}.
|
||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||
-- @param #POSITIONABLE self
|
||||
@ -1231,6 +1258,30 @@ function POSITIONABLE:MessageToSetGroup( Message, Duration, MessageSetGroup, Nam
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Send a message to a @{Core.Set#SET_UNIT}.
|
||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||
-- @param #POSITIONABLE self
|
||||
-- @param #string Message The message text
|
||||
-- @param DCS#Duration Duration The duration of the message.
|
||||
-- @param Core.Set#SET_UNIT MessageSetUnit The SET_UNIT collection receiving the message.
|
||||
-- @param #string Name (optional) The Name of the sender. If not provided, the Name is the type of the Positionable.
|
||||
function POSITIONABLE:MessageToSetUnit( Message, Duration, MessageSetUnit, Name )
|
||||
self:F2( { Message, Duration } )
|
||||
|
||||
local DCSObject = self:GetDCSObject()
|
||||
if DCSObject then
|
||||
if DCSObject:isExist() then
|
||||
MessageSetUnit:ForEachUnit(
|
||||
function( MessageGroup )
|
||||
self:GetMessage( Message, Duration, Name ):ToUnit( MessageGroup )
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Send a message to the players in the @{Wrapper.Group}.
|
||||
-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message.
|
||||
-- @param #POSITIONABLE self
|
||||
|
||||
@ -95,6 +95,7 @@ Ops/Commander.lua
|
||||
Ops/Chief.lua
|
||||
Ops/CSAR.lua
|
||||
Ops/CTLD.lua
|
||||
Ops/Awacs.lua
|
||||
|
||||
AI/AI_Balancer.lua
|
||||
AI/AI_Air.lua
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user