fa icon indicating copy to clipboard operation
fa copied to clipboard

Fix defensive and arty structure orientations on build.

Open Pokute opened this issue 5 months ago • 10 comments

Description of the proposed changes

Fix defensive structure orientations on build. Previously the orientation really worked right for pd1 and pd2.

  • Now torpedo defenses, SAMs and TMDs are oriented towards nearest enemy or center. The Aeon TMD getting rotated like an idiot might clash with fragile senses of aesthetics.
  • Previously t2 arty pointed only north or south towards closest enemy or center.
  • Now all t2+ static arty points at center of map but limited to 90 degree steps in order to not affect pathing/terrain. This fixes the very long time for T3+ artys to rotate towards enemy depending on position. Previously for a newly built Mavor at north of the map, it already faces towards center while one built at the south of the map will require a minute for the Mavor to turn towards center.

image image image

Bug: HARMS still always points south after being built due to it's unique spawning code.

Testing done on the proposed changes

Built pds, tmds, static aa and arties on various positions of the map with some enemies to check how the buildings are placed.

Checklist

  • [X] Changes are annotated, including comments where useful
  • [] Changes are documented in the changelog for the next game version

Pokute avatar Mar 31 '24 20:03 Pokute

It's possible to spawn the unit's weapon(s) rotated towards the enemy by using CAimManipulator:SetHeadingPitch. I think that would look better than rotating the entire unit. The only issue is that if there are no enemies to target then the weapon will rotate towards the default heading/pitch. If that could be solved, it would be an interesting change on top of/replacing the unit rotation. Or you could apply it if you do find an enemy in range, since you're searching for them already anyway. i.e. rotate cardinally towards enemy, then rotate weapon directly towards enemy

Example (there is a visible enemy far away, so it doesn't rotate to default here):

https://github.com/FAForever/fa/assets/82986251/44ecd88b-e8e5-487b-bd40-37ed9b05b438

Inside UEB2401_script.lua's MainGun

SetupTurret = function(self, bp)
    TIFArtilleryWeapon.SetupTurret(self, bp)
    local aimManip = self:GetAimManipulator()
    aimManip:SetHeadingPitch(90*math.pi/180, 0)
end,

lL1l1 avatar Apr 01 '24 07:04 lL1l1

I like the idea of the two-step approach: use the the 90 degrees angle for the rough approximation and fine-tune it by rotating the weapon (if applicable).

Garanas avatar Apr 01 '24 09:04 Garanas

This looks promising👍

One thing to note: the TurretYawSpeed of TMDs is over five times greater than that of PDs, so they probably do not need to be turned in intervals of 45 degrees, if they need to be turned at all.

Basilisk3 avatar Apr 01 '24 13:04 Basilisk3

With faster missiles the turn speed can matter, although it shouldn't be a significant issue after some recent speed reductions for TMLs.

lL1l1 avatar Apr 01 '24 20:04 lL1l1

Let's start small - these changes look promising and we can extend them further in a additional pull requests. I'll give it a review this week

Garanas avatar Apr 02 '24 07:04 Garanas

This may sound strange, but in what situation would artillery not end up pointing to the center of the map even if we search for valid targets?

Why don't we just always orientate towards the center (in 90 degree steps or not)? It removes the need to search for things

Garanas avatar Apr 07 '24 14:04 Garanas

This may sound strange, but in what situation would artillery not end up pointing to the center of the map even if we search for valid targets?

Why don't we just always orientate towards the center (in 90 degree steps or not)? It removes the need to search for things

The PR's code already does this for artillery. But answering the question, naval maps have beaches that point towards the center of the map or are behind the base, so it doesn't always make sense to point towards the center for t2 arty at those beaches.

lL1l1 avatar Apr 08 '24 06:04 lL1l1

8711699 HARMs now rotates towards the center of the map as well.

lL1l1 avatar May 01 '24 06:05 lL1l1

Here's how it looks like when the artillery finishes and the weapon is rotated. I haven't found any way to rotate the weapon itself while under construction. I don't think the janky animation is worth it for the turn speed since changing pitch already takes longer than the max 45 degrees yaw change with the 90 degree orientations.

https://github.com/FAForever/fa/assets/82986251/18908094-d927-4109-beb0-80371ca7bcae

https://github.com/FAForever/fa/assets/82986251/2924f110-f616-494c-81a9-76693b8b00f3

https://github.com/FAForever/fa/assets/82986251/297dd1aa-10ee-436f-88ef-ca0a45b44407

lL1l1 avatar May 01 '24 07:05 lL1l1

Old reasons to exempt arty from rotating:

  • Pathing is handled by the unrotateable footprint, and structure hitboxes do not affect unit pathing.
  • Terrain is handled separately by self:FlattenSkirt and self:FlattenSkirtHorizontally. The unit is just orientated onto that terrain after the fact.

Remaining reasons to exempt arty from rotating:

  • Adjacency visual effects
  • Selection hitbox vs selection visual being especially ugly on t3/t4 arties.
  • Doesn't fit UEF faction aesthetic, particularly on the large t3/t4 arty.

Since these reasons are more about aesthetics, should I change it to just checking the footprint size? Going off footprint size I can also get rid of the arty entity category filtering entirely by checking min range and adding an overall max range for the target search radius.

lL1l1 avatar May 01 '24 10:05 lL1l1