mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#PLAYERRECCE
This commit is contained in:
parent
d09f409359
commit
51be801637
@ -2425,6 +2425,26 @@ do -- SET_UNIT
|
|||||||
return CountU
|
return CountU
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets the alive set.
|
||||||
|
-- @param #SET_UNIT self
|
||||||
|
-- @return #table Table of SET objects
|
||||||
|
-- @return #SET_UNIT AliveSet
|
||||||
|
function SET_UNIT:GetAliveSet()
|
||||||
|
|
||||||
|
local AliveSet = SET_UNIT:New()
|
||||||
|
|
||||||
|
-- Clean the Set before returning with only the alive Groups.
|
||||||
|
for GroupName, GroupObject in pairs(self.Set) do
|
||||||
|
local GroupObject=GroupObject --Wrapper.Client#CLIENT
|
||||||
|
|
||||||
|
if GroupObject and GroupObject:IsAlive() then
|
||||||
|
AliveSet:Add(GroupName, GroupObject)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return AliveSet.Set or {}, AliveSet
|
||||||
|
end
|
||||||
|
|
||||||
--- [Internal] Private function for use of continous zone filter
|
--- [Internal] Private function for use of continous zone filter
|
||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
-- @return #SET_UNIT self
|
-- @return #SET_UNIT self
|
||||||
@ -2819,51 +2839,58 @@ do -- SET_UNIT
|
|||||||
-- @param #SET_UNIT self
|
-- @param #SET_UNIT self
|
||||||
-- @return Core.Point#COORDINATE The center coordinate of all the units in the set, including heading in degrees and speed in mps in case of moving units.
|
-- @return Core.Point#COORDINATE The center coordinate of all the units in the set, including heading in degrees and speed in mps in case of moving units.
|
||||||
function SET_UNIT:GetCoordinate()
|
function SET_UNIT:GetCoordinate()
|
||||||
|
|
||||||
local Coordinate = self:GetRandom():GetCoordinate()
|
|
||||||
--self:F({Coordinate:GetVec3()})
|
|
||||||
|
|
||||||
|
local Coordinate = nil
|
||||||
local x1 = Coordinate.x
|
local unit = self:GetRandom()
|
||||||
local x2 = Coordinate.x
|
if self:Count() == 1 and unit then
|
||||||
local y1 = Coordinate.y
|
return unit:GetCoordinate()
|
||||||
local y2 = Coordinate.y
|
end
|
||||||
local z1 = Coordinate.z
|
if unit then
|
||||||
local z2 = Coordinate.z
|
local Coordinate = unit:GetCoordinate()
|
||||||
local MaxVelocity = 0
|
--self:F({Coordinate:GetVec3()})
|
||||||
local AvgHeading = nil
|
|
||||||
local MovingCount = 0
|
|
||||||
|
local x1 = Coordinate.x
|
||||||
for UnitName, UnitData in pairs( self:GetSet() ) do
|
local x2 = Coordinate.x
|
||||||
|
local y1 = Coordinate.y
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
local y2 = Coordinate.y
|
||||||
local Coordinate = Unit:GetCoordinate()
|
local z1 = Coordinate.z
|
||||||
|
local z2 = Coordinate.z
|
||||||
x1 = (Coordinate.x < x1) and Coordinate.x or x1
|
local MaxVelocity = 0
|
||||||
x2 = (Coordinate.x > x2) and Coordinate.x or x2
|
local AvgHeading = nil
|
||||||
y1 = (Coordinate.y < y1) and Coordinate.y or y1
|
local MovingCount = 0
|
||||||
y2 = (Coordinate.y > y2) and Coordinate.y or y2
|
|
||||||
z1 = (Coordinate.y < z1) and Coordinate.z or z1
|
for UnitName, UnitData in pairs( self:GetAliveSet() ) do
|
||||||
z2 = (Coordinate.y > z2) and Coordinate.z or z2
|
|
||||||
|
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||||
local Velocity = Coordinate:GetVelocity()
|
local Coordinate = Unit:GetCoordinate()
|
||||||
if Velocity ~= 0 then
|
|
||||||
MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity
|
x1 = (Coordinate.x < x1) and Coordinate.x or x1
|
||||||
local Heading = Coordinate:GetHeading()
|
x2 = (Coordinate.x > x2) and Coordinate.x or x2
|
||||||
AvgHeading = AvgHeading and (AvgHeading + Heading) or Heading
|
y1 = (Coordinate.y < y1) and Coordinate.y or y1
|
||||||
MovingCount = MovingCount + 1
|
y2 = (Coordinate.y > y2) and Coordinate.y or y2
|
||||||
end
|
z1 = (Coordinate.y < z1) and Coordinate.z or z1
|
||||||
|
z2 = (Coordinate.y > z2) and Coordinate.z or z2
|
||||||
|
|
||||||
|
local Velocity = Coordinate:GetVelocity()
|
||||||
|
if Velocity ~= 0 then
|
||||||
|
MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity
|
||||||
|
local Heading = Coordinate:GetHeading()
|
||||||
|
AvgHeading = AvgHeading and (AvgHeading + Heading) or Heading
|
||||||
|
MovingCount = MovingCount + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
AvgHeading = AvgHeading and (AvgHeading / MovingCount)
|
||||||
|
|
||||||
|
Coordinate.x = (x2 - x1) / 2 + x1
|
||||||
|
Coordinate.y = (y2 - y1) / 2 + y1
|
||||||
|
Coordinate.z = (z2 - z1) / 2 + z1
|
||||||
|
Coordinate:SetHeading( AvgHeading )
|
||||||
|
Coordinate:SetVelocity( MaxVelocity )
|
||||||
|
|
||||||
|
self:F( { Coordinate = Coordinate } )
|
||||||
end
|
end
|
||||||
|
|
||||||
AvgHeading = AvgHeading and (AvgHeading / MovingCount)
|
|
||||||
|
|
||||||
Coordinate.x = (x2 - x1) / 2 + x1
|
|
||||||
Coordinate.y = (y2 - y1) / 2 + y1
|
|
||||||
Coordinate.z = (z2 - z1) / 2 + z1
|
|
||||||
Coordinate:SetHeading( AvgHeading )
|
|
||||||
Coordinate:SetVelocity( MaxVelocity )
|
|
||||||
|
|
||||||
self:F( { Coordinate = Coordinate } )
|
|
||||||
return Coordinate
|
return Coordinate
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -916,7 +916,8 @@ function PLAYERRECCE:_LaseTarget(client,targetset)
|
|||||||
-- still looking at target?
|
-- still looking at target?
|
||||||
local target=self.LaserTarget[playername] -- Ops.Target#TARGET
|
local target=self.LaserTarget[playername] -- Ops.Target#TARGET
|
||||||
local oldtarget = target:GetObject() --or laser.Target
|
local oldtarget = target:GetObject() --or laser.Target
|
||||||
self:T("Targetstate: "..target:GetState())
|
--self:I("Targetstate: "..target:GetState())
|
||||||
|
--self:I("Laser State: "..tostring(laser:IsLasing()))
|
||||||
if not oldtarget or targetset:IsNotInSet(oldtarget) or target:IsDead() or target:IsDestroyed() then
|
if not oldtarget or targetset:IsNotInSet(oldtarget) or target:IsDead() or target:IsDestroyed() then
|
||||||
-- lost LOS or dead
|
-- lost LOS or dead
|
||||||
laser:LaseOff()
|
laser:LaseOff()
|
||||||
@ -928,12 +929,20 @@ function PLAYERRECCE:_LaseTarget(client,targetset)
|
|||||||
self.LaserTarget[playername] = nil
|
self.LaserTarget[playername] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if oldtarget and (not laser:IsLasing()) then
|
||||||
|
--self:I("Switching laser back on ..")
|
||||||
|
local lasercode = self.UnitLaserCodes[playername] or laser.LaserCode or 1688
|
||||||
|
local lasingtime = self.lasingtime or 60
|
||||||
|
--local targettype = target:GetTypeName()
|
||||||
|
laser:LaseOn(oldtarget,lasercode,lasingtime)
|
||||||
|
--self:__TargetLasing(-1,client,oldtarget,lasercode,lasingtime)
|
||||||
|
end
|
||||||
elseif not laser:IsLasing() and target then
|
elseif not laser:IsLasing() and target then
|
||||||
local relativecam = self.LaserRelativePos[client:GetTypeName()]
|
local relativecam = self.LaserRelativePos[client:GetTypeName()]
|
||||||
laser:SetRelativeStartPosition(relativecam)
|
laser:SetRelativeStartPosition(relativecam)
|
||||||
local lasercode = self.UnitLaserCodes[playername] or laser.LaserCode or 1688
|
local lasercode = self.UnitLaserCodes[playername] or laser.LaserCode or 1688
|
||||||
local lasingtime = self.lasingtime or 60
|
local lasingtime = self.lasingtime or 60
|
||||||
local targettype = target:GetTypeName()
|
--local targettype = target:GetTypeName()
|
||||||
laser:LaseOn(target,lasercode,lasingtime)
|
laser:LaseOn(target,lasercode,lasingtime)
|
||||||
self.LaserTarget[playername] = TARGET:New(target)
|
self.LaserTarget[playername] = TARGET:New(target)
|
||||||
self.LaserTarget[playername].TStatus = 9
|
self.LaserTarget[playername].TStatus = 9
|
||||||
@ -1101,9 +1110,13 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local coordinate = nil
|
||||||
|
local setthreat = 0
|
||||||
-- smoke everything else
|
-- smoke everything else
|
||||||
local coordinate = cameraset:GetCoordinate()
|
if cameraset:CountAlive() > 1 then
|
||||||
local setthreat = cameraset:CalculateThreatLevelA2G()
|
local coordinate = cameraset:GetCoordinate()
|
||||||
|
local setthreat = cameraset:CalculateThreatLevelA2G()
|
||||||
|
end
|
||||||
|
|
||||||
if coordinate then
|
if coordinate then
|
||||||
local color = lowsmoke
|
local color = lowsmoke
|
||||||
@ -1983,7 +1996,7 @@ function PLAYERRECCE:onafterTargetLasing(From, Event, To, Client, Target, Laserc
|
|||||||
coordtext = coord:ToStringFromRPShort(self.ReferencePoint,self.RPName,client,Settings)
|
coordtext = coord:ToStringFromRPShort(self.ReferencePoint,self.RPName,client,Settings)
|
||||||
end
|
end
|
||||||
local coordtext = coord:ToStringA2G(client,Settings)
|
local coordtext = coord:ToStringA2G(client,Settings)
|
||||||
local text = string.format("All stations, %s lasing %s\nat %s!\nCode %d, Duration %d seconds!",callsign, targettype, coordtext, Lasercode, Lasingtime)
|
local text = string.format("All stations, %s lasing %s\nat %s!\nCode %d, Duration %d plus seconds!",callsign, targettype, coordtext, Lasercode, Lasingtime)
|
||||||
MESSAGE:New(text,15,self.Name or "FACA"):ToClient(client)
|
MESSAGE:New(text,15,self.Name or "FACA"):ToClient(client)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user