Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable collisions with dead units consistently #6543

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/snippets/fix.6543.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6543) Fix dead units having collision with projectiles and beams for 0.1-0.6 seconds after death.
13 changes: 6 additions & 7 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni
FxDamage2 = {EffectTemplate.DamageFireSmoke01, EffectTemplate.DamageSparks01},
FxDamage3 = {EffectTemplate.DamageFire01, EffectTemplate.DamageSparks01},

-- Disables all collisions. This will be true for all units being constructed as upgrades
-- Disables all collisions. This will be true for all units being constructed as upgrades and dead units
DisallowCollisions = false,

-- Destruction parameters
Expand Down Expand Up @@ -1474,6 +1474,9 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni
-- this flag is used to skip the need of `IsDestroyed`
self.Dead = true

-- don't allow projectiles/beams to collide since we are dead
self.DisallowCollisions = true

local layer = self.Layer
local bp = self.Blueprint
local army = self.Army
Expand All @@ -1500,7 +1503,6 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni
local FractionThreshold = bp.General.FractionThreshold or 0.5
if self.PlayDeathAnimation and self:GetFractionComplete() > FractionThreshold then
self:ForkThread(self.PlayAnimationThread, 'AnimationDeath')
self.DisallowCollisions = true
end

self:DoUnitCallbacks('OnKilled')
Expand Down Expand Up @@ -1572,7 +1574,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni
---@param firingWeapon Weapon The weapon that the projectile originates from
---@return boolean
OnCollisionCheck = function(self, other, firingWeapon)
-- bail out immediately
-- dead unit or unit that is an upgrade
if self.DisallowCollisions then
return false
end
Expand All @@ -1593,8 +1595,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni
---@param firingWeapon Weapon The weapon the beam originates from that we're checking the collision with
---@return boolean
OnCollisionCheckWeapon = function(self, firingWeapon)

-- bail out immediately
-- dead unit or unit that is an upgrade
if self.DisallowCollisions then
return false
end
Expand Down Expand Up @@ -1942,8 +1943,6 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni
end

if shallSink then
self.DisallowCollisions = true

-- Bubbles and stuff coming off the sinking wreck.
self:ForkThread(self.SinkDestructionEffects)

Expand Down
Loading