mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
xx
This commit is contained in:
parent
69c20e78fb
commit
e8c7e62900
@ -419,7 +419,11 @@ do -- SET_BASE
|
||||
-- @param #SET_BASE self
|
||||
-- @return Core.Base#BASE
|
||||
function SET_BASE:GetRandom()
|
||||
local tablemax = table.maxn(self.Index)
|
||||
local tablemax = 0
|
||||
for _,_ind in pairs(self.Index) do
|
||||
tablemax = tablemax + 1
|
||||
end
|
||||
--local tablemax = table.maxn(self.Index)
|
||||
local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
|
||||
self:T3( { RandomItem } )
|
||||
return RandomItem
|
||||
@ -561,10 +565,12 @@ do -- SET_BASE
|
||||
return self
|
||||
end
|
||||
|
||||
--- Iterate the SET_BASE while identifying the nearest object from a @{Core.Point#POINT_VEC2}.
|
||||
--- Iterate the SET_BASE while identifying the nearest object in the set from a @{Core.Point#POINT_VEC2}.
|
||||
-- @param #SET_BASE self
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2 A @{Core.Point#POINT_VEC2} object from where to evaluate the closest object in the set.
|
||||
-- @param Core.Point#POINT_VEC2 PointVec2 A @{Core.Point#COORDINATE} or @{Core.Point#POINT_VEC2} object (but **not** a simple DCS#Vec2!) from where to evaluate the closest object in the set.
|
||||
-- @return Core.Base#BASE The closest object.
|
||||
-- @usage
|
||||
-- myset:FindNearestObjectFromPointVec2( ZONE:New("Test Zone"):GetCoordinate() )
|
||||
function SET_BASE:FindNearestObjectFromPointVec2( PointVec2 )
|
||||
self:F2( PointVec2 )
|
||||
|
||||
@ -2849,14 +2855,13 @@ do -- SET_UNIT
|
||||
function SET_UNIT:GetCoordinate()
|
||||
|
||||
local Coordinate = nil
|
||||
local unit = self:GetRandom()
|
||||
local unit = self:GetFirst()
|
||||
if self:Count() == 1 and unit then
|
||||
return unit:GetCoordinate()
|
||||
end
|
||||
if unit then
|
||||
local Coordinate = unit:GetCoordinate()
|
||||
--self:F({Coordinate:GetVec3()})
|
||||
|
||||
Coordinate = unit:GetCoordinate()
|
||||
self:T2(UTILS.PrintTableToLog(Coordinate:GetVec3()))
|
||||
|
||||
local x1 = Coordinate.x
|
||||
local x2 = Coordinate.x
|
||||
@ -2868,19 +2873,19 @@ do -- SET_UNIT
|
||||
local AvgHeading = nil
|
||||
local MovingCount = 0
|
||||
|
||||
for UnitName, UnitData in pairs( self:GetAliveSet() ) do
|
||||
for UnitName, UnitData in pairs( self.Set) do
|
||||
|
||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||
local Coordinate = Unit:GetCoordinate()
|
||||
local Coord = Unit:GetCoordinate()
|
||||
|
||||
x1 = (Coordinate.x < x1) and Coordinate.x or x1
|
||||
x2 = (Coordinate.x > x2) and Coordinate.x or x2
|
||||
y1 = (Coordinate.y < y1) and Coordinate.y or y1
|
||||
y2 = (Coordinate.y > y2) and Coordinate.y or y2
|
||||
z1 = (Coordinate.y < z1) and Coordinate.z or z1
|
||||
z2 = (Coordinate.y > z2) and Coordinate.z or z2
|
||||
x1 = (Coord.x < x1) and Coord.x or x1
|
||||
x2 = (Coord.x > x2) and Coord.x or x2
|
||||
y1 = (Coord.y < y1) and Coord.y or y1
|
||||
y2 = (Coord.y > y2) and Coord.y or y2
|
||||
z1 = (Coord.y < z1) and Coord.z or z1
|
||||
z2 = (Coord.y > z2) and Coord.z or z2
|
||||
|
||||
local Velocity = Coordinate:GetVelocity()
|
||||
local Velocity = Coord:GetVelocity()
|
||||
if Velocity ~= 0 then
|
||||
MaxVelocity = (MaxVelocity < Velocity) and Velocity or MaxVelocity
|
||||
local Heading = Coordinate:GetHeading()
|
||||
@ -2897,7 +2902,7 @@ do -- SET_UNIT
|
||||
Coordinate:SetHeading( AvgHeading )
|
||||
Coordinate:SetVelocity( MaxVelocity )
|
||||
|
||||
self:F( { Coordinate = Coordinate } )
|
||||
self:T2(UTILS.PrintTableToLog(Coordinate:GetVec3()))
|
||||
end
|
||||
return Coordinate
|
||||
|
||||
|
||||
@ -79,6 +79,7 @@
|
||||
-- @field Utilities.FiFo#FIFO TargetCache
|
||||
-- @field #boolean smokeownposition
|
||||
-- @field #table SmokeOwn
|
||||
-- @field #boolean smokeaveragetargetpos
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
---
|
||||
@ -104,7 +105,7 @@ PLAYERRECCE = {
|
||||
ClassName = "PLAYERRECCE",
|
||||
verbose = true,
|
||||
lid = nil,
|
||||
version = "0.0.22",
|
||||
version = "0.1.23",
|
||||
ViewZone = {},
|
||||
ViewZoneVisual = {},
|
||||
ViewZoneLaser = {},
|
||||
@ -130,8 +131,9 @@ PLAYERRECCE = {
|
||||
ReferencePoint = nil,
|
||||
TForget = 600,
|
||||
TargetCache = nil,
|
||||
smokeownposition = true,
|
||||
smokeownposition = false,
|
||||
SmokeOwn = {},
|
||||
smokeaveragetargetpos = false,
|
||||
}
|
||||
|
||||
---
|
||||
@ -1109,9 +1111,8 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
|
||||
self:T(self.lid.."_SmokeTargets")
|
||||
local cameraset = self:_GetTargetSet(client,true) -- Core.Set#SET_UNIT
|
||||
local visualset = self:_GetTargetSet(client,false) -- Core.Set#SET_UNIT
|
||||
cameraset:AddSet(visualset)
|
||||
|
||||
if cameraset:CountAlive() > 0 then
|
||||
if cameraset:CountAlive() > 0 or visualset:CountAlive() > 0 then
|
||||
self:__TargetsSmoked(-1,client,playername,cameraset)
|
||||
else
|
||||
return self
|
||||
@ -1126,29 +1127,31 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
|
||||
-- laser targer gets extra smoke
|
||||
if laser and laser.Target and laser.Target:IsAlive() then
|
||||
laser.Target:GetCoordinate():Smoke(lasersmoke)
|
||||
if cameraset:IsInSet(laser.Target) then
|
||||
cameraset:Remove(laser.Target:GetName(),true)
|
||||
end
|
||||
end
|
||||
|
||||
local coordinate = nil
|
||||
local setthreat = 0
|
||||
-- smoke everything else
|
||||
if cameraset:CountAlive() > 1 then
|
||||
local coordinate = cameraset:GetCoordinate()
|
||||
local setthreat = cameraset:CalculateThreatLevelA2G()
|
||||
end
|
||||
|
||||
if coordinate then
|
||||
local coord = visualset:GetCoordinate()
|
||||
if coord and self.smokeaveragetargetpos then
|
||||
coord:SetAtLandheight()
|
||||
coord:Smoke(medsmoke)
|
||||
else
|
||||
-- smoke everything
|
||||
for _,_unit in pairs(visualset.Set) do
|
||||
local unit = _unit --Wrapper.Unit#UNIT
|
||||
if unit and unit:IsAlive() then
|
||||
local coord = unit:GetCoordinate()
|
||||
local threat = unit:GetThreatLevel()
|
||||
if coord then
|
||||
local color = lowsmoke
|
||||
if setthreat > 7 then
|
||||
if threat > 7 then
|
||||
color = highsmoke
|
||||
elseif threat > 2 then
|
||||
color = medsmoke
|
||||
elseif setthreat > 2 then
|
||||
color = lowsmoke
|
||||
end
|
||||
coordinate:Smoke(color)
|
||||
coord:Smoke(color)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.SmokeOwn[playername] then
|
||||
local cc = client:GetVec2()
|
||||
-- don't smoke mid-air
|
||||
@ -1189,15 +1192,15 @@ function PLAYERRECCE:_FlareTargets(client,group,playername)
|
||||
-- smoke everything else
|
||||
for _,_unit in pairs(cameraset.Set) do
|
||||
local unit = _unit --Wrapper.Unit#UNIT
|
||||
if unit then
|
||||
if unit and unit:IsAlive() then
|
||||
local coord = unit:GetCoordinate()
|
||||
local threat = unit:GetThreatLevel()
|
||||
if coord then
|
||||
local color = lowsmoke
|
||||
if threat > 7 then
|
||||
color = medsmoke
|
||||
color = highsmoke
|
||||
elseif threat > 2 then
|
||||
color = lowsmoke
|
||||
color = medsmoke
|
||||
end
|
||||
coord:Flare(color)
|
||||
end
|
||||
@ -1546,7 +1549,7 @@ end
|
||||
-- @param #PLAYERRECCE self
|
||||
-- @return #PLAYERRECCE self
|
||||
function PLAYERRECCE:EnableSmokeOwnPosition()
|
||||
self:T(self.lid.."ENableSmokeOwnPosition")
|
||||
self:T(self.lid.."EnableSmokeOwnPosition")
|
||||
self.smokeownposition = true
|
||||
return self
|
||||
end
|
||||
@ -1560,6 +1563,24 @@ function PLAYERRECCE:DisableSmokeOwnPosition()
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Enable smoking of average target positions, instead of all targets visible. Loses smoke per threatlevel -- each is med threat. Default is - smoke all positions.
|
||||
-- @param #PLAYERRECCE self
|
||||
-- @return #PLAYERRECCE self
|
||||
function PLAYERRECCE:EnableSmokeAverageTargetPosition()
|
||||
self:T(self.lid.."ENableSmokeOwnPosition")
|
||||
self.smokeaveragetargetpos = true
|
||||
return self
|
||||
end
|
||||
|
||||
--- [User] Disable smoking of average target positions, instead of all targets visible. Default is - smoke all positions.
|
||||
-- @param #PLAYERRECCE self
|
||||
-- @return #PLAYERRECCE
|
||||
function PLAYERRECCE:DisableSmokeAverageTargetPosition()
|
||||
self:T(self.lid.."DisableSmokeAverageTargetPosition")
|
||||
self.smokeaveragetargetpos = false
|
||||
return self
|
||||
end
|
||||
|
||||
--- [Internal] Get text for text-to-speech.
|
||||
-- Numbers are spaced out, e.g. "Heading 180" becomes "Heading 1 8 0 ".
|
||||
-- @param #PLAYERRECCE self
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user