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

Cycle through all Armament.LocalOffsets if weapon has Burst: 1 #14579

Merged
merged 4 commits into from Dec 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions OpenRA.Mods.Common/Traits/Armament.cs
Expand Up @@ -39,7 +39,8 @@ public class ArmamentInfo : PausableConditionalTraitInfo, Requires<AttackBaseInf
[Desc("Time (in frames) until the weapon can fire again.")]
public readonly int FireDelay = 0;

[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
[Desc("Muzzle position relative to turret or body, (forward, right, up) triples.",
"If weapon Burst = 1, it cycles through all listed offsets, otherwise the offset corresponding to current burst is used.")]
Copy link
Member

Choose a reason for hiding this comment

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

current shot in the burst, right?

Copy link
Contributor Author

@reaperrr reaperrr Dec 26, 2017

Choose a reason for hiding this comment

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

According to what I found online, 'burst' stands for a shot in a salvo.

Edit: Googling for "burst salvo" brought up this (quote from F4 Phantom manual):

The number of bursts within the salvo and the interval between the bursts is determined by the settings of the burst selector knob

Copy link
Member

Choose a reason for hiding this comment

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

See #13090 in relation to this ongoing confusion.

public readonly WVec[] LocalOffset = { };

[Desc("Muzzle yaw relative to turret or body.")]
Expand Down Expand Up @@ -113,6 +114,8 @@ public class Armament : PausableConditionalTrait<ArmamentInfo>, ITick, IExplodeM
IEnumerable<int> inaccuracyModifiers;

int ticksSinceLastShot;
int currentBarrel;
int barrelCount;

List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>();

Expand Down Expand Up @@ -141,6 +144,8 @@ public Armament(Actor self, ArmamentInfo info)
if (barrels.Count == 0)
barrels.Add(new Barrel { Offset = WVec.Zero, Yaw = WAngle.Zero });

barrelCount = barrels.Count;

Barrels = barrels.ToArray();
}

Expand Down Expand Up @@ -232,7 +237,10 @@ public virtual Barrel CheckFire(Actor self, IFacing facing, Target target)

ticksSinceLastShot = 0;

var barrel = Barrels[Burst % Barrels.Length];
// If Weapon.Burst == 1, cycle through all LocalOffsets, otherwise use the offset corresponding to current Burst
Copy link
Member

Choose a reason for hiding this comment

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

Can you please document this in the LocalOffset desc too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

currentBarrel %= barrelCount;
var barrel = Weapon.Burst == 1 ? Barrels[currentBarrel] : Barrels[Burst % Barrels.Length];
currentBarrel++;

FireBarrel(self, facing, target, barrel);

Expand Down
2 changes: 0 additions & 2 deletions mods/cnc/weapons/missiles.yaml
Expand Up @@ -75,8 +75,6 @@ BikeRockets:
OrcaAGMissiles:
Inherits: ^MissileWeapon
ReloadDelay: 12
Burst: 2
BurstDelays: 12
Range: 5c0
MinRange: 1c256
ValidTargets: Ground
Expand Down
8 changes: 4 additions & 4 deletions mods/ra/rules/aircraft.yaml
Expand Up @@ -294,11 +294,11 @@ HELI:
Type: GroundPosition
Armament@PRIMARY:
Weapon: HellfireAA
LocalOffset: 0,-213,-85
LocalOffset: 0,-213,-85, 0,213,-85
PauseOnCondition: !ammo
Armament@SECONDARY:
Weapon: HellfireAG
LocalOffset: 0,213,-85
LocalOffset: 0,213,-85, 0,-213,-85
PauseOnCondition: !ammo
AttackHeli:
FacingTolerance: 20
Expand Down Expand Up @@ -358,13 +358,13 @@ HIND:
Type: GroundPosition
Armament@PRIMARY:
Weapon: ChainGun
LocalOffset: 85,-213,-85
LocalOffset: 85,-213,-85, 85,213,-85
MuzzleSequence: muzzle
PauseOnCondition: !ammo
Armament@SECONDARY:
Name: secondary
Weapon: ChainGun
LocalOffset: 85,213,-85
LocalOffset: 85,213,-85, 85,-213,-85
MuzzleSequence: muzzle
PauseOnCondition: !ammo
AttackHeli:
Expand Down
2 changes: 0 additions & 2 deletions mods/ts/weapons/energyweapons.yaml
Expand Up @@ -44,8 +44,6 @@ LtRail:
MechRailgun:
Inherits: ^Railgun
Range: 8c0
Burst: 2 # for alternating muzzle offsets, dmg/s identical to original
BurstDelays: 60
Report: railuse5.aud
Projectile: Railgun
BeamColor: 00FFFFC8
Expand Down
2 changes: 0 additions & 2 deletions mods/ts/weapons/missiles.yaml
Expand Up @@ -93,8 +93,6 @@ MammothTusk:

BikeMissile:
Inherits: ^DefaultMissile
Burst: 2 # to make bike alternate between left and right launcher, no change in dmg/s compared to original TS
BurstDelays: 60
Range: 5c0
Report: misl1.aud
ValidTargets: Ground
Expand Down
2 changes: 0 additions & 2 deletions mods/ts/weapons/smallguns.yaml
Expand Up @@ -85,8 +85,6 @@ RaiderCannon:
Inherits: ^MG
ReloadDelay: 55
Range: 4c0
Burst: 2 # this + BurstDelay just makes the buggy alternate between barrels (for muzzle flash), no actual difference to original TS
BurstDelays: 55
Report: chaingn1.aud
Warhead@1Dam: SpreadDamage
Damage: 40
Expand Down