Skip to content

Commit

Permalink
Fix beam weapons not disabling themselves (#4154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Aug 20, 2022
1 parent 1618f0f commit e297c4a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lua/sim/defaultweapons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1409,13 +1409,21 @@ DefaultBeamWeapon = Class(DefaultProjectileWeapon) {
-- Kill the beam if hold fire is requested
WatchForHoldFire = function(self, beam)
local unit = self.unit
while true do
WaitSeconds(1)
--if we're at hold fire, stop beam
if self.unit and (self.unit:GetFireState() == 1) then
local hasTargetPrev = true
while not (IsDestroyed(self) or IsDestroyed(unit)) do

local hasTarget = self:GetCurrentTarget() != nil
if -- check for hold fire
(unit:GetFireState() == 1) or
-- check if we have a target still, relevant for beam weapons that work indefinitely
(not (hasTarget or hasTargetPrev))
then
self.BeamStarted = false
self:PlayFxBeamEnd(beam)
end

hasTargetPrev = hasTarget
WaitSeconds(0.5)
end
end,

Expand Down

0 comments on commit e297c4a

Please sign in to comment.