From f956f548d50ea644e11bae38d8774bb1366e1a9b Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 10 Jan 2025 03:31:53 -0800 Subject: [PATCH 01/15] Format and annotate volcano script --- engine/Sim.lua | 2 +- units/UAB4201/UAB4201_script.lua | 62 ++++++++++++++++---------------- units/URL0001/URL0001_script.lua | 6 ++-- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/engine/Sim.lua b/engine/Sim.lua index 666da4fd85..7e826c1449 100644 --- a/engine/Sim.lua +++ b/engine/Sim.lua @@ -335,7 +335,7 @@ end ---@param object BoneObject ---@param bone Bone ---@param axis "x" | "y" | "z" | "-x" | "-y" | "-z" ----@param goal? unknown +---@param goal? number ---@param speed? number ---@param accel? number ---@param goalspeed? number diff --git a/units/UAB4201/UAB4201_script.lua b/units/UAB4201/UAB4201_script.lua index 8f9a99a875..13a7edc92c 100644 --- a/units/UAB4201/UAB4201_script.lua +++ b/units/UAB4201/UAB4201_script.lua @@ -15,41 +15,43 @@ local AAMWillOWisp = import("/lua/aeonweapons.lua").AAMWillOWisp local CreateRotator = CreateRotator local TrashBagAdd = TrashBag.Add - ---@class UAB4201 : AStructureUnit UAB4201 = ClassUnit(AStructureUnit) { Weapons = { + ---@class UAB4201_AntiMissile: AAMWillOWisp + ---@field RotatorManipulator moho.RotateManipulator + ---@field RotatorManipulatorCounter number AntiMissile = ClassWeapon(AAMWillOWisp) { - PlayRackRecoil = function(self, rackList) - AAMWillOWisp.PlayRackRecoil(self, rackList) - - local unit = self.unit - local rotatorManipulator = self.RotatorManipulator - - --CreateRotator(unit, bone, axis, [goal], [speed], [accel], [goalspeed]) - if not rotatorManipulator then - rotatorManipulator = CreateRotator(unit, 'Dome', 'z', 20, 40, 40, 40) - rotatorManipulator:SetGoal(45) - self.RotatorManipulatorCounter = 1 - else - self.RotatorManipulatorCounter = self.RotatorManipulatorCounter + 1 - rotatorManipulator:SetGoal(45 * self.RotatorManipulatorCounter) - end - self.unit.Trash:Add(self.RotatorManipulator) - end, - - PlayRackRecoilReturn = function(self, rackList) - AAMWillOWisp.PlayRackRecoilReturn(self, rackList) - if self.RotatorManipulatorCounter == 8 then - self.RotatorManipulator:Destroy() - self.RotatorManipulator = nil - end - end, - - }, + --- Rotate the dome 45 degrees when the volcano fires. Non-functional due to the volcano not having a rack recoild distance. + ---@param self UAB4201_AntiMissile + ---@param rackList Bone[] + PlayRackRecoil = function(self, rackList) + AAMWillOWisp.PlayRackRecoil(self, rackList) + + local unit = self.unit + local rotatorManipulator = self.RotatorManipulator + + --CreateRotator(unit, bone, axis, [goal], [speed], [accel], [goalspeed]) + if not rotatorManipulator then + rotatorManipulator = CreateRotator(unit, 'Dome', 'z', 20, 40, 40, 40) + rotatorManipulator:SetGoal(45) + self.RotatorManipulatorCounter = 1 + else + self.RotatorManipulatorCounter = self.RotatorManipulatorCounter + 1 + rotatorManipulator:SetGoal(45 * self.RotatorManipulatorCounter) + end + TrashBagAdd(unit.Trash, self.RotatorManipulator) + end, + + PlayRackRecoilReturn = function(self, rackList) + AAMWillOWisp.PlayRackRecoilReturn(self, rackList) + if self.RotatorManipulatorCounter == 8 then + self.RotatorManipulator:Destroy() + self.RotatorManipulator = nil + end + end, + }, }, - } TypeClass = UAB4201 - diff --git a/units/URL0001/URL0001_script.lua b/units/URL0001/URL0001_script.lua index e07206f936..fc60c22330 100644 --- a/units/URL0001/URL0001_script.lua +++ b/units/URL0001/URL0001_script.lua @@ -40,18 +40,18 @@ URL0001 = ClassUnit(ACUUnit, CCommandUnit) { DeathWeapon = ClassWeapon(ACUDeathWeapon) {}, RightRipper = ClassWeapon(CCannonMolecularWeapon) {}, Torpedo = ClassWeapon(CANTorpedoLauncherWeapon) {}, - ---@class MLG : CDFHeavyMicrowaveLaserGeneratorCom + ---@class URL0001_MLG : CDFHeavyMicrowaveLaserGeneratorCom MLG = ClassWeapon(CDFHeavyMicrowaveLaserGeneratorCom) { DisabledFiringBones = { 'Turret_Muzzle_03' }, - ---@param self MLG + ---@param self URL0001_MLG ---@param transportstate boolean SetOnTransport = function(self, transportstate) CDFHeavyMicrowaveLaserGeneratorCom.SetOnTransport(self, transportstate) self.Trash:Add(ForkThread(self.OnTransportWatch, self)) end, - ---@param self MLG + ---@param self URL0001_MLG OnTransportWatch = function(self) while self:GetOnTransport() do self:PlayFxBeamEnd() From 394ba4cf415b00a4728435a1c394eb5a01b69bf2 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 10 Jan 2025 03:41:51 -0800 Subject: [PATCH 02/15] Remove volcano's rotator script --- units/UAB4201/UAB4201_script.lua | 34 +------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/units/UAB4201/UAB4201_script.lua b/units/UAB4201/UAB4201_script.lua index 13a7edc92c..2da737e59a 100644 --- a/units/UAB4201/UAB4201_script.lua +++ b/units/UAB4201/UAB4201_script.lua @@ -18,39 +18,7 @@ local TrashBagAdd = TrashBag.Add ---@class UAB4201 : AStructureUnit UAB4201 = ClassUnit(AStructureUnit) { Weapons = { - ---@class UAB4201_AntiMissile: AAMWillOWisp - ---@field RotatorManipulator moho.RotateManipulator - ---@field RotatorManipulatorCounter number - AntiMissile = ClassWeapon(AAMWillOWisp) { - --- Rotate the dome 45 degrees when the volcano fires. Non-functional due to the volcano not having a rack recoild distance. - ---@param self UAB4201_AntiMissile - ---@param rackList Bone[] - PlayRackRecoil = function(self, rackList) - AAMWillOWisp.PlayRackRecoil(self, rackList) - - local unit = self.unit - local rotatorManipulator = self.RotatorManipulator - - --CreateRotator(unit, bone, axis, [goal], [speed], [accel], [goalspeed]) - if not rotatorManipulator then - rotatorManipulator = CreateRotator(unit, 'Dome', 'z', 20, 40, 40, 40) - rotatorManipulator:SetGoal(45) - self.RotatorManipulatorCounter = 1 - else - self.RotatorManipulatorCounter = self.RotatorManipulatorCounter + 1 - rotatorManipulator:SetGoal(45 * self.RotatorManipulatorCounter) - end - TrashBagAdd(unit.Trash, self.RotatorManipulator) - end, - - PlayRackRecoilReturn = function(self, rackList) - AAMWillOWisp.PlayRackRecoilReturn(self, rackList) - if self.RotatorManipulatorCounter == 8 then - self.RotatorManipulator:Destroy() - self.RotatorManipulator = nil - end - end, - }, + AntiMissile = ClassWeapon(AAMWillOWisp) {}, }, } From 965c29e68521dbc1d25cfd58df208ec17246c2ee Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 10 Jan 2025 03:42:10 -0800 Subject: [PATCH 03/15] Implement a fixed version of the rotator script --- units/UAB4201/UAB4201_script.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/units/UAB4201/UAB4201_script.lua b/units/UAB4201/UAB4201_script.lua index 2da737e59a..6f422b75e6 100644 --- a/units/UAB4201/UAB4201_script.lua +++ b/units/UAB4201/UAB4201_script.lua @@ -18,7 +18,27 @@ local TrashBagAdd = TrashBag.Add ---@class UAB4201 : AStructureUnit UAB4201 = ClassUnit(AStructureUnit) { Weapons = { - AntiMissile = ClassWeapon(AAMWillOWisp) {}, + ---@class UAB4201_AntiMissile: AAMWillOWisp + ---@field RotatorManipulator moho.RotateManipulator + ---@field RotatorManipulatorCounter number + AntiMissile = ClassWeapon(AAMWillOWisp) { + RotatorManipulatorCounter = 1, + + ---@param self UAB4201_AntiMissile + OnCreate = function(self) + AAMWillOWisp.OnCreate(self) + self.RotatorManipulator = TrashBagAdd(self.Trash, CreateRotator(self.unit, 'Dome', 'z', 0, 40, nil, nil)) + end, + + --- Rotate the dome 45 degrees when the volcano fires. + ---@param self UAB4201_AntiMissile + PlayFxWeaponUnpackSequence = function(self) + local rotations = self.RotatorManipulatorCounter + self.RotatorManipulator:SetGoal(45 * rotations) + self.RotatorManipulatorCounter = rotations < 8 and rotations + 1 or 0 + AAMWillOWisp.PlayFxWeaponUnpackSequence(self) + end, + }, }, } From d9d42ddf457e0f85d89da3d960cc5d9ec74218b9 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Fri, 10 Jan 2025 05:13:49 -0800 Subject: [PATCH 04/15] Tweak the rotation to match the unpack animation --- units/UAB4201/UAB4201_script.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/units/UAB4201/UAB4201_script.lua b/units/UAB4201/UAB4201_script.lua index 6f422b75e6..155057bd01 100644 --- a/units/UAB4201/UAB4201_script.lua +++ b/units/UAB4201/UAB4201_script.lua @@ -27,17 +27,29 @@ UAB4201 = ClassUnit(AStructureUnit) { ---@param self UAB4201_AntiMissile OnCreate = function(self) AAMWillOWisp.OnCreate(self) - self.RotatorManipulator = TrashBagAdd(self.Trash, CreateRotator(self.unit, 'Dome', 'z', 0, 40, nil, nil)) + -- Speed is set to do a rotation in 1 tick + self.RotatorManipulator = TrashBagAdd(self.Trash, CreateRotator(self.unit, 'Dome', 'z', 0, 225, nil, nil)) end, - --- Rotate the dome 45 degrees when the volcano fires. + --- Rotate the dome when the volcano unpacks ---@param self UAB4201_AntiMissile PlayFxWeaponUnpackSequence = function(self) local rotations = self.RotatorManipulatorCounter - self.RotatorManipulator:SetGoal(45 * rotations) - self.RotatorManipulatorCounter = rotations < 8 and rotations + 1 or 0 + self.RotatorManipulator:SetGoal(22.5 * rotations) + self.RotatorManipulatorCounter = rotations + 1 + AAMWillOWisp.PlayFxWeaponUnpackSequence(self) end, + + --- Rotate the dome when the volcano packs. Ends on a 45 degree turn so that the mesh doesn't self-intersect. + ---@param self UAB4201_AntiMissile + PlayFxWeaponPackSequence = function(self) + local rotations = self.RotatorManipulatorCounter + self.RotatorManipulator:SetGoal(22.5 * rotations) + self.RotatorManipulatorCounter = rotations < 16 and rotations + 1 or 1 + + AAMWillOWisp.PlayFxWeaponPackSequence(self) + end }, }, } From 08d9696e299e052ba76992ed18e74bf67860d18a Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:45:50 -0800 Subject: [PATCH 05/15] Annotate `Unit:GetVelocity` speed unit --- engine/Sim/Unit.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/Sim/Unit.lua b/engine/Sim/Unit.lua index ea46780f7e..fa4f85f508 100644 --- a/engine/Sim/Unit.lua +++ b/engine/Sim/Unit.lua @@ -297,6 +297,7 @@ end function Unit:GetUnitId() end +--- Velocity in ogrids/tick ---@return number x ---@return number y ---@return number z From 4b7b0d85cffea133fd3a41ce9627dad23714a9b4 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:46:50 -0800 Subject: [PATCH 06/15] Make Aeon TMD launch flare to target height --- lua/sim/weapons/aeon/AAMWillOWisp.lua | 41 +++++++++++++++++++ .../AIMAntiMissile01/AIMAntiMissile01_proj.bp | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lua/sim/weapons/aeon/AAMWillOWisp.lua b/lua/sim/weapons/aeon/AAMWillOWisp.lua index 90a1471cd5..f63f2e4589 100644 --- a/lua/sim/weapons/aeon/AAMWillOWisp.lua +++ b/lua/sim/weapons/aeon/AAMWillOWisp.lua @@ -22,8 +22,49 @@ local DefaultProjectileWeapon = import("/lua/sim/defaultweapons.lua").DefaultProjectileWeapon local EffectTemplate = import("/lua/effecttemplates.lua") +local EntityMethods = moho.entity_methods +local EntityGetPositionXYZ = EntityMethods.GetPositionXYZ +local EntityGetBoneDirection = EntityMethods.GetBoneDirection +local GetDistanceBetweenTwoPoints2 = import('/lua/utilities.lua').GetDistanceBetweenTwoPoints2 + +---@param proj Projectile +---@param t number +local function floatProjectile(proj, t) + WaitSeconds(t) + proj:SetVelocity(0, 0, 0) + proj:SetBallisticAcceleration(-4.9) +end ---@class AAMWillOWisp : DefaultProjectileWeapon AAMWillOWisp = ClassWeapon(DefaultProjectileWeapon) { FxMuzzleFlash = EffectTemplate.AAntiMissileFlareFlash, + + --- Launch the flare to the target's height + ---@param self AAMWillOWisp + ---@param muzzle Bone + ---@return Projectile + CreateProjectileAtMuzzle = function(self, muzzle) + local proj = DefaultProjectileWeapon.CreateProjectileAtMuzzle(self, muzzle) + + local target = self:GetCurrentTarget() + if target then + local targetX, targetY, targetZ = EntityGetPositionXYZ(target) + local targetDX, targetDY, targetDZ = target:GetVelocity() + + local unit = self.unit + local posX, posY, posZ = EntityGetPositionXYZ(unit, muzzle) + + local arriveTime = (GetDistanceBetweenTwoPoints2(targetX, targetZ, posX, posZ) - 10) / (math.sqrt(targetDX * targetDX + targetDZ * targetDZ) * 10) + + local dy = math.max(targetY - posY + targetDY * arriveTime + 9, 17) + + local vy0 = dy / arriveTime * 2 + local g = -vy0 / arriveTime + proj:SetVelocity(0, vy0, 0) + proj:SetBallisticAcceleration(g) + ForkThread(floatProjectile, proj, arriveTime) + end + + return proj + end, } diff --git a/projectiles/AIMAntiMissile01/AIMAntiMissile01_proj.bp b/projectiles/AIMAntiMissile01/AIMAntiMissile01_proj.bp index a4f5e9e1d0..c942cc9f32 100644 --- a/projectiles/AIMAntiMissile01/AIMAntiMissile01_proj.bp +++ b/projectiles/AIMAntiMissile01/AIMAntiMissile01_proj.bp @@ -23,7 +23,7 @@ ProjectileBlueprint{ Acceleration = -1.25, DestroyOnWater = true, LifeTime = 3, - MaxSpeed = 15, + MaxSpeed = false, MaxZigZag = 10, TrackTarget = false, TurnRate = 0, From 9b4e9ea1838e8b847d99403a2b215b7868f71537 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:47:19 -0800 Subject: [PATCH 07/15] Tweak aeon flare hitbox to catch missiles better --- lua/sim/projectiles/aeon/AIMFlareProjectile.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/sim/projectiles/aeon/AIMFlareProjectile.lua b/lua/sim/projectiles/aeon/AIMFlareProjectile.lua index d05bb31df6..76fb37d82b 100644 --- a/lua/sim/projectiles/aeon/AIMFlareProjectile.lua +++ b/lua/sim/projectiles/aeon/AIMFlareProjectile.lua @@ -73,7 +73,7 @@ AIMFlareProjectile = ClassProjectile(EmitterProjectile) { local trash = self.Trash for k = 1, 3 do - flareSpecs.Radius = 8 + k * 5 + flareSpecs.Radius = 2 + k * 7 trash:Add(Flare(flareSpecs)) end end, From ad90a2f60f00245aa27968231e2cdf101c138235 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:07:47 -0800 Subject: [PATCH 08/15] Final cleanup and comments --- lua/sim/weapons/aeon/AAMWillOWisp.lua | 54 ++++++++++++++++----------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/lua/sim/weapons/aeon/AAMWillOWisp.lua b/lua/sim/weapons/aeon/AAMWillOWisp.lua index f63f2e4589..434c8d2de2 100644 --- a/lua/sim/weapons/aeon/AAMWillOWisp.lua +++ b/lua/sim/weapons/aeon/AAMWillOWisp.lua @@ -21,20 +21,31 @@ --********************************************************************************** local DefaultProjectileWeapon = import("/lua/sim/defaultweapons.lua").DefaultProjectileWeapon +local DefaultCreateProjectileAtMuzzle = DefaultProjectileWeapon.CreateProjectileAtMuzzle local EffectTemplate = import("/lua/effecttemplates.lua") -local EntityMethods = moho.entity_methods -local EntityGetPositionXYZ = EntityMethods.GetPositionXYZ -local EntityGetBoneDirection = EntityMethods.GetBoneDirection local GetDistanceBetweenTwoPoints2 = import('/lua/utilities.lua').GetDistanceBetweenTwoPoints2 +local EntityGetPositionXYZ = moho.entity_methods.GetPositionXYZ +local ProjectileGetVelocity = moho.projectile_methods.GetVelocity +local ProjectileSetVelocity = moho.projectile_methods.SetVelocity +local ProjectileSetBallisticAcceleration = moho.projectile_methods.SetBallisticAcceleration +local WeaponGetCurrentTarget = moho.weapon_methods.GetCurrentTarget + +local MathSqrt = math.sqrt +local MathMax = math.max +local ForkThread = ForkThread +local WaitSeconds = WaitSeconds + +--- Makes the flare fall at a natural speed at the top of its trajectory so that it can catch the missile better ---@param proj Projectile ---@param t number local function floatProjectile(proj, t) WaitSeconds(t) - proj:SetVelocity(0, 0, 0) - proj:SetBallisticAcceleration(-4.9) + ProjectileSetVelocity(proj, 0, 0, 0) + ProjectileSetBallisticAcceleration(proj, -4.9) end +--- Aeon anti-projectile weapon that launches flares to a bit above the target projectile's height. ---@class AAMWillOWisp : DefaultProjectileWeapon AAMWillOWisp = ClassWeapon(DefaultProjectileWeapon) { FxMuzzleFlash = EffectTemplate.AAntiMissileFlareFlash, @@ -44,26 +55,27 @@ AAMWillOWisp = ClassWeapon(DefaultProjectileWeapon) { ---@param muzzle Bone ---@return Projectile CreateProjectileAtMuzzle = function(self, muzzle) - local proj = DefaultProjectileWeapon.CreateProjectileAtMuzzle(self, muzzle) + local proj = DefaultCreateProjectileAtMuzzle(self, muzzle) + + -- Assume we only target and fire at projectiles + local target = WeaponGetCurrentTarget(self) --[[@as Projectile]] + local targetX, targetY, targetZ = EntityGetPositionXYZ(target) + local targetVX, targetVY, targetVZ = ProjectileGetVelocity(target) - local target = self:GetCurrentTarget() - if target then - local targetX, targetY, targetZ = EntityGetPositionXYZ(target) - local targetDX, targetDY, targetDZ = target:GetVelocity() + local posX, posY, posZ = EntityGetPositionXYZ(self.unit, muzzle) - local unit = self.unit - local posX, posY, posZ = EntityGetPositionXYZ(unit, muzzle) - - local arriveTime = (GetDistanceBetweenTwoPoints2(targetX, targetZ, posX, posZ) - 10) / (math.sqrt(targetDX * targetDX + targetDZ * targetDZ) * 10) + -- Make the distance a bit shorter to allow the flare hitbox to catch the projectile and to launch faster to catch projectiles on the edge of the range + local arriveTime = (GetDistanceBetweenTwoPoints2(targetX, targetZ, posX, posZ) - 10) / (MathSqrt(targetVX * targetVX + targetVZ * targetVZ) * 10) - local dy = math.max(targetY - posY + targetDY * arriveTime + 9, 17) + -- Have a minimum height so that shields don't get hit by diverted projectiles + -- Also launch a bit above the projectile's height to catch it better as the flare falls down + local dy = MathMax(targetY - posY + targetVY * arriveTime + 9, 17) - local vy0 = dy / arriveTime * 2 - local g = -vy0 / arriveTime - proj:SetVelocity(0, vy0, 0) - proj:SetBallisticAcceleration(g) - ForkThread(floatProjectile, proj, arriveTime) - end + local vy0 = dy / arriveTime * 2 + ProjectileSetVelocity(proj, 0, vy0, 0) + ProjectileSetBallisticAcceleration(proj, -vy0 / arriveTime) + -- Can't wait in here or else it interrupts the firing cycle + ForkThread(floatProjectile, proj, arriveTime) return proj end, From 5dc29586e654edfca1f70aad21e35bd88b132d60 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:35:15 -0800 Subject: [PATCH 09/15] Fix error calling methods on destroyed proj --- lua/sim/weapons/aeon/AAMWillOWisp.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/sim/weapons/aeon/AAMWillOWisp.lua b/lua/sim/weapons/aeon/AAMWillOWisp.lua index 434c8d2de2..abc86334e1 100644 --- a/lua/sim/weapons/aeon/AAMWillOWisp.lua +++ b/lua/sim/weapons/aeon/AAMWillOWisp.lua @@ -35,14 +35,17 @@ local MathSqrt = math.sqrt local MathMax = math.max local ForkThread = ForkThread local WaitSeconds = WaitSeconds +local IsDestroyed = IsDestroyed --- Makes the flare fall at a natural speed at the top of its trajectory so that it can catch the missile better ---@param proj Projectile ---@param t number local function floatProjectile(proj, t) WaitSeconds(t) - ProjectileSetVelocity(proj, 0, 0, 0) - ProjectileSetBallisticAcceleration(proj, -4.9) + if not IsDestroyed(proj) then + ProjectileSetVelocity(proj, 0, 0, 0) + ProjectileSetBallisticAcceleration(proj, -4.9) + end end --- Aeon anti-projectile weapon that launches flares to a bit above the target projectile's height. From a00c38f283dc40302cc1a35b94b4396156058f89 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:35:38 -0800 Subject: [PATCH 10/15] Fix negative arrive time being possible --- lua/sim/weapons/aeon/AAMWillOWisp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/sim/weapons/aeon/AAMWillOWisp.lua b/lua/sim/weapons/aeon/AAMWillOWisp.lua index abc86334e1..d39e994b3e 100644 --- a/lua/sim/weapons/aeon/AAMWillOWisp.lua +++ b/lua/sim/weapons/aeon/AAMWillOWisp.lua @@ -68,7 +68,7 @@ AAMWillOWisp = ClassWeapon(DefaultProjectileWeapon) { local posX, posY, posZ = EntityGetPositionXYZ(self.unit, muzzle) -- Make the distance a bit shorter to allow the flare hitbox to catch the projectile and to launch faster to catch projectiles on the edge of the range - local arriveTime = (GetDistanceBetweenTwoPoints2(targetX, targetZ, posX, posZ) - 10) / (MathSqrt(targetVX * targetVX + targetVZ * targetVZ) * 10) + local arriveTime = MathMax(GetDistanceBetweenTwoPoints2(targetX, targetZ, posX, posZ) - 10, 10) / (MathSqrt(targetVX * targetVX + targetVZ * targetVZ) * 10) -- Have a minimum height so that shields don't get hit by diverted projectiles -- Also launch a bit above the projectile's height to catch it better as the flare falls down From 4f89dc4e1b2f93637679966b1ed7f106cf7fa4ad Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:44:55 -0800 Subject: [PATCH 11/15] Remove vertical velocity estimation would cause the flares to really derp vs cybran MML because the split missiles can randomly go quite fast vertically Removing it seems to improve the consistency of flare hitboxes against UEF TML as well --- lua/sim/weapons/aeon/AAMWillOWisp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/sim/weapons/aeon/AAMWillOWisp.lua b/lua/sim/weapons/aeon/AAMWillOWisp.lua index d39e994b3e..8a529f9d13 100644 --- a/lua/sim/weapons/aeon/AAMWillOWisp.lua +++ b/lua/sim/weapons/aeon/AAMWillOWisp.lua @@ -72,7 +72,7 @@ AAMWillOWisp = ClassWeapon(DefaultProjectileWeapon) { -- Have a minimum height so that shields don't get hit by diverted projectiles -- Also launch a bit above the projectile's height to catch it better as the flare falls down - local dy = MathMax(targetY - posY + targetVY * arriveTime + 9, 17) + local dy = MathMax(targetY - posY + 9, 17) local vy0 = dy / arriveTime * 2 ProjectileSetVelocity(proj, 0, vy0, 0) From 7818bfb733376abffb5e3457ef366384916090bb Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:52:28 -0800 Subject: [PATCH 12/15] handle nil target case happens when we fire at a projectile that destroys itself --- lua/sim/weapons/aeon/AAMWillOWisp.lua | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lua/sim/weapons/aeon/AAMWillOWisp.lua b/lua/sim/weapons/aeon/AAMWillOWisp.lua index 8a529f9d13..842f0d630a 100644 --- a/lua/sim/weapons/aeon/AAMWillOWisp.lua +++ b/lua/sim/weapons/aeon/AAMWillOWisp.lua @@ -60,25 +60,27 @@ AAMWillOWisp = ClassWeapon(DefaultProjectileWeapon) { CreateProjectileAtMuzzle = function(self, muzzle) local proj = DefaultCreateProjectileAtMuzzle(self, muzzle) - -- Assume we only target and fire at projectiles - local target = WeaponGetCurrentTarget(self) --[[@as Projectile]] - local targetX, targetY, targetZ = EntityGetPositionXYZ(target) - local targetVX, targetVY, targetVZ = ProjectileGetVelocity(target) + -- Assume we only target and fire at projectiles. The projectile may destroy itself right as we fire though if it hit something. + local target = WeaponGetCurrentTarget(self) --[[@as Projectile?]] + if target then + local targetX, targetY, targetZ = EntityGetPositionXYZ(target) + local targetVX, targetVY, targetVZ = ProjectileGetVelocity(target) - local posX, posY, posZ = EntityGetPositionXYZ(self.unit, muzzle) + local posX, posY, posZ = EntityGetPositionXYZ(self.unit, muzzle) - -- Make the distance a bit shorter to allow the flare hitbox to catch the projectile and to launch faster to catch projectiles on the edge of the range - local arriveTime = MathMax(GetDistanceBetweenTwoPoints2(targetX, targetZ, posX, posZ) - 10, 10) / (MathSqrt(targetVX * targetVX + targetVZ * targetVZ) * 10) + -- Make the distance a bit shorter to allow the flare hitbox to catch the projectile and to launch faster to catch projectiles on the edge of the range + local arriveTime = MathMax(GetDistanceBetweenTwoPoints2(targetX, targetZ, posX, posZ) - 10, 10) / (MathSqrt(targetVX * targetVX + targetVZ * targetVZ) * 10) - -- Have a minimum height so that shields don't get hit by diverted projectiles - -- Also launch a bit above the projectile's height to catch it better as the flare falls down - local dy = MathMax(targetY - posY + 9, 17) + -- Have a minimum height so that shields don't get hit by diverted projectiles + -- Also launch a bit above the projectile's height to catch it better as the flare falls down + local dy = MathMax(targetY - posY + 9, 17) - local vy0 = dy / arriveTime * 2 - ProjectileSetVelocity(proj, 0, vy0, 0) - ProjectileSetBallisticAcceleration(proj, -vy0 / arriveTime) - -- Can't wait in here or else it interrupts the firing cycle - ForkThread(floatProjectile, proj, arriveTime) + local vy0 = dy / arriveTime * 2 + ProjectileSetVelocity(proj, 0, vy0, 0) + ProjectileSetBallisticAcceleration(proj, -vy0 / arriveTime) + -- Can't wait in here or else it interrupts the firing cycle + ForkThread(floatProjectile, proj, arriveTime) + end return proj end, From 2e50d6d3ea228d524efaf2f29d08b40b9e708748 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:52:46 -0800 Subject: [PATCH 13/15] Update `UnitWeapon.GetCurrentTarget` Annotation --- engine/Sim/UnitWeapon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/Sim/UnitWeapon.lua b/engine/Sim/UnitWeapon.lua index 31e92c5d22..ff9e474d14 100644 --- a/engine/Sim/UnitWeapon.lua +++ b/engine/Sim/UnitWeapon.lua @@ -87,7 +87,7 @@ function UnitWeapon:GetBlueprint() end --- ----@return Blip | Unit | nil +---@return Blip | Unit | Projectile | nil function UnitWeapon:GetCurrentTarget() end From b4eff81abeb23c00ae46d322fe542839de537e48 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:57:01 -0800 Subject: [PATCH 14/15] Create balance.6619.md --- changelog/snippets/balance.6619.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/snippets/balance.6619.md diff --git a/changelog/snippets/balance.6619.md b/changelog/snippets/balance.6619.md new file mode 100644 index 0000000000..66c2670764 --- /dev/null +++ b/changelog/snippets/balance.6619.md @@ -0,0 +1 @@ +- (#6619) Make Aeon TMD (static and naval) shoot the flare to the height of the missile being intercepted. This fixes the issue where UEF TML flies too high in the middle of its path for Aeon TMD to intercept it. From 6bfbecfeb314572332c6b47a766c53bcf16700b1 Mon Sep 17 00:00:00 2001 From: lL1l1 <82986251+lL1l1@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:58:03 -0800 Subject: [PATCH 15/15] Update balance.6619.md --- changelog/snippets/balance.6619.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/snippets/balance.6619.md b/changelog/snippets/balance.6619.md index 66c2670764..541c8a3f32 100644 --- a/changelog/snippets/balance.6619.md +++ b/changelog/snippets/balance.6619.md @@ -1 +1 @@ -- (#6619) Make Aeon TMD (static and naval) shoot the flare to the height of the missile being intercepted. This fixes the issue where UEF TML flies too high in the middle of its path for Aeon TMD to intercept it. +- (#6619) Make Aeon TMD (static and naval) launch the flare to the height of the missile being intercepted. This fixes the issue where Aeon TMD cannot intercept UEF TMLs due to them flying too high.