mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
#PLAYERRECCE
* minor enhancements
This commit is contained in:
parent
7e6aa20168
commit
eecef9a0aa
@ -1,4 +1,4 @@
|
|||||||
--- **Ops** - Allow a player in the Gazelle to detect, smoke, flare, lase and report ground units to others.
|
--- **Ops** - Allow a player in a helo like the Gazelle to detect, smoke, flare, lase and report ground units to others.
|
||||||
--
|
--
|
||||||
-- ## Features:
|
-- ## Features:
|
||||||
--
|
--
|
||||||
@ -97,7 +97,7 @@ PLAYERRECCE = {
|
|||||||
ClassName = "PLAYERRECCE",
|
ClassName = "PLAYERRECCE",
|
||||||
verbose = true,
|
verbose = true,
|
||||||
lid = nil,
|
lid = nil,
|
||||||
version = "0.0.11",
|
version = "0.0.12",
|
||||||
ViewZone = {},
|
ViewZone = {},
|
||||||
ViewZoneVisual = {},
|
ViewZoneVisual = {},
|
||||||
ViewZoneLaser = {},
|
ViewZoneLaser = {},
|
||||||
@ -272,6 +272,13 @@ function PLAYERRECCE:_EventHandler(EventData)
|
|||||||
self.ClientMenus[EventData.IniPlayerName] = nil
|
self.ClientMenus[EventData.IniPlayerName] = nil
|
||||||
self.LaserSpots[EventData.IniPlayerName] = nil
|
self.LaserSpots[EventData.IniPlayerName] = nil
|
||||||
self.OnStation[EventData.IniPlayerName] = false
|
self.OnStation[EventData.IniPlayerName] = false
|
||||||
|
self.LaserFOV[EventData.IniPlayerName] = nil
|
||||||
|
self.UnitLaserCodes[EventData.IniPlayerName] = nil
|
||||||
|
self.LaserTarget[EventData.IniPlayerName] = nil
|
||||||
|
self.AutoLase[EventData.IniPlayerName] = false
|
||||||
|
if self.ViewZone[EventData.IniPlayerName] then self.ViewZone[EventData.IniPlayerName]:UndrawZone() end
|
||||||
|
if self.ViewZoneLaser[EventData.IniPlayerName] then self.ViewZoneLaser[EventData.IniPlayerName]:UndrawZone() end
|
||||||
|
if self.ViewZoneVisual[EventData.IniPlayerName] then self.ViewZoneVisual[EventData.IniPlayerName]:UndrawZone() end
|
||||||
end
|
end
|
||||||
elseif EventData.id == EVENTS.PlayerEnterAircraft and EventData.IniCoalition == self.Coalition then
|
elseif EventData.id == EVENTS.PlayerEnterAircraft and EventData.IniCoalition == self.Coalition then
|
||||||
if EventData.IniPlayerName and EventData.IniGroup and self.UseSRS then
|
if EventData.IniPlayerName and EventData.IniGroup and self.UseSRS then
|
||||||
@ -280,6 +287,13 @@ function PLAYERRECCE:_EventHandler(EventData)
|
|||||||
self.ClientMenus[EventData.IniPlayerName] = nil
|
self.ClientMenus[EventData.IniPlayerName] = nil
|
||||||
self.LaserSpots[EventData.IniPlayerName] = nil
|
self.LaserSpots[EventData.IniPlayerName] = nil
|
||||||
self.OnStation[EventData.IniPlayerName] = false
|
self.OnStation[EventData.IniPlayerName] = false
|
||||||
|
self.LaserFOV[EventData.IniPlayerName] = nil
|
||||||
|
self.UnitLaserCodes[EventData.IniPlayerName] = nil
|
||||||
|
self.LaserTarget[EventData.IniPlayerName] = nil
|
||||||
|
self.AutoLase[EventData.IniPlayerName] = false
|
||||||
|
if self.ViewZone[EventData.IniPlayerName] then self.ViewZone[EventData.IniPlayerName]:UndrawZone() end
|
||||||
|
if self.ViewZoneLaser[EventData.IniPlayerName] then self.ViewZoneLaser[EventData.IniPlayerName]:UndrawZone() end
|
||||||
|
if self.ViewZoneVisual[EventData.IniPlayerName] then self.ViewZoneVisual[EventData.IniPlayerName]:UndrawZone() end
|
||||||
self:_BuildMenus()
|
self:_BuildMenus()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -364,6 +378,24 @@ function PLAYERRECCE:SetAttackSet(AttackSet)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---[Internal] Check Gazelle camera in on
|
||||||
|
-- @param #PLAYERRECCE self
|
||||||
|
-- @param Wrapper.Client#CLIENT client
|
||||||
|
-- @param #string playername
|
||||||
|
-- @return #boolen OnOff
|
||||||
|
function PLAYERRECCE:_CameraOn(client,playername)
|
||||||
|
local camera = true
|
||||||
|
local unit = client -- Wrapper.Unit#UNIT
|
||||||
|
if unit and unit:IsAlive() then
|
||||||
|
local dcsunit = Unit.getByName(client:GetName())
|
||||||
|
local vivihorizontal = dcsunit:getDrawArgumentValue(215) or 0 -- (not in MiniGun) 1 to -1 -- zero is straight ahead, 1/-1 = 180 deg
|
||||||
|
if vivihorizontal < -0.7 or vivihorizontal > 0.7 then
|
||||||
|
camera = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return camera
|
||||||
|
end
|
||||||
|
|
||||||
--- [Internal] Get the view parameters from a Gazelle camera
|
--- [Internal] Get the view parameters from a Gazelle camera
|
||||||
-- @param #PLAYERRECCE self
|
-- @param #PLAYERRECCE self
|
||||||
-- @param Wrapper.Unit#UNIT Gazelle
|
-- @param Wrapper.Unit#UNIT Gazelle
|
||||||
@ -485,7 +517,7 @@ end
|
|||||||
function PLAYERRECCE:_GetViewZone(unit, vheading, minview, maxview, angle, camon, laser)
|
function PLAYERRECCE:_GetViewZone(unit, vheading, minview, maxview, angle, camon, laser)
|
||||||
self:T(self.lid.."_GetViewZone")
|
self:T(self.lid.."_GetViewZone")
|
||||||
local viewzone = nil
|
local viewzone = nil
|
||||||
--if not camon then return nil end
|
if not camon then return nil end
|
||||||
if unit and unit:IsAlive() then
|
if unit and unit:IsAlive() then
|
||||||
local unitname = unit:GetName()
|
local unitname = unit:GetName()
|
||||||
if not laser then
|
if not laser then
|
||||||
@ -580,6 +612,7 @@ end
|
|||||||
--@param #PLAYERRECCE self
|
--@param #PLAYERRECCE self
|
||||||
--@param Wrapper.Unit#UNIT unit The FACA unit
|
--@param Wrapper.Unit#UNIT unit The FACA unit
|
||||||
--@param #boolean camera If true, use the unit's camera for targets in sight
|
--@param #boolean camera If true, use the unit's camera for targets in sight
|
||||||
|
--@param #laser Use laser zone
|
||||||
--@return Core.Set#SET_UNIT Set of targets, can be empty!
|
--@return Core.Set#SET_UNIT Set of targets, can be empty!
|
||||||
--@return #number count Count of targets
|
--@return #number count Count of targets
|
||||||
function PLAYERRECCE:_GetTargetSet(unit,camera,laser)
|
function PLAYERRECCE:_GetTargetSet(unit,camera,laser)
|
||||||
@ -591,7 +624,7 @@ function PLAYERRECCE:_GetTargetSet(unit,camera,laser)
|
|||||||
local playername = unit:GetPlayerName()
|
local playername = unit:GetPlayerName()
|
||||||
local maxview = self.MaxViewDistance[typename] or 5000
|
local maxview = self.MaxViewDistance[typename] or 5000
|
||||||
local heading,nod,maxview,angle = 0,30,8000,10
|
local heading,nod,maxview,angle = 0,30,8000,10
|
||||||
local camon = true
|
local camon = false
|
||||||
local name = unit:GetName()
|
local name = unit:GetName()
|
||||||
if string.find(typename,"SA342") and camera then
|
if string.find(typename,"SA342") and camera then
|
||||||
heading,nod,maxview,camon = self:_GetGazelleVivianneSight(unit)
|
heading,nod,maxview,camon = self:_GetGazelleVivianneSight(unit)
|
||||||
@ -1281,23 +1314,28 @@ function PLAYERRECCE:onafterStatus(From, Event, To)
|
|||||||
function(Client)
|
function(Client)
|
||||||
local client = Client -- Wrapper.Client#CLIENT
|
local client = Client -- Wrapper.Client#CLIENT
|
||||||
local playername = client:GetPlayerName()
|
local playername = client:GetPlayerName()
|
||||||
|
local cameraison = self:_CameraOn(client,playername)
|
||||||
if client and client:IsAlive() and self.OnStation[playername] then
|
if client and client:IsAlive() and self.OnStation[playername] then
|
||||||
|
---
|
||||||
|
local targetset, targetcount, tzone = nil,0,nil
|
||||||
|
local laserset, lzone = nil,nil
|
||||||
|
local vistargetset, vistargetcount, viszone = nil,0,nil
|
||||||
-- targets on camera
|
-- targets on camera
|
||||||
local targetset, targetcount, tzone = self:_GetTargetSet(client,true)
|
if cameraison then
|
||||||
if targetset then
|
targetset, targetcount, tzone = self:_GetTargetSet(client,true)
|
||||||
if self.ViewZone[playername] then
|
if targetset then
|
||||||
self.ViewZone[playername]:UndrawZone()
|
if self.ViewZone[playername] then
|
||||||
end
|
self.ViewZone[playername]:UndrawZone()
|
||||||
if self.debug and tzone then
|
end
|
||||||
self.ViewZone[playername]=tzone:DrawZone(self.Coalition,{0,0,1},nil,nil,nil,1)
|
if self.debug and tzone then
|
||||||
|
self.ViewZone[playername]=tzone:DrawZone(self.Coalition,{0,0,1},nil,nil,nil,1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
self:T({targetcount=targetcount})
|
||||||
end
|
end
|
||||||
self:T({targetcount=targetcount})
|
|
||||||
|
|
||||||
-- lase targets on camera
|
-- lase targets on camera
|
||||||
if self.AutoLase[playername] then
|
if self.AutoLase[playername] and cameraison then
|
||||||
local laserset, targetcount, lzone = self:_GetTargetSet(client,true,true)
|
laserset, targetcount, lzone = self:_GetTargetSet(client,true,true)
|
||||||
if targetcount > 0 or self.LaserTarget[playername] then
|
if targetcount > 0 or self.LaserTarget[playername] then
|
||||||
if self.CanLase[client:GetTypeName()] then
|
if self.CanLase[client:GetTypeName()] then
|
||||||
-- DONE move to lase at will
|
-- DONE move to lase at will
|
||||||
@ -1315,7 +1353,7 @@ function PLAYERRECCE:onafterStatus(From, Event, To)
|
|||||||
self:I({lasercount=targetcount})
|
self:I({lasercount=targetcount})
|
||||||
end
|
end
|
||||||
-- visual targets
|
-- visual targets
|
||||||
local vistargetset, vistargetcount, viszone = self:_GetTargetSet(client,false)
|
vistargetset, vistargetcount, viszone = self:_GetTargetSet(client,false)
|
||||||
if vistargetset then
|
if vistargetset then
|
||||||
if self.ViewZoneVisual[playername] then
|
if self.ViewZoneVisual[playername] then
|
||||||
self.ViewZoneVisual[playername]:UndrawZone()
|
self.ViewZoneVisual[playername]:UndrawZone()
|
||||||
@ -1325,8 +1363,21 @@ function PLAYERRECCE:onafterStatus(From, Event, To)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:T({visualtargetcount=vistargetcount})
|
self:T({visualtargetcount=vistargetcount})
|
||||||
targetset:AddSet(vistargetset)
|
if targetset then
|
||||||
self:_CheckNewTargets(targetset,client,playername)
|
vistargetset:AddSet(targetset)
|
||||||
|
end
|
||||||
|
if laserset then
|
||||||
|
vistargetset:AddSet(laserset)
|
||||||
|
end
|
||||||
|
if not cameraison and self.debug then
|
||||||
|
if self.ViewZoneLaser[playername] then
|
||||||
|
self.ViewZoneLaser[playername]:UndrawZone()
|
||||||
|
end
|
||||||
|
if self.ViewZone[playername] then
|
||||||
|
self.ViewZone[playername]:UndrawZone()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:_CheckNewTargets(vistargetset,client,playername)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user