#PLAYERRECCE

* Fix issue which stops lasing though target is alive and in sight
This commit is contained in:
Applevangelist 2023-11-17 15:07:29 +01:00
parent 9a360a3bd5
commit 58ce4b001e
2 changed files with 20 additions and 7 deletions

View File

@ -329,14 +329,14 @@ do
if self.Lasing then if self.Lasing then
if self.Target and self.Target:IsAlive() then if self.Target and self.Target:IsAlive() then
self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/100):AddX(math.random(-100,100)/100):GetVec3() ) self.SpotIR:setPoint( self.Target:GetPointVec3():AddY(1):AddY(math.random(-100,100)/200):AddX(math.random(-100,100)/200):GetVec3() )
self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() ) self.SpotLaser:setPoint( self.Target:GetPointVec3():AddY(1):GetVec3() )
self:__Lasing(0.2) self:__Lasing(0.2)
elseif self.TargetCoord then elseif self.TargetCoord then
-- Wiggle the IR spot a bit. -- Wiggle the IR spot a bit.
local irvec3={x=self.TargetCoord.x+math.random(-100,100)/100, y=self.TargetCoord.y+math.random(-100,100)/100, z=self.TargetCoord.z} --#DCS.Vec3 local irvec3={x=self.TargetCoord.x+math.random(-100,100)/200, y=self.TargetCoord.y+math.random(-100,100)/200, z=self.TargetCoord.z} --#DCS.Vec3
local lsvec3={x=self.TargetCoord.x, y=self.TargetCoord.y, z=self.TargetCoord.z} --#DCS.Vec3 local lsvec3={x=self.TargetCoord.x, y=self.TargetCoord.y, z=self.TargetCoord.z} --#DCS.Vec3
self.SpotIR:setPoint(irvec3) self.SpotIR:setPoint(irvec3)

View File

@ -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