diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index 19d6275884..2b79a04ee0 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -194,16 +194,17 @@ namespace OpenRA.Mods.RA return Util.RotateVectorByFacing(localRecoil, facing, .7f); } + public static float2 GetTurretPosition(Actor self, IFacing facing, Turret turret) { - if(facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */ + if (facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */ var ru = self.TraitOrDefault(); var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8; var bodyFacing = facing.Facing; var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs); - return (Util.RotateVectorByFacing(turret.UnitSpacePosition, quantizedFacing, .7f) + return (Util.RotateVectorByFacing(turret.UnitSpacePosition, quantizedFacing, .7f) + GetRecoil(self, turret.Recoil)) + turret.ScreenSpacePosition; } diff --git a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs index dff1c73056..4169edf75e 100644 --- a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs @@ -11,10 +11,11 @@ using System.Collections.Generic; using OpenRA.Graphics; using OpenRA.Traits; +using System; namespace OpenRA.Mods.RA.Render { - class WithMuzzleFlashInfo : ITraitInfo, Requires + class WithMuzzleFlashInfo : ITraitInfo, Requires, Requires { public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self); } } @@ -28,21 +29,29 @@ namespace OpenRA.Mods.RA.Render { var attack = self.Trait(); var render = self.Trait(); - var facing = self.Trait(); + var facing = self.TraitOrDefault(); + var turreted = self.TraitOrDefault(); - foreach (var t in attack.Turrets) - { - var turret = t; - var muzzleFlash = new Animation(render.GetImage(self), () => self.Trait().Facing); - muzzleFlash.Play("muzzle"); + var getFacing = facing != null + ? () => facing.Facing : + turreted != null ? (Func)(() => turreted.turretFacing) : () => 0; - render.anims.Add("muzzle{0}".F(muzzleFlashes.Count), new RenderSimple.AnimationWithOffset( - muzzleFlash, - () => Combat.GetTurretPosition(self, facing, turret), - () => !isShowing)); + foreach (var w in attack.Weapons) + foreach( var b in w.Barrels ) + { + var barrel = b; + var turret = w.Turret; - muzzleFlashes.Add(muzzleFlash); - } + var muzzleFlash = new Animation(render.GetImage(self), getFacing); + muzzleFlash.Play("muzzle"); + + render.anims.Add("muzzle{0}".F(muzzleFlashes.Count), new RenderSimple.AnimationWithOffset( + muzzleFlash, + () => Combat.GetBarrelPosition(self, facing, turret, barrel), + () => !isShowing)); + + muzzleFlashes.Add(muzzleFlash); + } } public void Attacking(Actor self, Target target) diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 473e8aa2ca..f8a3fa2fd7 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -379,12 +379,17 @@ PBOX: Type: Wood RevealsShroud: Range: 6 - AttackOmni: + AttackTurreted: PrimaryWeapon: Vulcan + PrimaryOffset: 0,0,0,-2 + PrimaryLocalOffset: 0,-12,0 AutoTarget: IronCurtainable: RenderRangeCircle: -AcceptsSupplies: + WithMuzzleFlash: + Turreted: + ROT: 255 HBOX: Inherits: ^Building @@ -408,12 +413,17 @@ HBOX: Type: Wood RevealsShroud: Range: 6 - AttackOmni: + AttackTurreted: PrimaryWeapon: Vulcan + PrimaryOffset: 0,0,0,-2 + PrimaryLocalOffset: 0,-12,0 AutoTarget: IronCurtainable: RenderRangeCircle: -AcceptsSupplies: + WithMuzzleFlash: + Turreted: + ROT: 255 GUN: Inherits: ^Building diff --git a/mods/ra/sequences.yaml b/mods/ra/sequences.yaml index 3dddcdaf54..5f764394d1 100644 --- a/mods/ra/sequences.yaml +++ b/mods/ra/sequences.yaml @@ -285,6 +285,10 @@ pbox: make: pboxmake Start: 0 Length: * + muzzle: minigun + Start: 0 + Length: 6 + Facings: 8 hbox: damaged-idle: @@ -294,6 +298,10 @@ hbox: make: hboxmake Start: 0 Length: * + muzzle: minigun + Start: 0 + Length: 6 + Facings: 8 gap: idle: