Skip to content

Commit

Permalink
Allow actors to target terrain without force-fire
Browse files Browse the repository at this point in the history
  • Loading branch information
obrakmann authored and PunkPun committed Oct 24, 2023
1 parent f1fba1e commit 4cc9b1b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions OpenRA.Mods.Common/Traits/Attack/AttackBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public abstract class AttackBaseInfo : PausableConditionalTraitInfo
[Desc("Tolerance for attack angle. Range [0, 512], 512 covers 360 degrees.")]
public readonly WAngle FacingTolerance = new(512);

[Desc("When enabled, show the target cursor on terrain cells even without force-fire.")]
public readonly bool TargetTerrainWithoutForceFire = false;

public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
base.RulesetLoaded(rules, ai);
Expand Down Expand Up @@ -361,7 +364,7 @@ public IEnumerable<Armament> ChooseArmamentsForTarget(Target t, bool forceAttack
{
// If force-fire is not used, and the target requires force-firing or the target is
// terrain or invalid, no armaments can be used
if (!forceAttack && (t.Type == TargetType.Terrain || t.Type == TargetType.Invalid || t.RequiresForceFire))
if (!forceAttack && ((t.Type == TargetType.Terrain && !Info.TargetTerrainWithoutForceFire) || t.Type == TargetType.Invalid || t.RequiresForceFire))
return Enumerable.Empty<Armament>();

// Get target's owner; in case of terrain or invalid target there will be no problems
Expand Down Expand Up @@ -477,8 +480,9 @@ bool CanTargetLocation(Actor self, CPos location, TargetModifiers modifiers, ref

IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);

// Targeting the terrain is only possible with force-attack modifier
if (modifiers.HasModifier(TargetModifiers.ForceMove) || !modifiers.HasModifier(TargetModifiers.ForceAttack))
// Targeting the terrain is only possible with force-attack modifier or when TargetTerrainWithoutForceFire is set
if (modifiers.HasModifier(TargetModifiers.ForceMove) ||
!(ab.Info.TargetTerrainWithoutForceFire || modifiers.HasModifier(TargetModifiers.ForceAttack)))
return false;

var target = Target.FromCell(self.World, location);
Expand Down

0 comments on commit 4cc9b1b

Please sign in to comment.