Add strafing support to weapons
This commit is contained in:
@@ -39,6 +39,12 @@ namespace OpenRA.GameRules
|
|||||||
[Desc("The maximum range the weapon can fire.")]
|
[Desc("The maximum range the weapon can fire.")]
|
||||||
public readonly WDist Range = WDist.Zero;
|
public readonly WDist Range = WDist.Zero;
|
||||||
|
|
||||||
|
[Desc("First burst is aimed at this offset relative to target position.")]
|
||||||
|
public readonly WVec FirstBurstTargetOffset = WVec.Zero;
|
||||||
|
|
||||||
|
[Desc("Each burst after the first lands by this offset away from the previous burst.")]
|
||||||
|
public readonly WVec FollowingBurstTargetOffset = WVec.Zero;
|
||||||
|
|
||||||
[Desc("The sound played each time the weapon is fired.")]
|
[Desc("The sound played each time the weapon is fired.")]
|
||||||
public readonly string[] Report = null;
|
public readonly string[] Report = null;
|
||||||
|
|
||||||
|
|||||||
@@ -225,6 +225,23 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Func<WPos> muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel);
|
Func<WPos> muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel);
|
||||||
var legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4;
|
var legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4;
|
||||||
|
|
||||||
|
var passiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition());
|
||||||
|
var initialOffset = Weapon.FirstBurstTargetOffset;
|
||||||
|
if (initialOffset != WVec.Zero)
|
||||||
|
{
|
||||||
|
// We want this to match Armament.LocalOffset, so we need to convert it to forward, right, up
|
||||||
|
initialOffset = new WVec(initialOffset.Y, -initialOffset.X, initialOffset.Z);
|
||||||
|
passiveTarget += initialOffset.Rotate(WRot.FromFacing(legacyFacing));
|
||||||
|
}
|
||||||
|
|
||||||
|
var followingOffset = Weapon.FollowingBurstTargetOffset;
|
||||||
|
if (followingOffset != WVec.Zero)
|
||||||
|
{
|
||||||
|
// We want this to match Armament.LocalOffset, so we need to convert it to forward, right, up
|
||||||
|
followingOffset = new WVec(followingOffset.Y, -followingOffset.X, followingOffset.Z);
|
||||||
|
passiveTarget += ((Weapon.Burst - Burst) * followingOffset).Rotate(WRot.FromFacing(legacyFacing));
|
||||||
|
}
|
||||||
|
|
||||||
var args = new ProjectileArgs
|
var args = new ProjectileArgs
|
||||||
{
|
{
|
||||||
Weapon = Weapon,
|
Weapon = Weapon,
|
||||||
@@ -239,7 +256,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Source = muzzlePosition(),
|
Source = muzzlePosition(),
|
||||||
CurrentSource = muzzlePosition,
|
CurrentSource = muzzlePosition,
|
||||||
SourceActor = self,
|
SourceActor = self,
|
||||||
PassiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition()),
|
PassiveTarget = passiveTarget,
|
||||||
GuidedTarget = target
|
GuidedTarget = target
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user