#PLAYERRECCE

* Fixed visual targets not being smoked
* Added option to smoke an average coordinate of targets instead of all
* Defaulted self-smoking of player to false
This commit is contained in:
Applevangelist 2023-12-07 11:21:52 +01:00
parent d0491b3b5a
commit fe9d841af5

View File

@ -79,6 +79,7 @@
-- @field Utilities.FiFo#FIFO TargetCache -- @field Utilities.FiFo#FIFO TargetCache
-- @field #boolean smokeownposition -- @field #boolean smokeownposition
-- @field #table SmokeOwn -- @field #table SmokeOwn
-- @field #boolean smokeaveragetargetpos
-- @extends Core.Fsm#FSM -- @extends Core.Fsm#FSM
--- ---
@ -104,7 +105,7 @@ PLAYERRECCE = {
ClassName = "PLAYERRECCE", ClassName = "PLAYERRECCE",
verbose = true, verbose = true,
lid = nil, lid = nil,
version = "0.0.22", version = "0.1.23",
ViewZone = {}, ViewZone = {},
ViewZoneVisual = {}, ViewZoneVisual = {},
ViewZoneLaser = {}, ViewZoneLaser = {},
@ -130,8 +131,9 @@ PLAYERRECCE = {
ReferencePoint = nil, ReferencePoint = nil,
TForget = 600, TForget = 600,
TargetCache = nil, TargetCache = nil,
smokeownposition = true, smokeownposition = false,
SmokeOwn = {}, SmokeOwn = {},
smokeaveragetargetpos = false,
} }
--- ---
@ -1109,9 +1111,8 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
self:T(self.lid.."_SmokeTargets") self:T(self.lid.."_SmokeTargets")
local cameraset = self:_GetTargetSet(client,true) -- Core.Set#SET_UNIT local cameraset = self:_GetTargetSet(client,true) -- Core.Set#SET_UNIT
local visualset = self:_GetTargetSet(client,false) -- 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) self:__TargetsSmoked(-1,client,playername,cameraset)
else else
return self return self
@ -1126,29 +1127,31 @@ function PLAYERRECCE:_SmokeTargets(client,group,playername)
-- laser targer gets extra smoke -- laser targer gets extra smoke
if laser and laser.Target and laser.Target:IsAlive() then if laser and laser.Target and laser.Target:IsAlive() then
laser.Target:GetCoordinate():Smoke(lasersmoke) laser.Target:GetCoordinate():Smoke(lasersmoke)
if cameraset:IsInSet(laser.Target) then
cameraset:Remove(laser.Target:GetName(),true)
end
end end
local coordinate = nil local coord = visualset:GetCoordinate()
local setthreat = 0 if coord and self.smokeaveragetargetpos then
-- smoke everything else coord:SetAtLandheight()
if cameraset:CountAlive() > 1 then coord:Smoke(medsmoke)
local coordinate = cameraset:GetCoordinate() else
local setthreat = cameraset:CalculateThreatLevelA2G() -- smoke everything
end for _,_unit in pairs(visualset.Set) do
local unit = _unit --Wrapper.Unit#UNIT
if coordinate then if unit and unit:IsAlive() then
local coord = unit:GetCoordinate()
local threat = unit:GetThreatLevel()
if coord then
local color = lowsmoke local color = lowsmoke
if setthreat > 7 then if threat > 7 then
color = highsmoke
elseif threat > 2 then
color = medsmoke color = medsmoke
elseif setthreat > 2 then
color = lowsmoke
end end
coordinate:Smoke(color) coord:Smoke(color)
end
end
end
end end
if self.SmokeOwn[playername] then if self.SmokeOwn[playername] then
local cc = client:GetVec2() local cc = client:GetVec2()
-- don't smoke mid-air -- don't smoke mid-air
@ -1189,15 +1192,15 @@ function PLAYERRECCE:_FlareTargets(client,group,playername)
-- smoke everything else -- smoke everything else
for _,_unit in pairs(cameraset.Set) do for _,_unit in pairs(cameraset.Set) do
local unit = _unit --Wrapper.Unit#UNIT local unit = _unit --Wrapper.Unit#UNIT
if unit then if unit and unit:IsAlive() then
local coord = unit:GetCoordinate() local coord = unit:GetCoordinate()
local threat = unit:GetThreatLevel() local threat = unit:GetThreatLevel()
if coord then if coord then
local color = lowsmoke local color = lowsmoke
if threat > 7 then if threat > 7 then
color = medsmoke color = highsmoke
elseif threat > 2 then elseif threat > 2 then
color = lowsmoke color = medsmoke
end end
coord:Flare(color) coord:Flare(color)
end end
@ -1546,7 +1549,7 @@ end
-- @param #PLAYERRECCE self -- @param #PLAYERRECCE self
-- @return #PLAYERRECCE self -- @return #PLAYERRECCE self
function PLAYERRECCE:EnableSmokeOwnPosition() function PLAYERRECCE:EnableSmokeOwnPosition()
self:T(self.lid.."ENableSmokeOwnPosition") self:T(self.lid.."EnableSmokeOwnPosition")
self.smokeownposition = true self.smokeownposition = true
return self return self
end end
@ -1560,6 +1563,24 @@ function PLAYERRECCE:DisableSmokeOwnPosition()
return self return self
end 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. --- [Internal] Get text for text-to-speech.
-- Numbers are spaced out, e.g. "Heading 180" becomes "Heading 1 8 0 ". -- Numbers are spaced out, e.g. "Heading 180" becomes "Heading 1 8 0 ".
-- @param #PLAYERRECCE self -- @param #PLAYERRECCE self