Skip to content

Commit

Permalink
much better tailchase performance
Browse files Browse the repository at this point in the history
  • Loading branch information
clyfordv committed Oct 23, 2023
1 parent 99c8b7d commit 499b364
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
33 changes: 23 additions & 10 deletions units/XRL0302/XRL0302_Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ local DeathWeaponEMP = ClassWeapon(Weapon) {
-- Don't leave wreckage
self.unit:Destroy()
end,

-- This prevents us from firing the death weapon when we're moving
OnMotionHorzEventChange = function(self, new, old)
if new == 'Cruise' then
self:SetEnabled(false)
elseif new == 'Stopping' then
if not self.unit:IsUnitState('Moving') then
self:SetEnabled(true)
if self.unit:IsUnitState('Attacking') then
local target = self.unit:GetCommandQueue()[1].target
if target and self.chasing then
if VDist3(self.unit:GetPosition(), target:GetPosition()) < self.Blueprint.DamageRadius then
self:FireWeapon()
end
end
self.chasing = true
end
end
elseif new == 'Stopped' then
self:SetEnabled(true)
self.chasing = nil
end
end,
}

---@class XRL0302 : CWalkingLandUnit
Expand Down Expand Up @@ -93,16 +116,6 @@ XRL0302 = ClassUnit(CWalkingLandUnit) {
self:GetWeaponByLabel('KamikazeEMP'):FireWeapon()
end,

-- This prevents us from firing the death weapon when we're moving
OnMotionHorzEventChange = function(self, new, old)
CWalkingLandUnit.OnMotionHorzEventChange(self, new, old)
if new == 'Cruise' then
self:SetBusy(true)
elseif new == 'Stopping' then
self:SetBusy(false)
end
end,

DoDeathWeapon = function(self)
self:GetWeaponByLabel('KamikazeEMP'):FireWeapon()
end,
Expand Down
1 change: 1 addition & 0 deletions units/XRL0302/XRL0302_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ UnitBlueprint{
Weapon = {
{
AboveWaterTargetsOnly = true,
AlwaysRecheckTarget = false,
AutoInitiateAttackCommand = true,
Buffs = {
{
Expand Down

0 comments on commit 499b364

Please sign in to comment.