Unhardcode AttackBomber bomb and gun logic
This commit is contained in:
@@ -18,11 +18,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class AttackBomberInfo : AttackBaseInfo
|
||||
{
|
||||
[Desc("Armament name")]
|
||||
public readonly string Bombs = "primary";
|
||||
|
||||
[Desc("Armament name")]
|
||||
public readonly string Guns = "secondary";
|
||||
public readonly int FacingTolerance = 2;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackBomber(init.Self, this); }
|
||||
@@ -47,8 +42,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
var bombHeight = self.World.Map.DistanceAboveTerrain(self.CenterPosition);
|
||||
var bombTarget = Target.FromPos(self.CenterPosition - new WVec(WDist.Zero, WDist.Zero, bombHeight));
|
||||
var dat = self.World.Map.DistanceAboveTerrain(target.CenterPosition);
|
||||
target = Target.FromPos(target.CenterPosition - new WVec(WDist.Zero, WDist.Zero, dat));
|
||||
var wasInAttackRange = inAttackRange;
|
||||
var wasFacingTarget = facingTarget;
|
||||
|
||||
@@ -59,30 +54,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var facingToTarget = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : f;
|
||||
facingTarget = Math.Abs(facingToTarget - f) % 256 <= info.FacingTolerance;
|
||||
|
||||
// Bombs drop anywhere in range
|
||||
foreach (var a in Armaments.Where(a => a.Info.Name == info.Bombs))
|
||||
foreach (var a in Armaments)
|
||||
{
|
||||
if (!target.IsInRange(self.CenterPosition, a.MaxRange()))
|
||||
continue;
|
||||
|
||||
inAttackRange = true;
|
||||
a.CheckFire(self, facing, bombTarget);
|
||||
}
|
||||
|
||||
// Guns only fire when approaching the target
|
||||
if (facingTarget)
|
||||
{
|
||||
foreach (var a in Armaments.Where(a => a.Info.Name == info.Guns))
|
||||
{
|
||||
if (!target.IsInRange(self.CenterPosition, a.MaxRange()))
|
||||
continue;
|
||||
|
||||
inAttackRange = true;
|
||||
|
||||
var gunPos = self.CenterPosition - new WVec(0, a.MaxRange().Length / 2, 0).Rotate(WRot.FromFacing(f));
|
||||
var gunHeight = self.World.Map.DistanceAboveTerrain(gunPos);
|
||||
a.CheckFire(self, facing, Target.FromPos(gunPos - new WVec(WDist.Zero, WDist.Zero, gunHeight)));
|
||||
}
|
||||
a.CheckFire(self, facing, target);
|
||||
}
|
||||
|
||||
// Actors without armaments may want to trigger an action when it passes the target
|
||||
|
||||
@@ -829,6 +829,22 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
node.Key = "UseTargetableCellsOffsets";
|
||||
}
|
||||
|
||||
// Refactored AttackBomb so it doesn't need it's own special sauce anymore
|
||||
if (engineVersion < 20170713)
|
||||
{
|
||||
if (node.Key == "AttackBomber")
|
||||
{
|
||||
var gunsOrBombs = node.Value.Nodes.FirstOrDefault(n => n.Key == "Guns" || n.Key == "Bombs");
|
||||
if (gunsOrBombs != null)
|
||||
{
|
||||
Console.WriteLine("Hardcoded Guns and Bombs logic has been removed from AttackBomber.");
|
||||
Console.WriteLine("Bombs should work like usual, for gun strafing use the new Weapon TargetOffset modifiers.");
|
||||
Console.WriteLine("Look at the TD mod's A10 for an example.");
|
||||
node.Value.Nodes.RemoveAll(n => n.Key == "Guns" || n.Key == "Bombs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,6 @@ A10:
|
||||
Repulsable: False
|
||||
AttackBomber:
|
||||
Armaments: gun, bombs
|
||||
Guns: gun
|
||||
Bombs: bombs
|
||||
Armament@GUNS:
|
||||
Name: gun
|
||||
Weapon: Vulcan
|
||||
|
||||
@@ -36,7 +36,12 @@ HighV:
|
||||
|
||||
Vulcan:
|
||||
Inherits: ^HeavyMG
|
||||
ReloadDelay: 2
|
||||
Range: 8c0
|
||||
Burst: 9
|
||||
BurstDelay: 2
|
||||
FirstBurstTargetOffset: -2984,0,0
|
||||
FollowingBurstTargetOffset: 746,0,0
|
||||
ReloadDelay: 125
|
||||
Report: gun5.aud
|
||||
Warhead@1Dam: SpreadDamage
|
||||
Spread: 426
|
||||
|
||||
Reference in New Issue
Block a user