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

Only consider non-paused armaments (if any exist) when determining max range for attack #20902

Merged

Conversation

darkademic
Copy link
Contributor

Fixes #20901

AttackBase has this:

// Use valid armament with highest range out of those that have ammo
// If all are out of ammo, just use valid armament with highest range
armaments = armaments.OrderByDescending(x => x.MaxRange());
var a = armaments.FirstOrDefault(x => !x.IsTraitPaused);
if (a == null)
	a = armaments.First();

Whereas in the Attack activity paused armaments are still considered when calculating the max range, which means, if a paused armament has less range than the active armaments, the unit will stop when reaching the real max range, but not shoot because the Attack activity is using the max range of a paused armament.

@darkademic darkademic changed the title Only consider non-paused armaments (if any exist) when determining ma… Only consider non-paused armaments (if any exist) when determining max range for attack Jun 6, 2023
@darkademic darkademic force-pushed the pr/paused-armament-range-calculation branch from 69f0cb6 to 4fe82c9 Compare June 6, 2023 21:35
@darkademic darkademic force-pushed the pr/paused-armament-range-calculation branch from 4fe82c9 to c96f95f Compare June 11, 2023 07:43
Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

Tbh this feels more like a hack. It's intended for paused armament ranges to be considered. Perhaps we need to rethink how we combine the ranges of multiple weapons instead?

@darkademic
Copy link
Contributor Author

Tbh this feels more like a hack. It's intended for paused armament ranges to be considered. Perhaps we need to rethink how we combine the ranges of multiple weapons instead?

Hm, can you elaborate?

AttackBase ignores paused armaments when calculating min/max range in GetMinimumRange(), GetMaximumRange(), GetMinimumRangeVersusTarget() and GetMaximumRangeVersusTarget(), as well as in CanTargetActor() and CanTargetLocation(), so this is just changing Attack to do the same, as per the comment:

// We want actors to use only weapons with ammo for this, except when ALL weapons are out of ammo,
// then we use the paused, valid weapon with highest range.

@PunkPun
Copy link
Member

PunkPun commented Jun 11, 2023

I see. So the current system is already hacky. Only GetMaximumRangeVersusTarget has a fallback on non-paused weapons that isn't 0.

If we were to follow that logic, we should fallback on 0 for minimum range, and then as fallback for max range, we should use the highest max range instead of the lowest max range.

@PunkPun
Copy link
Member

PunkPun commented Jun 11, 2023

also a comment should be added for this weirdly specific logic, perhaps the one you just quoted

@darkademic darkademic force-pushed the pr/paused-armament-range-calculation branch from c96f95f to 559ee4c Compare June 11, 2023 09:46
@darkademic
Copy link
Contributor Author

I see. So the current system is already hacky. Only GetMaximumRangeVersusTarget has a fallback on non-paused weapons that isn't 0.

If we were to follow that logic, we should fallback on 0 for minimum range, and then as fallback for max range, we should use the highest max range instead of the lowest max range.

I wondered if AttackBase.ChooseArmamentsForTarget() should actually be excluding the paused armaments, but the armaments returned by that are also used in AttackFollow to determine whether the target can be aimed at, so that'd need further changes.

Falling back to zero for minimum range seems wrong, as you'd expect a unit to try to make sure it's at the correct range for when the paused condition expires, but happy to keep it consistent with AttackBase so this remains a targeted fix and doesn't become more of a rework.

@darkademic darkademic force-pushed the pr/paused-armament-range-calculation branch from 559ee4c to 69af83c Compare June 11, 2023 09:52
@darkademic darkademic force-pushed the pr/paused-armament-range-calculation branch from 69af83c to 4eec376 Compare June 11, 2023 10:14
Copy link
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

LGTM

@dnqbob
Copy link
Contributor

dnqbob commented Jun 20, 2023

I think it is intended, as for Armament we have pause and disable (RequiresCondition), which means when "pause", the Armament is not abandoned by actor, and actor will abandon this Armament when it is "disabled". I believe this setting is part of the game logic.

For example, an unit has long range weapon1 and short range weapon2 (like a artillery with a gunner on it), and it perfer weapon1 when attack, only use short range weapon when long range weapon is considered dead by it. In order to do that, we can use "PauseOnCondition" when it get emp and cannot use its weapon1 temporarily, and "RequiresCondition" when its barrel is destroyed to force it use weapon2.

@abcdefg30 abcdefg30 merged commit 19fa034 into OpenRA:bleed Jun 20, 2023
3 checks passed
@abcdefg30
Copy link
Member

Changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paused armament used for determining max range
4 participants