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

Limited turret arc #18

Merged
merged 70 commits into from
Apr 27, 2023
Merged

Conversation

1010todd
Copy link

@1010todd 1010todd commented Apr 26, 2023


Feature: This PR implements the feature request detailed and discussed in issue endless-sky#3148

Just endless-sky#7094 but PRed to ES-Delta

Feature Details

Allow limiting the angle that turrets can aim and fire both from ship's hardpoint and the weapon itself. Will use the most limiting of the two if both exist. Unlike the previous PR, the arc is relative to baseAngle/idleAngle as I think it is more intuitive and easier to visualize. Now first arc value have to be less than second arc value.

This PR also allows turrets to restrict their own angle, if both the outfit and the hardpoint have limit it will pick the most restrictive of the two.

PRing this to Delta fork experimental branch because I think it's can greatly affect combat gameplay especially when used along side other potential balance changes like large difference in speed between large and small ships as well as new fighter AI in #17 .

Currently this PR does not introduce any data change so all ship still have their default 360 turret.

Usage Examples

Syntax:

	# The turret is omnidirectional and points to the front when idling.
	turret x y outfit_name
	
	# The turret is omnidirectional and points to 'baseAngle' when idling.
	turret x y outfit_name
		angle baseAngle
	
	# The turret can rotate in the range from 'minAngle' to 'maxAngle' (clock orientation) and points to the center of the range when idling.
	turret x y outfit_name
		arc minAngle maxAngle
	
	# The turret can rotate in the range from 'minAngle' to 'maxAngle' (clock orientation) relative to 'baseAngle'.
	turret x y outfit_name
		angle baseAngle
		arc minAngle maxAngle

Example use:

	# Points forward and can turn up to 135 degrees counterclockwise or clockwise. 
	turret 0 -167.5 "Large Cannon Turret"
		arc -135 135

	# Points backward and can turn up to 135 degrees  counterclockwise or clockwise from that direction i.e. 45 to 315 absolute degree 
	turret 0 148.5 "Large Cannon Turret"
		arc -135 135
		angle 180

	# Points left and can turn up to 90 degrees counterclockwise or clockwise from that direction.
	turret -26.5 -67 "Small Cannon Turret"
		arc -90 90
		angle -90

	# Points left and can turn up to 10 degrees counterclockwise  and 90 degrees clockwise from that direction
	turret -26.5 -67 "Small Cannon Turret"
		arc -10 90
		angle -90

UI Screenshots

Image

img

Testing Done

Tested various arc and flying around.

Automated Tests Added

None yet.

Performance Impact

From previous PR (endless-sky#5459):

  • Slightly slow down because this PR adds some condition checks for all omnidirectional turrets.
  • And for the directivity turret AI.cpp checks the angle every expected target.
  • I think nearly all humans cannot feel the delay.

oo13 and others added 30 commits October 18, 2020 19:30
- Introduce an attribute "angle of traverse" for a hardpoint.
- Change a type of parameter in the constructor of class "Hardpoint."
- GetAngleOfTraverse() returns some valid value in case this is Omnidirectional or a gun port.
- Rewrite some comments.
…cted hardpoint and weapon.

The previous commit introduced the bug.
…ad of in-flight.

And the turrets calculate the idle position considering the "parallel" parameter.
So it compiles.
@RisingLeaf
Copy link
Member

Conflicts

source/AI.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Zitchas Zitchas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't feel that I understand the code well enough to approve it; on a conceptual level I definitely like it, and trust RisingLeaf to understand the code better than I do. :)

Thoughts:

  • Being able to have limited-arc turrets allows a measure of "half benefit" or "lower value" hardpoints. Ex. Having a freighter that has a turret with a limited arc to the rear. Good for fending off an ambush or covering its retreat, but not good for offense. Militarily speaking, this makes this turret hard point "worth less" than an unrestricted turret.
  • Control: Especially for agile ships, having turrets swinging around all over can be detrimental, especially with slow turrets, as the turrets don't know what you are planning to do. Having them restricted to specific ranges means they can't wander as far off target and reduce the "regain target" time, at the cost of putting more of the aiming onus on the pilot.

Question:

  • Can these restricted ranges be put on the outfit too? I think I saw that mentioned somewhere, but confirmation would be nice.

@Zitchas Zitchas added the enhancement New feature or request label Apr 27, 2023
@RisingLeaf RisingLeaf merged commit 975b4ee into endless-sky:experimental Apr 27, 2023
@1010todd
Copy link
Author

Can these restricted ranges be put on the outfit too? I think I saw that mentioned somewhere, but confirmation would be nice.

Yes, I forgot to mention it on the summary. Will update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants